documentation.d.ts 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. }
  497. }
  498. declare module BABYLON {
  499. /**
  500. * File request interface
  501. */
  502. export interface IFileRequest {
  503. /**
  504. * Raised when the request is complete (success or error).
  505. */
  506. onCompleteObservable: Observable<IFileRequest>;
  507. /**
  508. * Aborts the request for a file.
  509. */
  510. abort: () => void;
  511. }
  512. }
  513. declare module BABYLON {
  514. /**
  515. * Define options used to create a render target texture
  516. */
  517. export class RenderTargetCreationOptions {
  518. /**
  519. * Specifies is mipmaps must be generated
  520. */
  521. generateMipMaps?: boolean;
  522. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  523. generateDepthBuffer?: boolean;
  524. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  525. generateStencilBuffer?: boolean;
  526. /** Defines texture type (int by default) */
  527. type?: number;
  528. /** Defines sampling mode (trilinear by default) */
  529. samplingMode?: number;
  530. /** Defines format (RGBA by default) */
  531. format?: number;
  532. }
  533. }
  534. declare module BABYLON {
  535. /**
  536. * @hidden
  537. **/
  538. export class _TimeToken {
  539. _startTimeQuery: Nullable<WebGLQuery>;
  540. _endTimeQuery: Nullable<WebGLQuery>;
  541. _timeElapsedQuery: Nullable<WebGLQuery>;
  542. _timeElapsedQueryEnded: boolean;
  543. }
  544. }
  545. declare module BABYLON {
  546. /** Defines the cross module used constants to avoid circular dependncies */
  547. export class Constants {
  548. /** Defines that alpha blending is disabled */
  549. static readonly ALPHA_DISABLE: number;
  550. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  551. static readonly ALPHA_ADD: number;
  552. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  553. static readonly ALPHA_COMBINE: number;
  554. /** Defines that alpha blending to DEST - SRC * DEST */
  555. static readonly ALPHA_SUBTRACT: number;
  556. /** Defines that alpha blending to SRC * DEST */
  557. static readonly ALPHA_MULTIPLY: number;
  558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  559. static readonly ALPHA_MAXIMIZED: number;
  560. /** Defines that alpha blending to SRC + DEST */
  561. static readonly ALPHA_ONEONE: number;
  562. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  563. static readonly ALPHA_PREMULTIPLIED: number;
  564. /**
  565. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  566. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  567. */
  568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  569. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  570. static readonly ALPHA_INTERPOLATE: number;
  571. /**
  572. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  573. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  574. */
  575. static readonly ALPHA_SCREENMODE: number;
  576. /**
  577. * Defines that alpha blending to SRC + DST
  578. * Alpha will be set to SRC ALPHA + DST ALPHA
  579. */
  580. static readonly ALPHA_ONEONE_ONEONE: number;
  581. /**
  582. * Defines that alpha blending to SRC * DST ALPHA + DST
  583. * Alpha will be set to 0
  584. */
  585. static readonly ALPHA_ALPHATOCOLOR: number;
  586. /**
  587. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  588. */
  589. static readonly ALPHA_REVERSEONEMINUS: number;
  590. /**
  591. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  592. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  593. */
  594. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  595. /**
  596. * Defines that alpha blending to SRC + DST
  597. * Alpha will be set to SRC ALPHA
  598. */
  599. static readonly ALPHA_ONEONE_ONEZERO: number;
  600. /** Defines that alpha blending equation a SUM */
  601. static readonly ALPHA_EQUATION_ADD: number;
  602. /** Defines that alpha blending equation a SUBSTRACTION */
  603. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  604. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  605. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  606. /** Defines that alpha blending equation a MAX operation */
  607. static readonly ALPHA_EQUATION_MAX: number;
  608. /** Defines that alpha blending equation a MIN operation */
  609. static readonly ALPHA_EQUATION_MIN: number;
  610. /**
  611. * Defines that alpha blending equation a DARKEN operation:
  612. * It takes the min of the src and sums the alpha channels.
  613. */
  614. static readonly ALPHA_EQUATION_DARKEN: number;
  615. /** Defines that the ressource is not delayed*/
  616. static readonly DELAYLOADSTATE_NONE: number;
  617. /** Defines that the ressource was successfully delay loaded */
  618. static readonly DELAYLOADSTATE_LOADED: number;
  619. /** Defines that the ressource is currently delay loading */
  620. static readonly DELAYLOADSTATE_LOADING: number;
  621. /** Defines that the ressource is delayed and has not started loading */
  622. static readonly DELAYLOADSTATE_NOTLOADED: number;
  623. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  624. static readonly NEVER: number;
  625. /** 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 */
  626. static readonly ALWAYS: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  628. static readonly LESS: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  630. static readonly EQUAL: number;
  631. /** 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 */
  632. static readonly LEQUAL: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  634. static readonly GREATER: number;
  635. /** 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 */
  636. static readonly GEQUAL: number;
  637. /** 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 */
  638. static readonly NOTEQUAL: number;
  639. /** Passed to stencilOperation to specify that stencil value must be kept */
  640. static readonly KEEP: number;
  641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  642. static readonly REPLACE: number;
  643. /** Passed to stencilOperation to specify that stencil value must be incremented */
  644. static readonly INCR: number;
  645. /** Passed to stencilOperation to specify that stencil value must be decremented */
  646. static readonly DECR: number;
  647. /** Passed to stencilOperation to specify that stencil value must be inverted */
  648. static readonly INVERT: number;
  649. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  650. static readonly INCR_WRAP: number;
  651. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  652. static readonly DECR_WRAP: number;
  653. /** Texture is not repeating outside of 0..1 UVs */
  654. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  655. /** Texture is repeating outside of 0..1 UVs */
  656. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  657. /** Texture is repeating and mirrored */
  658. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  659. /** ALPHA */
  660. static readonly TEXTUREFORMAT_ALPHA: number;
  661. /** LUMINANCE */
  662. static readonly TEXTUREFORMAT_LUMINANCE: number;
  663. /** LUMINANCE_ALPHA */
  664. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  665. /** RGB */
  666. static readonly TEXTUREFORMAT_RGB: number;
  667. /** RGBA */
  668. static readonly TEXTUREFORMAT_RGBA: number;
  669. /** RED */
  670. static readonly TEXTUREFORMAT_RED: number;
  671. /** RED (2nd reference) */
  672. static readonly TEXTUREFORMAT_R: number;
  673. /** RG */
  674. static readonly TEXTUREFORMAT_RG: number;
  675. /** RED_INTEGER */
  676. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  677. /** RED_INTEGER (2nd reference) */
  678. static readonly TEXTUREFORMAT_R_INTEGER: number;
  679. /** RG_INTEGER */
  680. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  681. /** RGB_INTEGER */
  682. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  683. /** RGBA_INTEGER */
  684. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  685. /** UNSIGNED_BYTE */
  686. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  687. /** UNSIGNED_BYTE (2nd reference) */
  688. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  689. /** FLOAT */
  690. static readonly TEXTURETYPE_FLOAT: number;
  691. /** HALF_FLOAT */
  692. static readonly TEXTURETYPE_HALF_FLOAT: number;
  693. /** BYTE */
  694. static readonly TEXTURETYPE_BYTE: number;
  695. /** SHORT */
  696. static readonly TEXTURETYPE_SHORT: number;
  697. /** UNSIGNED_SHORT */
  698. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  699. /** INT */
  700. static readonly TEXTURETYPE_INT: number;
  701. /** UNSIGNED_INT */
  702. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  703. /** UNSIGNED_SHORT_4_4_4_4 */
  704. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  705. /** UNSIGNED_SHORT_5_5_5_1 */
  706. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  707. /** UNSIGNED_SHORT_5_6_5 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  709. /** UNSIGNED_INT_2_10_10_10_REV */
  710. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  711. /** UNSIGNED_INT_24_8 */
  712. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  713. /** UNSIGNED_INT_10F_11F_11F_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  715. /** UNSIGNED_INT_5_9_9_9_REV */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  717. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  718. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  719. /** nearest is mag = nearest and min = nearest and mip = linear */
  720. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  721. /** Bilinear is mag = linear and min = linear and mip = nearest */
  722. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  723. /** Trilinear is mag = linear and min = linear and mip = linear */
  724. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  725. /** nearest is mag = nearest and min = nearest and mip = linear */
  726. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  728. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  729. /** Trilinear is mag = linear and min = linear and mip = linear */
  730. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  731. /** mag = nearest and min = nearest and mip = nearest */
  732. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  733. /** mag = nearest and min = linear and mip = nearest */
  734. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  735. /** mag = nearest and min = linear and mip = linear */
  736. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  737. /** mag = nearest and min = linear and mip = none */
  738. static readonly TEXTURE_NEAREST_LINEAR: number;
  739. /** mag = nearest and min = nearest and mip = none */
  740. static readonly TEXTURE_NEAREST_NEAREST: number;
  741. /** mag = linear and min = nearest and mip = nearest */
  742. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  743. /** mag = linear and min = nearest and mip = linear */
  744. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  745. /** mag = linear and min = linear and mip = none */
  746. static readonly TEXTURE_LINEAR_LINEAR: number;
  747. /** mag = linear and min = nearest and mip = none */
  748. static readonly TEXTURE_LINEAR_NEAREST: number;
  749. /** Explicit coordinates mode */
  750. static readonly TEXTURE_EXPLICIT_MODE: number;
  751. /** Spherical coordinates mode */
  752. static readonly TEXTURE_SPHERICAL_MODE: number;
  753. /** Planar coordinates mode */
  754. static readonly TEXTURE_PLANAR_MODE: number;
  755. /** Cubic coordinates mode */
  756. static readonly TEXTURE_CUBIC_MODE: number;
  757. /** Projection coordinates mode */
  758. static readonly TEXTURE_PROJECTION_MODE: number;
  759. /** Skybox coordinates mode */
  760. static readonly TEXTURE_SKYBOX_MODE: number;
  761. /** Inverse Cubic coordinates mode */
  762. static readonly TEXTURE_INVCUBIC_MODE: number;
  763. /** Equirectangular coordinates mode */
  764. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  765. /** Equirectangular Fixed coordinates mode */
  766. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  767. /** Equirectangular Fixed Mirrored coordinates mode */
  768. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  769. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  770. static readonly SCALEMODE_FLOOR: number;
  771. /** Defines that texture rescaling will look for the nearest power of 2 size */
  772. static readonly SCALEMODE_NEAREST: number;
  773. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  774. static readonly SCALEMODE_CEILING: number;
  775. /**
  776. * The dirty texture flag value
  777. */
  778. static readonly MATERIAL_TextureDirtyFlag: number;
  779. /**
  780. * The dirty light flag value
  781. */
  782. static readonly MATERIAL_LightDirtyFlag: number;
  783. /**
  784. * The dirty fresnel flag value
  785. */
  786. static readonly MATERIAL_FresnelDirtyFlag: number;
  787. /**
  788. * The dirty attribute flag value
  789. */
  790. static readonly MATERIAL_AttributesDirtyFlag: number;
  791. /**
  792. * The dirty misc flag value
  793. */
  794. static readonly MATERIAL_MiscDirtyFlag: number;
  795. /**
  796. * The all dirty flag value
  797. */
  798. static readonly MATERIAL_AllDirtyFlag: number;
  799. /**
  800. * Returns the triangle fill mode
  801. */
  802. static readonly MATERIAL_TriangleFillMode: number;
  803. /**
  804. * Returns the wireframe mode
  805. */
  806. static readonly MATERIAL_WireFrameFillMode: number;
  807. /**
  808. * Returns the point fill mode
  809. */
  810. static readonly MATERIAL_PointFillMode: number;
  811. /**
  812. * Returns the point list draw mode
  813. */
  814. static readonly MATERIAL_PointListDrawMode: number;
  815. /**
  816. * Returns the line list draw mode
  817. */
  818. static readonly MATERIAL_LineListDrawMode: number;
  819. /**
  820. * Returns the line loop draw mode
  821. */
  822. static readonly MATERIAL_LineLoopDrawMode: number;
  823. /**
  824. * Returns the line strip draw mode
  825. */
  826. static readonly MATERIAL_LineStripDrawMode: number;
  827. /**
  828. * Returns the triangle strip draw mode
  829. */
  830. static readonly MATERIAL_TriangleStripDrawMode: number;
  831. /**
  832. * Returns the triangle fan draw mode
  833. */
  834. static readonly MATERIAL_TriangleFanDrawMode: number;
  835. /**
  836. * Stores the clock-wise side orientation
  837. */
  838. static readonly MATERIAL_ClockWiseSideOrientation: number;
  839. /**
  840. * Stores the counter clock-wise side orientation
  841. */
  842. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  843. /**
  844. * Nothing
  845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  846. */
  847. static readonly ACTION_NothingTrigger: number;
  848. /**
  849. * On pick
  850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  851. */
  852. static readonly ACTION_OnPickTrigger: number;
  853. /**
  854. * On left pick
  855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  856. */
  857. static readonly ACTION_OnLeftPickTrigger: number;
  858. /**
  859. * On right pick
  860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  861. */
  862. static readonly ACTION_OnRightPickTrigger: number;
  863. /**
  864. * On center pick
  865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  866. */
  867. static readonly ACTION_OnCenterPickTrigger: number;
  868. /**
  869. * On pick down
  870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  871. */
  872. static readonly ACTION_OnPickDownTrigger: number;
  873. /**
  874. * On double pick
  875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  876. */
  877. static readonly ACTION_OnDoublePickTrigger: number;
  878. /**
  879. * On pick up
  880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  881. */
  882. static readonly ACTION_OnPickUpTrigger: number;
  883. /**
  884. * On pick out.
  885. * This trigger will only be raised if you also declared a OnPickDown
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_OnPickOutTrigger: number;
  889. /**
  890. * On long press
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnLongPressTrigger: number;
  894. /**
  895. * On pointer over
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnPointerOverTrigger: number;
  899. /**
  900. * On pointer out
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnPointerOutTrigger: number;
  904. /**
  905. * On every frame
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnEveryFrameTrigger: number;
  909. /**
  910. * On intersection enter
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnIntersectionEnterTrigger: number;
  914. /**
  915. * On intersection exit
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnIntersectionExitTrigger: number;
  919. /**
  920. * On key down
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnKeyDownTrigger: number;
  924. /**
  925. * On key up
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnKeyUpTrigger: number;
  929. /**
  930. * Billboard mode will only apply to Y axis
  931. */
  932. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  933. /**
  934. * Billboard mode will apply to all axes
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  937. /**
  938. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  941. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  942. * Test order :
  943. * Is the bounding sphere outside the frustum ?
  944. * If not, are the bounding box vertices outside the frustum ?
  945. * It not, then the cullable object is in the frustum.
  946. */
  947. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  948. /** Culling strategy : Bounding Sphere Only.
  949. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  950. * It's also less accurate than the standard because some not visible objects can still be selected.
  951. * Test : is the bounding sphere outside the frustum ?
  952. * If not, then the cullable object is in the frustum.
  953. */
  954. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  955. /** Culling strategy : Optimistic Inclusion.
  956. * This in an inclusion test first, then the standard exclusion test.
  957. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  958. * 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.
  959. * Anyway, it's as accurate as the standard strategy.
  960. * Test :
  961. * Is the cullable object bounding sphere center in the frustum ?
  962. * If not, apply the default culling strategy.
  963. */
  964. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  965. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  966. * This in an inclusion test first, then the bounding sphere only exclusion test.
  967. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  968. * 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.
  969. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  970. * Test :
  971. * Is the cullable object bounding sphere center in the frustum ?
  972. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  973. */
  974. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  975. /**
  976. * No logging while loading
  977. */
  978. static readonly SCENELOADER_NO_LOGGING: number;
  979. /**
  980. * Minimal logging while loading
  981. */
  982. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  983. /**
  984. * Summary logging while loading
  985. */
  986. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  987. /**
  988. * Detailled logging while loading
  989. */
  990. static readonly SCENELOADER_DETAILED_LOGGING: number;
  991. }
  992. }
  993. declare module BABYLON {
  994. /**
  995. * This represents the required contract to create a new type of texture loader.
  996. */
  997. export interface IInternalTextureLoader {
  998. /**
  999. * Defines wether the loader supports cascade loading the different faces.
  1000. */
  1001. supportCascades: boolean;
  1002. /**
  1003. * This returns if the loader support the current file information.
  1004. * @param extension defines the file extension of the file being loaded
  1005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1006. * @param fallback defines the fallback internal texture if any
  1007. * @param isBase64 defines whether the texture is encoded as a base64
  1008. * @param isBuffer defines whether the texture data are stored as a buffer
  1009. * @returns true if the loader can load the specified file
  1010. */
  1011. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1012. /**
  1013. * Transform the url before loading if required.
  1014. * @param rootUrl the url of the texture
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @returns the transformed texture
  1017. */
  1018. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1019. /**
  1020. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1021. * @param rootUrl the url of the texture
  1022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1023. * @returns the fallback texture
  1024. */
  1025. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1026. /**
  1027. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1028. * @param data contains the texture data
  1029. * @param texture defines the BabylonJS internal texture
  1030. * @param createPolynomials will be true if polynomials have been requested
  1031. * @param onLoad defines the callback to trigger once the texture is ready
  1032. * @param onError defines the callback to trigger in case of error
  1033. */
  1034. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1035. /**
  1036. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1037. * @param data contains the texture data
  1038. * @param texture defines the BabylonJS internal texture
  1039. * @param callback defines the method to call once ready to upload
  1040. */
  1041. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1042. }
  1043. }
  1044. declare module BABYLON {
  1045. /**
  1046. * Class used to store and describe the pipeline context associated with an effect
  1047. */
  1048. export interface IPipelineContext {
  1049. /**
  1050. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1051. */
  1052. isAsync: boolean;
  1053. /**
  1054. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1055. */
  1056. isReady: boolean;
  1057. /** @hidden */
  1058. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1059. }
  1060. }
  1061. declare module BABYLON {
  1062. /**
  1063. * Class used to store gfx data (like WebGLBuffer)
  1064. */
  1065. export class DataBuffer {
  1066. /**
  1067. * Gets or sets the number of objects referencing this buffer
  1068. */
  1069. references: number;
  1070. /** Gets or sets the size of the underlying buffer */
  1071. capacity: number;
  1072. /**
  1073. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1074. */
  1075. is32Bits: boolean;
  1076. /**
  1077. * Gets the underlying buffer
  1078. */
  1079. readonly underlyingResource: any;
  1080. }
  1081. }
  1082. declare module BABYLON {
  1083. /** @hidden */
  1084. export interface IShaderProcessor {
  1085. attributeProcessor?: (attribute: string) => string;
  1086. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1087. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1088. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1089. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1090. lineProcessor?: (line: string, isFragment: boolean) => string;
  1091. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1092. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /** @hidden */
  1097. export interface ProcessingOptions {
  1098. defines: string[];
  1099. indexParameters: any;
  1100. isFragment: boolean;
  1101. shouldUseHighPrecisionShader: boolean;
  1102. supportsUniformBuffers: boolean;
  1103. shadersRepository: string;
  1104. includesShadersStore: {
  1105. [key: string]: string;
  1106. };
  1107. processor?: IShaderProcessor;
  1108. version: string;
  1109. platformName: string;
  1110. lookForClosingBracketForUniformBuffer?: boolean;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Helper to manipulate strings
  1116. */
  1117. export class StringTools {
  1118. /**
  1119. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1120. * @param str Source string
  1121. * @param suffix Suffix to search for in the source string
  1122. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1123. */
  1124. static EndsWith(str: string, suffix: string): boolean;
  1125. /**
  1126. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1127. * @param str Source string
  1128. * @param suffix Suffix to search for in the source string
  1129. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1130. */
  1131. static StartsWith(str: string, suffix: string): boolean;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export class ShaderCodeNode {
  1137. line: string;
  1138. children: ShaderCodeNode[];
  1139. additionalDefineKey?: string;
  1140. additionalDefineValue?: string;
  1141. isValid(preprocessors: {
  1142. [key: string]: string;
  1143. }): boolean;
  1144. process(preprocessors: {
  1145. [key: string]: string;
  1146. }, options: ProcessingOptions): string;
  1147. }
  1148. }
  1149. declare module BABYLON {
  1150. /** @hidden */
  1151. export class ShaderCodeCursor {
  1152. private _lines;
  1153. lineIndex: number;
  1154. readonly currentLine: string;
  1155. readonly canRead: boolean;
  1156. lines: string[];
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderDefineExpression {
  1170. isTrue(preprocessors: {
  1171. [key: string]: string;
  1172. }): boolean;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeTestNode extends ShaderCodeNode {
  1178. testExpression: ShaderDefineExpression;
  1179. isValid(preprocessors: {
  1180. [key: string]: string;
  1181. }): boolean;
  1182. }
  1183. }
  1184. declare module BABYLON {
  1185. /** @hidden */
  1186. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1187. define: string;
  1188. not: boolean;
  1189. constructor(define: string, not?: boolean);
  1190. isTrue(preprocessors: {
  1191. [key: string]: string;
  1192. }): boolean;
  1193. }
  1194. }
  1195. declare module BABYLON {
  1196. /** @hidden */
  1197. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1198. leftOperand: ShaderDefineExpression;
  1199. rightOperand: ShaderDefineExpression;
  1200. isTrue(preprocessors: {
  1201. [key: string]: string;
  1202. }): boolean;
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1208. leftOperand: ShaderDefineExpression;
  1209. rightOperand: ShaderDefineExpression;
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. operand: string;
  1220. testValue: string;
  1221. constructor(define: string, operand: string, testValue: string);
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /**
  1229. * @ignore
  1230. * Application error to support additional information when loading a file
  1231. */
  1232. export class LoadFileError extends Error {
  1233. /** defines the optional web request */
  1234. request?: WebRequest | undefined;
  1235. private static _setPrototypeOf;
  1236. /**
  1237. * Creates a new LoadFileError
  1238. * @param message defines the message of the error
  1239. * @param request defines the optional web request
  1240. */
  1241. constructor(message: string,
  1242. /** defines the optional web request */
  1243. request?: WebRequest | undefined);
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /**
  1248. * Class used to enable access to offline support
  1249. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1250. */
  1251. export interface IOfflineProvider {
  1252. /**
  1253. * Gets a boolean indicating if scene must be saved in the database
  1254. */
  1255. enableSceneOffline: boolean;
  1256. /**
  1257. * Gets a boolean indicating if textures must be saved in the database
  1258. */
  1259. enableTexturesOffline: boolean;
  1260. /**
  1261. * Open the offline support and make it available
  1262. * @param successCallback defines the callback to call on success
  1263. * @param errorCallback defines the callback to call on error
  1264. */
  1265. open(successCallback: () => void, errorCallback: () => void): void;
  1266. /**
  1267. * Loads an image from the offline support
  1268. * @param url defines the url to load from
  1269. * @param image defines the target DOM image
  1270. */
  1271. loadImage(url: string, image: HTMLImageElement): void;
  1272. /**
  1273. * Loads a file from offline support
  1274. * @param url defines the URL to load from
  1275. * @param sceneLoaded defines a callback to call on success
  1276. * @param progressCallBack defines a callback to call when progress changed
  1277. * @param errorCallback defines a callback to call on error
  1278. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1279. */
  1280. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /**
  1285. * Class used to help managing file picking and drag'n'drop
  1286. * File Storage
  1287. */
  1288. export class FilesInputStore {
  1289. /**
  1290. * List of files ready to be loaded
  1291. */
  1292. static FilesToLoad: {
  1293. [key: string]: File;
  1294. };
  1295. }
  1296. }
  1297. declare module BABYLON {
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * @hidden
  1314. */
  1315. export class FileTools {
  1316. /**
  1317. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1318. */
  1319. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1320. /**
  1321. * Gets or sets the base URL to use to load assets
  1322. */
  1323. static BaseUrl: string;
  1324. /**
  1325. * Default behaviour for cors in the application.
  1326. * It can be a string if the expected behavior is identical in the entire app.
  1327. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1328. */
  1329. static CorsBehavior: string | ((url: string | string[]) => string);
  1330. /**
  1331. * Gets or sets a function used to pre-process url before using them to load assets
  1332. */
  1333. static PreprocessUrl: (url: string) => string;
  1334. /**
  1335. * Removes unwanted characters from an url
  1336. * @param url defines the url to clean
  1337. * @returns the cleaned url
  1338. */
  1339. private static _CleanUrl;
  1340. /**
  1341. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1342. * @param url define the url we are trying
  1343. * @param element define the dom element where to configure the cors policy
  1344. */
  1345. static SetCorsBehavior(url: string | string[], element: {
  1346. crossOrigin: string | null;
  1347. }): void;
  1348. private static _ArrayBufferToBase64;
  1349. /**
  1350. * Loads an image as an HTMLImageElement.
  1351. * @param input url string, ArrayBuffer, or Blob to load
  1352. * @param onLoad callback called when the image successfully loads
  1353. * @param onError callback called when the image fails to load
  1354. * @param offlineProvider offline provider for caching
  1355. * @param mimeType optional mime type
  1356. * @returns the HTMLImageElement of the loaded image
  1357. */
  1358. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1359. /**
  1360. * Loads a file
  1361. * @param fileToLoad defines the file to load
  1362. * @param callback defines the callback to call when data is loaded
  1363. * @param progressCallBack defines the callback to call during loading process
  1364. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1365. * @returns a file request object
  1366. */
  1367. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1368. /**
  1369. * Loads a file
  1370. * @param url url string, ArrayBuffer, or Blob to load
  1371. * @param onSuccess callback called when the file successfully loads
  1372. * @param onProgress callback called while file is loading (if the server supports this mode)
  1373. * @param offlineProvider defines the offline provider for caching
  1374. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1375. * @param onError callback called when the file fails to load
  1376. * @returns a file request object
  1377. */
  1378. 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;
  1379. /**
  1380. * Checks if the loaded document was accessed via `file:`-Protocol.
  1381. * @returns boolean
  1382. */
  1383. static IsFileURL(): boolean;
  1384. }
  1385. }
  1386. declare module BABYLON {
  1387. /** @hidden */
  1388. export class ShaderProcessor {
  1389. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1390. private static _ProcessPrecision;
  1391. private static _ExtractOperation;
  1392. private static _BuildSubExpression;
  1393. private static _BuildExpression;
  1394. private static _MoveCursorWithinIf;
  1395. private static _MoveCursor;
  1396. private static _EvaluatePreProcessors;
  1397. private static _PreparePreProcessors;
  1398. private static _ProcessShaderConversion;
  1399. private static _ProcessIncludes;
  1400. }
  1401. }
  1402. declare module BABYLON {
  1403. /**
  1404. * @hidden
  1405. */
  1406. export interface IColor4Like {
  1407. r: float;
  1408. g: float;
  1409. b: float;
  1410. a: float;
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export interface IColor3Like {
  1416. r: float;
  1417. g: float;
  1418. b: float;
  1419. }
  1420. /**
  1421. * @hidden
  1422. */
  1423. export interface IVector4Like {
  1424. x: float;
  1425. y: float;
  1426. z: float;
  1427. w: float;
  1428. }
  1429. /**
  1430. * @hidden
  1431. */
  1432. export interface IVector3Like {
  1433. x: float;
  1434. y: float;
  1435. z: float;
  1436. }
  1437. /**
  1438. * @hidden
  1439. */
  1440. export interface IVector2Like {
  1441. x: float;
  1442. y: float;
  1443. }
  1444. /**
  1445. * @hidden
  1446. */
  1447. export interface IMatrixLike {
  1448. toArray(): DeepImmutable<Float32Array>;
  1449. updateFlag: int;
  1450. }
  1451. /**
  1452. * @hidden
  1453. */
  1454. export interface IViewportLike {
  1455. x: float;
  1456. y: float;
  1457. width: float;
  1458. height: float;
  1459. }
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IPlaneLike {
  1464. normal: IVector3Like;
  1465. d: float;
  1466. normalize(): void;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * Interface used to define common properties for effect fallbacks
  1472. */
  1473. export interface IEffectFallbacks {
  1474. /**
  1475. * Removes the defines that should be removed when falling back.
  1476. * @param currentDefines defines the current define statements for the shader.
  1477. * @param effect defines the current effect we try to compile
  1478. * @returns The resulting defines with defines of the current rank removed.
  1479. */
  1480. reduce(currentDefines: string, effect: Effect): string;
  1481. /**
  1482. * Removes the fallback from the bound mesh.
  1483. */
  1484. unBindMesh(): void;
  1485. /**
  1486. * Checks to see if more fallbacks are still availible.
  1487. */
  1488. hasMoreFallbacks: boolean;
  1489. }
  1490. }
  1491. declare module BABYLON {
  1492. /**
  1493. * Class used to evalaute queries containing `and` and `or` operators
  1494. */
  1495. export class AndOrNotEvaluator {
  1496. /**
  1497. * Evaluate a query
  1498. * @param query defines the query to evaluate
  1499. * @param evaluateCallback defines the callback used to filter result
  1500. * @returns true if the query matches
  1501. */
  1502. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1503. private static _HandleParenthesisContent;
  1504. private static _SimplifyNegation;
  1505. }
  1506. }
  1507. declare module BABYLON {
  1508. /**
  1509. * Class used to store custom tags
  1510. */
  1511. export class Tags {
  1512. /**
  1513. * Adds support for tags on the given object
  1514. * @param obj defines the object to use
  1515. */
  1516. static EnableFor(obj: any): void;
  1517. /**
  1518. * Removes tags support
  1519. * @param obj defines the object to use
  1520. */
  1521. static DisableFor(obj: any): void;
  1522. /**
  1523. * Gets a boolean indicating if the given object has tags
  1524. * @param obj defines the object to use
  1525. * @returns a boolean
  1526. */
  1527. static HasTags(obj: any): boolean;
  1528. /**
  1529. * Gets the tags available on a given object
  1530. * @param obj defines the object to use
  1531. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1532. * @returns the tags
  1533. */
  1534. static GetTags(obj: any, asString?: boolean): any;
  1535. /**
  1536. * Adds tags to an object
  1537. * @param obj defines the object to use
  1538. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1539. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1540. */
  1541. static AddTagsTo(obj: any, tagsString: string): void;
  1542. /**
  1543. * @hidden
  1544. */
  1545. static _AddTagTo(obj: any, tag: string): void;
  1546. /**
  1547. * Removes specific tags from a specific object
  1548. * @param obj defines the object to use
  1549. * @param tagsString defines the tags to remove
  1550. */
  1551. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1552. /**
  1553. * @hidden
  1554. */
  1555. static _RemoveTagFrom(obj: any, tag: string): void;
  1556. /**
  1557. * Defines if tags hosted on an object match a given query
  1558. * @param obj defines the object to use
  1559. * @param tagsQuery defines the tag query
  1560. * @returns a boolean
  1561. */
  1562. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Scalar computation library
  1568. */
  1569. export class Scalar {
  1570. /**
  1571. * Two pi constants convenient for computation.
  1572. */
  1573. static TwoPi: number;
  1574. /**
  1575. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1576. * @param a number
  1577. * @param b number
  1578. * @param epsilon (default = 1.401298E-45)
  1579. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1580. */
  1581. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1582. /**
  1583. * Returns a string : the upper case translation of the number i to hexadecimal.
  1584. * @param i number
  1585. * @returns the upper case translation of the number i to hexadecimal.
  1586. */
  1587. static ToHex(i: number): string;
  1588. /**
  1589. * Returns -1 if value is negative and +1 is value is positive.
  1590. * @param value the value
  1591. * @returns the value itself if it's equal to zero.
  1592. */
  1593. static Sign(value: number): number;
  1594. /**
  1595. * Returns the value itself if it's between min and max.
  1596. * Returns min if the value is lower than min.
  1597. * Returns max if the value is greater than max.
  1598. * @param value the value to clmap
  1599. * @param min the min value to clamp to (default: 0)
  1600. * @param max the max value to clamp to (default: 1)
  1601. * @returns the clamped value
  1602. */
  1603. static Clamp(value: number, min?: number, max?: number): number;
  1604. /**
  1605. * the log2 of value.
  1606. * @param value the value to compute log2 of
  1607. * @returns the log2 of value.
  1608. */
  1609. static Log2(value: number): number;
  1610. /**
  1611. * Loops the value, so that it is never larger than length and never smaller than 0.
  1612. *
  1613. * This is similar to the modulo operator but it works with floating point numbers.
  1614. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1615. * With t = 5 and length = 2.5, the result would be 0.0.
  1616. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1617. * @param value the value
  1618. * @param length the length
  1619. * @returns the looped value
  1620. */
  1621. static Repeat(value: number, length: number): number;
  1622. /**
  1623. * Normalize the value between 0.0 and 1.0 using min and max values
  1624. * @param value value to normalize
  1625. * @param min max to normalize between
  1626. * @param max min to normalize between
  1627. * @returns the normalized value
  1628. */
  1629. static Normalize(value: number, min: number, max: number): number;
  1630. /**
  1631. * Denormalize the value from 0.0 and 1.0 using min and max values
  1632. * @param normalized value to denormalize
  1633. * @param min max to denormalize between
  1634. * @param max min to denormalize between
  1635. * @returns the denormalized value
  1636. */
  1637. static Denormalize(normalized: number, min: number, max: number): number;
  1638. /**
  1639. * Calculates the shortest difference between two given angles given in degrees.
  1640. * @param current current angle in degrees
  1641. * @param target target angle in degrees
  1642. * @returns the delta
  1643. */
  1644. static DeltaAngle(current: number, target: number): number;
  1645. /**
  1646. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1647. * @param tx value
  1648. * @param length length
  1649. * @returns The returned value will move back and forth between 0 and length
  1650. */
  1651. static PingPong(tx: number, length: number): number;
  1652. /**
  1653. * Interpolates between min and max with smoothing at the limits.
  1654. *
  1655. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1656. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1657. * @param from from
  1658. * @param to to
  1659. * @param tx value
  1660. * @returns the smooth stepped value
  1661. */
  1662. static SmoothStep(from: number, to: number, tx: number): number;
  1663. /**
  1664. * Moves a value current towards target.
  1665. *
  1666. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1667. * Negative values of maxDelta pushes the value away from target.
  1668. * @param current current value
  1669. * @param target target value
  1670. * @param maxDelta max distance to move
  1671. * @returns resulting value
  1672. */
  1673. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1674. /**
  1675. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1676. *
  1677. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1678. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1679. * @param current current value
  1680. * @param target target value
  1681. * @param maxDelta max distance to move
  1682. * @returns resulting angle
  1683. */
  1684. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1685. /**
  1686. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1687. * @param start start value
  1688. * @param end target value
  1689. * @param amount amount to lerp between
  1690. * @returns the lerped value
  1691. */
  1692. static Lerp(start: number, end: number, amount: number): number;
  1693. /**
  1694. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1695. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1696. * @param start start value
  1697. * @param end target value
  1698. * @param amount amount to lerp between
  1699. * @returns the lerped value
  1700. */
  1701. static LerpAngle(start: number, end: number, amount: number): number;
  1702. /**
  1703. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1704. * @param a start value
  1705. * @param b target value
  1706. * @param value value between a and b
  1707. * @returns the inverseLerp value
  1708. */
  1709. static InverseLerp(a: number, b: number, value: number): number;
  1710. /**
  1711. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1712. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1713. * @param value1 spline value
  1714. * @param tangent1 spline value
  1715. * @param value2 spline value
  1716. * @param tangent2 spline value
  1717. * @param amount input value
  1718. * @returns hermite result
  1719. */
  1720. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1721. /**
  1722. * Returns a random float number between and min and max values
  1723. * @param min min value of random
  1724. * @param max max value of random
  1725. * @returns random value
  1726. */
  1727. static RandomRange(min: number, max: number): number;
  1728. /**
  1729. * This function returns percentage of a number in a given range.
  1730. *
  1731. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1732. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1733. * @param number to convert to percentage
  1734. * @param min min range
  1735. * @param max max range
  1736. * @returns the percentage
  1737. */
  1738. static RangeToPercent(number: number, min: number, max: number): number;
  1739. /**
  1740. * This function returns number that corresponds to the percentage in a given range.
  1741. *
  1742. * PercentToRange(0.34,0,100) will return 34.
  1743. * @param percent to convert to number
  1744. * @param min min range
  1745. * @param max max range
  1746. * @returns the number
  1747. */
  1748. static PercentToRange(percent: number, min: number, max: number): number;
  1749. /**
  1750. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1751. * @param angle The angle to normalize in radian.
  1752. * @return The converted angle.
  1753. */
  1754. static NormalizeRadians(angle: number): number;
  1755. }
  1756. }
  1757. declare module BABYLON {
  1758. /**
  1759. * Constant used to convert a value to gamma space
  1760. * @ignorenaming
  1761. */
  1762. export const ToGammaSpace: number;
  1763. /**
  1764. * Constant used to convert a value to linear space
  1765. * @ignorenaming
  1766. */
  1767. export const ToLinearSpace = 2.2;
  1768. /**
  1769. * Constant used to define the minimal number value in Babylon.js
  1770. * @ignorenaming
  1771. */
  1772. let Epsilon: number;
  1773. }
  1774. declare module BABYLON {
  1775. /**
  1776. * Class used to represent a viewport on screen
  1777. */
  1778. export class Viewport {
  1779. /** viewport left coordinate */
  1780. x: number;
  1781. /** viewport top coordinate */
  1782. y: number;
  1783. /**viewport width */
  1784. width: number;
  1785. /** viewport height */
  1786. height: number;
  1787. /**
  1788. * Creates a Viewport object located at (x, y) and sized (width, height)
  1789. * @param x defines viewport left coordinate
  1790. * @param y defines viewport top coordinate
  1791. * @param width defines the viewport width
  1792. * @param height defines the viewport height
  1793. */
  1794. constructor(
  1795. /** viewport left coordinate */
  1796. x: number,
  1797. /** viewport top coordinate */
  1798. y: number,
  1799. /**viewport width */
  1800. width: number,
  1801. /** viewport height */
  1802. height: number);
  1803. /**
  1804. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1805. * @param renderWidth defines the rendering width
  1806. * @param renderHeight defines the rendering height
  1807. * @returns a new Viewport
  1808. */
  1809. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1810. /**
  1811. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1812. * @param renderWidth defines the rendering width
  1813. * @param renderHeight defines the rendering height
  1814. * @param ref defines the target viewport
  1815. * @returns the current viewport
  1816. */
  1817. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1818. /**
  1819. * Returns a new Viewport copied from the current one
  1820. * @returns a new Viewport
  1821. */
  1822. clone(): Viewport;
  1823. }
  1824. }
  1825. declare module BABYLON {
  1826. /**
  1827. * Class containing a set of static utilities functions for arrays.
  1828. */
  1829. export class ArrayTools {
  1830. /**
  1831. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1832. * @param size the number of element to construct and put in the array
  1833. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1834. * @returns a new array filled with new objects
  1835. */
  1836. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1837. }
  1838. }
  1839. declare module BABYLON {
  1840. /**
  1841. * Class representing a vector containing 2 coordinates
  1842. */
  1843. export class Vector2 {
  1844. /** defines the first coordinate */
  1845. x: number;
  1846. /** defines the second coordinate */
  1847. y: number;
  1848. /**
  1849. * Creates a new Vector2 from the given x and y coordinates
  1850. * @param x defines the first coordinate
  1851. * @param y defines the second coordinate
  1852. */
  1853. constructor(
  1854. /** defines the first coordinate */
  1855. x?: number,
  1856. /** defines the second coordinate */
  1857. y?: number);
  1858. /**
  1859. * Gets a string with the Vector2 coordinates
  1860. * @returns a string with the Vector2 coordinates
  1861. */
  1862. toString(): string;
  1863. /**
  1864. * Gets class name
  1865. * @returns the string "Vector2"
  1866. */
  1867. getClassName(): string;
  1868. /**
  1869. * Gets current vector hash code
  1870. * @returns the Vector2 hash code as a number
  1871. */
  1872. getHashCode(): number;
  1873. /**
  1874. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1875. * @param array defines the source array
  1876. * @param index defines the offset in source array
  1877. * @returns the current Vector2
  1878. */
  1879. toArray(array: FloatArray, index?: number): Vector2;
  1880. /**
  1881. * Copy the current vector to an array
  1882. * @returns a new array with 2 elements: the Vector2 coordinates.
  1883. */
  1884. asArray(): number[];
  1885. /**
  1886. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1887. * @param source defines the source Vector2
  1888. * @returns the current updated Vector2
  1889. */
  1890. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1891. /**
  1892. * Sets the Vector2 coordinates with the given floats
  1893. * @param x defines the first coordinate
  1894. * @param y defines the second coordinate
  1895. * @returns the current updated Vector2
  1896. */
  1897. copyFromFloats(x: number, y: number): Vector2;
  1898. /**
  1899. * Sets the Vector2 coordinates with the given floats
  1900. * @param x defines the first coordinate
  1901. * @param y defines the second coordinate
  1902. * @returns the current updated Vector2
  1903. */
  1904. set(x: number, y: number): Vector2;
  1905. /**
  1906. * Add another vector with the current one
  1907. * @param otherVector defines the other vector
  1908. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1909. */
  1910. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1911. /**
  1912. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1913. * @param otherVector defines the other vector
  1914. * @param result defines the target vector
  1915. * @returns the unmodified current Vector2
  1916. */
  1917. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1918. /**
  1919. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1920. * @param otherVector defines the other vector
  1921. * @returns the current updated Vector2
  1922. */
  1923. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1924. /**
  1925. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1926. * @param otherVector defines the other vector
  1927. * @returns a new Vector2
  1928. */
  1929. addVector3(otherVector: Vector3): Vector2;
  1930. /**
  1931. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1932. * @param otherVector defines the other vector
  1933. * @returns a new Vector2
  1934. */
  1935. subtract(otherVector: Vector2): Vector2;
  1936. /**
  1937. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1938. * @param otherVector defines the other vector
  1939. * @param result defines the target vector
  1940. * @returns the unmodified current Vector2
  1941. */
  1942. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1943. /**
  1944. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1945. * @param otherVector defines the other vector
  1946. * @returns the current updated Vector2
  1947. */
  1948. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Multiplies in place the current Vector2 coordinates by the given ones
  1951. * @param otherVector defines the other vector
  1952. * @returns the current updated Vector2
  1953. */
  1954. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1957. * @param otherVector defines the other vector
  1958. * @returns a new Vector2
  1959. */
  1960. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1961. /**
  1962. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1963. * @param otherVector defines the other vector
  1964. * @param result defines the target vector
  1965. * @returns the unmodified current Vector2
  1966. */
  1967. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1968. /**
  1969. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1970. * @param x defines the first coordinate
  1971. * @param y defines the second coordinate
  1972. * @returns a new Vector2
  1973. */
  1974. multiplyByFloats(x: number, y: number): Vector2;
  1975. /**
  1976. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns a new Vector2
  1979. */
  1980. divide(otherVector: Vector2): Vector2;
  1981. /**
  1982. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1983. * @param otherVector defines the other vector
  1984. * @param result defines the target vector
  1985. * @returns the unmodified current Vector2
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1988. /**
  1989. * Divides the current Vector2 coordinates by the given ones
  1990. * @param otherVector defines the other vector
  1991. * @returns the current updated Vector2
  1992. */
  1993. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1994. /**
  1995. * Gets a new Vector2 with current Vector2 negated coordinates
  1996. * @returns a new Vector2
  1997. */
  1998. negate(): Vector2;
  1999. /**
  2000. * Multiply the Vector2 coordinates by scale
  2001. * @param scale defines the scaling factor
  2002. * @returns the current updated Vector2
  2003. */
  2004. scaleInPlace(scale: number): Vector2;
  2005. /**
  2006. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2007. * @param scale defines the scaling factor
  2008. * @returns a new Vector2
  2009. */
  2010. scale(scale: number): Vector2;
  2011. /**
  2012. * Scale the current Vector2 values by a factor to a given Vector2
  2013. * @param scale defines the scale factor
  2014. * @param result defines the Vector2 object where to store the result
  2015. * @returns the unmodified current Vector2
  2016. */
  2017. scaleToRef(scale: number, result: Vector2): Vector2;
  2018. /**
  2019. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2020. * @param scale defines the scale factor
  2021. * @param result defines the Vector2 object where to store the result
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a boolean if two vectors are equals
  2027. * @param otherVector defines the other vector
  2028. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2029. */
  2030. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2031. /**
  2032. * Gets a boolean if two vectors are equals (using an epsilon value)
  2033. * @param otherVector defines the other vector
  2034. * @param epsilon defines the minimal distance to consider equality
  2035. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2036. */
  2037. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2038. /**
  2039. * Gets a new Vector2 from current Vector2 floored values
  2040. * @returns a new Vector2
  2041. */
  2042. floor(): Vector2;
  2043. /**
  2044. * Gets a new Vector2 from current Vector2 floored values
  2045. * @returns a new Vector2
  2046. */
  2047. fract(): Vector2;
  2048. /**
  2049. * Gets the length of the vector
  2050. * @returns the vector length (float)
  2051. */
  2052. length(): number;
  2053. /**
  2054. * Gets the vector squared length
  2055. * @returns the vector squared length (float)
  2056. */
  2057. lengthSquared(): number;
  2058. /**
  2059. * Normalize the vector
  2060. * @returns the current updated Vector2
  2061. */
  2062. normalize(): Vector2;
  2063. /**
  2064. * Gets a new Vector2 copied from the Vector2
  2065. * @returns a new Vector2
  2066. */
  2067. clone(): Vector2;
  2068. /**
  2069. * Gets a new Vector2(0, 0)
  2070. * @returns a new Vector2
  2071. */
  2072. static Zero(): Vector2;
  2073. /**
  2074. * Gets a new Vector2(1, 1)
  2075. * @returns a new Vector2
  2076. */
  2077. static One(): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set from the given index element of the given array
  2080. * @param array defines the data source
  2081. * @param offset defines the offset in the data source
  2082. * @returns a new Vector2
  2083. */
  2084. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2085. /**
  2086. * Sets "result" from the given index element of the given array
  2087. * @param array defines the data source
  2088. * @param offset defines the offset in the data source
  2089. * @param result defines the target vector
  2090. */
  2091. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2092. /**
  2093. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2094. * @param value1 defines 1st point of control
  2095. * @param value2 defines 2nd point of control
  2096. * @param value3 defines 3rd point of control
  2097. * @param value4 defines 4th point of control
  2098. * @param amount defines the interpolation factor
  2099. * @returns a new Vector2
  2100. */
  2101. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2102. /**
  2103. * 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".
  2104. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2105. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2106. * @param value defines the value to clamp
  2107. * @param min defines the lower limit
  2108. * @param max defines the upper limit
  2109. * @returns a new Vector2
  2110. */
  2111. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2112. /**
  2113. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2114. * @param value1 defines the 1st control point
  2115. * @param tangent1 defines the outgoing tangent
  2116. * @param value2 defines the 2nd control point
  2117. * @param tangent2 defines the incoming tangent
  2118. * @param amount defines the interpolation factor
  2119. * @returns a new Vector2
  2120. */
  2121. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2122. /**
  2123. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2124. * @param start defines the start vector
  2125. * @param end defines the end vector
  2126. * @param amount defines the interpolation factor
  2127. * @returns a new Vector2
  2128. */
  2129. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2130. /**
  2131. * Gets the dot product of the vector "left" and the vector "right"
  2132. * @param left defines first vector
  2133. * @param right defines second vector
  2134. * @returns the dot product (float)
  2135. */
  2136. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2137. /**
  2138. * Returns a new Vector2 equal to the normalized given vector
  2139. * @param vector defines the vector to normalize
  2140. * @returns a new Vector2
  2141. */
  2142. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2145. * @param left defines 1st vector
  2146. * @param right defines 2nd vector
  2147. * @returns a new Vector2
  2148. */
  2149. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2150. /**
  2151. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2152. * @param left defines 1st vector
  2153. * @param right defines 2nd vector
  2154. * @returns a new Vector2
  2155. */
  2156. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2157. /**
  2158. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2159. * @param vector defines the vector to transform
  2160. * @param transformation defines the matrix to apply
  2161. * @returns a new Vector2
  2162. */
  2163. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2164. /**
  2165. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2166. * @param vector defines the vector to transform
  2167. * @param transformation defines the matrix to apply
  2168. * @param result defines the target vector
  2169. */
  2170. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2171. /**
  2172. * Determines if a given vector is included in a triangle
  2173. * @param p defines the vector to test
  2174. * @param p0 defines 1st triangle point
  2175. * @param p1 defines 2nd triangle point
  2176. * @param p2 defines 3rd triangle point
  2177. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2178. */
  2179. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2180. /**
  2181. * Gets the distance between the vectors "value1" and "value2"
  2182. * @param value1 defines first vector
  2183. * @param value2 defines second vector
  2184. * @returns the distance between vectors
  2185. */
  2186. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2187. /**
  2188. * Returns the squared distance between the vectors "value1" and "value2"
  2189. * @param value1 defines first vector
  2190. * @param value2 defines second vector
  2191. * @returns the squared distance between vectors
  2192. */
  2193. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2196. * @param value1 defines first vector
  2197. * @param value2 defines second vector
  2198. * @returns a new Vector2
  2199. */
  2200. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2203. * @param p defines the middle point
  2204. * @param segA defines one point of the segment
  2205. * @param segB defines the other point of the segment
  2206. * @returns the shortest distance
  2207. */
  2208. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2209. }
  2210. /**
  2211. * Classed used to store (x,y,z) vector representation
  2212. * A Vector3 is the main object used in 3D geometry
  2213. * It can represent etiher the coordinates of a point the space, either a direction
  2214. * Reminder: js uses a left handed forward facing system
  2215. */
  2216. export class Vector3 {
  2217. /**
  2218. * Defines the first coordinates (on X axis)
  2219. */
  2220. x: number;
  2221. /**
  2222. * Defines the second coordinates (on Y axis)
  2223. */
  2224. y: number;
  2225. /**
  2226. * Defines the third coordinates (on Z axis)
  2227. */
  2228. z: number;
  2229. private static _UpReadOnly;
  2230. private static _ZeroReadOnly;
  2231. /**
  2232. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2233. * @param x defines the first coordinates (on X axis)
  2234. * @param y defines the second coordinates (on Y axis)
  2235. * @param z defines the third coordinates (on Z axis)
  2236. */
  2237. constructor(
  2238. /**
  2239. * Defines the first coordinates (on X axis)
  2240. */
  2241. x?: number,
  2242. /**
  2243. * Defines the second coordinates (on Y axis)
  2244. */
  2245. y?: number,
  2246. /**
  2247. * Defines the third coordinates (on Z axis)
  2248. */
  2249. z?: number);
  2250. /**
  2251. * Creates a string representation of the Vector3
  2252. * @returns a string with the Vector3 coordinates.
  2253. */
  2254. toString(): string;
  2255. /**
  2256. * Gets the class name
  2257. * @returns the string "Vector3"
  2258. */
  2259. getClassName(): string;
  2260. /**
  2261. * Creates the Vector3 hash code
  2262. * @returns a number which tends to be unique between Vector3 instances
  2263. */
  2264. getHashCode(): number;
  2265. /**
  2266. * Creates an array containing three elements : the coordinates of the Vector3
  2267. * @returns a new array of numbers
  2268. */
  2269. asArray(): number[];
  2270. /**
  2271. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2272. * @param array defines the destination array
  2273. * @param index defines the offset in the destination array
  2274. * @returns the current Vector3
  2275. */
  2276. toArray(array: FloatArray, index?: number): Vector3;
  2277. /**
  2278. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2279. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2280. */
  2281. toQuaternion(): Quaternion;
  2282. /**
  2283. * Adds the given vector to the current Vector3
  2284. * @param otherVector defines the second operand
  2285. * @returns the current updated Vector3
  2286. */
  2287. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2288. /**
  2289. * Adds the given coordinates to the current Vector3
  2290. * @param x defines the x coordinate of the operand
  2291. * @param y defines the y coordinate of the operand
  2292. * @param z defines the z coordinate of the operand
  2293. * @returns the current updated Vector3
  2294. */
  2295. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2296. /**
  2297. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2298. * @param otherVector defines the second operand
  2299. * @returns the resulting Vector3
  2300. */
  2301. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2302. /**
  2303. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2304. * @param otherVector defines the second operand
  2305. * @param result defines the Vector3 object where to store the result
  2306. * @returns the current Vector3
  2307. */
  2308. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2309. /**
  2310. * Subtract the given vector from the current Vector3
  2311. * @param otherVector defines the second operand
  2312. * @returns the current updated Vector3
  2313. */
  2314. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2315. /**
  2316. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2317. * @param otherVector defines the second operand
  2318. * @returns the resulting Vector3
  2319. */
  2320. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2321. /**
  2322. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2323. * @param otherVector defines the second operand
  2324. * @param result defines the Vector3 object where to store the result
  2325. * @returns the current Vector3
  2326. */
  2327. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2328. /**
  2329. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2330. * @param x defines the x coordinate of the operand
  2331. * @param y defines the y coordinate of the operand
  2332. * @param z defines the z coordinate of the operand
  2333. * @returns the resulting Vector3
  2334. */
  2335. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2336. /**
  2337. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2338. * @param x defines the x coordinate of the operand
  2339. * @param y defines the y coordinate of the operand
  2340. * @param z defines the z coordinate of the operand
  2341. * @param result defines the Vector3 object where to store the result
  2342. * @returns the current Vector3
  2343. */
  2344. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2345. /**
  2346. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2347. * @returns a new Vector3
  2348. */
  2349. negate(): Vector3;
  2350. /**
  2351. * Multiplies the Vector3 coordinates by the float "scale"
  2352. * @param scale defines the multiplier factor
  2353. * @returns the current updated Vector3
  2354. */
  2355. scaleInPlace(scale: number): Vector3;
  2356. /**
  2357. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2358. * @param scale defines the multiplier factor
  2359. * @returns a new Vector3
  2360. */
  2361. scale(scale: number): Vector3;
  2362. /**
  2363. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2364. * @param scale defines the multiplier factor
  2365. * @param result defines the Vector3 object where to store the result
  2366. * @returns the current Vector3
  2367. */
  2368. scaleToRef(scale: number, result: Vector3): Vector3;
  2369. /**
  2370. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2371. * @param scale defines the scale factor
  2372. * @param result defines the Vector3 object where to store the result
  2373. * @returns the unmodified current Vector3
  2374. */
  2375. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2376. /**
  2377. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2378. * @param otherVector defines the second operand
  2379. * @returns true if both vectors are equals
  2380. */
  2381. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2382. /**
  2383. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2384. * @param otherVector defines the second operand
  2385. * @param epsilon defines the minimal distance to define values as equals
  2386. * @returns true if both vectors are distant less than epsilon
  2387. */
  2388. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2389. /**
  2390. * Returns true if the current Vector3 coordinates equals the given floats
  2391. * @param x defines the x coordinate of the operand
  2392. * @param y defines the y coordinate of the operand
  2393. * @param z defines the z coordinate of the operand
  2394. * @returns true if both vectors are equals
  2395. */
  2396. equalsToFloats(x: number, y: number, z: number): boolean;
  2397. /**
  2398. * Multiplies the current Vector3 coordinates by the given ones
  2399. * @param otherVector defines the second operand
  2400. * @returns the current updated Vector3
  2401. */
  2402. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2403. /**
  2404. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2405. * @param otherVector defines the second operand
  2406. * @returns the new Vector3
  2407. */
  2408. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2411. * @param otherVector defines the second operand
  2412. * @param result defines the Vector3 object where to store the result
  2413. * @returns the current Vector3
  2414. */
  2415. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2416. /**
  2417. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2418. * @param x defines the x coordinate of the operand
  2419. * @param y defines the y coordinate of the operand
  2420. * @param z defines the z coordinate of the operand
  2421. * @returns the new Vector3
  2422. */
  2423. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2424. /**
  2425. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2426. * @param otherVector defines the second operand
  2427. * @returns the new Vector3
  2428. */
  2429. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2430. /**
  2431. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2432. * @param otherVector defines the second operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2437. /**
  2438. * Divides the current Vector3 coordinates by the given ones.
  2439. * @param otherVector defines the second operand
  2440. * @returns the current updated Vector3
  2441. */
  2442. divideInPlace(otherVector: Vector3): Vector3;
  2443. /**
  2444. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2445. * @param other defines the second operand
  2446. * @returns the current updated Vector3
  2447. */
  2448. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2451. * @param other defines the second operand
  2452. * @returns the current updated Vector3
  2453. */
  2454. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2455. /**
  2456. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2457. * @param x defines the x coordinate of the operand
  2458. * @param y defines the y coordinate of the operand
  2459. * @param z defines the z coordinate of the operand
  2460. * @returns the current updated Vector3
  2461. */
  2462. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2463. /**
  2464. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2465. * @param x defines the x coordinate of the operand
  2466. * @param y defines the y coordinate of the operand
  2467. * @param z defines the z coordinate of the operand
  2468. * @returns the current updated Vector3
  2469. */
  2470. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2471. /**
  2472. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2473. * Check if is non uniform within a certain amount of decimal places to account for this
  2474. * @param epsilon the amount the values can differ
  2475. * @returns if the the vector is non uniform to a certain number of decimal places
  2476. */
  2477. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2478. /**
  2479. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2480. */
  2481. readonly isNonUniform: boolean;
  2482. /**
  2483. * Gets a new Vector3 from current Vector3 floored values
  2484. * @returns a new Vector3
  2485. */
  2486. floor(): Vector3;
  2487. /**
  2488. * Gets a new Vector3 from current Vector3 floored values
  2489. * @returns a new Vector3
  2490. */
  2491. fract(): Vector3;
  2492. /**
  2493. * Gets the length of the Vector3
  2494. * @returns the length of the Vector3
  2495. */
  2496. length(): number;
  2497. /**
  2498. * Gets the squared length of the Vector3
  2499. * @returns squared length of the Vector3
  2500. */
  2501. lengthSquared(): number;
  2502. /**
  2503. * Normalize the current Vector3.
  2504. * Please note that this is an in place operation.
  2505. * @returns the current updated Vector3
  2506. */
  2507. normalize(): Vector3;
  2508. /**
  2509. * Reorders the x y z properties of the vector in place
  2510. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2511. * @returns the current updated vector
  2512. */
  2513. reorderInPlace(order: string): this;
  2514. /**
  2515. * Rotates the vector around 0,0,0 by a quaternion
  2516. * @param quaternion the rotation quaternion
  2517. * @param result vector to store the result
  2518. * @returns the resulting vector
  2519. */
  2520. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2521. /**
  2522. * Rotates a vector around a given point
  2523. * @param quaternion the rotation quaternion
  2524. * @param point the point to rotate around
  2525. * @param result vector to store the result
  2526. * @returns the resulting vector
  2527. */
  2528. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2531. * The cross product is then orthogonal to both current and "other"
  2532. * @param other defines the right operand
  2533. * @returns the cross product
  2534. */
  2535. cross(other: Vector3): Vector3;
  2536. /**
  2537. * Normalize the current Vector3 with the given input length.
  2538. * Please note that this is an in place operation.
  2539. * @param len the length of the vector
  2540. * @returns the current updated Vector3
  2541. */
  2542. normalizeFromLength(len: number): Vector3;
  2543. /**
  2544. * Normalize the current Vector3 to a new vector
  2545. * @returns the new Vector3
  2546. */
  2547. normalizeToNew(): Vector3;
  2548. /**
  2549. * Normalize the current Vector3 to the reference
  2550. * @param reference define the Vector3 to update
  2551. * @returns the updated Vector3
  2552. */
  2553. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Creates a new Vector3 copied from the current Vector3
  2556. * @returns the new Vector3
  2557. */
  2558. clone(): Vector3;
  2559. /**
  2560. * Copies the given vector coordinates to the current Vector3 ones
  2561. * @param source defines the source Vector3
  2562. * @returns the current updated Vector3
  2563. */
  2564. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2565. /**
  2566. * Copies the given floats to the current Vector3 coordinates
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. copyFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Copies the given floats to the current Vector3 coordinates
  2575. * @param x defines the x coordinate of the operand
  2576. * @param y defines the y coordinate of the operand
  2577. * @param z defines the z coordinate of the operand
  2578. * @returns the current updated Vector3
  2579. */
  2580. set(x: number, y: number, z: number): Vector3;
  2581. /**
  2582. * Copies the given float to the current Vector3 coordinates
  2583. * @param v defines the x, y and z coordinates of the operand
  2584. * @returns the current updated Vector3
  2585. */
  2586. setAll(v: number): Vector3;
  2587. /**
  2588. * Get the clip factor between two vectors
  2589. * @param vector0 defines the first operand
  2590. * @param vector1 defines the second operand
  2591. * @param axis defines the axis to use
  2592. * @param size defines the size along the axis
  2593. * @returns the clip factor
  2594. */
  2595. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2596. /**
  2597. * Get angle between two vectors
  2598. * @param vector0 angle between vector0 and vector1
  2599. * @param vector1 angle between vector0 and vector1
  2600. * @param normal direction of the normal
  2601. * @return the angle between vector0 and vector1
  2602. */
  2603. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2604. /**
  2605. * Returns a new Vector3 set from the index "offset" of the given array
  2606. * @param array defines the source array
  2607. * @param offset defines the offset in the source array
  2608. * @returns the new Vector3
  2609. */
  2610. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2611. /**
  2612. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2613. * This function is deprecated. Use FromArray instead
  2614. * @param array defines the source array
  2615. * @param offset defines the offset in the source array
  2616. * @returns the new Vector3
  2617. */
  2618. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2619. /**
  2620. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2621. * @param array defines the source array
  2622. * @param offset defines the offset in the source array
  2623. * @param result defines the Vector3 where to store the result
  2624. */
  2625. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2626. /**
  2627. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2628. * This function is deprecated. Use FromArrayToRef instead.
  2629. * @param array defines the source array
  2630. * @param offset defines the offset in the source array
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2634. /**
  2635. * Sets the given vector "result" with the given floats.
  2636. * @param x defines the x coordinate of the source
  2637. * @param y defines the y coordinate of the source
  2638. * @param z defines the z coordinate of the source
  2639. * @param result defines the Vector3 where to store the result
  2640. */
  2641. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2642. /**
  2643. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2644. * @returns a new empty Vector3
  2645. */
  2646. static Zero(): Vector3;
  2647. /**
  2648. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2649. * @returns a new unit Vector3
  2650. */
  2651. static One(): Vector3;
  2652. /**
  2653. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2654. * @returns a new up Vector3
  2655. */
  2656. static Up(): Vector3;
  2657. /**
  2658. * Gets a up Vector3 that must not be updated
  2659. */
  2660. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2661. /**
  2662. * Gets a zero Vector3 that must not be updated
  2663. */
  2664. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2665. /**
  2666. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2667. * @returns a new down Vector3
  2668. */
  2669. static Down(): Vector3;
  2670. /**
  2671. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2672. * @returns a new forward Vector3
  2673. */
  2674. static Forward(): Vector3;
  2675. /**
  2676. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2677. * @returns a new forward Vector3
  2678. */
  2679. static Backward(): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2682. * @returns a new right Vector3
  2683. */
  2684. static Right(): Vector3;
  2685. /**
  2686. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2687. * @returns a new left Vector3
  2688. */
  2689. static Left(): Vector3;
  2690. /**
  2691. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2692. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2693. * @param vector defines the Vector3 to transform
  2694. * @param transformation defines the transformation matrix
  2695. * @returns the transformed Vector3
  2696. */
  2697. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2698. /**
  2699. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2700. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2701. * @param vector defines the Vector3 to transform
  2702. * @param transformation defines the transformation matrix
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2708. * This method computes tranformed coordinates only, not transformed direction vectors
  2709. * @param x define the x coordinate of the source vector
  2710. * @param y define the y coordinate of the source vector
  2711. * @param z define the z coordinate of the source vector
  2712. * @param transformation defines the transformation matrix
  2713. * @param result defines the Vector3 where to store the result
  2714. */
  2715. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2716. /**
  2717. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2718. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2719. * @param vector defines the Vector3 to transform
  2720. * @param transformation defines the transformation matrix
  2721. * @returns the new Vector3
  2722. */
  2723. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2724. /**
  2725. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2726. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2727. * @param vector defines the Vector3 to transform
  2728. * @param transformation defines the transformation matrix
  2729. * @param result defines the Vector3 where to store the result
  2730. */
  2731. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2732. /**
  2733. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2734. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2735. * @param x define the x coordinate of the source vector
  2736. * @param y define the y coordinate of the source vector
  2737. * @param z define the z coordinate of the source vector
  2738. * @param transformation defines the transformation matrix
  2739. * @param result defines the Vector3 where to store the result
  2740. */
  2741. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2742. /**
  2743. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2744. * @param value1 defines the first control point
  2745. * @param value2 defines the second control point
  2746. * @param value3 defines the third control point
  2747. * @param value4 defines the fourth control point
  2748. * @param amount defines the amount on the spline to use
  2749. * @returns the new Vector3
  2750. */
  2751. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2752. /**
  2753. * 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"
  2754. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2755. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2756. * @param value defines the current value
  2757. * @param min defines the lower range value
  2758. * @param max defines the upper range value
  2759. * @returns the new Vector3
  2760. */
  2761. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * 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"
  2764. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2765. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2766. * @param value defines the current value
  2767. * @param min defines the lower range value
  2768. * @param max defines the upper range value
  2769. * @param result defines the Vector3 where to store the result
  2770. */
  2771. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2772. /**
  2773. * Checks if a given vector is inside a specific range
  2774. * @param v defines the vector to test
  2775. * @param min defines the minimum range
  2776. * @param max defines the maximum range
  2777. */
  2778. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2779. /**
  2780. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2781. * @param value1 defines the first control point
  2782. * @param tangent1 defines the first tangent vector
  2783. * @param value2 defines the second control point
  2784. * @param tangent2 defines the second tangent vector
  2785. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2786. * @returns the new Vector3
  2787. */
  2788. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2789. /**
  2790. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2791. * @param start defines the start value
  2792. * @param end defines the end value
  2793. * @param amount max defines amount between both (between 0 and 1)
  2794. * @returns the new Vector3
  2795. */
  2796. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2797. /**
  2798. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2799. * @param start defines the start value
  2800. * @param end defines the end value
  2801. * @param amount max defines amount between both (between 0 and 1)
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2805. /**
  2806. * Returns the dot product (float) between the vectors "left" and "right"
  2807. * @param left defines the left operand
  2808. * @param right defines the right operand
  2809. * @returns the dot product
  2810. */
  2811. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2812. /**
  2813. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2814. * The cross product is then orthogonal to both "left" and "right"
  2815. * @param left defines the left operand
  2816. * @param right defines the right operand
  2817. * @returns the cross product
  2818. */
  2819. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2820. /**
  2821. * Sets the given vector "result" with the cross product of "left" and "right"
  2822. * The cross product is then orthogonal to both "left" and "right"
  2823. * @param left defines the left operand
  2824. * @param right defines the right operand
  2825. * @param result defines the Vector3 where to store the result
  2826. */
  2827. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2828. /**
  2829. * Returns a new Vector3 as the normalization of the given vector
  2830. * @param vector defines the Vector3 to normalize
  2831. * @returns the new Vector3
  2832. */
  2833. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2834. /**
  2835. * Sets the given vector "result" with the normalization of the given first vector
  2836. * @param vector defines the Vector3 to normalize
  2837. * @param result defines the Vector3 where to store the result
  2838. */
  2839. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2840. /**
  2841. * Project a Vector3 onto screen space
  2842. * @param vector defines the Vector3 to project
  2843. * @param world defines the world matrix to use
  2844. * @param transform defines the transform (view x projection) matrix to use
  2845. * @param viewport defines the screen viewport to use
  2846. * @returns the new Vector3
  2847. */
  2848. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2849. /** @hidden */
  2850. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2851. /**
  2852. * Unproject from screen space to object space
  2853. * @param source defines the screen space Vector3 to use
  2854. * @param viewportWidth defines the current width of the viewport
  2855. * @param viewportHeight defines the current height of the viewport
  2856. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2857. * @param transform defines the transform (view x projection) matrix to use
  2858. * @returns the new Vector3
  2859. */
  2860. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2861. /**
  2862. * Unproject from screen space to object space
  2863. * @param source defines the screen space Vector3 to use
  2864. * @param viewportWidth defines the current width of the viewport
  2865. * @param viewportHeight defines the current height of the viewport
  2866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2867. * @param view defines the view matrix to use
  2868. * @param projection defines the projection matrix to use
  2869. * @returns the new Vector3
  2870. */
  2871. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2872. /**
  2873. * Unproject from screen space to object space
  2874. * @param source defines the screen space Vector3 to use
  2875. * @param viewportWidth defines the current width of the viewport
  2876. * @param viewportHeight defines the current height of the viewport
  2877. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2878. * @param view defines the view matrix to use
  2879. * @param projection defines the projection matrix to use
  2880. * @param result defines the Vector3 where to store the result
  2881. */
  2882. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2883. /**
  2884. * Unproject from screen space to object space
  2885. * @param sourceX defines the screen space x coordinate to use
  2886. * @param sourceY defines the screen space y coordinate to use
  2887. * @param sourceZ defines the screen space z coordinate to use
  2888. * @param viewportWidth defines the current width of the viewport
  2889. * @param viewportHeight defines the current height of the viewport
  2890. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2891. * @param view defines the view matrix to use
  2892. * @param projection defines the projection matrix to use
  2893. * @param result defines the Vector3 where to store the result
  2894. */
  2895. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2896. /**
  2897. * Gets the minimal coordinate values between two Vector3
  2898. * @param left defines the first operand
  2899. * @param right defines the second operand
  2900. * @returns the new Vector3
  2901. */
  2902. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2903. /**
  2904. * Gets the maximal coordinate values between two Vector3
  2905. * @param left defines the first operand
  2906. * @param right defines the second operand
  2907. * @returns the new Vector3
  2908. */
  2909. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2910. /**
  2911. * Returns the distance between the vectors "value1" and "value2"
  2912. * @param value1 defines the first operand
  2913. * @param value2 defines the second operand
  2914. * @returns the distance
  2915. */
  2916. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns the squared distance between the vectors "value1" and "value2"
  2919. * @param value1 defines the first operand
  2920. * @param value2 defines the second operand
  2921. * @returns the squared distance
  2922. */
  2923. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2924. /**
  2925. * Returns a new Vector3 located at the center between "value1" and "value2"
  2926. * @param value1 defines the first operand
  2927. * @param value2 defines the second operand
  2928. * @returns the new Vector3
  2929. */
  2930. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2931. /**
  2932. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2933. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2934. * to something in order to rotate it from its local system to the given target system
  2935. * Note: axis1, axis2 and axis3 are normalized during this operation
  2936. * @param axis1 defines the first axis
  2937. * @param axis2 defines the second axis
  2938. * @param axis3 defines the third axis
  2939. * @returns a new Vector3
  2940. */
  2941. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2942. /**
  2943. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2944. * @param axis1 defines the first axis
  2945. * @param axis2 defines the second axis
  2946. * @param axis3 defines the third axis
  2947. * @param ref defines the Vector3 where to store the result
  2948. */
  2949. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2950. }
  2951. /**
  2952. * Vector4 class created for EulerAngle class conversion to Quaternion
  2953. */
  2954. export class Vector4 {
  2955. /** x value of the vector */
  2956. x: number;
  2957. /** y value of the vector */
  2958. y: number;
  2959. /** z value of the vector */
  2960. z: number;
  2961. /** w value of the vector */
  2962. w: number;
  2963. /**
  2964. * Creates a Vector4 object from the given floats.
  2965. * @param x x value of the vector
  2966. * @param y y value of the vector
  2967. * @param z z value of the vector
  2968. * @param w w value of the vector
  2969. */
  2970. constructor(
  2971. /** x value of the vector */
  2972. x: number,
  2973. /** y value of the vector */
  2974. y: number,
  2975. /** z value of the vector */
  2976. z: number,
  2977. /** w value of the vector */
  2978. w: number);
  2979. /**
  2980. * Returns the string with the Vector4 coordinates.
  2981. * @returns a string containing all the vector values
  2982. */
  2983. toString(): string;
  2984. /**
  2985. * Returns the string "Vector4".
  2986. * @returns "Vector4"
  2987. */
  2988. getClassName(): string;
  2989. /**
  2990. * Returns the Vector4 hash code.
  2991. * @returns a unique hash code
  2992. */
  2993. getHashCode(): number;
  2994. /**
  2995. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2996. * @returns the resulting array
  2997. */
  2998. asArray(): number[];
  2999. /**
  3000. * Populates the given array from the given index with the Vector4 coordinates.
  3001. * @param array array to populate
  3002. * @param index index of the array to start at (default: 0)
  3003. * @returns the Vector4.
  3004. */
  3005. toArray(array: FloatArray, index?: number): Vector4;
  3006. /**
  3007. * Adds the given vector to the current Vector4.
  3008. * @param otherVector the vector to add
  3009. * @returns the updated Vector4.
  3010. */
  3011. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3012. /**
  3013. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3014. * @param otherVector the vector to add
  3015. * @returns the resulting vector
  3016. */
  3017. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3018. /**
  3019. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3020. * @param otherVector the vector to add
  3021. * @param result the vector to store the result
  3022. * @returns the current Vector4.
  3023. */
  3024. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3025. /**
  3026. * Subtract in place the given vector from the current Vector4.
  3027. * @param otherVector the vector to subtract
  3028. * @returns the updated Vector4.
  3029. */
  3030. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3031. /**
  3032. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3033. * @param otherVector the vector to add
  3034. * @returns the new vector with the result
  3035. */
  3036. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3037. /**
  3038. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3039. * @param otherVector the vector to subtract
  3040. * @param result the vector to store the result
  3041. * @returns the current Vector4.
  3042. */
  3043. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3044. /**
  3045. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3046. */
  3047. /**
  3048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3049. * @param x value to subtract
  3050. * @param y value to subtract
  3051. * @param z value to subtract
  3052. * @param w value to subtract
  3053. * @returns new vector containing the result
  3054. */
  3055. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3056. /**
  3057. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3058. * @param x value to subtract
  3059. * @param y value to subtract
  3060. * @param z value to subtract
  3061. * @param w value to subtract
  3062. * @param result the vector to store the result in
  3063. * @returns the current Vector4.
  3064. */
  3065. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3066. /**
  3067. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3068. * @returns a new vector with the negated values
  3069. */
  3070. negate(): Vector4;
  3071. /**
  3072. * Multiplies the current Vector4 coordinates by scale (float).
  3073. * @param scale the number to scale with
  3074. * @returns the updated Vector4.
  3075. */
  3076. scaleInPlace(scale: number): Vector4;
  3077. /**
  3078. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3079. * @param scale the number to scale with
  3080. * @returns a new vector with the result
  3081. */
  3082. scale(scale: number): Vector4;
  3083. /**
  3084. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3085. * @param scale the number to scale with
  3086. * @param result a vector to store the result in
  3087. * @returns the current Vector4.
  3088. */
  3089. scaleToRef(scale: number, result: Vector4): Vector4;
  3090. /**
  3091. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3092. * @param scale defines the scale factor
  3093. * @param result defines the Vector4 object where to store the result
  3094. * @returns the unmodified current Vector4
  3095. */
  3096. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3097. /**
  3098. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3099. * @param otherVector the vector to compare against
  3100. * @returns true if they are equal
  3101. */
  3102. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3103. /**
  3104. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3105. * @param otherVector vector to compare against
  3106. * @param epsilon (Default: very small number)
  3107. * @returns true if they are equal
  3108. */
  3109. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3110. /**
  3111. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3112. * @param x x value to compare against
  3113. * @param y y value to compare against
  3114. * @param z z value to compare against
  3115. * @param w w value to compare against
  3116. * @returns true if equal
  3117. */
  3118. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3119. /**
  3120. * Multiplies in place the current Vector4 by the given one.
  3121. * @param otherVector vector to multiple with
  3122. * @returns the updated Vector4.
  3123. */
  3124. multiplyInPlace(otherVector: Vector4): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3127. * @param otherVector vector to multiple with
  3128. * @returns resulting new vector
  3129. */
  3130. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3133. * @param otherVector vector to multiple with
  3134. * @param result vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3140. * @param x x value multiply with
  3141. * @param y y value multiply with
  3142. * @param z z value multiply with
  3143. * @param w w value multiply with
  3144. * @returns resulting new vector
  3145. */
  3146. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3147. /**
  3148. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3149. * @param otherVector vector to devide with
  3150. * @returns resulting new vector
  3151. */
  3152. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3153. /**
  3154. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3155. * @param otherVector vector to devide with
  3156. * @param result vector to store the result
  3157. * @returns the current Vector4.
  3158. */
  3159. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3160. /**
  3161. * Divides the current Vector3 coordinates by the given ones.
  3162. * @param otherVector vector to devide with
  3163. * @returns the updated Vector3.
  3164. */
  3165. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3166. /**
  3167. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3168. * @param other defines the second operand
  3169. * @returns the current updated Vector4
  3170. */
  3171. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3172. /**
  3173. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3174. * @param other defines the second operand
  3175. * @returns the current updated Vector4
  3176. */
  3177. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3178. /**
  3179. * Gets a new Vector4 from current Vector4 floored values
  3180. * @returns a new Vector4
  3181. */
  3182. floor(): Vector4;
  3183. /**
  3184. * Gets a new Vector4 from current Vector3 floored values
  3185. * @returns a new Vector4
  3186. */
  3187. fract(): Vector4;
  3188. /**
  3189. * Returns the Vector4 length (float).
  3190. * @returns the length
  3191. */
  3192. length(): number;
  3193. /**
  3194. * Returns the Vector4 squared length (float).
  3195. * @returns the length squared
  3196. */
  3197. lengthSquared(): number;
  3198. /**
  3199. * Normalizes in place the Vector4.
  3200. * @returns the updated Vector4.
  3201. */
  3202. normalize(): Vector4;
  3203. /**
  3204. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3205. * @returns this converted to a new vector3
  3206. */
  3207. toVector3(): Vector3;
  3208. /**
  3209. * Returns a new Vector4 copied from the current one.
  3210. * @returns the new cloned vector
  3211. */
  3212. clone(): Vector4;
  3213. /**
  3214. * Updates the current Vector4 with the given one coordinates.
  3215. * @param source the source vector to copy from
  3216. * @returns the updated Vector4.
  3217. */
  3218. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3219. /**
  3220. * Updates the current Vector4 coordinates with the given floats.
  3221. * @param x float to copy from
  3222. * @param y float to copy from
  3223. * @param z float to copy from
  3224. * @param w float to copy from
  3225. * @returns the updated Vector4.
  3226. */
  3227. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3228. /**
  3229. * Updates the current Vector4 coordinates with the given floats.
  3230. * @param x float to set from
  3231. * @param y float to set from
  3232. * @param z float to set from
  3233. * @param w float to set from
  3234. * @returns the updated Vector4.
  3235. */
  3236. set(x: number, y: number, z: number, w: number): Vector4;
  3237. /**
  3238. * Copies the given float to the current Vector3 coordinates
  3239. * @param v defines the x, y, z and w coordinates of the operand
  3240. * @returns the current updated Vector3
  3241. */
  3242. setAll(v: number): Vector4;
  3243. /**
  3244. * Returns a new Vector4 set from the starting index of the given array.
  3245. * @param array the array to pull values from
  3246. * @param offset the offset into the array to start at
  3247. * @returns the new vector
  3248. */
  3249. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3250. /**
  3251. * Updates the given vector "result" from the starting index of the given array.
  3252. * @param array the array to pull values from
  3253. * @param offset the offset into the array to start at
  3254. * @param result the vector to store the result in
  3255. */
  3256. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3257. /**
  3258. * Updates the given vector "result" from the starting index of the given Float32Array.
  3259. * @param array the array to pull values from
  3260. * @param offset the offset into the array to start at
  3261. * @param result the vector to store the result in
  3262. */
  3263. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3264. /**
  3265. * Updates the given vector "result" coordinates from the given floats.
  3266. * @param x float to set from
  3267. * @param y float to set from
  3268. * @param z float to set from
  3269. * @param w float to set from
  3270. * @param result the vector to the floats in
  3271. */
  3272. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3273. /**
  3274. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3275. * @returns the new vector
  3276. */
  3277. static Zero(): Vector4;
  3278. /**
  3279. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3280. * @returns the new vector
  3281. */
  3282. static One(): Vector4;
  3283. /**
  3284. * Returns a new normalized Vector4 from the given one.
  3285. * @param vector the vector to normalize
  3286. * @returns the vector
  3287. */
  3288. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3289. /**
  3290. * Updates the given vector "result" from the normalization of the given one.
  3291. * @param vector the vector to normalize
  3292. * @param result the vector to store the result in
  3293. */
  3294. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3295. /**
  3296. * Returns a vector with the minimum values from the left and right vectors
  3297. * @param left left vector to minimize
  3298. * @param right right vector to minimize
  3299. * @returns a new vector with the minimum of the left and right vector values
  3300. */
  3301. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Returns a vector with the maximum values from the left and right vectors
  3304. * @param left left vector to maximize
  3305. * @param right right vector to maximize
  3306. * @returns a new vector with the maximum of the left and right vector values
  3307. */
  3308. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Returns the distance (float) between the vectors "value1" and "value2".
  3311. * @param value1 value to calulate the distance between
  3312. * @param value2 value to calulate the distance between
  3313. * @return the distance between the two vectors
  3314. */
  3315. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3316. /**
  3317. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3318. * @param value1 value to calulate the distance between
  3319. * @param value2 value to calulate the distance between
  3320. * @return the distance between the two vectors squared
  3321. */
  3322. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3323. /**
  3324. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3325. * @param value1 value to calulate the center between
  3326. * @param value2 value to calulate the center between
  3327. * @return the center between the two vectors
  3328. */
  3329. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3332. * This methods computes transformed normalized direction vectors only.
  3333. * @param vector the vector to transform
  3334. * @param transformation the transformation matrix to apply
  3335. * @returns the new vector
  3336. */
  3337. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3338. /**
  3339. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3340. * This methods computes transformed normalized direction vectors only.
  3341. * @param vector the vector to transform
  3342. * @param transformation the transformation matrix to apply
  3343. * @param result the vector to store the result in
  3344. */
  3345. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3346. /**
  3347. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3348. * This methods computes transformed normalized direction vectors only.
  3349. * @param x value to transform
  3350. * @param y value to transform
  3351. * @param z value to transform
  3352. * @param w value to transform
  3353. * @param transformation the transformation matrix to apply
  3354. * @param result the vector to store the results in
  3355. */
  3356. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3357. /**
  3358. * Creates a new Vector4 from a Vector3
  3359. * @param source defines the source data
  3360. * @param w defines the 4th component (default is 0)
  3361. * @returns a new Vector4
  3362. */
  3363. static FromVector3(source: Vector3, w?: number): Vector4;
  3364. }
  3365. /**
  3366. * Class used to store quaternion data
  3367. * @see https://en.wikipedia.org/wiki/Quaternion
  3368. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3369. */
  3370. export class Quaternion {
  3371. /** defines the first component (0 by default) */
  3372. x: number;
  3373. /** defines the second component (0 by default) */
  3374. y: number;
  3375. /** defines the third component (0 by default) */
  3376. z: number;
  3377. /** defines the fourth component (1.0 by default) */
  3378. w: number;
  3379. /**
  3380. * Creates a new Quaternion from the given floats
  3381. * @param x defines the first component (0 by default)
  3382. * @param y defines the second component (0 by default)
  3383. * @param z defines the third component (0 by default)
  3384. * @param w defines the fourth component (1.0 by default)
  3385. */
  3386. constructor(
  3387. /** defines the first component (0 by default) */
  3388. x?: number,
  3389. /** defines the second component (0 by default) */
  3390. y?: number,
  3391. /** defines the third component (0 by default) */
  3392. z?: number,
  3393. /** defines the fourth component (1.0 by default) */
  3394. w?: number);
  3395. /**
  3396. * Gets a string representation for the current quaternion
  3397. * @returns a string with the Quaternion coordinates
  3398. */
  3399. toString(): string;
  3400. /**
  3401. * Gets the class name of the quaternion
  3402. * @returns the string "Quaternion"
  3403. */
  3404. getClassName(): string;
  3405. /**
  3406. * Gets a hash code for this quaternion
  3407. * @returns the quaternion hash code
  3408. */
  3409. getHashCode(): number;
  3410. /**
  3411. * Copy the quaternion to an array
  3412. * @returns a new array populated with 4 elements from the quaternion coordinates
  3413. */
  3414. asArray(): number[];
  3415. /**
  3416. * Check if two quaternions are equals
  3417. * @param otherQuaternion defines the second operand
  3418. * @return true if the current quaternion and the given one coordinates are strictly equals
  3419. */
  3420. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3421. /**
  3422. * Clone the current quaternion
  3423. * @returns a new quaternion copied from the current one
  3424. */
  3425. clone(): Quaternion;
  3426. /**
  3427. * Copy a quaternion to the current one
  3428. * @param other defines the other quaternion
  3429. * @returns the updated current quaternion
  3430. */
  3431. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3432. /**
  3433. * Updates the current quaternion with the given float coordinates
  3434. * @param x defines the x coordinate
  3435. * @param y defines the y coordinate
  3436. * @param z defines the z coordinate
  3437. * @param w defines the w coordinate
  3438. * @returns the updated current quaternion
  3439. */
  3440. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3441. /**
  3442. * Updates the current quaternion from the given float coordinates
  3443. * @param x defines the x coordinate
  3444. * @param y defines the y coordinate
  3445. * @param z defines the z coordinate
  3446. * @param w defines the w coordinate
  3447. * @returns the updated current quaternion
  3448. */
  3449. set(x: number, y: number, z: number, w: number): Quaternion;
  3450. /**
  3451. * Adds two quaternions
  3452. * @param other defines the second operand
  3453. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3454. */
  3455. add(other: DeepImmutable<Quaternion>): Quaternion;
  3456. /**
  3457. * Add a quaternion to the current one
  3458. * @param other defines the quaternion to add
  3459. * @returns the current quaternion
  3460. */
  3461. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3462. /**
  3463. * Subtract two quaternions
  3464. * @param other defines the second operand
  3465. * @returns a new quaternion as the subtraction result of the given one from the current one
  3466. */
  3467. subtract(other: Quaternion): Quaternion;
  3468. /**
  3469. * Multiplies the current quaternion by a scale factor
  3470. * @param value defines the scale factor
  3471. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3472. */
  3473. scale(value: number): Quaternion;
  3474. /**
  3475. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3476. * @param scale defines the scale factor
  3477. * @param result defines the Quaternion object where to store the result
  3478. * @returns the unmodified current quaternion
  3479. */
  3480. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3481. /**
  3482. * Multiplies in place the current quaternion by a scale factor
  3483. * @param value defines the scale factor
  3484. * @returns the current modified quaternion
  3485. */
  3486. scaleInPlace(value: number): Quaternion;
  3487. /**
  3488. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3489. * @param scale defines the scale factor
  3490. * @param result defines the Quaternion object where to store the result
  3491. * @returns the unmodified current quaternion
  3492. */
  3493. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3494. /**
  3495. * Multiplies two quaternions
  3496. * @param q1 defines the second operand
  3497. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3498. */
  3499. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3500. /**
  3501. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3502. * @param q1 defines the second operand
  3503. * @param result defines the target quaternion
  3504. * @returns the current quaternion
  3505. */
  3506. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3507. /**
  3508. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3509. * @param q1 defines the second operand
  3510. * @returns the currentupdated quaternion
  3511. */
  3512. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3515. * @param ref defines the target quaternion
  3516. * @returns the current quaternion
  3517. */
  3518. conjugateToRef(ref: Quaternion): Quaternion;
  3519. /**
  3520. * Conjugates in place (1-q) the current quaternion
  3521. * @returns the current updated quaternion
  3522. */
  3523. conjugateInPlace(): Quaternion;
  3524. /**
  3525. * Conjugates in place (1-q) the current quaternion
  3526. * @returns a new quaternion
  3527. */
  3528. conjugate(): Quaternion;
  3529. /**
  3530. * Gets length of current quaternion
  3531. * @returns the quaternion length (float)
  3532. */
  3533. length(): number;
  3534. /**
  3535. * Normalize in place the current quaternion
  3536. * @returns the current updated quaternion
  3537. */
  3538. normalize(): Quaternion;
  3539. /**
  3540. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3541. * @param order is a reserved parameter and is ignore for now
  3542. * @returns a new Vector3 containing the Euler angles
  3543. */
  3544. toEulerAngles(order?: string): Vector3;
  3545. /**
  3546. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3547. * @param result defines the vector which will be filled with the Euler angles
  3548. * @param order is a reserved parameter and is ignore for now
  3549. * @returns the current unchanged quaternion
  3550. */
  3551. toEulerAnglesToRef(result: Vector3): Quaternion;
  3552. /**
  3553. * Updates the given rotation matrix with the current quaternion values
  3554. * @param result defines the target matrix
  3555. * @returns the current unchanged quaternion
  3556. */
  3557. toRotationMatrix(result: Matrix): Quaternion;
  3558. /**
  3559. * Updates the current quaternion from the given rotation matrix values
  3560. * @param matrix defines the source matrix
  3561. * @returns the current updated quaternion
  3562. */
  3563. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3564. /**
  3565. * Creates a new quaternion from a rotation matrix
  3566. * @param matrix defines the source matrix
  3567. * @returns a new quaternion created from the given rotation matrix values
  3568. */
  3569. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3570. /**
  3571. * Updates the given quaternion with the given rotation matrix values
  3572. * @param matrix defines the source matrix
  3573. * @param result defines the target quaternion
  3574. */
  3575. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3576. /**
  3577. * Returns the dot product (float) between the quaternions "left" and "right"
  3578. * @param left defines the left operand
  3579. * @param right defines the right operand
  3580. * @returns the dot product
  3581. */
  3582. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3583. /**
  3584. * Checks if the two quaternions are close to each other
  3585. * @param quat0 defines the first quaternion to check
  3586. * @param quat1 defines the second quaternion to check
  3587. * @returns true if the two quaternions are close to each other
  3588. */
  3589. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3590. /**
  3591. * Creates an empty quaternion
  3592. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3593. */
  3594. static Zero(): Quaternion;
  3595. /**
  3596. * Inverse a given quaternion
  3597. * @param q defines the source quaternion
  3598. * @returns a new quaternion as the inverted current quaternion
  3599. */
  3600. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3601. /**
  3602. * Inverse a given quaternion
  3603. * @param q defines the source quaternion
  3604. * @param result the quaternion the result will be stored in
  3605. * @returns the result quaternion
  3606. */
  3607. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3608. /**
  3609. * Creates an identity quaternion
  3610. * @returns the identity quaternion
  3611. */
  3612. static Identity(): Quaternion;
  3613. /**
  3614. * Gets a boolean indicating if the given quaternion is identity
  3615. * @param quaternion defines the quaternion to check
  3616. * @returns true if the quaternion is identity
  3617. */
  3618. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3619. /**
  3620. * Creates a quaternion from a rotation around an axis
  3621. * @param axis defines the axis to use
  3622. * @param angle defines the angle to use
  3623. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3624. */
  3625. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3626. /**
  3627. * Creates a rotation around an axis and stores it into the given quaternion
  3628. * @param axis defines the axis to use
  3629. * @param angle defines the angle to use
  3630. * @param result defines the target quaternion
  3631. * @returns the target quaternion
  3632. */
  3633. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3634. /**
  3635. * Creates a new quaternion from data stored into an array
  3636. * @param array defines the data source
  3637. * @param offset defines the offset in the source array where the data starts
  3638. * @returns a new quaternion
  3639. */
  3640. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3641. /**
  3642. * Create a quaternion from Euler rotation angles
  3643. * @param x Pitch
  3644. * @param y Yaw
  3645. * @param z Roll
  3646. * @returns the new Quaternion
  3647. */
  3648. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3649. /**
  3650. * Updates a quaternion from Euler rotation angles
  3651. * @param x Pitch
  3652. * @param y Yaw
  3653. * @param z Roll
  3654. * @param result the quaternion to store the result
  3655. * @returns the updated quaternion
  3656. */
  3657. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3658. /**
  3659. * Create a quaternion from Euler rotation vector
  3660. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3661. * @returns the new Quaternion
  3662. */
  3663. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3664. /**
  3665. * Updates a quaternion from Euler rotation vector
  3666. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3667. * @param result the quaternion to store the result
  3668. * @returns the updated quaternion
  3669. */
  3670. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3673. * @param yaw defines the rotation around Y axis
  3674. * @param pitch defines the rotation around X axis
  3675. * @param roll defines the rotation around Z axis
  3676. * @returns the new quaternion
  3677. */
  3678. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3679. /**
  3680. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3681. * @param yaw defines the rotation around Y axis
  3682. * @param pitch defines the rotation around X axis
  3683. * @param roll defines the rotation around Z axis
  3684. * @param result defines the target quaternion
  3685. */
  3686. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3687. /**
  3688. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3689. * @param alpha defines the rotation around first axis
  3690. * @param beta defines the rotation around second axis
  3691. * @param gamma defines the rotation around third axis
  3692. * @returns the new quaternion
  3693. */
  3694. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3697. * @param alpha defines the rotation around first axis
  3698. * @param beta defines the rotation around second axis
  3699. * @param gamma defines the rotation around third axis
  3700. * @param result defines the target quaternion
  3701. */
  3702. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3703. /**
  3704. * 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)
  3705. * @param axis1 defines the first axis
  3706. * @param axis2 defines the second axis
  3707. * @param axis3 defines the third axis
  3708. * @returns the new quaternion
  3709. */
  3710. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3711. /**
  3712. * 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
  3713. * @param axis1 defines the first axis
  3714. * @param axis2 defines the second axis
  3715. * @param axis3 defines the third axis
  3716. * @param ref defines the target quaternion
  3717. */
  3718. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3719. /**
  3720. * Interpolates between two quaternions
  3721. * @param left defines first quaternion
  3722. * @param right defines second quaternion
  3723. * @param amount defines the gradient to use
  3724. * @returns the new interpolated quaternion
  3725. */
  3726. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3727. /**
  3728. * Interpolates between two quaternions and stores it into a target quaternion
  3729. * @param left defines first quaternion
  3730. * @param right defines second quaternion
  3731. * @param amount defines the gradient to use
  3732. * @param result defines the target quaternion
  3733. */
  3734. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3735. /**
  3736. * Interpolate between two quaternions using Hermite interpolation
  3737. * @param value1 defines first quaternion
  3738. * @param tangent1 defines the incoming tangent
  3739. * @param value2 defines second quaternion
  3740. * @param tangent2 defines the outgoing tangent
  3741. * @param amount defines the target quaternion
  3742. * @returns the new interpolated quaternion
  3743. */
  3744. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3745. }
  3746. /**
  3747. * Class used to store matrix data (4x4)
  3748. */
  3749. export class Matrix {
  3750. private static _updateFlagSeed;
  3751. private static _identityReadOnly;
  3752. private _isIdentity;
  3753. private _isIdentityDirty;
  3754. private _isIdentity3x2;
  3755. private _isIdentity3x2Dirty;
  3756. /**
  3757. * Gets the update flag of the matrix which is an unique number for the matrix.
  3758. * It will be incremented every time the matrix data change.
  3759. * You can use it to speed the comparison between two versions of the same matrix.
  3760. */
  3761. updateFlag: number;
  3762. private readonly _m;
  3763. /**
  3764. * Gets the internal data of the matrix
  3765. */
  3766. readonly m: DeepImmutable<Float32Array>;
  3767. /** @hidden */
  3768. _markAsUpdated(): void;
  3769. /** @hidden */
  3770. private _updateIdentityStatus;
  3771. /**
  3772. * Creates an empty matrix (filled with zeros)
  3773. */
  3774. constructor();
  3775. /**
  3776. * Check if the current matrix is identity
  3777. * @returns true is the matrix is the identity matrix
  3778. */
  3779. isIdentity(): boolean;
  3780. /**
  3781. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3782. * @returns true is the matrix is the identity matrix
  3783. */
  3784. isIdentityAs3x2(): boolean;
  3785. /**
  3786. * Gets the determinant of the matrix
  3787. * @returns the matrix determinant
  3788. */
  3789. determinant(): number;
  3790. /**
  3791. * Returns the matrix as a Float32Array
  3792. * @returns the matrix underlying array
  3793. */
  3794. toArray(): DeepImmutable<Float32Array>;
  3795. /**
  3796. * Returns the matrix as a Float32Array
  3797. * @returns the matrix underlying array.
  3798. */
  3799. asArray(): DeepImmutable<Float32Array>;
  3800. /**
  3801. * Inverts the current matrix in place
  3802. * @returns the current inverted matrix
  3803. */
  3804. invert(): Matrix;
  3805. /**
  3806. * Sets all the matrix elements to zero
  3807. * @returns the current matrix
  3808. */
  3809. reset(): Matrix;
  3810. /**
  3811. * Adds the current matrix with a second one
  3812. * @param other defines the matrix to add
  3813. * @returns a new matrix as the addition of the current matrix and the given one
  3814. */
  3815. add(other: DeepImmutable<Matrix>): Matrix;
  3816. /**
  3817. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3818. * @param other defines the matrix to add
  3819. * @param result defines the target matrix
  3820. * @returns the current matrix
  3821. */
  3822. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3823. /**
  3824. * Adds in place the given matrix to the current matrix
  3825. * @param other defines the second operand
  3826. * @returns the current updated matrix
  3827. */
  3828. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3829. /**
  3830. * Sets the given matrix to the current inverted Matrix
  3831. * @param other defines the target matrix
  3832. * @returns the unmodified current matrix
  3833. */
  3834. invertToRef(other: Matrix): Matrix;
  3835. /**
  3836. * add a value at the specified position in the current Matrix
  3837. * @param index the index of the value within the matrix. between 0 and 15.
  3838. * @param value the value to be added
  3839. * @returns the current updated matrix
  3840. */
  3841. addAtIndex(index: number, value: number): Matrix;
  3842. /**
  3843. * mutiply the specified position in the current Matrix by a value
  3844. * @param index the index of the value within the matrix. between 0 and 15.
  3845. * @param value the value to be added
  3846. * @returns the current updated matrix
  3847. */
  3848. multiplyAtIndex(index: number, value: number): Matrix;
  3849. /**
  3850. * Inserts the translation vector (using 3 floats) in the current matrix
  3851. * @param x defines the 1st component of the translation
  3852. * @param y defines the 2nd component of the translation
  3853. * @param z defines the 3rd component of the translation
  3854. * @returns the current updated matrix
  3855. */
  3856. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3857. /**
  3858. * Adds the translation vector (using 3 floats) in the current matrix
  3859. * @param x defines the 1st component of the translation
  3860. * @param y defines the 2nd component of the translation
  3861. * @param z defines the 3rd component of the translation
  3862. * @returns the current updated matrix
  3863. */
  3864. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3865. /**
  3866. * Inserts the translation vector in the current matrix
  3867. * @param vector3 defines the translation to insert
  3868. * @returns the current updated matrix
  3869. */
  3870. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3871. /**
  3872. * Gets the translation value of the current matrix
  3873. * @returns a new Vector3 as the extracted translation from the matrix
  3874. */
  3875. getTranslation(): Vector3;
  3876. /**
  3877. * Fill a Vector3 with the extracted translation from the matrix
  3878. * @param result defines the Vector3 where to store the translation
  3879. * @returns the current matrix
  3880. */
  3881. getTranslationToRef(result: Vector3): Matrix;
  3882. /**
  3883. * Remove rotation and scaling part from the matrix
  3884. * @returns the updated matrix
  3885. */
  3886. removeRotationAndScaling(): Matrix;
  3887. /**
  3888. * Multiply two matrices
  3889. * @param other defines the second operand
  3890. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3891. */
  3892. multiply(other: DeepImmutable<Matrix>): Matrix;
  3893. /**
  3894. * Copy the current matrix from the given one
  3895. * @param other defines the source matrix
  3896. * @returns the current updated matrix
  3897. */
  3898. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3899. /**
  3900. * Populates the given array from the starting index with the current matrix values
  3901. * @param array defines the target array
  3902. * @param offset defines the offset in the target array where to start storing values
  3903. * @returns the current matrix
  3904. */
  3905. copyToArray(array: Float32Array, offset?: number): Matrix;
  3906. /**
  3907. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3908. * @param other defines the second operand
  3909. * @param result defines the matrix where to store the multiplication
  3910. * @returns the current matrix
  3911. */
  3912. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3913. /**
  3914. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3915. * @param other defines the second operand
  3916. * @param result defines the array where to store the multiplication
  3917. * @param offset defines the offset in the target array where to start storing values
  3918. * @returns the current matrix
  3919. */
  3920. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3921. /**
  3922. * Check equality between this matrix and a second one
  3923. * @param value defines the second matrix to compare
  3924. * @returns true is the current matrix and the given one values are strictly equal
  3925. */
  3926. equals(value: DeepImmutable<Matrix>): boolean;
  3927. /**
  3928. * Clone the current matrix
  3929. * @returns a new matrix from the current matrix
  3930. */
  3931. clone(): Matrix;
  3932. /**
  3933. * Returns the name of the current matrix class
  3934. * @returns the string "Matrix"
  3935. */
  3936. getClassName(): string;
  3937. /**
  3938. * Gets the hash code of the current matrix
  3939. * @returns the hash code
  3940. */
  3941. getHashCode(): number;
  3942. /**
  3943. * Decomposes the current Matrix into a translation, rotation and scaling components
  3944. * @param scale defines the scale vector3 given as a reference to update
  3945. * @param rotation defines the rotation quaternion given as a reference to update
  3946. * @param translation defines the translation vector3 given as a reference to update
  3947. * @returns true if operation was successful
  3948. */
  3949. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3950. /**
  3951. * Gets specific row of the matrix
  3952. * @param index defines the number of the row to get
  3953. * @returns the index-th row of the current matrix as a new Vector4
  3954. */
  3955. getRow(index: number): Nullable<Vector4>;
  3956. /**
  3957. * Sets the index-th row of the current matrix to the vector4 values
  3958. * @param index defines the number of the row to set
  3959. * @param row defines the target vector4
  3960. * @returns the updated current matrix
  3961. */
  3962. setRow(index: number, row: Vector4): Matrix;
  3963. /**
  3964. * Compute the transpose of the matrix
  3965. * @returns the new transposed matrix
  3966. */
  3967. transpose(): Matrix;
  3968. /**
  3969. * Compute the transpose of the matrix and store it in a given matrix
  3970. * @param result defines the target matrix
  3971. * @returns the current matrix
  3972. */
  3973. transposeToRef(result: Matrix): Matrix;
  3974. /**
  3975. * Sets the index-th row of the current matrix with the given 4 x float values
  3976. * @param index defines the row index
  3977. * @param x defines the x component to set
  3978. * @param y defines the y component to set
  3979. * @param z defines the z component to set
  3980. * @param w defines the w component to set
  3981. * @returns the updated current matrix
  3982. */
  3983. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3984. /**
  3985. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3986. * @param scale defines the scale factor
  3987. * @returns a new matrix
  3988. */
  3989. scale(scale: number): Matrix;
  3990. /**
  3991. * Scale the current matrix values by a factor to a given result matrix
  3992. * @param scale defines the scale factor
  3993. * @param result defines the matrix to store the result
  3994. * @returns the current matrix
  3995. */
  3996. scaleToRef(scale: number, result: Matrix): Matrix;
  3997. /**
  3998. * Scale the current matrix values by a factor and add the result to a given matrix
  3999. * @param scale defines the scale factor
  4000. * @param result defines the Matrix to store the result
  4001. * @returns the current matrix
  4002. */
  4003. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4004. /**
  4005. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4006. * @param ref matrix to store the result
  4007. */
  4008. toNormalMatrix(ref: Matrix): void;
  4009. /**
  4010. * Gets only rotation part of the current matrix
  4011. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4012. */
  4013. getRotationMatrix(): Matrix;
  4014. /**
  4015. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4016. * @param result defines the target matrix to store data to
  4017. * @returns the current matrix
  4018. */
  4019. getRotationMatrixToRef(result: Matrix): Matrix;
  4020. /**
  4021. * Toggles model matrix from being right handed to left handed in place and vice versa
  4022. */
  4023. toggleModelMatrixHandInPlace(): void;
  4024. /**
  4025. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4026. */
  4027. toggleProjectionMatrixHandInPlace(): void;
  4028. /**
  4029. * Creates a matrix from an array
  4030. * @param array defines the source array
  4031. * @param offset defines an offset in the source array
  4032. * @returns a new Matrix set from the starting index of the given array
  4033. */
  4034. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4035. /**
  4036. * Copy the content of an array into a given matrix
  4037. * @param array defines the source array
  4038. * @param offset defines an offset in the source array
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4042. /**
  4043. * Stores an array into a matrix after having multiplied each component by a given factor
  4044. * @param array defines the source array
  4045. * @param offset defines the offset in the source array
  4046. * @param scale defines the scaling factor
  4047. * @param result defines the target matrix
  4048. */
  4049. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4050. /**
  4051. * Gets an identity matrix that must not be updated
  4052. */
  4053. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4054. /**
  4055. * Stores a list of values (16) inside a given matrix
  4056. * @param initialM11 defines 1st value of 1st row
  4057. * @param initialM12 defines 2nd value of 1st row
  4058. * @param initialM13 defines 3rd value of 1st row
  4059. * @param initialM14 defines 4th value of 1st row
  4060. * @param initialM21 defines 1st value of 2nd row
  4061. * @param initialM22 defines 2nd value of 2nd row
  4062. * @param initialM23 defines 3rd value of 2nd row
  4063. * @param initialM24 defines 4th value of 2nd row
  4064. * @param initialM31 defines 1st value of 3rd row
  4065. * @param initialM32 defines 2nd value of 3rd row
  4066. * @param initialM33 defines 3rd value of 3rd row
  4067. * @param initialM34 defines 4th value of 3rd row
  4068. * @param initialM41 defines 1st value of 4th row
  4069. * @param initialM42 defines 2nd value of 4th row
  4070. * @param initialM43 defines 3rd value of 4th row
  4071. * @param initialM44 defines 4th value of 4th row
  4072. * @param result defines the target matrix
  4073. */
  4074. 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;
  4075. /**
  4076. * Creates new matrix from a list of values (16)
  4077. * @param initialM11 defines 1st value of 1st row
  4078. * @param initialM12 defines 2nd value of 1st row
  4079. * @param initialM13 defines 3rd value of 1st row
  4080. * @param initialM14 defines 4th value of 1st row
  4081. * @param initialM21 defines 1st value of 2nd row
  4082. * @param initialM22 defines 2nd value of 2nd row
  4083. * @param initialM23 defines 3rd value of 2nd row
  4084. * @param initialM24 defines 4th value of 2nd row
  4085. * @param initialM31 defines 1st value of 3rd row
  4086. * @param initialM32 defines 2nd value of 3rd row
  4087. * @param initialM33 defines 3rd value of 3rd row
  4088. * @param initialM34 defines 4th value of 3rd row
  4089. * @param initialM41 defines 1st value of 4th row
  4090. * @param initialM42 defines 2nd value of 4th row
  4091. * @param initialM43 defines 3rd value of 4th row
  4092. * @param initialM44 defines 4th value of 4th row
  4093. * @returns the new matrix
  4094. */
  4095. 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;
  4096. /**
  4097. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4098. * @param scale defines the scale vector3
  4099. * @param rotation defines the rotation quaternion
  4100. * @param translation defines the translation vector3
  4101. * @returns a new matrix
  4102. */
  4103. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4104. /**
  4105. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4106. * @param scale defines the scale vector3
  4107. * @param rotation defines the rotation quaternion
  4108. * @param translation defines the translation vector3
  4109. * @param result defines the target matrix
  4110. */
  4111. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4112. /**
  4113. * Creates a new identity matrix
  4114. * @returns a new identity matrix
  4115. */
  4116. static Identity(): Matrix;
  4117. /**
  4118. * Creates a new identity matrix and stores the result in a given matrix
  4119. * @param result defines the target matrix
  4120. */
  4121. static IdentityToRef(result: Matrix): void;
  4122. /**
  4123. * Creates a new zero matrix
  4124. * @returns a new zero matrix
  4125. */
  4126. static Zero(): Matrix;
  4127. /**
  4128. * Creates a new rotation matrix for "angle" radians around the X axis
  4129. * @param angle defines the angle (in radians) to use
  4130. * @return the new matrix
  4131. */
  4132. static RotationX(angle: number): Matrix;
  4133. /**
  4134. * Creates a new matrix as the invert of a given matrix
  4135. * @param source defines the source matrix
  4136. * @returns the new matrix
  4137. */
  4138. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4141. * @param angle defines the angle (in radians) to use
  4142. * @param result defines the target matrix
  4143. */
  4144. static RotationXToRef(angle: number, result: Matrix): void;
  4145. /**
  4146. * Creates a new rotation matrix for "angle" radians around the Y axis
  4147. * @param angle defines the angle (in radians) to use
  4148. * @return the new matrix
  4149. */
  4150. static RotationY(angle: number): Matrix;
  4151. /**
  4152. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4153. * @param angle defines the angle (in radians) to use
  4154. * @param result defines the target matrix
  4155. */
  4156. static RotationYToRef(angle: number, result: Matrix): void;
  4157. /**
  4158. * Creates a new rotation matrix for "angle" radians around the Z axis
  4159. * @param angle defines the angle (in radians) to use
  4160. * @return the new matrix
  4161. */
  4162. static RotationZ(angle: number): Matrix;
  4163. /**
  4164. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4165. * @param angle defines the angle (in radians) to use
  4166. * @param result defines the target matrix
  4167. */
  4168. static RotationZToRef(angle: number, result: Matrix): void;
  4169. /**
  4170. * Creates a new rotation matrix for "angle" radians around the given axis
  4171. * @param axis defines the axis to use
  4172. * @param angle defines the angle (in radians) to use
  4173. * @return the new matrix
  4174. */
  4175. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4176. /**
  4177. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4178. * @param axis defines the axis to use
  4179. * @param angle defines the angle (in radians) to use
  4180. * @param result defines the target matrix
  4181. */
  4182. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4183. /**
  4184. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4185. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4186. * @param from defines the vector to align
  4187. * @param to defines the vector to align to
  4188. * @param result defines the target matrix
  4189. */
  4190. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4191. /**
  4192. * Creates a rotation matrix
  4193. * @param yaw defines the yaw angle in radians (Y axis)
  4194. * @param pitch defines the pitch angle in radians (X axis)
  4195. * @param roll defines the roll angle in radians (X axis)
  4196. * @returns the new rotation matrix
  4197. */
  4198. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4199. /**
  4200. * Creates a rotation matrix and stores it in a given matrix
  4201. * @param yaw defines the yaw angle in radians (Y axis)
  4202. * @param pitch defines the pitch angle in radians (X axis)
  4203. * @param roll defines the roll angle in radians (X axis)
  4204. * @param result defines the target matrix
  4205. */
  4206. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4207. /**
  4208. * Creates a scaling matrix
  4209. * @param x defines the scale factor on X axis
  4210. * @param y defines the scale factor on Y axis
  4211. * @param z defines the scale factor on Z axis
  4212. * @returns the new matrix
  4213. */
  4214. static Scaling(x: number, y: number, z: number): Matrix;
  4215. /**
  4216. * Creates a scaling matrix and stores it in a given matrix
  4217. * @param x defines the scale factor on X axis
  4218. * @param y defines the scale factor on Y axis
  4219. * @param z defines the scale factor on Z axis
  4220. * @param result defines the target matrix
  4221. */
  4222. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4223. /**
  4224. * Creates a translation matrix
  4225. * @param x defines the translation on X axis
  4226. * @param y defines the translation on Y axis
  4227. * @param z defines the translationon Z axis
  4228. * @returns the new matrix
  4229. */
  4230. static Translation(x: number, y: number, z: number): Matrix;
  4231. /**
  4232. * Creates a translation matrix and stores it in a given matrix
  4233. * @param x defines the translation on X axis
  4234. * @param y defines the translation on Y axis
  4235. * @param z defines the translationon Z axis
  4236. * @param result defines the target matrix
  4237. */
  4238. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4239. /**
  4240. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4241. * @param startValue defines the start value
  4242. * @param endValue defines the end value
  4243. * @param gradient defines the gradient factor
  4244. * @returns the new matrix
  4245. */
  4246. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4247. /**
  4248. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4249. * @param startValue defines the start value
  4250. * @param endValue defines the end value
  4251. * @param gradient defines the gradient factor
  4252. * @param result defines the Matrix object where to store data
  4253. */
  4254. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4255. /**
  4256. * Builds a new matrix whose values are computed by:
  4257. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4258. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4259. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4260. * @param startValue defines the first matrix
  4261. * @param endValue defines the second matrix
  4262. * @param gradient defines the gradient between the two matrices
  4263. * @returns the new matrix
  4264. */
  4265. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4266. /**
  4267. * Update a matrix to values which are computed by:
  4268. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4269. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4270. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4271. * @param startValue defines the first matrix
  4272. * @param endValue defines the second matrix
  4273. * @param gradient defines the gradient between the two matrices
  4274. * @param result defines the target matrix
  4275. */
  4276. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4277. /**
  4278. * 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"
  4279. * This function works in left handed mode
  4280. * @param eye defines the final position of the entity
  4281. * @param target defines where the entity should look at
  4282. * @param up defines the up vector for the entity
  4283. * @returns the new matrix
  4284. */
  4285. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4286. /**
  4287. * 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".
  4288. * This function works in left handed mode
  4289. * @param eye defines the final position of the entity
  4290. * @param target defines where the entity should look at
  4291. * @param up defines the up vector for the entity
  4292. * @param result defines the target matrix
  4293. */
  4294. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4295. /**
  4296. * 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"
  4297. * This function works in right handed mode
  4298. * @param eye defines the final position of the entity
  4299. * @param target defines where the entity should look at
  4300. * @param up defines the up vector for the entity
  4301. * @returns the new matrix
  4302. */
  4303. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4304. /**
  4305. * 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".
  4306. * This function works in right handed mode
  4307. * @param eye defines the final position of the entity
  4308. * @param target defines where the entity should look at
  4309. * @param up defines the up vector for the entity
  4310. * @param result defines the target matrix
  4311. */
  4312. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Create a left-handed orthographic projection matrix
  4315. * @param width defines the viewport width
  4316. * @param height defines the viewport height
  4317. * @param znear defines the near clip plane
  4318. * @param zfar defines the far clip plane
  4319. * @returns a new matrix as a left-handed orthographic projection matrix
  4320. */
  4321. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4322. /**
  4323. * Store a left-handed orthographic projection to a given matrix
  4324. * @param width defines the viewport width
  4325. * @param height defines the viewport height
  4326. * @param znear defines the near clip plane
  4327. * @param zfar defines the far clip plane
  4328. * @param result defines the target matrix
  4329. */
  4330. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4331. /**
  4332. * Create a left-handed orthographic projection matrix
  4333. * @param left defines the viewport left coordinate
  4334. * @param right defines the viewport right coordinate
  4335. * @param bottom defines the viewport bottom coordinate
  4336. * @param top defines the viewport top coordinate
  4337. * @param znear defines the near clip plane
  4338. * @param zfar defines the far clip plane
  4339. * @returns a new matrix as a left-handed orthographic projection matrix
  4340. */
  4341. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4342. /**
  4343. * Stores a left-handed orthographic projection into a given matrix
  4344. * @param left defines the viewport left coordinate
  4345. * @param right defines the viewport right coordinate
  4346. * @param bottom defines the viewport bottom coordinate
  4347. * @param top defines the viewport top coordinate
  4348. * @param znear defines the near clip plane
  4349. * @param zfar defines the far clip plane
  4350. * @param result defines the target matrix
  4351. */
  4352. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4353. /**
  4354. * Creates a right-handed orthographic projection matrix
  4355. * @param left defines the viewport left coordinate
  4356. * @param right defines the viewport right coordinate
  4357. * @param bottom defines the viewport bottom coordinate
  4358. * @param top defines the viewport top coordinate
  4359. * @param znear defines the near clip plane
  4360. * @param zfar defines the far clip plane
  4361. * @returns a new matrix as a right-handed orthographic projection matrix
  4362. */
  4363. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4364. /**
  4365. * Stores a right-handed orthographic projection into a given matrix
  4366. * @param left defines the viewport left coordinate
  4367. * @param right defines the viewport right coordinate
  4368. * @param bottom defines the viewport bottom coordinate
  4369. * @param top defines the viewport top coordinate
  4370. * @param znear defines the near clip plane
  4371. * @param zfar defines the far clip plane
  4372. * @param result defines the target matrix
  4373. */
  4374. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4375. /**
  4376. * Creates a left-handed perspective projection matrix
  4377. * @param width defines the viewport width
  4378. * @param height defines the viewport height
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @returns a new matrix as a left-handed perspective projection matrix
  4382. */
  4383. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4384. /**
  4385. * Creates a left-handed perspective projection matrix
  4386. * @param fov defines the horizontal field of view
  4387. * @param aspect defines the aspect ratio
  4388. * @param znear defines the near clip plane
  4389. * @param zfar defines the far clip plane
  4390. * @returns a new matrix as a left-handed perspective projection matrix
  4391. */
  4392. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4393. /**
  4394. * Stores a left-handed perspective projection into a given matrix
  4395. * @param fov defines the horizontal field of view
  4396. * @param aspect defines the aspect ratio
  4397. * @param znear defines the near clip plane
  4398. * @param zfar defines the far clip plane
  4399. * @param result defines the target matrix
  4400. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4401. */
  4402. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4403. /**
  4404. * Creates a right-handed perspective projection matrix
  4405. * @param fov defines the horizontal field of view
  4406. * @param aspect defines the aspect ratio
  4407. * @param znear defines the near clip plane
  4408. * @param zfar defines the far clip plane
  4409. * @returns a new matrix as a right-handed perspective projection matrix
  4410. */
  4411. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4412. /**
  4413. * Stores a right-handed perspective projection into a given matrix
  4414. * @param fov defines the horizontal field of view
  4415. * @param aspect defines the aspect ratio
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @param result defines the target matrix
  4419. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4420. */
  4421. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4422. /**
  4423. * Stores a perspective projection for WebVR info a given matrix
  4424. * @param fov defines the field of view
  4425. * @param znear defines the near clip plane
  4426. * @param zfar defines the far clip plane
  4427. * @param result defines the target matrix
  4428. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4429. */
  4430. static PerspectiveFovWebVRToRef(fov: {
  4431. upDegrees: number;
  4432. downDegrees: number;
  4433. leftDegrees: number;
  4434. rightDegrees: number;
  4435. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4436. /**
  4437. * Computes a complete transformation matrix
  4438. * @param viewport defines the viewport to use
  4439. * @param world defines the world matrix
  4440. * @param view defines the view matrix
  4441. * @param projection defines the projection matrix
  4442. * @param zmin defines the near clip plane
  4443. * @param zmax defines the far clip plane
  4444. * @returns the transformation matrix
  4445. */
  4446. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4447. /**
  4448. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4449. * @param matrix defines the matrix to use
  4450. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4451. */
  4452. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4453. /**
  4454. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4455. * @param matrix defines the matrix to use
  4456. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4457. */
  4458. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4459. /**
  4460. * Compute the transpose of a given matrix
  4461. * @param matrix defines the matrix to transpose
  4462. * @returns the new matrix
  4463. */
  4464. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4465. /**
  4466. * Compute the transpose of a matrix and store it in a target matrix
  4467. * @param matrix defines the matrix to transpose
  4468. * @param result defines the target matrix
  4469. */
  4470. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4471. /**
  4472. * Computes a reflection matrix from a plane
  4473. * @param plane defines the reflection plane
  4474. * @returns a new matrix
  4475. */
  4476. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4477. /**
  4478. * Computes a reflection matrix from a plane
  4479. * @param plane defines the reflection plane
  4480. * @param result defines the target matrix
  4481. */
  4482. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4483. /**
  4484. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4485. * @param xaxis defines the value of the 1st axis
  4486. * @param yaxis defines the value of the 2nd axis
  4487. * @param zaxis defines the value of the 3rd axis
  4488. * @param result defines the target matrix
  4489. */
  4490. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4491. /**
  4492. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4493. * @param quat defines the quaternion to use
  4494. * @param result defines the target matrix
  4495. */
  4496. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4497. }
  4498. /**
  4499. * @hidden
  4500. */
  4501. export class TmpVectors {
  4502. static Vector2: Vector2[];
  4503. static Vector3: Vector3[];
  4504. static Vector4: Vector4[];
  4505. static Quaternion: Quaternion[];
  4506. static Matrix: Matrix[];
  4507. }
  4508. }
  4509. declare module BABYLON {
  4510. /**
  4511. * Defines potential orientation for back face culling
  4512. */
  4513. export enum Orientation {
  4514. /**
  4515. * Clockwise
  4516. */
  4517. CW = 0,
  4518. /** Counter clockwise */
  4519. CCW = 1
  4520. }
  4521. /** Class used to represent a Bezier curve */
  4522. export class BezierCurve {
  4523. /**
  4524. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4525. * @param t defines the time
  4526. * @param x1 defines the left coordinate on X axis
  4527. * @param y1 defines the left coordinate on Y axis
  4528. * @param x2 defines the right coordinate on X axis
  4529. * @param y2 defines the right coordinate on Y axis
  4530. * @returns the interpolated value
  4531. */
  4532. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4533. }
  4534. /**
  4535. * Defines angle representation
  4536. */
  4537. export class Angle {
  4538. private _radians;
  4539. /**
  4540. * Creates an Angle object of "radians" radians (float).
  4541. * @param radians the angle in radians
  4542. */
  4543. constructor(radians: number);
  4544. /**
  4545. * Get value in degrees
  4546. * @returns the Angle value in degrees (float)
  4547. */
  4548. degrees(): number;
  4549. /**
  4550. * Get value in radians
  4551. * @returns the Angle value in radians (float)
  4552. */
  4553. radians(): number;
  4554. /**
  4555. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4556. * @param a defines first vector
  4557. * @param b defines second vector
  4558. * @returns a new Angle
  4559. */
  4560. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4561. /**
  4562. * Gets a new Angle object from the given float in radians
  4563. * @param radians defines the angle value in radians
  4564. * @returns a new Angle
  4565. */
  4566. static FromRadians(radians: number): Angle;
  4567. /**
  4568. * Gets a new Angle object from the given float in degrees
  4569. * @param degrees defines the angle value in degrees
  4570. * @returns a new Angle
  4571. */
  4572. static FromDegrees(degrees: number): Angle;
  4573. }
  4574. /**
  4575. * This represents an arc in a 2d space.
  4576. */
  4577. export class Arc2 {
  4578. /** Defines the start point of the arc */
  4579. startPoint: Vector2;
  4580. /** Defines the mid point of the arc */
  4581. midPoint: Vector2;
  4582. /** Defines the end point of the arc */
  4583. endPoint: Vector2;
  4584. /**
  4585. * Defines the center point of the arc.
  4586. */
  4587. centerPoint: Vector2;
  4588. /**
  4589. * Defines the radius of the arc.
  4590. */
  4591. radius: number;
  4592. /**
  4593. * Defines the angle of the arc (from mid point to end point).
  4594. */
  4595. angle: Angle;
  4596. /**
  4597. * Defines the start angle of the arc (from start point to middle point).
  4598. */
  4599. startAngle: Angle;
  4600. /**
  4601. * Defines the orientation of the arc (clock wise/counter clock wise).
  4602. */
  4603. orientation: Orientation;
  4604. /**
  4605. * Creates an Arc object from the three given points : start, middle and end.
  4606. * @param startPoint Defines the start point of the arc
  4607. * @param midPoint Defines the midlle point of the arc
  4608. * @param endPoint Defines the end point of the arc
  4609. */
  4610. constructor(
  4611. /** Defines the start point of the arc */
  4612. startPoint: Vector2,
  4613. /** Defines the mid point of the arc */
  4614. midPoint: Vector2,
  4615. /** Defines the end point of the arc */
  4616. endPoint: Vector2);
  4617. }
  4618. /**
  4619. * Represents a 2D path made up of multiple 2D points
  4620. */
  4621. export class Path2 {
  4622. private _points;
  4623. private _length;
  4624. /**
  4625. * If the path start and end point are the same
  4626. */
  4627. closed: boolean;
  4628. /**
  4629. * Creates a Path2 object from the starting 2D coordinates x and y.
  4630. * @param x the starting points x value
  4631. * @param y the starting points y value
  4632. */
  4633. constructor(x: number, y: number);
  4634. /**
  4635. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4636. * @param x the added points x value
  4637. * @param y the added points y value
  4638. * @returns the updated Path2.
  4639. */
  4640. addLineTo(x: number, y: number): Path2;
  4641. /**
  4642. * 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.
  4643. * @param midX middle point x value
  4644. * @param midY middle point y value
  4645. * @param endX end point x value
  4646. * @param endY end point y value
  4647. * @param numberOfSegments (default: 36)
  4648. * @returns the updated Path2.
  4649. */
  4650. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4651. /**
  4652. * Closes the Path2.
  4653. * @returns the Path2.
  4654. */
  4655. close(): Path2;
  4656. /**
  4657. * Gets the sum of the distance between each sequential point in the path
  4658. * @returns the Path2 total length (float).
  4659. */
  4660. length(): number;
  4661. /**
  4662. * Gets the points which construct the path
  4663. * @returns the Path2 internal array of points.
  4664. */
  4665. getPoints(): Vector2[];
  4666. /**
  4667. * Retreives the point at the distance aways from the starting point
  4668. * @param normalizedLengthPosition the length along the path to retreive the point from
  4669. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4670. */
  4671. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4672. /**
  4673. * Creates a new path starting from an x and y position
  4674. * @param x starting x value
  4675. * @param y starting y value
  4676. * @returns a new Path2 starting at the coordinates (x, y).
  4677. */
  4678. static StartingAt(x: number, y: number): Path2;
  4679. }
  4680. /**
  4681. * Represents a 3D path made up of multiple 3D points
  4682. */
  4683. export class Path3D {
  4684. /**
  4685. * an array of Vector3, the curve axis of the Path3D
  4686. */
  4687. path: Vector3[];
  4688. private _curve;
  4689. private _distances;
  4690. private _tangents;
  4691. private _normals;
  4692. private _binormals;
  4693. private _raw;
  4694. /**
  4695. * new Path3D(path, normal, raw)
  4696. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4697. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4698. * @param path an array of Vector3, the curve axis of the Path3D
  4699. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4700. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4701. */
  4702. constructor(
  4703. /**
  4704. * an array of Vector3, the curve axis of the Path3D
  4705. */
  4706. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4707. /**
  4708. * Returns the Path3D array of successive Vector3 designing its curve.
  4709. * @returns the Path3D array of successive Vector3 designing its curve.
  4710. */
  4711. getCurve(): Vector3[];
  4712. /**
  4713. * Returns an array populated with tangent vectors on each Path3D curve point.
  4714. * @returns an array populated with tangent vectors on each Path3D curve point.
  4715. */
  4716. getTangents(): Vector3[];
  4717. /**
  4718. * Returns an array populated with normal vectors on each Path3D curve point.
  4719. * @returns an array populated with normal vectors on each Path3D curve point.
  4720. */
  4721. getNormals(): Vector3[];
  4722. /**
  4723. * Returns an array populated with binormal vectors on each Path3D curve point.
  4724. * @returns an array populated with binormal vectors on each Path3D curve point.
  4725. */
  4726. getBinormals(): Vector3[];
  4727. /**
  4728. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4729. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4730. */
  4731. getDistances(): number[];
  4732. /**
  4733. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4734. * @param path path which all values are copied into the curves points
  4735. * @param firstNormal which should be projected onto the curve
  4736. * @returns the same object updated.
  4737. */
  4738. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4739. private _compute;
  4740. private _getFirstNonNullVector;
  4741. private _getLastNonNullVector;
  4742. private _normalVector;
  4743. }
  4744. /**
  4745. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4746. * A Curve3 is designed from a series of successive Vector3.
  4747. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4748. */
  4749. export class Curve3 {
  4750. private _points;
  4751. private _length;
  4752. /**
  4753. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4754. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4755. * @param v1 (Vector3) the control point
  4756. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4757. * @param nbPoints (integer) the wanted number of points in the curve
  4758. * @returns the created Curve3
  4759. */
  4760. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4761. /**
  4762. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4763. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4764. * @param v1 (Vector3) the first control point
  4765. * @param v2 (Vector3) the second control point
  4766. * @param v3 (Vector3) the end point of the Cubic Bezier
  4767. * @param nbPoints (integer) the wanted number of points in the curve
  4768. * @returns the created Curve3
  4769. */
  4770. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4771. /**
  4772. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4773. * @param p1 (Vector3) the origin point of the Hermite Spline
  4774. * @param t1 (Vector3) the tangent vector at the origin point
  4775. * @param p2 (Vector3) the end point of the Hermite Spline
  4776. * @param t2 (Vector3) the tangent vector at the end point
  4777. * @param nbPoints (integer) the wanted number of points in the curve
  4778. * @returns the created Curve3
  4779. */
  4780. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4781. /**
  4782. * Returns a Curve3 object along a CatmullRom Spline curve :
  4783. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4784. * @param nbPoints (integer) the wanted number of points between each curve control points
  4785. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4786. * @returns the created Curve3
  4787. */
  4788. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4789. /**
  4790. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4791. * A Curve3 is designed from a series of successive Vector3.
  4792. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4793. * @param points points which make up the curve
  4794. */
  4795. constructor(points: Vector3[]);
  4796. /**
  4797. * @returns the Curve3 stored array of successive Vector3
  4798. */
  4799. getPoints(): Vector3[];
  4800. /**
  4801. * @returns the computed length (float) of the curve.
  4802. */
  4803. length(): number;
  4804. /**
  4805. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4806. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4807. * curveA and curveB keep unchanged.
  4808. * @param curve the curve to continue from this curve
  4809. * @returns the newly constructed curve
  4810. */
  4811. continue(curve: DeepImmutable<Curve3>): Curve3;
  4812. private _computeLength;
  4813. }
  4814. }
  4815. declare module BABYLON {
  4816. /**
  4817. * This represents the main contract an easing function should follow.
  4818. * Easing functions are used throughout the animation system.
  4819. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4820. */
  4821. export interface IEasingFunction {
  4822. /**
  4823. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4824. * of the easing function.
  4825. * The link below provides some of the most common examples of easing functions.
  4826. * @see https://easings.net/
  4827. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4828. * @returns the corresponding value on the curve defined by the easing function
  4829. */
  4830. ease(gradient: number): number;
  4831. }
  4832. /**
  4833. * Base class used for every default easing function.
  4834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4835. */
  4836. export class EasingFunction implements IEasingFunction {
  4837. /**
  4838. * Interpolation follows the mathematical formula associated with the easing function.
  4839. */
  4840. static readonly EASINGMODE_EASEIN: number;
  4841. /**
  4842. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4843. */
  4844. static readonly EASINGMODE_EASEOUT: number;
  4845. /**
  4846. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4847. */
  4848. static readonly EASINGMODE_EASEINOUT: number;
  4849. private _easingMode;
  4850. /**
  4851. * Sets the easing mode of the current function.
  4852. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4853. */
  4854. setEasingMode(easingMode: number): void;
  4855. /**
  4856. * Gets the current easing mode.
  4857. * @returns the easing mode
  4858. */
  4859. getEasingMode(): number;
  4860. /**
  4861. * @hidden
  4862. */
  4863. easeInCore(gradient: number): number;
  4864. /**
  4865. * Given an input gradient between 0 and 1, this returns the corresponding value
  4866. * of the easing function.
  4867. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4868. * @returns the corresponding value on the curve defined by the easing function
  4869. */
  4870. ease(gradient: number): number;
  4871. }
  4872. /**
  4873. * Easing function with a circle shape (see link below).
  4874. * @see https://easings.net/#easeInCirc
  4875. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4876. */
  4877. export class CircleEase extends EasingFunction implements IEasingFunction {
  4878. /** @hidden */
  4879. easeInCore(gradient: number): number;
  4880. }
  4881. /**
  4882. * Easing function with a ease back shape (see link below).
  4883. * @see https://easings.net/#easeInBack
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. export class BackEase extends EasingFunction implements IEasingFunction {
  4887. /** Defines the amplitude of the function */
  4888. amplitude: number;
  4889. /**
  4890. * Instantiates a back ease easing
  4891. * @see https://easings.net/#easeInBack
  4892. * @param amplitude Defines the amplitude of the function
  4893. */
  4894. constructor(
  4895. /** Defines the amplitude of the function */
  4896. amplitude?: number);
  4897. /** @hidden */
  4898. easeInCore(gradient: number): number;
  4899. }
  4900. /**
  4901. * Easing function with a bouncing shape (see link below).
  4902. * @see https://easings.net/#easeInBounce
  4903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4904. */
  4905. export class BounceEase extends EasingFunction implements IEasingFunction {
  4906. /** Defines the number of bounces */
  4907. bounces: number;
  4908. /** Defines the amplitude of the bounce */
  4909. bounciness: number;
  4910. /**
  4911. * Instantiates a bounce easing
  4912. * @see https://easings.net/#easeInBounce
  4913. * @param bounces Defines the number of bounces
  4914. * @param bounciness Defines the amplitude of the bounce
  4915. */
  4916. constructor(
  4917. /** Defines the number of bounces */
  4918. bounces?: number,
  4919. /** Defines the amplitude of the bounce */
  4920. bounciness?: number);
  4921. /** @hidden */
  4922. easeInCore(gradient: number): number;
  4923. }
  4924. /**
  4925. * Easing function with a power of 3 shape (see link below).
  4926. * @see https://easings.net/#easeInCubic
  4927. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4928. */
  4929. export class CubicEase extends EasingFunction implements IEasingFunction {
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with an elastic shape (see link below).
  4935. * @see https://easings.net/#easeInElastic
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the number of oscillations*/
  4940. oscillations: number;
  4941. /** Defines the amplitude of the oscillations*/
  4942. springiness: number;
  4943. /**
  4944. * Instantiates an elastic easing function
  4945. * @see https://easings.net/#easeInElastic
  4946. * @param oscillations Defines the number of oscillations
  4947. * @param springiness Defines the amplitude of the oscillations
  4948. */
  4949. constructor(
  4950. /** Defines the number of oscillations*/
  4951. oscillations?: number,
  4952. /** Defines the amplitude of the oscillations*/
  4953. springiness?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with an exponential shape (see link below).
  4959. * @see https://easings.net/#easeInExpo
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4963. /** Defines the exponent of the function */
  4964. exponent: number;
  4965. /**
  4966. * Instantiates an exponential easing function
  4967. * @see https://easings.net/#easeInExpo
  4968. * @param exponent Defines the exponent of the function
  4969. */
  4970. constructor(
  4971. /** Defines the exponent of the function */
  4972. exponent?: number);
  4973. /** @hidden */
  4974. easeInCore(gradient: number): number;
  4975. }
  4976. /**
  4977. * Easing function with a power shape (see link below).
  4978. * @see https://easings.net/#easeInQuad
  4979. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4980. */
  4981. export class PowerEase extends EasingFunction implements IEasingFunction {
  4982. /** Defines the power of the function */
  4983. power: number;
  4984. /**
  4985. * Instantiates an power base easing function
  4986. * @see https://easings.net/#easeInQuad
  4987. * @param power Defines the power of the function
  4988. */
  4989. constructor(
  4990. /** Defines the power of the function */
  4991. power?: number);
  4992. /** @hidden */
  4993. easeInCore(gradient: number): number;
  4994. }
  4995. /**
  4996. * Easing function with a power of 2 shape (see link below).
  4997. * @see https://easings.net/#easeInQuad
  4998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4999. */
  5000. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5001. /** @hidden */
  5002. easeInCore(gradient: number): number;
  5003. }
  5004. /**
  5005. * Easing function with a power of 4 shape (see link below).
  5006. * @see https://easings.net/#easeInQuart
  5007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5008. */
  5009. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 5 shape (see link below).
  5015. * @see https://easings.net/#easeInQuint
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with a sin shape (see link below).
  5024. * @see https://easings.net/#easeInSine
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class SineEase extends EasingFunction implements IEasingFunction {
  5028. /** @hidden */
  5029. easeInCore(gradient: number): number;
  5030. }
  5031. /**
  5032. * Easing function with a bezier shape (see link below).
  5033. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5035. */
  5036. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5037. /** Defines the x component of the start tangent in the bezier curve */
  5038. x1: number;
  5039. /** Defines the y component of the start tangent in the bezier curve */
  5040. y1: number;
  5041. /** Defines the x component of the end tangent in the bezier curve */
  5042. x2: number;
  5043. /** Defines the y component of the end tangent in the bezier curve */
  5044. y2: number;
  5045. /**
  5046. * Instantiates a bezier function
  5047. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5048. * @param x1 Defines the x component of the start tangent in the bezier curve
  5049. * @param y1 Defines the y component of the start tangent in the bezier curve
  5050. * @param x2 Defines the x component of the end tangent in the bezier curve
  5051. * @param y2 Defines the y component of the end tangent in the bezier curve
  5052. */
  5053. constructor(
  5054. /** Defines the x component of the start tangent in the bezier curve */
  5055. x1?: number,
  5056. /** Defines the y component of the start tangent in the bezier curve */
  5057. y1?: number,
  5058. /** Defines the x component of the end tangent in the bezier curve */
  5059. x2?: number,
  5060. /** Defines the y component of the end tangent in the bezier curve */
  5061. y2?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. }
  5066. declare module BABYLON {
  5067. /**
  5068. * Class used to hold a RBG color
  5069. */
  5070. export class Color3 {
  5071. /**
  5072. * Defines the red component (between 0 and 1, default is 0)
  5073. */
  5074. r: number;
  5075. /**
  5076. * Defines the green component (between 0 and 1, default is 0)
  5077. */
  5078. g: number;
  5079. /**
  5080. * Defines the blue component (between 0 and 1, default is 0)
  5081. */
  5082. b: number;
  5083. /**
  5084. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5085. * @param r defines the red component (between 0 and 1, default is 0)
  5086. * @param g defines the green component (between 0 and 1, default is 0)
  5087. * @param b defines the blue component (between 0 and 1, default is 0)
  5088. */
  5089. constructor(
  5090. /**
  5091. * Defines the red component (between 0 and 1, default is 0)
  5092. */
  5093. r?: number,
  5094. /**
  5095. * Defines the green component (between 0 and 1, default is 0)
  5096. */
  5097. g?: number,
  5098. /**
  5099. * Defines the blue component (between 0 and 1, default is 0)
  5100. */
  5101. b?: number);
  5102. /**
  5103. * Creates a string with the Color3 current values
  5104. * @returns the string representation of the Color3 object
  5105. */
  5106. toString(): string;
  5107. /**
  5108. * Returns the string "Color3"
  5109. * @returns "Color3"
  5110. */
  5111. getClassName(): string;
  5112. /**
  5113. * Compute the Color3 hash code
  5114. * @returns an unique number that can be used to hash Color3 objects
  5115. */
  5116. getHashCode(): number;
  5117. /**
  5118. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5119. * @param array defines the array where to store the r,g,b components
  5120. * @param index defines an optional index in the target array to define where to start storing values
  5121. * @returns the current Color3 object
  5122. */
  5123. toArray(array: FloatArray, index?: number): Color3;
  5124. /**
  5125. * Returns a new Color4 object from the current Color3 and the given alpha
  5126. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5127. * @returns a new Color4 object
  5128. */
  5129. toColor4(alpha?: number): Color4;
  5130. /**
  5131. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5132. * @returns the new array
  5133. */
  5134. asArray(): number[];
  5135. /**
  5136. * Returns the luminance value
  5137. * @returns a float value
  5138. */
  5139. toLuminance(): number;
  5140. /**
  5141. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5142. * @param otherColor defines the second operand
  5143. * @returns the new Color3 object
  5144. */
  5145. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5146. /**
  5147. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5148. * @param otherColor defines the second operand
  5149. * @param result defines the Color3 object where to store the result
  5150. * @returns the current Color3
  5151. */
  5152. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5153. /**
  5154. * Determines equality between Color3 objects
  5155. * @param otherColor defines the second operand
  5156. * @returns true if the rgb values are equal to the given ones
  5157. */
  5158. equals(otherColor: DeepImmutable<Color3>): boolean;
  5159. /**
  5160. * Determines equality between the current Color3 object and a set of r,b,g values
  5161. * @param r defines the red component to check
  5162. * @param g defines the green component to check
  5163. * @param b defines the blue component to check
  5164. * @returns true if the rgb values are equal to the given ones
  5165. */
  5166. equalsFloats(r: number, g: number, b: number): boolean;
  5167. /**
  5168. * Multiplies in place each rgb value by scale
  5169. * @param scale defines the scaling factor
  5170. * @returns the updated Color3
  5171. */
  5172. scale(scale: number): Color3;
  5173. /**
  5174. * Multiplies the rgb values by scale and stores the result into "result"
  5175. * @param scale defines the scaling factor
  5176. * @param result defines the Color3 object where to store the result
  5177. * @returns the unmodified current Color3
  5178. */
  5179. scaleToRef(scale: number, result: Color3): Color3;
  5180. /**
  5181. * Scale the current Color3 values by a factor and add the result to a given Color3
  5182. * @param scale defines the scale factor
  5183. * @param result defines color to store the result into
  5184. * @returns the unmodified current Color3
  5185. */
  5186. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5187. /**
  5188. * Clamps the rgb values by the min and max values and stores the result into "result"
  5189. * @param min defines minimum clamping value (default is 0)
  5190. * @param max defines maximum clamping value (default is 1)
  5191. * @param result defines color to store the result into
  5192. * @returns the original Color3
  5193. */
  5194. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5195. /**
  5196. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5197. * @param otherColor defines the second operand
  5198. * @returns the new Color3
  5199. */
  5200. add(otherColor: DeepImmutable<Color3>): Color3;
  5201. /**
  5202. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5203. * @param otherColor defines the second operand
  5204. * @param result defines Color3 object to store the result into
  5205. * @returns the unmodified current Color3
  5206. */
  5207. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5208. /**
  5209. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5210. * @param otherColor defines the second operand
  5211. * @returns the new Color3
  5212. */
  5213. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5214. /**
  5215. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5216. * @param otherColor defines the second operand
  5217. * @param result defines Color3 object to store the result into
  5218. * @returns the unmodified current Color3
  5219. */
  5220. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5221. /**
  5222. * Copy the current object
  5223. * @returns a new Color3 copied the current one
  5224. */
  5225. clone(): Color3;
  5226. /**
  5227. * Copies the rgb values from the source in the current Color3
  5228. * @param source defines the source Color3 object
  5229. * @returns the updated Color3 object
  5230. */
  5231. copyFrom(source: DeepImmutable<Color3>): Color3;
  5232. /**
  5233. * Updates the Color3 rgb values from the given floats
  5234. * @param r defines the red component to read from
  5235. * @param g defines the green component to read from
  5236. * @param b defines the blue component to read from
  5237. * @returns the current Color3 object
  5238. */
  5239. copyFromFloats(r: number, g: number, b: number): Color3;
  5240. /**
  5241. * Updates the Color3 rgb values from the given floats
  5242. * @param r defines the red component to read from
  5243. * @param g defines the green component to read from
  5244. * @param b defines the blue component to read from
  5245. * @returns the current Color3 object
  5246. */
  5247. set(r: number, g: number, b: number): Color3;
  5248. /**
  5249. * Compute the Color3 hexadecimal code as a string
  5250. * @returns a string containing the hexadecimal representation of the Color3 object
  5251. */
  5252. toHexString(): string;
  5253. /**
  5254. * Computes a new Color3 converted from the current one to linear space
  5255. * @returns a new Color3 object
  5256. */
  5257. toLinearSpace(): Color3;
  5258. /**
  5259. * Converts current color in rgb space to HSV values
  5260. * @returns a new color3 representing the HSV values
  5261. */
  5262. toHSV(): Color3;
  5263. /**
  5264. * Converts current color in rgb space to HSV values
  5265. * @param result defines the Color3 where to store the HSV values
  5266. */
  5267. toHSVToRef(result: Color3): void;
  5268. /**
  5269. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5270. * @param convertedColor defines the Color3 object where to store the linear space version
  5271. * @returns the unmodified Color3
  5272. */
  5273. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5274. /**
  5275. * Computes a new Color3 converted from the current one to gamma space
  5276. * @returns a new Color3 object
  5277. */
  5278. toGammaSpace(): Color3;
  5279. /**
  5280. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5281. * @param convertedColor defines the Color3 object where to store the gamma space version
  5282. * @returns the unmodified Color3
  5283. */
  5284. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5285. private static _BlackReadOnly;
  5286. /**
  5287. * Convert Hue, saturation and value to a Color3 (RGB)
  5288. * @param hue defines the hue
  5289. * @param saturation defines the saturation
  5290. * @param value defines the value
  5291. * @param result defines the Color3 where to store the RGB values
  5292. */
  5293. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5294. /**
  5295. * Creates a new Color3 from the string containing valid hexadecimal values
  5296. * @param hex defines a string containing valid hexadecimal values
  5297. * @returns a new Color3 object
  5298. */
  5299. static FromHexString(hex: string): Color3;
  5300. /**
  5301. * Creates a new Color3 from the starting index of the given array
  5302. * @param array defines the source array
  5303. * @param offset defines an offset in the source array
  5304. * @returns a new Color3 object
  5305. */
  5306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5307. /**
  5308. * Creates a new Color3 from integer values (< 256)
  5309. * @param r defines the red component to read from (value between 0 and 255)
  5310. * @param g defines the green component to read from (value between 0 and 255)
  5311. * @param b defines the blue component to read from (value between 0 and 255)
  5312. * @returns a new Color3 object
  5313. */
  5314. static FromInts(r: number, g: number, b: number): Color3;
  5315. /**
  5316. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5317. * @param start defines the start Color3 value
  5318. * @param end defines the end Color3 value
  5319. * @param amount defines the gradient value between start and end
  5320. * @returns a new Color3 object
  5321. */
  5322. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5323. /**
  5324. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5325. * @param left defines the start value
  5326. * @param right defines the end value
  5327. * @param amount defines the gradient factor
  5328. * @param result defines the Color3 object where to store the result
  5329. */
  5330. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5331. /**
  5332. * Returns a Color3 value containing a red color
  5333. * @returns a new Color3 object
  5334. */
  5335. static Red(): Color3;
  5336. /**
  5337. * Returns a Color3 value containing a green color
  5338. * @returns a new Color3 object
  5339. */
  5340. static Green(): Color3;
  5341. /**
  5342. * Returns a Color3 value containing a blue color
  5343. * @returns a new Color3 object
  5344. */
  5345. static Blue(): Color3;
  5346. /**
  5347. * Returns a Color3 value containing a black color
  5348. * @returns a new Color3 object
  5349. */
  5350. static Black(): Color3;
  5351. /**
  5352. * Gets a Color3 value containing a black color that must not be updated
  5353. */
  5354. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5355. /**
  5356. * Returns a Color3 value containing a white color
  5357. * @returns a new Color3 object
  5358. */
  5359. static White(): Color3;
  5360. /**
  5361. * Returns a Color3 value containing a purple color
  5362. * @returns a new Color3 object
  5363. */
  5364. static Purple(): Color3;
  5365. /**
  5366. * Returns a Color3 value containing a magenta color
  5367. * @returns a new Color3 object
  5368. */
  5369. static Magenta(): Color3;
  5370. /**
  5371. * Returns a Color3 value containing a yellow color
  5372. * @returns a new Color3 object
  5373. */
  5374. static Yellow(): Color3;
  5375. /**
  5376. * Returns a Color3 value containing a gray color
  5377. * @returns a new Color3 object
  5378. */
  5379. static Gray(): Color3;
  5380. /**
  5381. * Returns a Color3 value containing a teal color
  5382. * @returns a new Color3 object
  5383. */
  5384. static Teal(): Color3;
  5385. /**
  5386. * Returns a Color3 value containing a random color
  5387. * @returns a new Color3 object
  5388. */
  5389. static Random(): Color3;
  5390. }
  5391. /**
  5392. * Class used to hold a RBGA color
  5393. */
  5394. export class Color4 {
  5395. /**
  5396. * Defines the red component (between 0 and 1, default is 0)
  5397. */
  5398. r: number;
  5399. /**
  5400. * Defines the green component (between 0 and 1, default is 0)
  5401. */
  5402. g: number;
  5403. /**
  5404. * Defines the blue component (between 0 and 1, default is 0)
  5405. */
  5406. b: number;
  5407. /**
  5408. * Defines the alpha component (between 0 and 1, default is 1)
  5409. */
  5410. a: number;
  5411. /**
  5412. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5413. * @param r defines the red component (between 0 and 1, default is 0)
  5414. * @param g defines the green component (between 0 and 1, default is 0)
  5415. * @param b defines the blue component (between 0 and 1, default is 0)
  5416. * @param a defines the alpha component (between 0 and 1, default is 1)
  5417. */
  5418. constructor(
  5419. /**
  5420. * Defines the red component (between 0 and 1, default is 0)
  5421. */
  5422. r?: number,
  5423. /**
  5424. * Defines the green component (between 0 and 1, default is 0)
  5425. */
  5426. g?: number,
  5427. /**
  5428. * Defines the blue component (between 0 and 1, default is 0)
  5429. */
  5430. b?: number,
  5431. /**
  5432. * Defines the alpha component (between 0 and 1, default is 1)
  5433. */
  5434. a?: number);
  5435. /**
  5436. * Adds in place the given Color4 values to the current Color4 object
  5437. * @param right defines the second operand
  5438. * @returns the current updated Color4 object
  5439. */
  5440. addInPlace(right: DeepImmutable<Color4>): Color4;
  5441. /**
  5442. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5443. * @returns the new array
  5444. */
  5445. asArray(): number[];
  5446. /**
  5447. * Stores from the starting index in the given array the Color4 successive values
  5448. * @param array defines the array where to store the r,g,b components
  5449. * @param index defines an optional index in the target array to define where to start storing values
  5450. * @returns the current Color4 object
  5451. */
  5452. toArray(array: number[], index?: number): Color4;
  5453. /**
  5454. * Determines equality between Color4 objects
  5455. * @param otherColor defines the second operand
  5456. * @returns true if the rgba values are equal to the given ones
  5457. */
  5458. equals(otherColor: DeepImmutable<Color4>): boolean;
  5459. /**
  5460. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5461. * @param right defines the second operand
  5462. * @returns a new Color4 object
  5463. */
  5464. add(right: DeepImmutable<Color4>): Color4;
  5465. /**
  5466. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5467. * @param right defines the second operand
  5468. * @returns a new Color4 object
  5469. */
  5470. subtract(right: DeepImmutable<Color4>): Color4;
  5471. /**
  5472. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5473. * @param right defines the second operand
  5474. * @param result defines the Color4 object where to store the result
  5475. * @returns the current Color4 object
  5476. */
  5477. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5478. /**
  5479. * Creates a new Color4 with the current Color4 values multiplied by scale
  5480. * @param scale defines the scaling factor to apply
  5481. * @returns a new Color4 object
  5482. */
  5483. scale(scale: number): Color4;
  5484. /**
  5485. * Multiplies the current Color4 values by scale and stores the result in "result"
  5486. * @param scale defines the scaling factor to apply
  5487. * @param result defines the Color4 object where to store the result
  5488. * @returns the current unmodified Color4
  5489. */
  5490. scaleToRef(scale: number, result: Color4): Color4;
  5491. /**
  5492. * Scale the current Color4 values by a factor and add the result to a given Color4
  5493. * @param scale defines the scale factor
  5494. * @param result defines the Color4 object where to store the result
  5495. * @returns the unmodified current Color4
  5496. */
  5497. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5498. /**
  5499. * Clamps the rgb values by the min and max values and stores the result into "result"
  5500. * @param min defines minimum clamping value (default is 0)
  5501. * @param max defines maximum clamping value (default is 1)
  5502. * @param result defines color to store the result into.
  5503. * @returns the cuurent Color4
  5504. */
  5505. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5506. /**
  5507. * Multipy an Color4 value by another and return a new Color4 object
  5508. * @param color defines the Color4 value to multiply by
  5509. * @returns a new Color4 object
  5510. */
  5511. multiply(color: Color4): Color4;
  5512. /**
  5513. * Multipy a Color4 value by another and push the result in a reference value
  5514. * @param color defines the Color4 value to multiply by
  5515. * @param result defines the Color4 to fill the result in
  5516. * @returns the result Color4
  5517. */
  5518. multiplyToRef(color: Color4, result: Color4): Color4;
  5519. /**
  5520. * Creates a string with the Color4 current values
  5521. * @returns the string representation of the Color4 object
  5522. */
  5523. toString(): string;
  5524. /**
  5525. * Returns the string "Color4"
  5526. * @returns "Color4"
  5527. */
  5528. getClassName(): string;
  5529. /**
  5530. * Compute the Color4 hash code
  5531. * @returns an unique number that can be used to hash Color4 objects
  5532. */
  5533. getHashCode(): number;
  5534. /**
  5535. * Creates a new Color4 copied from the current one
  5536. * @returns a new Color4 object
  5537. */
  5538. clone(): Color4;
  5539. /**
  5540. * Copies the given Color4 values into the current one
  5541. * @param source defines the source Color4 object
  5542. * @returns the current updated Color4 object
  5543. */
  5544. copyFrom(source: Color4): Color4;
  5545. /**
  5546. * Copies the given float values into the current one
  5547. * @param r defines the red component to read from
  5548. * @param g defines the green component to read from
  5549. * @param b defines the blue component to read from
  5550. * @param a defines the alpha component to read from
  5551. * @returns the current updated Color4 object
  5552. */
  5553. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5554. /**
  5555. * Copies the given float values into the current one
  5556. * @param r defines the red component to read from
  5557. * @param g defines the green component to read from
  5558. * @param b defines the blue component to read from
  5559. * @param a defines the alpha component to read from
  5560. * @returns the current updated Color4 object
  5561. */
  5562. set(r: number, g: number, b: number, a: number): Color4;
  5563. /**
  5564. * Compute the Color4 hexadecimal code as a string
  5565. * @returns a string containing the hexadecimal representation of the Color4 object
  5566. */
  5567. toHexString(): string;
  5568. /**
  5569. * Computes a new Color4 converted from the current one to linear space
  5570. * @returns a new Color4 object
  5571. */
  5572. toLinearSpace(): Color4;
  5573. /**
  5574. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5575. * @param convertedColor defines the Color4 object where to store the linear space version
  5576. * @returns the unmodified Color4
  5577. */
  5578. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5579. /**
  5580. * Computes a new Color4 converted from the current one to gamma space
  5581. * @returns a new Color4 object
  5582. */
  5583. toGammaSpace(): Color4;
  5584. /**
  5585. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5586. * @param convertedColor defines the Color4 object where to store the gamma space version
  5587. * @returns the unmodified Color4
  5588. */
  5589. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5590. /**
  5591. * Creates a new Color4 from the string containing valid hexadecimal values
  5592. * @param hex defines a string containing valid hexadecimal values
  5593. * @returns a new Color4 object
  5594. */
  5595. static FromHexString(hex: string): Color4;
  5596. /**
  5597. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5598. * @param left defines the start value
  5599. * @param right defines the end value
  5600. * @param amount defines the gradient factor
  5601. * @returns a new Color4 object
  5602. */
  5603. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5604. /**
  5605. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5606. * @param left defines the start value
  5607. * @param right defines the end value
  5608. * @param amount defines the gradient factor
  5609. * @param result defines the Color4 object where to store data
  5610. */
  5611. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5612. /**
  5613. * Creates a new Color4 from a Color3 and an alpha value
  5614. * @param color3 defines the source Color3 to read from
  5615. * @param alpha defines the alpha component (1.0 by default)
  5616. * @returns a new Color4 object
  5617. */
  5618. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5619. /**
  5620. * Creates a new Color4 from the starting index element of the given array
  5621. * @param array defines the source array to read from
  5622. * @param offset defines the offset in the source array
  5623. * @returns a new Color4 object
  5624. */
  5625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5626. /**
  5627. * Creates a new Color3 from integer values (< 256)
  5628. * @param r defines the red component to read from (value between 0 and 255)
  5629. * @param g defines the green component to read from (value between 0 and 255)
  5630. * @param b defines the blue component to read from (value between 0 and 255)
  5631. * @param a defines the alpha component to read from (value between 0 and 255)
  5632. * @returns a new Color3 object
  5633. */
  5634. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5635. /**
  5636. * Check the content of a given array and convert it to an array containing RGBA data
  5637. * If the original array was already containing count * 4 values then it is returned directly
  5638. * @param colors defines the array to check
  5639. * @param count defines the number of RGBA data to expect
  5640. * @returns an array containing count * 4 values (RGBA)
  5641. */
  5642. static CheckColors4(colors: number[], count: number): number[];
  5643. }
  5644. /**
  5645. * @hidden
  5646. */
  5647. export class TmpColors {
  5648. static Color3: Color3[];
  5649. static Color4: Color4[];
  5650. }
  5651. }
  5652. declare module BABYLON {
  5653. /**
  5654. * Defines an interface which represents an animation key frame
  5655. */
  5656. export interface IAnimationKey {
  5657. /**
  5658. * Frame of the key frame
  5659. */
  5660. frame: number;
  5661. /**
  5662. * Value at the specifies key frame
  5663. */
  5664. value: any;
  5665. /**
  5666. * The input tangent for the cubic hermite spline
  5667. */
  5668. inTangent?: any;
  5669. /**
  5670. * The output tangent for the cubic hermite spline
  5671. */
  5672. outTangent?: any;
  5673. /**
  5674. * The animation interpolation type
  5675. */
  5676. interpolation?: AnimationKeyInterpolation;
  5677. }
  5678. /**
  5679. * Enum for the animation key frame interpolation type
  5680. */
  5681. export enum AnimationKeyInterpolation {
  5682. /**
  5683. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5684. */
  5685. STEP = 1
  5686. }
  5687. }
  5688. declare module BABYLON {
  5689. /**
  5690. * Represents the range of an animation
  5691. */
  5692. export class AnimationRange {
  5693. /**The name of the animation range**/
  5694. name: string;
  5695. /**The starting frame of the animation */
  5696. from: number;
  5697. /**The ending frame of the animation*/
  5698. to: number;
  5699. /**
  5700. * Initializes the range of an animation
  5701. * @param name The name of the animation range
  5702. * @param from The starting frame of the animation
  5703. * @param to The ending frame of the animation
  5704. */
  5705. constructor(
  5706. /**The name of the animation range**/
  5707. name: string,
  5708. /**The starting frame of the animation */
  5709. from: number,
  5710. /**The ending frame of the animation*/
  5711. to: number);
  5712. /**
  5713. * Makes a copy of the animation range
  5714. * @returns A copy of the animation range
  5715. */
  5716. clone(): AnimationRange;
  5717. }
  5718. }
  5719. declare module BABYLON {
  5720. /**
  5721. * Composed of a frame, and an action function
  5722. */
  5723. export class AnimationEvent {
  5724. /** The frame for which the event is triggered **/
  5725. frame: number;
  5726. /** The event to perform when triggered **/
  5727. action: (currentFrame: number) => void;
  5728. /** Specifies if the event should be triggered only once**/
  5729. onlyOnce?: boolean | undefined;
  5730. /**
  5731. * Specifies if the animation event is done
  5732. */
  5733. isDone: boolean;
  5734. /**
  5735. * Initializes the animation event
  5736. * @param frame The frame for which the event is triggered
  5737. * @param action The event to perform when triggered
  5738. * @param onlyOnce Specifies if the event should be triggered only once
  5739. */
  5740. constructor(
  5741. /** The frame for which the event is triggered **/
  5742. frame: number,
  5743. /** The event to perform when triggered **/
  5744. action: (currentFrame: number) => void,
  5745. /** Specifies if the event should be triggered only once**/
  5746. onlyOnce?: boolean | undefined);
  5747. /** @hidden */
  5748. _clone(): AnimationEvent;
  5749. }
  5750. }
  5751. declare module BABYLON {
  5752. /**
  5753. * Interface used to define a behavior
  5754. */
  5755. export interface Behavior<T> {
  5756. /** gets or sets behavior's name */
  5757. name: string;
  5758. /**
  5759. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5760. */
  5761. init(): void;
  5762. /**
  5763. * Called when the behavior is attached to a target
  5764. * @param target defines the target where the behavior is attached to
  5765. */
  5766. attach(target: T): void;
  5767. /**
  5768. * Called when the behavior is detached from its target
  5769. */
  5770. detach(): void;
  5771. }
  5772. /**
  5773. * Interface implemented by classes supporting behaviors
  5774. */
  5775. export interface IBehaviorAware<T> {
  5776. /**
  5777. * Attach a behavior
  5778. * @param behavior defines the behavior to attach
  5779. * @returns the current host
  5780. */
  5781. addBehavior(behavior: Behavior<T>): T;
  5782. /**
  5783. * Remove a behavior from the current object
  5784. * @param behavior defines the behavior to detach
  5785. * @returns the current host
  5786. */
  5787. removeBehavior(behavior: Behavior<T>): T;
  5788. /**
  5789. * Gets a behavior using its name to search
  5790. * @param name defines the name to search
  5791. * @returns the behavior or null if not found
  5792. */
  5793. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5794. }
  5795. }
  5796. declare module BABYLON {
  5797. /**
  5798. * Defines an array and its length.
  5799. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5800. */
  5801. export interface ISmartArrayLike<T> {
  5802. /**
  5803. * The data of the array.
  5804. */
  5805. data: Array<T>;
  5806. /**
  5807. * The active length of the array.
  5808. */
  5809. length: number;
  5810. }
  5811. /**
  5812. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5813. */
  5814. export class SmartArray<T> implements ISmartArrayLike<T> {
  5815. /**
  5816. * The full set of data from the array.
  5817. */
  5818. data: Array<T>;
  5819. /**
  5820. * The active length of the array.
  5821. */
  5822. length: number;
  5823. protected _id: number;
  5824. /**
  5825. * Instantiates a Smart Array.
  5826. * @param capacity defines the default capacity of the array.
  5827. */
  5828. constructor(capacity: number);
  5829. /**
  5830. * Pushes a value at the end of the active data.
  5831. * @param value defines the object to push in the array.
  5832. */
  5833. push(value: T): void;
  5834. /**
  5835. * Iterates over the active data and apply the lambda to them.
  5836. * @param func defines the action to apply on each value.
  5837. */
  5838. forEach(func: (content: T) => void): void;
  5839. /**
  5840. * Sorts the full sets of data.
  5841. * @param compareFn defines the comparison function to apply.
  5842. */
  5843. sort(compareFn: (a: T, b: T) => number): void;
  5844. /**
  5845. * Resets the active data to an empty array.
  5846. */
  5847. reset(): void;
  5848. /**
  5849. * Releases all the data from the array as well as the array.
  5850. */
  5851. dispose(): void;
  5852. /**
  5853. * Concats the active data with a given array.
  5854. * @param array defines the data to concatenate with.
  5855. */
  5856. concat(array: any): void;
  5857. /**
  5858. * Returns the position of a value in the active data.
  5859. * @param value defines the value to find the index for
  5860. * @returns the index if found in the active data otherwise -1
  5861. */
  5862. indexOf(value: T): number;
  5863. /**
  5864. * Returns whether an element is part of the active data.
  5865. * @param value defines the value to look for
  5866. * @returns true if found in the active data otherwise false
  5867. */
  5868. contains(value: T): boolean;
  5869. private static _GlobalId;
  5870. }
  5871. /**
  5872. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5873. * The data in this array can only be present once
  5874. */
  5875. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5876. private _duplicateId;
  5877. /**
  5878. * Pushes a value at the end of the active data.
  5879. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5880. * @param value defines the object to push in the array.
  5881. */
  5882. push(value: T): void;
  5883. /**
  5884. * Pushes a value at the end of the active data.
  5885. * If the data is already present, it won t be added again
  5886. * @param value defines the object to push in the array.
  5887. * @returns true if added false if it was already present
  5888. */
  5889. pushNoDuplicate(value: T): boolean;
  5890. /**
  5891. * Resets the active data to an empty array.
  5892. */
  5893. reset(): void;
  5894. /**
  5895. * Concats the active data with a given array.
  5896. * This ensures no dupplicate will be present in the result.
  5897. * @param array defines the data to concatenate with.
  5898. */
  5899. concatWithNoDuplicate(array: any): void;
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * @ignore
  5905. * This is a list of all the different input types that are available in the application.
  5906. * Fo instance: ArcRotateCameraGamepadInput...
  5907. */
  5908. export var CameraInputTypes: {};
  5909. /**
  5910. * This is the contract to implement in order to create a new input class.
  5911. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5912. */
  5913. export interface ICameraInput<TCamera extends Camera> {
  5914. /**
  5915. * Defines the camera the input is attached to.
  5916. */
  5917. camera: Nullable<TCamera>;
  5918. /**
  5919. * Gets the class name of the current intput.
  5920. * @returns the class name
  5921. */
  5922. getClassName(): string;
  5923. /**
  5924. * Get the friendly name associated with the input class.
  5925. * @returns the input friendly name
  5926. */
  5927. getSimpleName(): string;
  5928. /**
  5929. * Attach the input controls to a specific dom element to get the input from.
  5930. * @param element Defines the element the controls should be listened from
  5931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5932. */
  5933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5934. /**
  5935. * Detach the current controls from the specified dom element.
  5936. * @param element Defines the element to stop listening the inputs from
  5937. */
  5938. detachControl(element: Nullable<HTMLElement>): void;
  5939. /**
  5940. * Update the current camera state depending on the inputs that have been used this frame.
  5941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5942. */
  5943. checkInputs?: () => void;
  5944. }
  5945. /**
  5946. * Represents a map of input types to input instance or input index to input instance.
  5947. */
  5948. export interface CameraInputsMap<TCamera extends Camera> {
  5949. /**
  5950. * Accessor to the input by input type.
  5951. */
  5952. [name: string]: ICameraInput<TCamera>;
  5953. /**
  5954. * Accessor to the input by input index.
  5955. */
  5956. [idx: number]: ICameraInput<TCamera>;
  5957. }
  5958. /**
  5959. * This represents the input manager used within a camera.
  5960. * It helps dealing with all the different kind of input attached to a camera.
  5961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5962. */
  5963. export class CameraInputsManager<TCamera extends Camera> {
  5964. /**
  5965. * Defines the list of inputs attahed to the camera.
  5966. */
  5967. attached: CameraInputsMap<TCamera>;
  5968. /**
  5969. * Defines the dom element the camera is collecting inputs from.
  5970. * This is null if the controls have not been attached.
  5971. */
  5972. attachedElement: Nullable<HTMLElement>;
  5973. /**
  5974. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5975. */
  5976. noPreventDefault: boolean;
  5977. /**
  5978. * Defined the camera the input manager belongs to.
  5979. */
  5980. camera: TCamera;
  5981. /**
  5982. * Update the current camera state depending on the inputs that have been used this frame.
  5983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5984. */
  5985. checkInputs: () => void;
  5986. /**
  5987. * Instantiate a new Camera Input Manager.
  5988. * @param camera Defines the camera the input manager blongs to
  5989. */
  5990. constructor(camera: TCamera);
  5991. /**
  5992. * Add an input method to a camera
  5993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5994. * @param input camera input method
  5995. */
  5996. add(input: ICameraInput<TCamera>): void;
  5997. /**
  5998. * Remove a specific input method from a camera
  5999. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6000. * @param inputToRemove camera input method
  6001. */
  6002. remove(inputToRemove: ICameraInput<TCamera>): void;
  6003. /**
  6004. * Remove a specific input type from a camera
  6005. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6006. * @param inputType the type of the input to remove
  6007. */
  6008. removeByType(inputType: string): void;
  6009. private _addCheckInputs;
  6010. /**
  6011. * Attach the input controls to the currently attached dom element to listen the events from.
  6012. * @param input Defines the input to attach
  6013. */
  6014. attachInput(input: ICameraInput<TCamera>): void;
  6015. /**
  6016. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6017. * @param element Defines the dom element to collect the events from
  6018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6019. */
  6020. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6021. /**
  6022. * Detach the current manager inputs controls from a specific dom element.
  6023. * @param element Defines the dom element to collect the events from
  6024. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6025. */
  6026. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6027. /**
  6028. * Rebuild the dynamic inputCheck function from the current list of
  6029. * defined inputs in the manager.
  6030. */
  6031. rebuildInputCheck(): void;
  6032. /**
  6033. * Remove all attached input methods from a camera
  6034. */
  6035. clear(): void;
  6036. /**
  6037. * Serialize the current input manager attached to a camera.
  6038. * This ensures than once parsed,
  6039. * the input associated to the camera will be identical to the current ones
  6040. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6041. */
  6042. serialize(serializedCamera: any): void;
  6043. /**
  6044. * Parses an input manager serialized JSON to restore the previous list of inputs
  6045. * and states associated to a camera.
  6046. * @param parsedCamera Defines the JSON to parse
  6047. */
  6048. parse(parsedCamera: any): void;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * Class used to store data that will be store in GPU memory
  6054. */
  6055. export class Buffer {
  6056. private _engine;
  6057. private _buffer;
  6058. /** @hidden */
  6059. _data: Nullable<DataArray>;
  6060. private _updatable;
  6061. private _instanced;
  6062. private _divisor;
  6063. /**
  6064. * Gets the byte stride.
  6065. */
  6066. readonly byteStride: number;
  6067. /**
  6068. * Constructor
  6069. * @param engine the engine
  6070. * @param data the data to use for this buffer
  6071. * @param updatable whether the data is updatable
  6072. * @param stride the stride (optional)
  6073. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6074. * @param instanced whether the buffer is instanced (optional)
  6075. * @param useBytes set to true if the stride in in bytes (optional)
  6076. * @param divisor sets an optional divisor for instances (1 by default)
  6077. */
  6078. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6079. /**
  6080. * Create a new VertexBuffer based on the current buffer
  6081. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6082. * @param offset defines offset in the buffer (0 by default)
  6083. * @param size defines the size in floats of attributes (position is 3 for instance)
  6084. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6085. * @param instanced defines if the vertex buffer contains indexed data
  6086. * @param useBytes defines if the offset and stride are in bytes *
  6087. * @param divisor sets an optional divisor for instances (1 by default)
  6088. * @returns the new vertex buffer
  6089. */
  6090. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6091. /**
  6092. * Gets a boolean indicating if the Buffer is updatable?
  6093. * @returns true if the buffer is updatable
  6094. */
  6095. isUpdatable(): boolean;
  6096. /**
  6097. * Gets current buffer's data
  6098. * @returns a DataArray or null
  6099. */
  6100. getData(): Nullable<DataArray>;
  6101. /**
  6102. * Gets underlying native buffer
  6103. * @returns underlying native buffer
  6104. */
  6105. getBuffer(): Nullable<DataBuffer>;
  6106. /**
  6107. * Gets the stride in float32 units (i.e. byte stride / 4).
  6108. * May not be an integer if the byte stride is not divisible by 4.
  6109. * DEPRECATED. Use byteStride instead.
  6110. * @returns the stride in float32 units
  6111. */
  6112. getStrideSize(): number;
  6113. /**
  6114. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6115. * @param data defines the data to store
  6116. */
  6117. create(data?: Nullable<DataArray>): void;
  6118. /** @hidden */
  6119. _rebuild(): void;
  6120. /**
  6121. * Update current buffer data
  6122. * @param data defines the data to store
  6123. */
  6124. update(data: DataArray): void;
  6125. /**
  6126. * Updates the data directly.
  6127. * @param data the new data
  6128. * @param offset the new offset
  6129. * @param vertexCount the vertex count (optional)
  6130. * @param useBytes set to true if the offset is in bytes
  6131. */
  6132. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6133. /**
  6134. * Release all resources
  6135. */
  6136. dispose(): void;
  6137. }
  6138. /**
  6139. * Specialized buffer used to store vertex data
  6140. */
  6141. export class VertexBuffer {
  6142. /** @hidden */
  6143. _buffer: Buffer;
  6144. private _kind;
  6145. private _size;
  6146. private _ownsBuffer;
  6147. private _instanced;
  6148. private _instanceDivisor;
  6149. /**
  6150. * The byte type.
  6151. */
  6152. static readonly BYTE: number;
  6153. /**
  6154. * The unsigned byte type.
  6155. */
  6156. static readonly UNSIGNED_BYTE: number;
  6157. /**
  6158. * The short type.
  6159. */
  6160. static readonly SHORT: number;
  6161. /**
  6162. * The unsigned short type.
  6163. */
  6164. static readonly UNSIGNED_SHORT: number;
  6165. /**
  6166. * The integer type.
  6167. */
  6168. static readonly INT: number;
  6169. /**
  6170. * The unsigned integer type.
  6171. */
  6172. static readonly UNSIGNED_INT: number;
  6173. /**
  6174. * The float type.
  6175. */
  6176. static readonly FLOAT: number;
  6177. /**
  6178. * Gets or sets the instance divisor when in instanced mode
  6179. */
  6180. instanceDivisor: number;
  6181. /**
  6182. * Gets the byte stride.
  6183. */
  6184. readonly byteStride: number;
  6185. /**
  6186. * Gets the byte offset.
  6187. */
  6188. readonly byteOffset: number;
  6189. /**
  6190. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6191. */
  6192. readonly normalized: boolean;
  6193. /**
  6194. * Gets the data type of each component in the array.
  6195. */
  6196. readonly type: number;
  6197. /**
  6198. * Constructor
  6199. * @param engine the engine
  6200. * @param data the data to use for this vertex buffer
  6201. * @param kind the vertex buffer kind
  6202. * @param updatable whether the data is updatable
  6203. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6204. * @param stride the stride (optional)
  6205. * @param instanced whether the buffer is instanced (optional)
  6206. * @param offset the offset of the data (optional)
  6207. * @param size the number of components (optional)
  6208. * @param type the type of the component (optional)
  6209. * @param normalized whether the data contains normalized data (optional)
  6210. * @param useBytes set to true if stride and offset are in bytes (optional)
  6211. * @param divisor defines the instance divisor to use (1 by default)
  6212. */
  6213. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6214. /** @hidden */
  6215. _rebuild(): void;
  6216. /**
  6217. * Returns the kind of the VertexBuffer (string)
  6218. * @returns a string
  6219. */
  6220. getKind(): string;
  6221. /**
  6222. * Gets a boolean indicating if the VertexBuffer is updatable?
  6223. * @returns true if the buffer is updatable
  6224. */
  6225. isUpdatable(): boolean;
  6226. /**
  6227. * Gets current buffer's data
  6228. * @returns a DataArray or null
  6229. */
  6230. getData(): Nullable<DataArray>;
  6231. /**
  6232. * Gets underlying native buffer
  6233. * @returns underlying native buffer
  6234. */
  6235. getBuffer(): Nullable<DataBuffer>;
  6236. /**
  6237. * Gets the stride in float32 units (i.e. byte stride / 4).
  6238. * May not be an integer if the byte stride is not divisible by 4.
  6239. * DEPRECATED. Use byteStride instead.
  6240. * @returns the stride in float32 units
  6241. */
  6242. getStrideSize(): number;
  6243. /**
  6244. * Returns the offset as a multiple of the type byte length.
  6245. * DEPRECATED. Use byteOffset instead.
  6246. * @returns the offset in bytes
  6247. */
  6248. getOffset(): number;
  6249. /**
  6250. * Returns the number of components per vertex attribute (integer)
  6251. * @returns the size in float
  6252. */
  6253. getSize(): number;
  6254. /**
  6255. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6256. * @returns true if this buffer is instanced
  6257. */
  6258. getIsInstanced(): boolean;
  6259. /**
  6260. * Returns the instancing divisor, zero for non-instanced (integer).
  6261. * @returns a number
  6262. */
  6263. getInstanceDivisor(): number;
  6264. /**
  6265. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6266. * @param data defines the data to store
  6267. */
  6268. create(data?: DataArray): void;
  6269. /**
  6270. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6271. * This function will create a new buffer if the current one is not updatable
  6272. * @param data defines the data to store
  6273. */
  6274. update(data: DataArray): void;
  6275. /**
  6276. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6277. * Returns the directly updated WebGLBuffer.
  6278. * @param data the new data
  6279. * @param offset the new offset
  6280. * @param useBytes set to true if the offset is in bytes
  6281. */
  6282. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6283. /**
  6284. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6285. */
  6286. dispose(): void;
  6287. /**
  6288. * Enumerates each value of this vertex buffer as numbers.
  6289. * @param count the number of values to enumerate
  6290. * @param callback the callback function called for each value
  6291. */
  6292. forEach(count: number, callback: (value: number, index: number) => void): void;
  6293. /**
  6294. * Positions
  6295. */
  6296. static readonly PositionKind: string;
  6297. /**
  6298. * Normals
  6299. */
  6300. static readonly NormalKind: string;
  6301. /**
  6302. * Tangents
  6303. */
  6304. static readonly TangentKind: string;
  6305. /**
  6306. * Texture coordinates
  6307. */
  6308. static readonly UVKind: string;
  6309. /**
  6310. * Texture coordinates 2
  6311. */
  6312. static readonly UV2Kind: string;
  6313. /**
  6314. * Texture coordinates 3
  6315. */
  6316. static readonly UV3Kind: string;
  6317. /**
  6318. * Texture coordinates 4
  6319. */
  6320. static readonly UV4Kind: string;
  6321. /**
  6322. * Texture coordinates 5
  6323. */
  6324. static readonly UV5Kind: string;
  6325. /**
  6326. * Texture coordinates 6
  6327. */
  6328. static readonly UV6Kind: string;
  6329. /**
  6330. * Colors
  6331. */
  6332. static readonly ColorKind: string;
  6333. /**
  6334. * Matrix indices (for bones)
  6335. */
  6336. static readonly MatricesIndicesKind: string;
  6337. /**
  6338. * Matrix weights (for bones)
  6339. */
  6340. static readonly MatricesWeightsKind: string;
  6341. /**
  6342. * Additional matrix indices (for bones)
  6343. */
  6344. static readonly MatricesIndicesExtraKind: string;
  6345. /**
  6346. * Additional matrix weights (for bones)
  6347. */
  6348. static readonly MatricesWeightsExtraKind: string;
  6349. /**
  6350. * Deduces the stride given a kind.
  6351. * @param kind The kind string to deduce
  6352. * @returns The deduced stride
  6353. */
  6354. static DeduceStride(kind: string): number;
  6355. /**
  6356. * Gets the byte length of the given type.
  6357. * @param type the type
  6358. * @returns the number of bytes
  6359. */
  6360. static GetTypeByteLength(type: number): number;
  6361. /**
  6362. * Enumerates each value of the given parameters as numbers.
  6363. * @param data the data to enumerate
  6364. * @param byteOffset the byte offset of the data
  6365. * @param byteStride the byte stride of the data
  6366. * @param componentCount the number of components per element
  6367. * @param componentType the type of the component
  6368. * @param count the number of values to enumerate
  6369. * @param normalized whether the data is normalized
  6370. * @param callback the callback function called for each value
  6371. */
  6372. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6373. private static _GetFloatValue;
  6374. }
  6375. }
  6376. declare module BABYLON {
  6377. /**
  6378. * @hidden
  6379. */
  6380. export class IntersectionInfo {
  6381. bu: Nullable<number>;
  6382. bv: Nullable<number>;
  6383. distance: number;
  6384. faceId: number;
  6385. subMeshId: number;
  6386. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6387. }
  6388. }
  6389. declare module BABYLON {
  6390. /**
  6391. * Represens a plane by the equation ax + by + cz + d = 0
  6392. */
  6393. export class Plane {
  6394. private static _TmpMatrix;
  6395. /**
  6396. * Normal of the plane (a,b,c)
  6397. */
  6398. normal: Vector3;
  6399. /**
  6400. * d component of the plane
  6401. */
  6402. d: number;
  6403. /**
  6404. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6405. * @param a a component of the plane
  6406. * @param b b component of the plane
  6407. * @param c c component of the plane
  6408. * @param d d component of the plane
  6409. */
  6410. constructor(a: number, b: number, c: number, d: number);
  6411. /**
  6412. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6413. */
  6414. asArray(): number[];
  6415. /**
  6416. * @returns a new plane copied from the current Plane.
  6417. */
  6418. clone(): Plane;
  6419. /**
  6420. * @returns the string "Plane".
  6421. */
  6422. getClassName(): string;
  6423. /**
  6424. * @returns the Plane hash code.
  6425. */
  6426. getHashCode(): number;
  6427. /**
  6428. * Normalize the current Plane in place.
  6429. * @returns the updated Plane.
  6430. */
  6431. normalize(): Plane;
  6432. /**
  6433. * Applies a transformation the plane and returns the result
  6434. * @param transformation the transformation matrix to be applied to the plane
  6435. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6436. */
  6437. transform(transformation: DeepImmutable<Matrix>): Plane;
  6438. /**
  6439. * Calcualtte the dot product between the point and the plane normal
  6440. * @param point point to calculate the dot product with
  6441. * @returns the dot product (float) of the point coordinates and the plane normal.
  6442. */
  6443. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6444. /**
  6445. * Updates the current Plane from the plane defined by the three given points.
  6446. * @param point1 one of the points used to contruct the plane
  6447. * @param point2 one of the points used to contruct the plane
  6448. * @param point3 one of the points used to contruct the plane
  6449. * @returns the updated Plane.
  6450. */
  6451. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6452. /**
  6453. * Checks if the plane is facing a given direction
  6454. * @param direction the direction to check if the plane is facing
  6455. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6456. * @returns True is the vector "direction" is the same side than the plane normal.
  6457. */
  6458. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6459. /**
  6460. * Calculates the distance to a point
  6461. * @param point point to calculate distance to
  6462. * @returns the signed distance (float) from the given point to the Plane.
  6463. */
  6464. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6465. /**
  6466. * Creates a plane from an array
  6467. * @param array the array to create a plane from
  6468. * @returns a new Plane from the given array.
  6469. */
  6470. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6471. /**
  6472. * Creates a plane from three points
  6473. * @param point1 point used to create the plane
  6474. * @param point2 point used to create the plane
  6475. * @param point3 point used to create the plane
  6476. * @returns a new Plane defined by the three given points.
  6477. */
  6478. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6479. /**
  6480. * Creates a plane from an origin point and a normal
  6481. * @param origin origin of the plane to be constructed
  6482. * @param normal normal of the plane to be constructed
  6483. * @returns a new Plane the normal vector to this plane at the given origin point.
  6484. * Note : the vector "normal" is updated because normalized.
  6485. */
  6486. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6487. /**
  6488. * Calculates the distance from a plane and a point
  6489. * @param origin origin of the plane to be constructed
  6490. * @param normal normal of the plane to be constructed
  6491. * @param point point to calculate distance to
  6492. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6493. */
  6494. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Class used to store bounding sphere information
  6500. */
  6501. export class BoundingSphere {
  6502. /**
  6503. * Gets the center of the bounding sphere in local space
  6504. */
  6505. readonly center: Vector3;
  6506. /**
  6507. * Radius of the bounding sphere in local space
  6508. */
  6509. radius: number;
  6510. /**
  6511. * Gets the center of the bounding sphere in world space
  6512. */
  6513. readonly centerWorld: Vector3;
  6514. /**
  6515. * Radius of the bounding sphere in world space
  6516. */
  6517. radiusWorld: number;
  6518. /**
  6519. * Gets the minimum vector in local space
  6520. */
  6521. readonly minimum: Vector3;
  6522. /**
  6523. * Gets the maximum vector in local space
  6524. */
  6525. readonly maximum: Vector3;
  6526. private _worldMatrix;
  6527. private static readonly TmpVector3;
  6528. /**
  6529. * Creates a new bounding sphere
  6530. * @param min defines the minimum vector (in local space)
  6531. * @param max defines the maximum vector (in local space)
  6532. * @param worldMatrix defines the new world matrix
  6533. */
  6534. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6535. /**
  6536. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6537. * @param min defines the new minimum vector (in local space)
  6538. * @param max defines the new maximum vector (in local space)
  6539. * @param worldMatrix defines the new world matrix
  6540. */
  6541. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6542. /**
  6543. * Scale the current bounding sphere by applying a scale factor
  6544. * @param factor defines the scale factor to apply
  6545. * @returns the current bounding box
  6546. */
  6547. scale(factor: number): BoundingSphere;
  6548. /**
  6549. * Gets the world matrix of the bounding box
  6550. * @returns a matrix
  6551. */
  6552. getWorldMatrix(): DeepImmutable<Matrix>;
  6553. /** @hidden */
  6554. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6555. /**
  6556. * Tests if the bounding sphere is intersecting the frustum planes
  6557. * @param frustumPlanes defines the frustum planes to test
  6558. * @returns true if there is an intersection
  6559. */
  6560. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6561. /**
  6562. * Tests if the bounding sphere center is in between the frustum planes.
  6563. * Used for optimistic fast inclusion.
  6564. * @param frustumPlanes defines the frustum planes to test
  6565. * @returns true if the sphere center is in between the frustum planes
  6566. */
  6567. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6568. /**
  6569. * Tests if a point is inside the bounding sphere
  6570. * @param point defines the point to test
  6571. * @returns true if the point is inside the bounding sphere
  6572. */
  6573. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6574. /**
  6575. * Checks if two sphere intersct
  6576. * @param sphere0 sphere 0
  6577. * @param sphere1 sphere 1
  6578. * @returns true if the speres intersect
  6579. */
  6580. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6581. }
  6582. }
  6583. declare module BABYLON {
  6584. /**
  6585. * Class used to store bounding box information
  6586. */
  6587. export class BoundingBox implements ICullable {
  6588. /**
  6589. * Gets the 8 vectors representing the bounding box in local space
  6590. */
  6591. readonly vectors: Vector3[];
  6592. /**
  6593. * Gets the center of the bounding box in local space
  6594. */
  6595. readonly center: Vector3;
  6596. /**
  6597. * Gets the center of the bounding box in world space
  6598. */
  6599. readonly centerWorld: Vector3;
  6600. /**
  6601. * Gets the extend size in local space
  6602. */
  6603. readonly extendSize: Vector3;
  6604. /**
  6605. * Gets the extend size in world space
  6606. */
  6607. readonly extendSizeWorld: Vector3;
  6608. /**
  6609. * Gets the OBB (object bounding box) directions
  6610. */
  6611. readonly directions: Vector3[];
  6612. /**
  6613. * Gets the 8 vectors representing the bounding box in world space
  6614. */
  6615. readonly vectorsWorld: Vector3[];
  6616. /**
  6617. * Gets the minimum vector in world space
  6618. */
  6619. readonly minimumWorld: Vector3;
  6620. /**
  6621. * Gets the maximum vector in world space
  6622. */
  6623. readonly maximumWorld: Vector3;
  6624. /**
  6625. * Gets the minimum vector in local space
  6626. */
  6627. readonly minimum: Vector3;
  6628. /**
  6629. * Gets the maximum vector in local space
  6630. */
  6631. readonly maximum: Vector3;
  6632. private _worldMatrix;
  6633. private static readonly TmpVector3;
  6634. /**
  6635. * @hidden
  6636. */
  6637. _tag: number;
  6638. /**
  6639. * Creates a new bounding box
  6640. * @param min defines the minimum vector (in local space)
  6641. * @param max defines the maximum vector (in local space)
  6642. * @param worldMatrix defines the new world matrix
  6643. */
  6644. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6645. /**
  6646. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6647. * @param min defines the new minimum vector (in local space)
  6648. * @param max defines the new maximum vector (in local space)
  6649. * @param worldMatrix defines the new world matrix
  6650. */
  6651. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6652. /**
  6653. * Scale the current bounding box by applying a scale factor
  6654. * @param factor defines the scale factor to apply
  6655. * @returns the current bounding box
  6656. */
  6657. scale(factor: number): BoundingBox;
  6658. /**
  6659. * Gets the world matrix of the bounding box
  6660. * @returns a matrix
  6661. */
  6662. getWorldMatrix(): DeepImmutable<Matrix>;
  6663. /** @hidden */
  6664. _update(world: DeepImmutable<Matrix>): void;
  6665. /**
  6666. * Tests if the bounding box is intersecting the frustum planes
  6667. * @param frustumPlanes defines the frustum planes to test
  6668. * @returns true if there is an intersection
  6669. */
  6670. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6671. /**
  6672. * Tests if the bounding box is entirely inside the frustum planes
  6673. * @param frustumPlanes defines the frustum planes to test
  6674. * @returns true if there is an inclusion
  6675. */
  6676. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6677. /**
  6678. * Tests if a point is inside the bounding box
  6679. * @param point defines the point to test
  6680. * @returns true if the point is inside the bounding box
  6681. */
  6682. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6683. /**
  6684. * Tests if the bounding box intersects with a bounding sphere
  6685. * @param sphere defines the sphere to test
  6686. * @returns true if there is an intersection
  6687. */
  6688. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6689. /**
  6690. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6691. * @param min defines the min vector to use
  6692. * @param max defines the max vector to use
  6693. * @returns true if there is an intersection
  6694. */
  6695. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6696. /**
  6697. * Tests if two bounding boxes are intersections
  6698. * @param box0 defines the first box to test
  6699. * @param box1 defines the second box to test
  6700. * @returns true if there is an intersection
  6701. */
  6702. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6703. /**
  6704. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6705. * @param minPoint defines the minimum vector of the bounding box
  6706. * @param maxPoint defines the maximum vector of the bounding box
  6707. * @param sphereCenter defines the sphere center
  6708. * @param sphereRadius defines the sphere radius
  6709. * @returns true if there is an intersection
  6710. */
  6711. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6712. /**
  6713. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6714. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @return true if there is an inclusion
  6717. */
  6718. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6721. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6722. * @param frustumPlanes defines the frustum planes to test
  6723. * @return true if there is an intersection
  6724. */
  6725. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. /** @hidden */
  6730. export class Collider {
  6731. /** Define if a collision was found */
  6732. collisionFound: boolean;
  6733. /**
  6734. * Define last intersection point in local space
  6735. */
  6736. intersectionPoint: Vector3;
  6737. /**
  6738. * Define last collided mesh
  6739. */
  6740. collidedMesh: Nullable<AbstractMesh>;
  6741. private _collisionPoint;
  6742. private _planeIntersectionPoint;
  6743. private _tempVector;
  6744. private _tempVector2;
  6745. private _tempVector3;
  6746. private _tempVector4;
  6747. private _edge;
  6748. private _baseToVertex;
  6749. private _destinationPoint;
  6750. private _slidePlaneNormal;
  6751. private _displacementVector;
  6752. /** @hidden */
  6753. _radius: Vector3;
  6754. /** @hidden */
  6755. _retry: number;
  6756. private _velocity;
  6757. private _basePoint;
  6758. private _epsilon;
  6759. /** @hidden */
  6760. _velocityWorldLength: number;
  6761. /** @hidden */
  6762. _basePointWorld: Vector3;
  6763. private _velocityWorld;
  6764. private _normalizedVelocity;
  6765. /** @hidden */
  6766. _initialVelocity: Vector3;
  6767. /** @hidden */
  6768. _initialPosition: Vector3;
  6769. private _nearestDistance;
  6770. private _collisionMask;
  6771. collisionMask: number;
  6772. /**
  6773. * Gets the plane normal used to compute the sliding response (in local space)
  6774. */
  6775. readonly slidePlaneNormal: Vector3;
  6776. /** @hidden */
  6777. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6778. /** @hidden */
  6779. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6780. /** @hidden */
  6781. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6782. /** @hidden */
  6783. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6784. /** @hidden */
  6785. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6786. /** @hidden */
  6787. _getResponse(pos: Vector3, vel: Vector3): void;
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. /**
  6792. * Interface for cullable objects
  6793. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6794. */
  6795. export interface ICullable {
  6796. /**
  6797. * Checks if the object or part of the object is in the frustum
  6798. * @param frustumPlanes Camera near/planes
  6799. * @returns true if the object is in frustum otherwise false
  6800. */
  6801. isInFrustum(frustumPlanes: Plane[]): boolean;
  6802. /**
  6803. * Checks if a cullable object (mesh...) is in the camera frustum
  6804. * Unlike isInFrustum this cheks the full bounding box
  6805. * @param frustumPlanes Camera near/planes
  6806. * @returns true if the object is in frustum otherwise false
  6807. */
  6808. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6809. }
  6810. /**
  6811. * Info for a bounding data of a mesh
  6812. */
  6813. export class BoundingInfo implements ICullable {
  6814. /**
  6815. * Bounding box for the mesh
  6816. */
  6817. readonly boundingBox: BoundingBox;
  6818. /**
  6819. * Bounding sphere for the mesh
  6820. */
  6821. readonly boundingSphere: BoundingSphere;
  6822. private _isLocked;
  6823. private static readonly TmpVector3;
  6824. /**
  6825. * Constructs bounding info
  6826. * @param minimum min vector of the bounding box/sphere
  6827. * @param maximum max vector of the bounding box/sphere
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6831. /**
  6832. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6833. * @param min defines the new minimum vector (in local space)
  6834. * @param max defines the new maximum vector (in local space)
  6835. * @param worldMatrix defines the new world matrix
  6836. */
  6837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6838. /**
  6839. * min vector of the bounding box/sphere
  6840. */
  6841. readonly minimum: Vector3;
  6842. /**
  6843. * max vector of the bounding box/sphere
  6844. */
  6845. readonly maximum: Vector3;
  6846. /**
  6847. * If the info is locked and won't be updated to avoid perf overhead
  6848. */
  6849. isLocked: boolean;
  6850. /**
  6851. * Updates the bounding sphere and box
  6852. * @param world world matrix to be used to update
  6853. */
  6854. update(world: DeepImmutable<Matrix>): void;
  6855. /**
  6856. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6857. * @param center New center of the bounding info
  6858. * @param extend New extend of the bounding info
  6859. * @returns the current bounding info
  6860. */
  6861. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6862. /**
  6863. * Scale the current bounding info by applying a scale factor
  6864. * @param factor defines the scale factor to apply
  6865. * @returns the current bounding info
  6866. */
  6867. scale(factor: number): BoundingInfo;
  6868. /**
  6869. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6870. * @param frustumPlanes defines the frustum to test
  6871. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6872. * @returns true if the bounding info is in the frustum planes
  6873. */
  6874. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6875. /**
  6876. * Gets the world distance between the min and max points of the bounding box
  6877. */
  6878. readonly diagonalLength: number;
  6879. /**
  6880. * Checks if a cullable object (mesh...) is in the camera frustum
  6881. * Unlike isInFrustum this cheks the full bounding box
  6882. * @param frustumPlanes Camera near/planes
  6883. * @returns true if the object is in frustum otherwise false
  6884. */
  6885. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /** @hidden */
  6887. _checkCollision(collider: Collider): boolean;
  6888. /**
  6889. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6890. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6891. * @param point the point to check intersection with
  6892. * @returns if the point intersects
  6893. */
  6894. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6895. /**
  6896. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6897. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6898. * @param boundingInfo the bounding info to check intersection with
  6899. * @param precise if the intersection should be done using OBB
  6900. * @returns if the bounding info intersects
  6901. */
  6902. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6903. }
  6904. }
  6905. declare module BABYLON {
  6906. /**
  6907. * Extracts minimum and maximum values from a list of indexed positions
  6908. * @param positions defines the positions to use
  6909. * @param indices defines the indices to the positions
  6910. * @param indexStart defines the start index
  6911. * @param indexCount defines the end index
  6912. * @param bias defines bias value to add to the result
  6913. * @return minimum and maximum values
  6914. */
  6915. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6916. minimum: Vector3;
  6917. maximum: Vector3;
  6918. };
  6919. /**
  6920. * Extracts minimum and maximum values from a list of positions
  6921. * @param positions defines the positions to use
  6922. * @param start defines the start index in the positions array
  6923. * @param count defines the number of positions to handle
  6924. * @param bias defines bias value to add to the result
  6925. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6926. * @return minimum and maximum values
  6927. */
  6928. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6929. minimum: Vector3;
  6930. maximum: Vector3;
  6931. };
  6932. }
  6933. declare module BABYLON {
  6934. /** @hidden */
  6935. export class WebGLDataBuffer extends DataBuffer {
  6936. private _buffer;
  6937. constructor(resource: WebGLBuffer);
  6938. readonly underlyingResource: any;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /** @hidden */
  6943. export class WebGLPipelineContext implements IPipelineContext {
  6944. engine: ThinEngine;
  6945. program: Nullable<WebGLProgram>;
  6946. context?: WebGLRenderingContext;
  6947. vertexShader?: WebGLShader;
  6948. fragmentShader?: WebGLShader;
  6949. isParallelCompiled: boolean;
  6950. onCompiled?: () => void;
  6951. transformFeedback?: WebGLTransformFeedback | null;
  6952. readonly isAsync: boolean;
  6953. readonly isReady: boolean;
  6954. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6955. }
  6956. }
  6957. declare module BABYLON {
  6958. interface ThinEngine {
  6959. /**
  6960. * Create an uniform buffer
  6961. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6962. * @param elements defines the content of the uniform buffer
  6963. * @returns the webGL uniform buffer
  6964. */
  6965. createUniformBuffer(elements: FloatArray): DataBuffer;
  6966. /**
  6967. * Create a dynamic uniform buffer
  6968. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6969. * @param elements defines the content of the uniform buffer
  6970. * @returns the webGL uniform buffer
  6971. */
  6972. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6973. /**
  6974. * Update an existing uniform buffer
  6975. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6976. * @param uniformBuffer defines the target uniform buffer
  6977. * @param elements defines the content to update
  6978. * @param offset defines the offset in the uniform buffer where update should start
  6979. * @param count defines the size of the data to update
  6980. */
  6981. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6982. /**
  6983. * Bind an uniform buffer to the current webGL context
  6984. * @param buffer defines the buffer to bind
  6985. */
  6986. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  6987. /**
  6988. * Bind a buffer to the current webGL context at a given location
  6989. * @param buffer defines the buffer to bind
  6990. * @param location defines the index where to bind the buffer
  6991. */
  6992. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  6993. /**
  6994. * Bind a specific block at a given index in a specific shader program
  6995. * @param pipelineContext defines the pipeline context to use
  6996. * @param blockName defines the block name
  6997. * @param index defines the index where to bind the block
  6998. */
  6999. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7000. }
  7001. }
  7002. declare module BABYLON {
  7003. /**
  7004. * Uniform buffer objects.
  7005. *
  7006. * Handles blocks of uniform on the GPU.
  7007. *
  7008. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7009. *
  7010. * For more information, please refer to :
  7011. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7012. */
  7013. export class UniformBuffer {
  7014. private _engine;
  7015. private _buffer;
  7016. private _data;
  7017. private _bufferData;
  7018. private _dynamic?;
  7019. private _uniformLocations;
  7020. private _uniformSizes;
  7021. private _uniformLocationPointer;
  7022. private _needSync;
  7023. private _noUBO;
  7024. private _currentEffect;
  7025. /** @hidden */
  7026. _alreadyBound: boolean;
  7027. private static _MAX_UNIFORM_SIZE;
  7028. private static _tempBuffer;
  7029. /**
  7030. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7031. * This is dynamic to allow compat with webgl 1 and 2.
  7032. * You will need to pass the name of the uniform as well as the value.
  7033. */
  7034. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7035. /**
  7036. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7037. * This is dynamic to allow compat with webgl 1 and 2.
  7038. * You will need to pass the name of the uniform as well as the value.
  7039. */
  7040. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7041. /**
  7042. * Lambda to Update a single float in a uniform buffer.
  7043. * This is dynamic to allow compat with webgl 1 and 2.
  7044. * You will need to pass the name of the uniform as well as the value.
  7045. */
  7046. updateFloat: (name: string, x: number) => void;
  7047. /**
  7048. * Lambda to Update a vec2 of float in a uniform buffer.
  7049. * This is dynamic to allow compat with webgl 1 and 2.
  7050. * You will need to pass the name of the uniform as well as the value.
  7051. */
  7052. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7053. /**
  7054. * Lambda to Update a vec3 of float in a uniform buffer.
  7055. * This is dynamic to allow compat with webgl 1 and 2.
  7056. * You will need to pass the name of the uniform as well as the value.
  7057. */
  7058. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7059. /**
  7060. * Lambda to Update a vec4 of float in a uniform buffer.
  7061. * This is dynamic to allow compat with webgl 1 and 2.
  7062. * You will need to pass the name of the uniform as well as the value.
  7063. */
  7064. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7065. /**
  7066. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7067. * This is dynamic to allow compat with webgl 1 and 2.
  7068. * You will need to pass the name of the uniform as well as the value.
  7069. */
  7070. updateMatrix: (name: string, mat: Matrix) => void;
  7071. /**
  7072. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7073. * This is dynamic to allow compat with webgl 1 and 2.
  7074. * You will need to pass the name of the uniform as well as the value.
  7075. */
  7076. updateVector3: (name: string, vector: Vector3) => void;
  7077. /**
  7078. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7079. * This is dynamic to allow compat with webgl 1 and 2.
  7080. * You will need to pass the name of the uniform as well as the value.
  7081. */
  7082. updateVector4: (name: string, vector: Vector4) => void;
  7083. /**
  7084. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7085. * This is dynamic to allow compat with webgl 1 and 2.
  7086. * You will need to pass the name of the uniform as well as the value.
  7087. */
  7088. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7089. /**
  7090. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7091. * This is dynamic to allow compat with webgl 1 and 2.
  7092. * You will need to pass the name of the uniform as well as the value.
  7093. */
  7094. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7095. /**
  7096. * Instantiates a new Uniform buffer objects.
  7097. *
  7098. * Handles blocks of uniform on the GPU.
  7099. *
  7100. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7101. *
  7102. * For more information, please refer to :
  7103. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7104. * @param engine Define the engine the buffer is associated with
  7105. * @param data Define the data contained in the buffer
  7106. * @param dynamic Define if the buffer is updatable
  7107. */
  7108. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7109. /**
  7110. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7111. * or just falling back on setUniformXXX calls.
  7112. */
  7113. readonly useUbo: boolean;
  7114. /**
  7115. * Indicates if the WebGL underlying uniform buffer is in sync
  7116. * with the javascript cache data.
  7117. */
  7118. readonly isSync: boolean;
  7119. /**
  7120. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7121. * Also, a dynamic UniformBuffer will disable cache verification and always
  7122. * update the underlying WebGL uniform buffer to the GPU.
  7123. * @returns if Dynamic, otherwise false
  7124. */
  7125. isDynamic(): boolean;
  7126. /**
  7127. * The data cache on JS side.
  7128. * @returns the underlying data as a float array
  7129. */
  7130. getData(): Float32Array;
  7131. /**
  7132. * The underlying WebGL Uniform buffer.
  7133. * @returns the webgl buffer
  7134. */
  7135. getBuffer(): Nullable<DataBuffer>;
  7136. /**
  7137. * std140 layout specifies how to align data within an UBO structure.
  7138. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7139. * for specs.
  7140. */
  7141. private _fillAlignment;
  7142. /**
  7143. * Adds an uniform in the buffer.
  7144. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7145. * for the layout to be correct !
  7146. * @param name Name of the uniform, as used in the uniform block in the shader.
  7147. * @param size Data size, or data directly.
  7148. */
  7149. addUniform(name: string, size: number | number[]): void;
  7150. /**
  7151. * Adds a Matrix 4x4 to the uniform buffer.
  7152. * @param name Name of the uniform, as used in the uniform block in the shader.
  7153. * @param mat A 4x4 matrix.
  7154. */
  7155. addMatrix(name: string, mat: Matrix): void;
  7156. /**
  7157. * Adds a vec2 to the uniform buffer.
  7158. * @param name Name of the uniform, as used in the uniform block in the shader.
  7159. * @param x Define the x component value of the vec2
  7160. * @param y Define the y component value of the vec2
  7161. */
  7162. addFloat2(name: string, x: number, y: number): void;
  7163. /**
  7164. * Adds a vec3 to the uniform buffer.
  7165. * @param name Name of the uniform, as used in the uniform block in the shader.
  7166. * @param x Define the x component value of the vec3
  7167. * @param y Define the y component value of the vec3
  7168. * @param z Define the z component value of the vec3
  7169. */
  7170. addFloat3(name: string, x: number, y: number, z: number): void;
  7171. /**
  7172. * Adds a vec3 to the uniform buffer.
  7173. * @param name Name of the uniform, as used in the uniform block in the shader.
  7174. * @param color Define the vec3 from a Color
  7175. */
  7176. addColor3(name: string, color: Color3): void;
  7177. /**
  7178. * Adds a vec4 to the uniform buffer.
  7179. * @param name Name of the uniform, as used in the uniform block in the shader.
  7180. * @param color Define the rgb components from a Color
  7181. * @param alpha Define the a component of the vec4
  7182. */
  7183. addColor4(name: string, color: Color3, alpha: number): void;
  7184. /**
  7185. * Adds a vec3 to the uniform buffer.
  7186. * @param name Name of the uniform, as used in the uniform block in the shader.
  7187. * @param vector Define the vec3 components from a Vector
  7188. */
  7189. addVector3(name: string, vector: Vector3): void;
  7190. /**
  7191. * Adds a Matrix 3x3 to the uniform buffer.
  7192. * @param name Name of the uniform, as used in the uniform block in the shader.
  7193. */
  7194. addMatrix3x3(name: string): void;
  7195. /**
  7196. * Adds a Matrix 2x2 to the uniform buffer.
  7197. * @param name Name of the uniform, as used in the uniform block in the shader.
  7198. */
  7199. addMatrix2x2(name: string): void;
  7200. /**
  7201. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7202. */
  7203. create(): void;
  7204. /** @hidden */
  7205. _rebuild(): void;
  7206. /**
  7207. * Updates the WebGL Uniform Buffer on the GPU.
  7208. * If the `dynamic` flag is set to true, no cache comparison is done.
  7209. * Otherwise, the buffer will be updated only if the cache differs.
  7210. */
  7211. update(): void;
  7212. /**
  7213. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7214. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7215. * @param data Define the flattened data
  7216. * @param size Define the size of the data.
  7217. */
  7218. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7219. private _valueCache;
  7220. private _cacheMatrix;
  7221. private _updateMatrix3x3ForUniform;
  7222. private _updateMatrix3x3ForEffect;
  7223. private _updateMatrix2x2ForEffect;
  7224. private _updateMatrix2x2ForUniform;
  7225. private _updateFloatForEffect;
  7226. private _updateFloatForUniform;
  7227. private _updateFloat2ForEffect;
  7228. private _updateFloat2ForUniform;
  7229. private _updateFloat3ForEffect;
  7230. private _updateFloat3ForUniform;
  7231. private _updateFloat4ForEffect;
  7232. private _updateFloat4ForUniform;
  7233. private _updateMatrixForEffect;
  7234. private _updateMatrixForUniform;
  7235. private _updateVector3ForEffect;
  7236. private _updateVector3ForUniform;
  7237. private _updateVector4ForEffect;
  7238. private _updateVector4ForUniform;
  7239. private _updateColor3ForEffect;
  7240. private _updateColor3ForUniform;
  7241. private _updateColor4ForEffect;
  7242. private _updateColor4ForUniform;
  7243. /**
  7244. * Sets a sampler uniform on the effect.
  7245. * @param name Define the name of the sampler.
  7246. * @param texture Define the texture to set in the sampler
  7247. */
  7248. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7249. /**
  7250. * Directly updates the value of the uniform in the cache AND on the GPU.
  7251. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7252. * @param data Define the flattened data
  7253. */
  7254. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7255. /**
  7256. * Binds this uniform buffer to an effect.
  7257. * @param effect Define the effect to bind the buffer to
  7258. * @param name Name of the uniform block in the shader.
  7259. */
  7260. bindToEffect(effect: Effect, name: string): void;
  7261. /**
  7262. * Disposes the uniform buffer.
  7263. */
  7264. dispose(): void;
  7265. }
  7266. }
  7267. declare module BABYLON {
  7268. /**
  7269. * Enum that determines the text-wrapping mode to use.
  7270. */
  7271. export enum InspectableType {
  7272. /**
  7273. * Checkbox for booleans
  7274. */
  7275. Checkbox = 0,
  7276. /**
  7277. * Sliders for numbers
  7278. */
  7279. Slider = 1,
  7280. /**
  7281. * Vector3
  7282. */
  7283. Vector3 = 2,
  7284. /**
  7285. * Quaternions
  7286. */
  7287. Quaternion = 3,
  7288. /**
  7289. * Color3
  7290. */
  7291. Color3 = 4,
  7292. /**
  7293. * String
  7294. */
  7295. String = 5
  7296. }
  7297. /**
  7298. * Interface used to define custom inspectable properties.
  7299. * This interface is used by the inspector to display custom property grids
  7300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7301. */
  7302. export interface IInspectable {
  7303. /**
  7304. * Gets the label to display
  7305. */
  7306. label: string;
  7307. /**
  7308. * Gets the name of the property to edit
  7309. */
  7310. propertyName: string;
  7311. /**
  7312. * Gets the type of the editor to use
  7313. */
  7314. type: InspectableType;
  7315. /**
  7316. * Gets the minimum value of the property when using in "slider" mode
  7317. */
  7318. min?: number;
  7319. /**
  7320. * Gets the maximum value of the property when using in "slider" mode
  7321. */
  7322. max?: number;
  7323. /**
  7324. * Gets the setp to use when using in "slider" mode
  7325. */
  7326. step?: number;
  7327. }
  7328. }
  7329. declare module BABYLON {
  7330. /**
  7331. * Class used to provide helper for timing
  7332. */
  7333. export class TimingTools {
  7334. /**
  7335. * Polyfill for setImmediate
  7336. * @param action defines the action to execute after the current execution block
  7337. */
  7338. static SetImmediate(action: () => void): void;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * Class used to enable instatition of objects by class name
  7344. */
  7345. export class InstantiationTools {
  7346. /**
  7347. * Use this object to register external classes like custom textures or material
  7348. * to allow the laoders to instantiate them
  7349. */
  7350. static RegisteredExternalClasses: {
  7351. [key: string]: Object;
  7352. };
  7353. /**
  7354. * Tries to instantiate a new object from a given class name
  7355. * @param className defines the class name to instantiate
  7356. * @returns the new object or null if the system was not able to do the instantiation
  7357. */
  7358. static Instantiate(className: string): any;
  7359. }
  7360. }
  7361. declare module BABYLON {
  7362. /**
  7363. * Define options used to create a depth texture
  7364. */
  7365. export class DepthTextureCreationOptions {
  7366. /** Specifies whether or not a stencil should be allocated in the texture */
  7367. generateStencil?: boolean;
  7368. /** Specifies whether or not bilinear filtering is enable on the texture */
  7369. bilinearFiltering?: boolean;
  7370. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7371. comparisonFunction?: number;
  7372. /** Specifies if the created texture is a cube texture */
  7373. isCube?: boolean;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Creates a depth stencil cube texture.
  7380. * This is only available in WebGL 2.
  7381. * @param size The size of face edge in the cube texture.
  7382. * @param options The options defining the cube texture.
  7383. * @returns The cube texture
  7384. */
  7385. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7386. /**
  7387. * Creates a cube texture
  7388. * @param rootUrl defines the url where the files to load is located
  7389. * @param scene defines the current scene
  7390. * @param files defines the list of files to load (1 per face)
  7391. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7392. * @param onLoad defines an optional callback raised when the texture is loaded
  7393. * @param onError defines an optional callback raised if there is an issue to load the texture
  7394. * @param format defines the format of the data
  7395. * @param forcedExtension defines the extension to use to pick the right loader
  7396. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7397. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7398. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7399. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7400. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7401. * @returns the cube texture as an InternalTexture
  7402. */
  7403. 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;
  7404. /**
  7405. * Creates a cube texture
  7406. * @param rootUrl defines the url where the files to load is located
  7407. * @param scene defines the current scene
  7408. * @param files defines the list of files to load (1 per face)
  7409. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7410. * @param onLoad defines an optional callback raised when the texture is loaded
  7411. * @param onError defines an optional callback raised if there is an issue to load the texture
  7412. * @param format defines the format of the data
  7413. * @param forcedExtension defines the extension to use to pick the right loader
  7414. * @returns the cube texture as an InternalTexture
  7415. */
  7416. 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;
  7417. /**
  7418. * Creates a cube texture
  7419. * @param rootUrl defines the url where the files to load is located
  7420. * @param scene defines the current scene
  7421. * @param files defines the list of files to load (1 per face)
  7422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7423. * @param onLoad defines an optional callback raised when the texture is loaded
  7424. * @param onError defines an optional callback raised if there is an issue to load the texture
  7425. * @param format defines the format of the data
  7426. * @param forcedExtension defines the extension to use to pick the right loader
  7427. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7428. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7429. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7430. * @returns the cube texture as an InternalTexture
  7431. */
  7432. 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;
  7433. /** @hidden */
  7434. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7435. /** @hidden */
  7436. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7437. /** @hidden */
  7438. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7439. /** @hidden */
  7440. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7441. }
  7442. }
  7443. declare module BABYLON {
  7444. /**
  7445. * Class for creating a cube texture
  7446. */
  7447. export class CubeTexture extends BaseTexture {
  7448. private _delayedOnLoad;
  7449. /**
  7450. * The url of the texture
  7451. */
  7452. url: string;
  7453. /**
  7454. * Gets or sets the center of the bounding box associated with the cube texture.
  7455. * It must define where the camera used to render the texture was set
  7456. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7457. */
  7458. boundingBoxPosition: Vector3;
  7459. private _boundingBoxSize;
  7460. /**
  7461. * Gets or sets the size of the bounding box associated with the cube texture
  7462. * When defined, the cubemap will switch to local mode
  7463. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7464. * @example https://www.babylonjs-playground.com/#RNASML
  7465. */
  7466. /**
  7467. * Returns the bounding box size
  7468. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7469. */
  7470. boundingBoxSize: Vector3;
  7471. protected _rotationY: number;
  7472. /**
  7473. * Sets texture matrix rotation angle around Y axis in radians.
  7474. */
  7475. /**
  7476. * Gets texture matrix rotation angle around Y axis radians.
  7477. */
  7478. rotationY: number;
  7479. /**
  7480. * Are mip maps generated for this texture or not.
  7481. */
  7482. readonly noMipmap: boolean;
  7483. private _noMipmap;
  7484. private _files;
  7485. protected _forcedExtension: Nullable<string>;
  7486. private _extensions;
  7487. private _textureMatrix;
  7488. private _format;
  7489. private _createPolynomials;
  7490. /** @hidden */
  7491. _prefiltered: boolean;
  7492. /**
  7493. * Creates a cube texture from an array of image urls
  7494. * @param files defines an array of image urls
  7495. * @param scene defines the hosting scene
  7496. * @param noMipmap specifies if mip maps are not used
  7497. * @returns a cube texture
  7498. */
  7499. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7500. /**
  7501. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7502. * @param url defines the url of the prefiltered texture
  7503. * @param scene defines the scene the texture is attached to
  7504. * @param forcedExtension defines the extension of the file if different from the url
  7505. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7506. * @return the prefiltered texture
  7507. */
  7508. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7509. /**
  7510. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7511. * as prefiltered data.
  7512. * @param rootUrl defines the url of the texture or the root name of the six images
  7513. * @param scene defines the scene the texture is attached to
  7514. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7515. * @param noMipmap defines if mipmaps should be created or not
  7516. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7517. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7518. * @param onError defines a callback triggered in case of error during load
  7519. * @param format defines the internal format to use for the texture once loaded
  7520. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7521. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7522. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7523. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7524. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7525. * @return the cube texture
  7526. */
  7527. 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);
  7528. /**
  7529. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7530. */
  7531. readonly isPrefiltered: boolean;
  7532. /**
  7533. * Get the current class name of the texture useful for serialization or dynamic coding.
  7534. * @returns "CubeTexture"
  7535. */
  7536. getClassName(): string;
  7537. /**
  7538. * Update the url (and optional buffer) of this texture if url was null during construction.
  7539. * @param url the url of the texture
  7540. * @param forcedExtension defines the extension to use
  7541. * @param onLoad callback called when the texture is loaded (defaults to null)
  7542. */
  7543. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7544. /**
  7545. * Delays loading of the cube texture
  7546. * @param forcedExtension defines the extension to use
  7547. */
  7548. delayLoad(forcedExtension?: string): void;
  7549. /**
  7550. * Returns the reflection texture matrix
  7551. * @returns the reflection texture matrix
  7552. */
  7553. getReflectionTextureMatrix(): Matrix;
  7554. /**
  7555. * Sets the reflection texture matrix
  7556. * @param value Reflection texture matrix
  7557. */
  7558. setReflectionTextureMatrix(value: Matrix): void;
  7559. /**
  7560. * Parses text to create a cube texture
  7561. * @param parsedTexture define the serialized text to read from
  7562. * @param scene defines the hosting scene
  7563. * @param rootUrl defines the root url of the cube texture
  7564. * @returns a cube texture
  7565. */
  7566. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7567. /**
  7568. * Makes a clone, or deep copy, of the cube texture
  7569. * @returns a new cube texture
  7570. */
  7571. clone(): CubeTexture;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Manages the defines for the Material
  7577. */
  7578. export class MaterialDefines {
  7579. /** @hidden */
  7580. protected _keys: string[];
  7581. private _isDirty;
  7582. /** @hidden */
  7583. _renderId: number;
  7584. /** @hidden */
  7585. _areLightsDirty: boolean;
  7586. /** @hidden */
  7587. _areLightsDisposed: boolean;
  7588. /** @hidden */
  7589. _areAttributesDirty: boolean;
  7590. /** @hidden */
  7591. _areTexturesDirty: boolean;
  7592. /** @hidden */
  7593. _areFresnelDirty: boolean;
  7594. /** @hidden */
  7595. _areMiscDirty: boolean;
  7596. /** @hidden */
  7597. _areImageProcessingDirty: boolean;
  7598. /** @hidden */
  7599. _normals: boolean;
  7600. /** @hidden */
  7601. _uvs: boolean;
  7602. /** @hidden */
  7603. _needNormals: boolean;
  7604. /** @hidden */
  7605. _needUVs: boolean;
  7606. [id: string]: any;
  7607. /**
  7608. * Specifies if the material needs to be re-calculated
  7609. */
  7610. readonly isDirty: boolean;
  7611. /**
  7612. * Marks the material to indicate that it has been re-calculated
  7613. */
  7614. markAsProcessed(): void;
  7615. /**
  7616. * Marks the material to indicate that it needs to be re-calculated
  7617. */
  7618. markAsUnprocessed(): void;
  7619. /**
  7620. * Marks the material to indicate all of its defines need to be re-calculated
  7621. */
  7622. markAllAsDirty(): void;
  7623. /**
  7624. * Marks the material to indicate that image processing needs to be re-calculated
  7625. */
  7626. markAsImageProcessingDirty(): void;
  7627. /**
  7628. * Marks the material to indicate the lights need to be re-calculated
  7629. * @param disposed Defines whether the light is dirty due to dispose or not
  7630. */
  7631. markAsLightDirty(disposed?: boolean): void;
  7632. /**
  7633. * Marks the attribute state as changed
  7634. */
  7635. markAsAttributesDirty(): void;
  7636. /**
  7637. * Marks the texture state as changed
  7638. */
  7639. markAsTexturesDirty(): void;
  7640. /**
  7641. * Marks the fresnel state as changed
  7642. */
  7643. markAsFresnelDirty(): void;
  7644. /**
  7645. * Marks the misc state as changed
  7646. */
  7647. markAsMiscDirty(): void;
  7648. /**
  7649. * Rebuilds the material defines
  7650. */
  7651. rebuild(): void;
  7652. /**
  7653. * Specifies if two material defines are equal
  7654. * @param other - A material define instance to compare to
  7655. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7656. */
  7657. isEqual(other: MaterialDefines): boolean;
  7658. /**
  7659. * Clones this instance's defines to another instance
  7660. * @param other - material defines to clone values to
  7661. */
  7662. cloneTo(other: MaterialDefines): void;
  7663. /**
  7664. * Resets the material define values
  7665. */
  7666. reset(): void;
  7667. /**
  7668. * Converts the material define values to a string
  7669. * @returns - String of material define information
  7670. */
  7671. toString(): string;
  7672. }
  7673. }
  7674. declare module BABYLON {
  7675. /**
  7676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7678. * 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;
  7679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7680. */
  7681. export class ColorCurves {
  7682. private _dirty;
  7683. private _tempColor;
  7684. private _globalCurve;
  7685. private _highlightsCurve;
  7686. private _midtonesCurve;
  7687. private _shadowsCurve;
  7688. private _positiveCurve;
  7689. private _negativeCurve;
  7690. private _globalHue;
  7691. private _globalDensity;
  7692. private _globalSaturation;
  7693. private _globalExposure;
  7694. /**
  7695. * Gets the global Hue value.
  7696. * 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).
  7697. */
  7698. /**
  7699. * Sets the global Hue value.
  7700. * 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).
  7701. */
  7702. globalHue: number;
  7703. /**
  7704. * Gets the global Density value.
  7705. * 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.
  7706. * Values less than zero provide a filter of opposite hue.
  7707. */
  7708. /**
  7709. * Sets the global Density value.
  7710. * 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.
  7711. * Values less than zero provide a filter of opposite hue.
  7712. */
  7713. globalDensity: number;
  7714. /**
  7715. * Gets the global Saturation value.
  7716. * 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.
  7717. */
  7718. /**
  7719. * Sets the global Saturation value.
  7720. * 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.
  7721. */
  7722. globalSaturation: number;
  7723. /**
  7724. * Gets the global Exposure value.
  7725. * 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.
  7726. */
  7727. /**
  7728. * Sets the global Exposure value.
  7729. * 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.
  7730. */
  7731. globalExposure: number;
  7732. private _highlightsHue;
  7733. private _highlightsDensity;
  7734. private _highlightsSaturation;
  7735. private _highlightsExposure;
  7736. /**
  7737. * Gets the highlights 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. /**
  7741. * Sets the highlights Hue value.
  7742. * 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).
  7743. */
  7744. highlightsHue: number;
  7745. /**
  7746. * Gets the highlights Density value.
  7747. * 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.
  7748. * Values less than zero provide a filter of opposite hue.
  7749. */
  7750. /**
  7751. * Sets the highlights Density value.
  7752. * 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.
  7753. * Values less than zero provide a filter of opposite hue.
  7754. */
  7755. highlightsDensity: number;
  7756. /**
  7757. * Gets the highlights 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. /**
  7761. * Sets the highlights Saturation value.
  7762. * 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.
  7763. */
  7764. highlightsSaturation: number;
  7765. /**
  7766. * Gets the highlights 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. /**
  7770. * Sets the highlights Exposure value.
  7771. * 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.
  7772. */
  7773. highlightsExposure: number;
  7774. private _midtonesHue;
  7775. private _midtonesDensity;
  7776. private _midtonesSaturation;
  7777. private _midtonesExposure;
  7778. /**
  7779. * Gets the midtones 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. /**
  7783. * Sets the midtones Hue value.
  7784. * 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).
  7785. */
  7786. midtonesHue: number;
  7787. /**
  7788. * Gets the midtones Density value.
  7789. * 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.
  7790. * Values less than zero provide a filter of opposite hue.
  7791. */
  7792. /**
  7793. * Sets the midtones Density value.
  7794. * 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.
  7795. * Values less than zero provide a filter of opposite hue.
  7796. */
  7797. midtonesDensity: number;
  7798. /**
  7799. * Gets the midtones 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. /**
  7803. * Sets the midtones Saturation value.
  7804. * 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.
  7805. */
  7806. midtonesSaturation: number;
  7807. /**
  7808. * Gets the midtones 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. /**
  7812. * Sets the midtones Exposure value.
  7813. * 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.
  7814. */
  7815. midtonesExposure: number;
  7816. private _shadowsHue;
  7817. private _shadowsDensity;
  7818. private _shadowsSaturation;
  7819. private _shadowsExposure;
  7820. /**
  7821. * Gets the shadows 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. /**
  7825. * Sets the shadows Hue value.
  7826. * 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).
  7827. */
  7828. shadowsHue: number;
  7829. /**
  7830. * Gets the shadows Density value.
  7831. * 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.
  7832. * Values less than zero provide a filter of opposite hue.
  7833. */
  7834. /**
  7835. * Sets the shadows Density value.
  7836. * 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.
  7837. * Values less than zero provide a filter of opposite hue.
  7838. */
  7839. shadowsDensity: number;
  7840. /**
  7841. * Gets the shadows 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. /**
  7845. * Sets the shadows Saturation value.
  7846. * 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.
  7847. */
  7848. shadowsSaturation: number;
  7849. /**
  7850. * Gets the shadows 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. /**
  7854. * Sets the shadows Exposure value.
  7855. * 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.
  7856. */
  7857. shadowsExposure: number;
  7858. /**
  7859. * Returns the class name
  7860. * @returns The class name
  7861. */
  7862. getClassName(): string;
  7863. /**
  7864. * Binds the color curves to the shader.
  7865. * @param colorCurves The color curve to bind
  7866. * @param effect The effect to bind to
  7867. * @param positiveUniform The positive uniform shader parameter
  7868. * @param neutralUniform The neutral uniform shader parameter
  7869. * @param negativeUniform The negative uniform shader parameter
  7870. */
  7871. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7872. /**
  7873. * Prepare the list of uniforms associated with the ColorCurves effects.
  7874. * @param uniformsList The list of uniforms used in the effect
  7875. */
  7876. static PrepareUniforms(uniformsList: string[]): void;
  7877. /**
  7878. * Returns color grading data based on a hue, density, saturation and exposure value.
  7879. * @param filterHue The hue of the color filter.
  7880. * @param filterDensity The density of the color filter.
  7881. * @param saturation The saturation.
  7882. * @param exposure The exposure.
  7883. * @param result The result data container.
  7884. */
  7885. private getColorGradingDataToRef;
  7886. /**
  7887. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7888. * @param value The input slider value in range [-100,100].
  7889. * @returns Adjusted value.
  7890. */
  7891. private static applyColorGradingSliderNonlinear;
  7892. /**
  7893. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7894. * @param hue The hue (H) input.
  7895. * @param saturation The saturation (S) input.
  7896. * @param brightness The brightness (B) input.
  7897. * @result An RGBA color represented as Vector4.
  7898. */
  7899. private static fromHSBToRef;
  7900. /**
  7901. * Returns a value clamped between min and max
  7902. * @param value The value to clamp
  7903. * @param min The minimum of value
  7904. * @param max The maximum of value
  7905. * @returns The clamped value.
  7906. */
  7907. private static clamp;
  7908. /**
  7909. * Clones the current color curve instance.
  7910. * @return The cloned curves
  7911. */
  7912. clone(): ColorCurves;
  7913. /**
  7914. * Serializes the current color curve instance to a json representation.
  7915. * @return a JSON representation
  7916. */
  7917. serialize(): any;
  7918. /**
  7919. * Parses the color curve from a json representation.
  7920. * @param source the JSON source to parse
  7921. * @return The parsed curves
  7922. */
  7923. static Parse(source: any): ColorCurves;
  7924. }
  7925. }
  7926. declare module BABYLON {
  7927. /**
  7928. * Interface to follow in your material defines to integrate easily the
  7929. * Image proccessing functions.
  7930. * @hidden
  7931. */
  7932. export interface IImageProcessingConfigurationDefines {
  7933. IMAGEPROCESSING: boolean;
  7934. VIGNETTE: boolean;
  7935. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7936. VIGNETTEBLENDMODEOPAQUE: boolean;
  7937. TONEMAPPING: boolean;
  7938. TONEMAPPING_ACES: boolean;
  7939. CONTRAST: boolean;
  7940. EXPOSURE: boolean;
  7941. COLORCURVES: boolean;
  7942. COLORGRADING: boolean;
  7943. COLORGRADING3D: boolean;
  7944. SAMPLER3DGREENDEPTH: boolean;
  7945. SAMPLER3DBGRMAP: boolean;
  7946. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7947. }
  7948. /**
  7949. * @hidden
  7950. */
  7951. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7952. IMAGEPROCESSING: boolean;
  7953. VIGNETTE: boolean;
  7954. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7955. VIGNETTEBLENDMODEOPAQUE: boolean;
  7956. TONEMAPPING: boolean;
  7957. TONEMAPPING_ACES: boolean;
  7958. CONTRAST: boolean;
  7959. COLORCURVES: boolean;
  7960. COLORGRADING: boolean;
  7961. COLORGRADING3D: boolean;
  7962. SAMPLER3DGREENDEPTH: boolean;
  7963. SAMPLER3DBGRMAP: boolean;
  7964. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7965. EXPOSURE: boolean;
  7966. constructor();
  7967. }
  7968. /**
  7969. * This groups together the common properties used for image processing either in direct forward pass
  7970. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7971. * or not.
  7972. */
  7973. export class ImageProcessingConfiguration {
  7974. /**
  7975. * Default tone mapping applied in BabylonJS.
  7976. */
  7977. static readonly TONEMAPPING_STANDARD: number;
  7978. /**
  7979. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7980. * to other engines rendering to increase portability.
  7981. */
  7982. static readonly TONEMAPPING_ACES: number;
  7983. /**
  7984. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7985. */
  7986. colorCurves: Nullable<ColorCurves>;
  7987. private _colorCurvesEnabled;
  7988. /**
  7989. * Gets wether the color curves effect is enabled.
  7990. */
  7991. /**
  7992. * Sets wether the color curves effect is enabled.
  7993. */
  7994. colorCurvesEnabled: boolean;
  7995. private _colorGradingTexture;
  7996. /**
  7997. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7998. */
  7999. /**
  8000. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8001. */
  8002. colorGradingTexture: Nullable<BaseTexture>;
  8003. private _colorGradingEnabled;
  8004. /**
  8005. * Gets wether the color grading effect is enabled.
  8006. */
  8007. /**
  8008. * Sets wether the color grading effect is enabled.
  8009. */
  8010. colorGradingEnabled: boolean;
  8011. private _colorGradingWithGreenDepth;
  8012. /**
  8013. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8014. */
  8015. /**
  8016. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8017. */
  8018. colorGradingWithGreenDepth: boolean;
  8019. private _colorGradingBGR;
  8020. /**
  8021. * Gets wether the color grading texture contains BGR values.
  8022. */
  8023. /**
  8024. * Sets wether the color grading texture contains BGR values.
  8025. */
  8026. colorGradingBGR: boolean;
  8027. /** @hidden */
  8028. _exposure: number;
  8029. /**
  8030. * Gets the Exposure used in the effect.
  8031. */
  8032. /**
  8033. * Sets the Exposure used in the effect.
  8034. */
  8035. exposure: number;
  8036. private _toneMappingEnabled;
  8037. /**
  8038. * Gets wether the tone mapping effect is enabled.
  8039. */
  8040. /**
  8041. * Sets wether the tone mapping effect is enabled.
  8042. */
  8043. toneMappingEnabled: boolean;
  8044. private _toneMappingType;
  8045. /**
  8046. * Gets the type of tone mapping effect.
  8047. */
  8048. /**
  8049. * Sets the type of tone mapping effect used in BabylonJS.
  8050. */
  8051. toneMappingType: number;
  8052. protected _contrast: number;
  8053. /**
  8054. * Gets the contrast used in the effect.
  8055. */
  8056. /**
  8057. * Sets the contrast used in the effect.
  8058. */
  8059. contrast: number;
  8060. /**
  8061. * Vignette stretch size.
  8062. */
  8063. vignetteStretch: number;
  8064. /**
  8065. * Vignette centre X Offset.
  8066. */
  8067. vignetteCentreX: number;
  8068. /**
  8069. * Vignette centre Y Offset.
  8070. */
  8071. vignetteCentreY: number;
  8072. /**
  8073. * Vignette weight or intensity of the vignette effect.
  8074. */
  8075. vignetteWeight: number;
  8076. /**
  8077. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8078. * if vignetteEnabled is set to true.
  8079. */
  8080. vignetteColor: Color4;
  8081. /**
  8082. * Camera field of view used by the Vignette effect.
  8083. */
  8084. vignetteCameraFov: number;
  8085. private _vignetteBlendMode;
  8086. /**
  8087. * Gets the vignette blend mode allowing different kind of effect.
  8088. */
  8089. /**
  8090. * Sets the vignette blend mode allowing different kind of effect.
  8091. */
  8092. vignetteBlendMode: number;
  8093. private _vignetteEnabled;
  8094. /**
  8095. * Gets wether the vignette effect is enabled.
  8096. */
  8097. /**
  8098. * Sets wether the vignette effect is enabled.
  8099. */
  8100. vignetteEnabled: boolean;
  8101. private _applyByPostProcess;
  8102. /**
  8103. * Gets wether the image processing is applied through a post process or not.
  8104. */
  8105. /**
  8106. * Sets wether the image processing is applied through a post process or not.
  8107. */
  8108. applyByPostProcess: boolean;
  8109. private _isEnabled;
  8110. /**
  8111. * Gets wether the image processing is enabled or not.
  8112. */
  8113. /**
  8114. * Sets wether the image processing is enabled or not.
  8115. */
  8116. isEnabled: boolean;
  8117. /**
  8118. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8119. */
  8120. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8121. /**
  8122. * Method called each time the image processing information changes requires to recompile the effect.
  8123. */
  8124. protected _updateParameters(): void;
  8125. /**
  8126. * Gets the current class name.
  8127. * @return "ImageProcessingConfiguration"
  8128. */
  8129. getClassName(): string;
  8130. /**
  8131. * Prepare the list of uniforms associated with the Image Processing effects.
  8132. * @param uniforms The list of uniforms used in the effect
  8133. * @param defines the list of defines currently in use
  8134. */
  8135. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8136. /**
  8137. * Prepare the list of samplers associated with the Image Processing effects.
  8138. * @param samplersList The list of uniforms used in the effect
  8139. * @param defines the list of defines currently in use
  8140. */
  8141. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8142. /**
  8143. * Prepare the list of defines associated to the shader.
  8144. * @param defines the list of defines to complete
  8145. * @param forPostProcess Define if we are currently in post process mode or not
  8146. */
  8147. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8148. /**
  8149. * Returns true if all the image processing information are ready.
  8150. * @returns True if ready, otherwise, false
  8151. */
  8152. isReady(): boolean;
  8153. /**
  8154. * Binds the image processing to the shader.
  8155. * @param effect The effect to bind to
  8156. * @param aspectRatio Define the current aspect ratio of the effect
  8157. */
  8158. bind(effect: Effect, aspectRatio?: number): void;
  8159. /**
  8160. * Clones the current image processing instance.
  8161. * @return The cloned image processing
  8162. */
  8163. clone(): ImageProcessingConfiguration;
  8164. /**
  8165. * Serializes the current image processing instance to a json representation.
  8166. * @return a JSON representation
  8167. */
  8168. serialize(): any;
  8169. /**
  8170. * Parses the image processing from a json representation.
  8171. * @param source the JSON source to parse
  8172. * @return The parsed image processing
  8173. */
  8174. static Parse(source: any): ImageProcessingConfiguration;
  8175. private static _VIGNETTEMODE_MULTIPLY;
  8176. private static _VIGNETTEMODE_OPAQUE;
  8177. /**
  8178. * Used to apply the vignette as a mix with the pixel color.
  8179. */
  8180. static readonly VIGNETTEMODE_MULTIPLY: number;
  8181. /**
  8182. * Used to apply the vignette as a replacement of the pixel color.
  8183. */
  8184. static readonly VIGNETTEMODE_OPAQUE: number;
  8185. }
  8186. }
  8187. declare module BABYLON {
  8188. /** @hidden */
  8189. export var postprocessVertexShader: {
  8190. name: string;
  8191. shader: string;
  8192. };
  8193. }
  8194. declare module BABYLON {
  8195. interface ThinEngine {
  8196. /**
  8197. * Creates a new render target texture
  8198. * @param size defines the size of the texture
  8199. * @param options defines the options used to create the texture
  8200. * @returns a new render target texture stored in an InternalTexture
  8201. */
  8202. createRenderTargetTexture(size: number | {
  8203. width: number;
  8204. height: number;
  8205. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8206. }
  8207. }
  8208. declare module BABYLON {
  8209. /** Defines supported spaces */
  8210. export enum Space {
  8211. /** Local (object) space */
  8212. LOCAL = 0,
  8213. /** World space */
  8214. WORLD = 1,
  8215. /** Bone space */
  8216. BONE = 2
  8217. }
  8218. /** Defines the 3 main axes */
  8219. export class Axis {
  8220. /** X axis */
  8221. static X: Vector3;
  8222. /** Y axis */
  8223. static Y: Vector3;
  8224. /** Z axis */
  8225. static Z: Vector3;
  8226. }
  8227. }
  8228. declare module BABYLON {
  8229. /**
  8230. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8231. * This is the base of the follow, arc rotate cameras and Free camera
  8232. * @see http://doc.babylonjs.com/features/cameras
  8233. */
  8234. export class TargetCamera extends Camera {
  8235. private static _RigCamTransformMatrix;
  8236. private static _TargetTransformMatrix;
  8237. private static _TargetFocalPoint;
  8238. /**
  8239. * Define the current direction the camera is moving to
  8240. */
  8241. cameraDirection: Vector3;
  8242. /**
  8243. * Define the current rotation the camera is rotating to
  8244. */
  8245. cameraRotation: Vector2;
  8246. /**
  8247. * When set, the up vector of the camera will be updated by the rotation of the camera
  8248. */
  8249. updateUpVectorFromRotation: boolean;
  8250. private _tmpQuaternion;
  8251. /**
  8252. * Define the current rotation of the camera
  8253. */
  8254. rotation: Vector3;
  8255. /**
  8256. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8257. */
  8258. rotationQuaternion: Quaternion;
  8259. /**
  8260. * Define the current speed of the camera
  8261. */
  8262. speed: number;
  8263. /**
  8264. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8265. * around all axis.
  8266. */
  8267. noRotationConstraint: boolean;
  8268. /**
  8269. * Define the current target of the camera as an object or a position.
  8270. */
  8271. lockedTarget: any;
  8272. /** @hidden */
  8273. _currentTarget: Vector3;
  8274. /** @hidden */
  8275. _initialFocalDistance: number;
  8276. /** @hidden */
  8277. _viewMatrix: Matrix;
  8278. /** @hidden */
  8279. _camMatrix: Matrix;
  8280. /** @hidden */
  8281. _cameraTransformMatrix: Matrix;
  8282. /** @hidden */
  8283. _cameraRotationMatrix: Matrix;
  8284. /** @hidden */
  8285. _referencePoint: Vector3;
  8286. /** @hidden */
  8287. _transformedReferencePoint: Vector3;
  8288. protected _globalCurrentTarget: Vector3;
  8289. protected _globalCurrentUpVector: Vector3;
  8290. /** @hidden */
  8291. _reset: () => void;
  8292. private _defaultUp;
  8293. /**
  8294. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8295. * This is the base of the follow, arc rotate cameras and Free camera
  8296. * @see http://doc.babylonjs.com/features/cameras
  8297. * @param name Defines the name of the camera in the scene
  8298. * @param position Defines the start position of the camera in the scene
  8299. * @param scene Defines the scene the camera belongs to
  8300. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8301. */
  8302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8303. /**
  8304. * Gets the position in front of the camera at a given distance.
  8305. * @param distance The distance from the camera we want the position to be
  8306. * @returns the position
  8307. */
  8308. getFrontPosition(distance: number): Vector3;
  8309. /** @hidden */
  8310. _getLockedTargetPosition(): Nullable<Vector3>;
  8311. private _storedPosition;
  8312. private _storedRotation;
  8313. private _storedRotationQuaternion;
  8314. /**
  8315. * Store current camera state of the camera (fov, position, rotation, etc..)
  8316. * @returns the camera
  8317. */
  8318. storeState(): Camera;
  8319. /**
  8320. * Restored camera state. You must call storeState() first
  8321. * @returns whether it was successful or not
  8322. * @hidden
  8323. */
  8324. _restoreStateValues(): boolean;
  8325. /** @hidden */
  8326. _initCache(): void;
  8327. /** @hidden */
  8328. _updateCache(ignoreParentClass?: boolean): void;
  8329. /** @hidden */
  8330. _isSynchronizedViewMatrix(): boolean;
  8331. /** @hidden */
  8332. _computeLocalCameraSpeed(): number;
  8333. /**
  8334. * Defines the target the camera should look at.
  8335. * @param target Defines the new target as a Vector or a mesh
  8336. */
  8337. setTarget(target: Vector3): void;
  8338. /**
  8339. * Return the current target position of the camera. This value is expressed in local space.
  8340. * @returns the target position
  8341. */
  8342. getTarget(): Vector3;
  8343. /** @hidden */
  8344. _decideIfNeedsToMove(): boolean;
  8345. /** @hidden */
  8346. _updatePosition(): void;
  8347. /** @hidden */
  8348. _checkInputs(): void;
  8349. protected _updateCameraRotationMatrix(): void;
  8350. /**
  8351. * 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)
  8352. * @returns the current camera
  8353. */
  8354. private _rotateUpVectorWithCameraRotationMatrix;
  8355. private _cachedRotationZ;
  8356. private _cachedQuaternionRotationZ;
  8357. /** @hidden */
  8358. _getViewMatrix(): Matrix;
  8359. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8360. /**
  8361. * @hidden
  8362. */
  8363. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8364. /**
  8365. * @hidden
  8366. */
  8367. _updateRigCameras(): void;
  8368. private _getRigCamPositionAndTarget;
  8369. /**
  8370. * Gets the current object class name.
  8371. * @return the class name
  8372. */
  8373. getClassName(): string;
  8374. }
  8375. }
  8376. declare module BABYLON {
  8377. /**
  8378. * Gather the list of keyboard event types as constants.
  8379. */
  8380. export class KeyboardEventTypes {
  8381. /**
  8382. * The keydown event is fired when a key becomes active (pressed).
  8383. */
  8384. static readonly KEYDOWN: number;
  8385. /**
  8386. * The keyup event is fired when a key has been released.
  8387. */
  8388. static readonly KEYUP: number;
  8389. }
  8390. /**
  8391. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8392. */
  8393. export class KeyboardInfo {
  8394. /**
  8395. * Defines the type of event (KeyboardEventTypes)
  8396. */
  8397. type: number;
  8398. /**
  8399. * Defines the related dom event
  8400. */
  8401. event: KeyboardEvent;
  8402. /**
  8403. * Instantiates a new keyboard info.
  8404. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8405. * @param type Defines the type of event (KeyboardEventTypes)
  8406. * @param event Defines the related dom event
  8407. */
  8408. constructor(
  8409. /**
  8410. * Defines the type of event (KeyboardEventTypes)
  8411. */
  8412. type: number,
  8413. /**
  8414. * Defines the related dom event
  8415. */
  8416. event: KeyboardEvent);
  8417. }
  8418. /**
  8419. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8420. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8421. */
  8422. export class KeyboardInfoPre extends KeyboardInfo {
  8423. /**
  8424. * Defines the type of event (KeyboardEventTypes)
  8425. */
  8426. type: number;
  8427. /**
  8428. * Defines the related dom event
  8429. */
  8430. event: KeyboardEvent;
  8431. /**
  8432. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8433. */
  8434. skipOnPointerObservable: boolean;
  8435. /**
  8436. * Instantiates a new keyboard pre info.
  8437. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8438. * @param type Defines the type of event (KeyboardEventTypes)
  8439. * @param event Defines the related dom event
  8440. */
  8441. constructor(
  8442. /**
  8443. * Defines the type of event (KeyboardEventTypes)
  8444. */
  8445. type: number,
  8446. /**
  8447. * Defines the related dom event
  8448. */
  8449. event: KeyboardEvent);
  8450. }
  8451. }
  8452. declare module BABYLON {
  8453. /**
  8454. * Manage the keyboard inputs to control the movement of a free camera.
  8455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8456. */
  8457. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8458. /**
  8459. * Defines the camera the input is attached to.
  8460. */
  8461. camera: FreeCamera;
  8462. /**
  8463. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8464. */
  8465. keysUp: number[];
  8466. /**
  8467. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8468. */
  8469. keysDown: number[];
  8470. /**
  8471. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8472. */
  8473. keysLeft: number[];
  8474. /**
  8475. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8476. */
  8477. keysRight: number[];
  8478. private _keys;
  8479. private _onCanvasBlurObserver;
  8480. private _onKeyboardObserver;
  8481. private _engine;
  8482. private _scene;
  8483. /**
  8484. * Attach the input controls to a specific dom element to get the input from.
  8485. * @param element Defines the element the controls should be listened from
  8486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8487. */
  8488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8489. /**
  8490. * Detach the current controls from the specified dom element.
  8491. * @param element Defines the element to stop listening the inputs from
  8492. */
  8493. detachControl(element: Nullable<HTMLElement>): void;
  8494. /**
  8495. * Update the current camera state depending on the inputs that have been used this frame.
  8496. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8497. */
  8498. checkInputs(): void;
  8499. /**
  8500. * Gets the class name of the current intput.
  8501. * @returns the class name
  8502. */
  8503. getClassName(): string;
  8504. /** @hidden */
  8505. _onLostFocus(): void;
  8506. /**
  8507. * Get the friendly name associated with the input class.
  8508. * @returns the input friendly name
  8509. */
  8510. getSimpleName(): string;
  8511. }
  8512. }
  8513. declare module BABYLON {
  8514. /**
  8515. * Interface describing all the common properties and methods a shadow light needs to implement.
  8516. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8517. * as well as binding the different shadow properties to the effects.
  8518. */
  8519. export interface IShadowLight extends Light {
  8520. /**
  8521. * The light id in the scene (used in scene.findLighById for instance)
  8522. */
  8523. id: string;
  8524. /**
  8525. * The position the shdow will be casted from.
  8526. */
  8527. position: Vector3;
  8528. /**
  8529. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8530. */
  8531. direction: Vector3;
  8532. /**
  8533. * The transformed position. Position of the light in world space taking parenting in account.
  8534. */
  8535. transformedPosition: Vector3;
  8536. /**
  8537. * The transformed direction. Direction of the light in world space taking parenting in account.
  8538. */
  8539. transformedDirection: Vector3;
  8540. /**
  8541. * The friendly name of the light in the scene.
  8542. */
  8543. name: string;
  8544. /**
  8545. * Defines the shadow projection clipping minimum z value.
  8546. */
  8547. shadowMinZ: number;
  8548. /**
  8549. * Defines the shadow projection clipping maximum z value.
  8550. */
  8551. shadowMaxZ: number;
  8552. /**
  8553. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8554. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8555. */
  8556. computeTransformedInformation(): boolean;
  8557. /**
  8558. * Gets the scene the light belongs to.
  8559. * @returns The scene
  8560. */
  8561. getScene(): Scene;
  8562. /**
  8563. * Callback defining a custom Projection Matrix Builder.
  8564. * This can be used to override the default projection matrix computation.
  8565. */
  8566. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8567. /**
  8568. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8569. * @param matrix The materix to updated with the projection information
  8570. * @param viewMatrix The transform matrix of the light
  8571. * @param renderList The list of mesh to render in the map
  8572. * @returns The current light
  8573. */
  8574. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8575. /**
  8576. * Gets the current depth scale used in ESM.
  8577. * @returns The scale
  8578. */
  8579. getDepthScale(): number;
  8580. /**
  8581. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8582. * @returns true if a cube texture needs to be use
  8583. */
  8584. needCube(): boolean;
  8585. /**
  8586. * Detects if the projection matrix requires to be recomputed this frame.
  8587. * @returns true if it requires to be recomputed otherwise, false.
  8588. */
  8589. needProjectionMatrixCompute(): boolean;
  8590. /**
  8591. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8592. */
  8593. forceProjectionMatrixCompute(): void;
  8594. /**
  8595. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8596. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8597. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8598. */
  8599. getShadowDirection(faceIndex?: number): Vector3;
  8600. /**
  8601. * Gets the minZ used for shadow according to both the scene and the light.
  8602. * @param activeCamera The camera we are returning the min for
  8603. * @returns the depth min z
  8604. */
  8605. getDepthMinZ(activeCamera: Camera): number;
  8606. /**
  8607. * Gets the maxZ used for shadow according to both the scene and the light.
  8608. * @param activeCamera The camera we are returning the max for
  8609. * @returns the depth max z
  8610. */
  8611. getDepthMaxZ(activeCamera: Camera): number;
  8612. }
  8613. /**
  8614. * Base implementation IShadowLight
  8615. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8616. */
  8617. export abstract class ShadowLight extends Light implements IShadowLight {
  8618. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8619. protected _position: Vector3;
  8620. protected _setPosition(value: Vector3): void;
  8621. /**
  8622. * Sets the position the shadow will be casted from. Also use as the light position for both
  8623. * point and spot lights.
  8624. */
  8625. /**
  8626. * Sets the position the shadow will be casted from. Also use as the light position for both
  8627. * point and spot lights.
  8628. */
  8629. position: Vector3;
  8630. protected _direction: Vector3;
  8631. protected _setDirection(value: Vector3): void;
  8632. /**
  8633. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8634. * Also use as the light direction on spot and directional lights.
  8635. */
  8636. /**
  8637. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8638. * Also use as the light direction on spot and directional lights.
  8639. */
  8640. direction: Vector3;
  8641. private _shadowMinZ;
  8642. /**
  8643. * Gets the shadow projection clipping minimum z value.
  8644. */
  8645. /**
  8646. * Sets the shadow projection clipping minimum z value.
  8647. */
  8648. shadowMinZ: number;
  8649. private _shadowMaxZ;
  8650. /**
  8651. * Sets the shadow projection clipping maximum z value.
  8652. */
  8653. /**
  8654. * Gets the shadow projection clipping maximum z value.
  8655. */
  8656. shadowMaxZ: number;
  8657. /**
  8658. * Callback defining a custom Projection Matrix Builder.
  8659. * This can be used to override the default projection matrix computation.
  8660. */
  8661. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8662. /**
  8663. * The transformed position. Position of the light in world space taking parenting in account.
  8664. */
  8665. transformedPosition: Vector3;
  8666. /**
  8667. * The transformed direction. Direction of the light in world space taking parenting in account.
  8668. */
  8669. transformedDirection: Vector3;
  8670. private _needProjectionMatrixCompute;
  8671. /**
  8672. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8673. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8674. */
  8675. computeTransformedInformation(): boolean;
  8676. /**
  8677. * Return the depth scale used for the shadow map.
  8678. * @returns the depth scale.
  8679. */
  8680. getDepthScale(): number;
  8681. /**
  8682. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8683. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8684. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8685. */
  8686. getShadowDirection(faceIndex?: number): Vector3;
  8687. /**
  8688. * Returns the ShadowLight absolute position in the World.
  8689. * @returns the position vector in world space
  8690. */
  8691. getAbsolutePosition(): Vector3;
  8692. /**
  8693. * Sets the ShadowLight direction toward the passed target.
  8694. * @param target The point to target in local space
  8695. * @returns the updated ShadowLight direction
  8696. */
  8697. setDirectionToTarget(target: Vector3): Vector3;
  8698. /**
  8699. * Returns the light rotation in euler definition.
  8700. * @returns the x y z rotation in local space.
  8701. */
  8702. getRotation(): Vector3;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /** @hidden */
  8718. _initCache(): void;
  8719. /** @hidden */
  8720. _isSynchronized(): boolean;
  8721. /**
  8722. * Computes the world matrix of the node
  8723. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8724. * @returns the world matrix
  8725. */
  8726. computeWorldMatrix(force?: boolean): Matrix;
  8727. /**
  8728. * Gets the minZ used for shadow according to both the scene and the light.
  8729. * @param activeCamera The camera we are returning the min for
  8730. * @returns the depth min z
  8731. */
  8732. getDepthMinZ(activeCamera: Camera): number;
  8733. /**
  8734. * Gets the maxZ used for shadow according to both the scene and the light.
  8735. * @param activeCamera The camera we are returning the max for
  8736. * @returns the depth max z
  8737. */
  8738. getDepthMaxZ(activeCamera: Camera): number;
  8739. /**
  8740. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8741. * @param matrix The materix to updated with the projection information
  8742. * @param viewMatrix The transform matrix of the light
  8743. * @param renderList The list of mesh to render in the map
  8744. * @returns The current light
  8745. */
  8746. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8747. }
  8748. }
  8749. declare module BABYLON {
  8750. /**
  8751. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8752. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8753. */
  8754. export class EffectFallbacks implements IEffectFallbacks {
  8755. private _defines;
  8756. private _currentRank;
  8757. private _maxRank;
  8758. private _mesh;
  8759. /**
  8760. * Removes the fallback from the bound mesh.
  8761. */
  8762. unBindMesh(): void;
  8763. /**
  8764. * Adds a fallback on the specified property.
  8765. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8766. * @param define The name of the define in the shader
  8767. */
  8768. addFallback(rank: number, define: string): void;
  8769. /**
  8770. * Sets the mesh to use CPU skinning when needing to fallback.
  8771. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8772. * @param mesh The mesh to use the fallbacks.
  8773. */
  8774. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8775. /**
  8776. * Checks to see if more fallbacks are still availible.
  8777. */
  8778. readonly hasMoreFallbacks: boolean;
  8779. /**
  8780. * Removes the defines that should be removed when falling back.
  8781. * @param currentDefines defines the current define statements for the shader.
  8782. * @param effect defines the current effect we try to compile
  8783. * @returns The resulting defines with defines of the current rank removed.
  8784. */
  8785. reduce(currentDefines: string, effect: Effect): string;
  8786. }
  8787. }
  8788. declare module BABYLON {
  8789. /**
  8790. * "Static Class" containing the most commonly used helper while dealing with material for
  8791. * rendering purpose.
  8792. *
  8793. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8794. *
  8795. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8796. */
  8797. export class MaterialHelper {
  8798. /**
  8799. * Bind the current view position to an effect.
  8800. * @param effect The effect to be bound
  8801. * @param scene The scene the eyes position is used from
  8802. */
  8803. static BindEyePosition(effect: Effect, scene: Scene): void;
  8804. /**
  8805. * Helps preparing the defines values about the UVs in used in the effect.
  8806. * UVs are shared as much as we can accross channels in the shaders.
  8807. * @param texture The texture we are preparing the UVs for
  8808. * @param defines The defines to update
  8809. * @param key The channel key "diffuse", "specular"... used in the shader
  8810. */
  8811. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8812. /**
  8813. * Binds a texture matrix value to its corrsponding uniform
  8814. * @param texture The texture to bind the matrix for
  8815. * @param uniformBuffer The uniform buffer receivin the data
  8816. * @param key The channel key "diffuse", "specular"... used in the shader
  8817. */
  8818. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8819. /**
  8820. * Gets the current status of the fog (should it be enabled?)
  8821. * @param mesh defines the mesh to evaluate for fog support
  8822. * @param scene defines the hosting scene
  8823. * @returns true if fog must be enabled
  8824. */
  8825. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8826. /**
  8827. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8828. * @param mesh defines the current mesh
  8829. * @param scene defines the current scene
  8830. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8831. * @param pointsCloud defines if point cloud rendering has to be turned on
  8832. * @param fogEnabled defines if fog has to be turned on
  8833. * @param alphaTest defines if alpha testing has to be turned on
  8834. * @param defines defines the current list of defines
  8835. */
  8836. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8837. /**
  8838. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8839. * @param scene defines the current scene
  8840. * @param engine defines the current engine
  8841. * @param defines specifies the list of active defines
  8842. * @param useInstances defines if instances have to be turned on
  8843. * @param useClipPlane defines if clip plane have to be turned on
  8844. */
  8845. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8846. /**
  8847. * Prepares the defines for bones
  8848. * @param mesh The mesh containing the geometry data we will draw
  8849. * @param defines The defines to update
  8850. */
  8851. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8852. /**
  8853. * Prepares the defines for morph targets
  8854. * @param mesh The mesh containing the geometry data we will draw
  8855. * @param defines The defines to update
  8856. */
  8857. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8858. /**
  8859. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8860. * @param mesh The mesh containing the geometry data we will draw
  8861. * @param defines The defines to update
  8862. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8863. * @param useBones Precise whether bones should be used or not (override mesh info)
  8864. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8865. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8866. * @returns false if defines are considered not dirty and have not been checked
  8867. */
  8868. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8869. /**
  8870. * Prepares the defines related to multiview
  8871. * @param scene The scene we are intending to draw
  8872. * @param defines The defines to update
  8873. */
  8874. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8875. /**
  8876. * Prepares the defines related to the light information passed in parameter
  8877. * @param scene The scene we are intending to draw
  8878. * @param mesh The mesh the effect is compiling for
  8879. * @param light The light the effect is compiling for
  8880. * @param lightIndex The index of the light
  8881. * @param defines The defines to update
  8882. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8883. * @param state Defines the current state regarding what is needed (normals, etc...)
  8884. */
  8885. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8886. needNormals: boolean;
  8887. needRebuild: boolean;
  8888. shadowEnabled: boolean;
  8889. specularEnabled: boolean;
  8890. lightmapMode: boolean;
  8891. }): void;
  8892. /**
  8893. * Prepares the defines related to the light information passed in parameter
  8894. * @param scene The scene we are intending to draw
  8895. * @param mesh The mesh the effect is compiling for
  8896. * @param defines The defines to update
  8897. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8898. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8899. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8900. * @returns true if normals will be required for the rest of the effect
  8901. */
  8902. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8903. /**
  8904. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8905. * @param lightIndex defines the light index
  8906. * @param uniformsList The uniform list
  8907. * @param samplersList The sampler list
  8908. * @param projectedLightTexture defines if projected texture must be used
  8909. * @param uniformBuffersList defines an optional list of uniform buffers
  8910. */
  8911. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8912. /**
  8913. * Prepares the uniforms and samplers list to be used in the effect
  8914. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8915. * @param samplersList The sampler list
  8916. * @param defines The defines helping in the list generation
  8917. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8918. */
  8919. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8920. /**
  8921. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8922. * @param defines The defines to update while falling back
  8923. * @param fallbacks The authorized effect fallbacks
  8924. * @param maxSimultaneousLights The maximum number of lights allowed
  8925. * @param rank the current rank of the Effect
  8926. * @returns The newly affected rank
  8927. */
  8928. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8929. private static _TmpMorphInfluencers;
  8930. /**
  8931. * Prepares the list of attributes required for morph targets according to the effect defines.
  8932. * @param attribs The current list of supported attribs
  8933. * @param mesh The mesh to prepare the morph targets attributes for
  8934. * @param influencers The number of influencers
  8935. */
  8936. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8937. /**
  8938. * Prepares the list of attributes required for morph targets according to the effect defines.
  8939. * @param attribs The current list of supported attribs
  8940. * @param mesh The mesh to prepare the morph targets attributes for
  8941. * @param defines The current Defines of the effect
  8942. */
  8943. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8944. /**
  8945. * Prepares the list of attributes required for bones according to the effect defines.
  8946. * @param attribs The current list of supported attribs
  8947. * @param mesh The mesh to prepare the bones attributes for
  8948. * @param defines The current Defines of the effect
  8949. * @param fallbacks The current efffect fallback strategy
  8950. */
  8951. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8952. /**
  8953. * Check and prepare the list of attributes required for instances according to the effect defines.
  8954. * @param attribs The current list of supported attribs
  8955. * @param defines The current MaterialDefines of the effect
  8956. */
  8957. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8958. /**
  8959. * Add the list of attributes required for instances to the attribs array.
  8960. * @param attribs The current list of supported attribs
  8961. */
  8962. static PushAttributesForInstances(attribs: string[]): void;
  8963. /**
  8964. * Binds the light information to the effect.
  8965. * @param light The light containing the generator
  8966. * @param effect The effect we are binding the data to
  8967. * @param lightIndex The light index in the effect used to render
  8968. */
  8969. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8970. /**
  8971. * Binds the lights information from the scene to the effect for the given mesh.
  8972. * @param light Light to bind
  8973. * @param lightIndex Light index
  8974. * @param scene The scene where the light belongs to
  8975. * @param effect The effect we are binding the data to
  8976. * @param useSpecular Defines if specular is supported
  8977. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8978. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8979. */
  8980. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8981. /**
  8982. * Binds the lights information from the scene to the effect for the given mesh.
  8983. * @param scene The scene the lights belongs to
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. * @param defines The generated defines for the effect
  8987. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8988. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8989. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8990. */
  8991. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8992. private static _tempFogColor;
  8993. /**
  8994. * Binds the fog information from the scene to the effect for the given mesh.
  8995. * @param scene The scene the lights belongs to
  8996. * @param mesh The mesh we are binding the information to render
  8997. * @param effect The effect we are binding the data to
  8998. * @param linearSpace Defines if the fog effect is applied in linear space
  8999. */
  9000. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9001. /**
  9002. * Binds the bones information from the mesh to the effect.
  9003. * @param mesh The mesh we are binding the information to render
  9004. * @param effect The effect we are binding the data to
  9005. */
  9006. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9007. /**
  9008. * Binds the morph targets information from the mesh to the effect.
  9009. * @param abstractMesh The mesh we are binding the information to render
  9010. * @param effect The effect we are binding the data to
  9011. */
  9012. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9013. /**
  9014. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9015. * @param defines The generated defines used in the effect
  9016. * @param effect The effect we are binding the data to
  9017. * @param scene The scene we are willing to render with logarithmic scale for
  9018. */
  9019. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9020. /**
  9021. * Binds the clip plane information from the scene to the effect.
  9022. * @param scene The scene the clip plane information are extracted from
  9023. * @param effect The effect we are binding the data to
  9024. */
  9025. static BindClipPlane(effect: Effect, scene: Scene): void;
  9026. }
  9027. }
  9028. declare module BABYLON {
  9029. /** @hidden */
  9030. export var packingFunctions: {
  9031. name: string;
  9032. shader: string;
  9033. };
  9034. }
  9035. declare module BABYLON {
  9036. /** @hidden */
  9037. export var shadowMapPixelShader: {
  9038. name: string;
  9039. shader: string;
  9040. };
  9041. }
  9042. declare module BABYLON {
  9043. /** @hidden */
  9044. export var bonesDeclaration: {
  9045. name: string;
  9046. shader: string;
  9047. };
  9048. }
  9049. declare module BABYLON {
  9050. /** @hidden */
  9051. export var morphTargetsVertexGlobalDeclaration: {
  9052. name: string;
  9053. shader: string;
  9054. };
  9055. }
  9056. declare module BABYLON {
  9057. /** @hidden */
  9058. export var morphTargetsVertexDeclaration: {
  9059. name: string;
  9060. shader: string;
  9061. };
  9062. }
  9063. declare module BABYLON {
  9064. /** @hidden */
  9065. export var instancesDeclaration: {
  9066. name: string;
  9067. shader: string;
  9068. };
  9069. }
  9070. declare module BABYLON {
  9071. /** @hidden */
  9072. export var helperFunctions: {
  9073. name: string;
  9074. shader: string;
  9075. };
  9076. }
  9077. declare module BABYLON {
  9078. /** @hidden */
  9079. export var morphTargetsVertex: {
  9080. name: string;
  9081. shader: string;
  9082. };
  9083. }
  9084. declare module BABYLON {
  9085. /** @hidden */
  9086. export var instancesVertex: {
  9087. name: string;
  9088. shader: string;
  9089. };
  9090. }
  9091. declare module BABYLON {
  9092. /** @hidden */
  9093. export var bonesVertex: {
  9094. name: string;
  9095. shader: string;
  9096. };
  9097. }
  9098. declare module BABYLON {
  9099. /** @hidden */
  9100. export var shadowMapVertexShader: {
  9101. name: string;
  9102. shader: string;
  9103. };
  9104. }
  9105. declare module BABYLON {
  9106. /** @hidden */
  9107. export var depthBoxBlurPixelShader: {
  9108. name: string;
  9109. shader: string;
  9110. };
  9111. }
  9112. declare module BABYLON {
  9113. /**
  9114. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9115. */
  9116. export interface ICustomShaderOptions {
  9117. /**
  9118. * Gets or sets the custom shader name to use
  9119. */
  9120. shaderName: string;
  9121. /**
  9122. * The list of attribute names used in the shader
  9123. */
  9124. attributes?: string[];
  9125. /**
  9126. * The list of unifrom names used in the shader
  9127. */
  9128. uniforms?: string[];
  9129. /**
  9130. * The list of sampler names used in the shader
  9131. */
  9132. samplers?: string[];
  9133. /**
  9134. * The list of defines used in the shader
  9135. */
  9136. defines?: string[];
  9137. }
  9138. /**
  9139. * Interface to implement to create a shadow generator compatible with BJS.
  9140. */
  9141. export interface IShadowGenerator {
  9142. /**
  9143. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9144. * @returns The render target texture if present otherwise, null
  9145. */
  9146. getShadowMap(): Nullable<RenderTargetTexture>;
  9147. /**
  9148. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9149. * @returns The render target texture if the shadow map is present otherwise, null
  9150. */
  9151. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9152. /**
  9153. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9154. * @param subMesh The submesh we want to render in the shadow map
  9155. * @param useInstances Defines wether will draw in the map using instances
  9156. * @returns true if ready otherwise, false
  9157. */
  9158. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9159. /**
  9160. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9161. * @param defines Defines of the material we want to update
  9162. * @param lightIndex Index of the light in the enabled light list of the material
  9163. */
  9164. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9165. /**
  9166. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9167. * defined in the generator but impacting the effect).
  9168. * It implies the unifroms available on the materials are the standard BJS ones.
  9169. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9170. * @param effect The effect we are binfing the information for
  9171. */
  9172. bindShadowLight(lightIndex: string, effect: Effect): void;
  9173. /**
  9174. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9175. * (eq to shadow prjection matrix * light transform matrix)
  9176. * @returns The transform matrix used to create the shadow map
  9177. */
  9178. getTransformMatrix(): Matrix;
  9179. /**
  9180. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9181. * Cube and 2D textures for instance.
  9182. */
  9183. recreateShadowMap(): void;
  9184. /**
  9185. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9186. * @param onCompiled Callback triggered at the and of the effects compilation
  9187. * @param options Sets of optional options forcing the compilation with different modes
  9188. */
  9189. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9190. useInstances: boolean;
  9191. }>): void;
  9192. /**
  9193. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9194. * @param options Sets of optional options forcing the compilation with different modes
  9195. * @returns A promise that resolves when the compilation completes
  9196. */
  9197. forceCompilationAsync(options?: Partial<{
  9198. useInstances: boolean;
  9199. }>): Promise<void>;
  9200. /**
  9201. * Serializes the shadow generator setup to a json object.
  9202. * @returns The serialized JSON object
  9203. */
  9204. serialize(): any;
  9205. /**
  9206. * Disposes the Shadow map and related Textures and effects.
  9207. */
  9208. dispose(): void;
  9209. }
  9210. /**
  9211. * Default implementation IShadowGenerator.
  9212. * This is the main object responsible of generating shadows in the framework.
  9213. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9214. */
  9215. export class ShadowGenerator implements IShadowGenerator {
  9216. /**
  9217. * Shadow generator mode None: no filtering applied.
  9218. */
  9219. static readonly FILTER_NONE: number;
  9220. /**
  9221. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9222. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9223. */
  9224. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9225. /**
  9226. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9227. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9228. */
  9229. static readonly FILTER_POISSONSAMPLING: number;
  9230. /**
  9231. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9233. */
  9234. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9235. /**
  9236. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9237. * edge artifacts on steep falloff.
  9238. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9239. */
  9240. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9241. /**
  9242. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9243. * edge artifacts on steep falloff.
  9244. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9245. */
  9246. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9247. /**
  9248. * Shadow generator mode PCF: Percentage Closer Filtering
  9249. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9250. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9251. */
  9252. static readonly FILTER_PCF: number;
  9253. /**
  9254. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9255. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9256. * Contact Hardening
  9257. */
  9258. static readonly FILTER_PCSS: number;
  9259. /**
  9260. * Reserved for PCF and PCSS
  9261. * Highest Quality.
  9262. *
  9263. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9264. *
  9265. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9266. */
  9267. static readonly QUALITY_HIGH: number;
  9268. /**
  9269. * Reserved for PCF and PCSS
  9270. * Good tradeoff for quality/perf cross devices
  9271. *
  9272. * Execute PCF on a 3*3 kernel.
  9273. *
  9274. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9275. */
  9276. static readonly QUALITY_MEDIUM: number;
  9277. /**
  9278. * Reserved for PCF and PCSS
  9279. * The lowest quality but the fastest.
  9280. *
  9281. * Execute PCF on a 1*1 kernel.
  9282. *
  9283. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9284. */
  9285. static readonly QUALITY_LOW: number;
  9286. /** Gets or sets the custom shader name to use */
  9287. customShaderOptions: ICustomShaderOptions;
  9288. /**
  9289. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9290. */
  9291. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9292. /**
  9293. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9294. */
  9295. onAfterShadowMapRenderObservable: Observable<Effect>;
  9296. /**
  9297. * Observable triggered before a mesh is rendered in the shadow map.
  9298. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9299. */
  9300. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9301. /**
  9302. * Observable triggered after a mesh is rendered in the shadow map.
  9303. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9304. */
  9305. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9306. private _bias;
  9307. /**
  9308. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9309. */
  9310. /**
  9311. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9312. */
  9313. bias: number;
  9314. private _normalBias;
  9315. /**
  9316. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9317. */
  9318. /**
  9319. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9320. */
  9321. normalBias: number;
  9322. private _blurBoxOffset;
  9323. /**
  9324. * Gets the blur box offset: offset applied during the blur pass.
  9325. * Only useful if useKernelBlur = false
  9326. */
  9327. /**
  9328. * Sets the blur box offset: offset applied during the blur pass.
  9329. * Only useful if useKernelBlur = false
  9330. */
  9331. blurBoxOffset: number;
  9332. private _blurScale;
  9333. /**
  9334. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9335. * 2 means half of the size.
  9336. */
  9337. /**
  9338. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9339. * 2 means half of the size.
  9340. */
  9341. blurScale: number;
  9342. private _blurKernel;
  9343. /**
  9344. * Gets the blur kernel: kernel size of the blur pass.
  9345. * Only useful if useKernelBlur = true
  9346. */
  9347. /**
  9348. * Sets the blur kernel: kernel size of the blur pass.
  9349. * Only useful if useKernelBlur = true
  9350. */
  9351. blurKernel: number;
  9352. private _useKernelBlur;
  9353. /**
  9354. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9355. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9356. */
  9357. /**
  9358. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9359. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9360. */
  9361. useKernelBlur: boolean;
  9362. private _depthScale;
  9363. /**
  9364. * Gets the depth scale used in ESM mode.
  9365. */
  9366. /**
  9367. * Sets the depth scale used in ESM mode.
  9368. * This can override the scale stored on the light.
  9369. */
  9370. depthScale: number;
  9371. private _filter;
  9372. /**
  9373. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9374. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9375. */
  9376. /**
  9377. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9378. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9379. */
  9380. filter: number;
  9381. /**
  9382. * Gets if the current filter is set to Poisson Sampling.
  9383. */
  9384. /**
  9385. * Sets the current filter to Poisson Sampling.
  9386. */
  9387. usePoissonSampling: boolean;
  9388. /**
  9389. * Gets if the current filter is set to ESM.
  9390. */
  9391. /**
  9392. * Sets the current filter is to ESM.
  9393. */
  9394. useExponentialShadowMap: boolean;
  9395. /**
  9396. * Gets if the current filter is set to filtered ESM.
  9397. */
  9398. /**
  9399. * Gets if the current filter is set to filtered ESM.
  9400. */
  9401. useBlurExponentialShadowMap: boolean;
  9402. /**
  9403. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9404. * exponential to prevent steep falloff artifacts).
  9405. */
  9406. /**
  9407. * Sets the current filter to "close ESM" (using the inverse of the
  9408. * exponential to prevent steep falloff artifacts).
  9409. */
  9410. useCloseExponentialShadowMap: boolean;
  9411. /**
  9412. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9413. * exponential to prevent steep falloff artifacts).
  9414. */
  9415. /**
  9416. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9417. * exponential to prevent steep falloff artifacts).
  9418. */
  9419. useBlurCloseExponentialShadowMap: boolean;
  9420. /**
  9421. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9422. */
  9423. /**
  9424. * Sets the current filter to "PCF" (percentage closer filtering).
  9425. */
  9426. usePercentageCloserFiltering: boolean;
  9427. private _filteringQuality;
  9428. /**
  9429. * Gets the PCF or PCSS Quality.
  9430. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9431. */
  9432. /**
  9433. * Sets the PCF or PCSS Quality.
  9434. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9435. */
  9436. filteringQuality: number;
  9437. /**
  9438. * Gets if the current filter is set to "PCSS" (contact hardening).
  9439. */
  9440. /**
  9441. * Sets the current filter to "PCSS" (contact hardening).
  9442. */
  9443. useContactHardeningShadow: boolean;
  9444. private _contactHardeningLightSizeUVRatio;
  9445. /**
  9446. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9447. * Using a ratio helps keeping shape stability independently of the map size.
  9448. *
  9449. * It does not account for the light projection as it was having too much
  9450. * instability during the light setup or during light position changes.
  9451. *
  9452. * Only valid if useContactHardeningShadow is true.
  9453. */
  9454. /**
  9455. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9456. * Using a ratio helps keeping shape stability independently of the map size.
  9457. *
  9458. * It does not account for the light projection as it was having too much
  9459. * instability during the light setup or during light position changes.
  9460. *
  9461. * Only valid if useContactHardeningShadow is true.
  9462. */
  9463. contactHardeningLightSizeUVRatio: number;
  9464. private _darkness;
  9465. /** Gets or sets the actual darkness of a shadow */
  9466. darkness: number;
  9467. /**
  9468. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9469. * 0 means strongest and 1 would means no shadow.
  9470. * @returns the darkness.
  9471. */
  9472. getDarkness(): number;
  9473. /**
  9474. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9475. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9476. * @returns the shadow generator allowing fluent coding.
  9477. */
  9478. setDarkness(darkness: number): ShadowGenerator;
  9479. private _transparencyShadow;
  9480. /** Gets or sets the ability to have transparent shadow */
  9481. transparencyShadow: boolean;
  9482. /**
  9483. * Sets the ability to have transparent shadow (boolean).
  9484. * @param transparent True if transparent else False
  9485. * @returns the shadow generator allowing fluent coding
  9486. */
  9487. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9488. private _shadowMap;
  9489. private _shadowMap2;
  9490. /**
  9491. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9492. * @returns The render target texture if present otherwise, null
  9493. */
  9494. getShadowMap(): Nullable<RenderTargetTexture>;
  9495. /**
  9496. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9497. * @returns The render target texture if the shadow map is present otherwise, null
  9498. */
  9499. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9500. /**
  9501. * Gets the class name of that object
  9502. * @returns "ShadowGenerator"
  9503. */
  9504. getClassName(): string;
  9505. /**
  9506. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9507. * @param mesh Mesh to add
  9508. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9509. * @returns the Shadow Generator itself
  9510. */
  9511. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9512. /**
  9513. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9514. * @param mesh Mesh to remove
  9515. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9516. * @returns the Shadow Generator itself
  9517. */
  9518. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9519. /**
  9520. * Controls the extent to which the shadows fade out at the edge of the frustum
  9521. * Used only by directionals and spots
  9522. */
  9523. frustumEdgeFalloff: number;
  9524. private _light;
  9525. /**
  9526. * Returns the associated light object.
  9527. * @returns the light generating the shadow
  9528. */
  9529. getLight(): IShadowLight;
  9530. /**
  9531. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9532. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9533. * It might on the other hand introduce peter panning.
  9534. */
  9535. forceBackFacesOnly: boolean;
  9536. private _scene;
  9537. private _lightDirection;
  9538. private _effect;
  9539. private _viewMatrix;
  9540. private _projectionMatrix;
  9541. private _transformMatrix;
  9542. private _cachedPosition;
  9543. private _cachedDirection;
  9544. private _cachedDefines;
  9545. private _currentRenderID;
  9546. private _boxBlurPostprocess;
  9547. private _kernelBlurXPostprocess;
  9548. private _kernelBlurYPostprocess;
  9549. private _blurPostProcesses;
  9550. private _mapSize;
  9551. private _currentFaceIndex;
  9552. private _currentFaceIndexCache;
  9553. private _textureType;
  9554. private _defaultTextureMatrix;
  9555. private _storedUniqueId;
  9556. /** @hidden */
  9557. static _SceneComponentInitialization: (scene: Scene) => void;
  9558. /**
  9559. * Creates a ShadowGenerator object.
  9560. * A ShadowGenerator is the required tool to use the shadows.
  9561. * Each light casting shadows needs to use its own ShadowGenerator.
  9562. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9563. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9564. * @param light The light object generating the shadows.
  9565. * @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.
  9566. */
  9567. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9568. private _initializeGenerator;
  9569. private _initializeShadowMap;
  9570. private _initializeBlurRTTAndPostProcesses;
  9571. private _renderForShadowMap;
  9572. private _renderSubMeshForShadowMap;
  9573. private _applyFilterValues;
  9574. /**
  9575. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9576. * @param onCompiled Callback triggered at the and of the effects compilation
  9577. * @param options Sets of optional options forcing the compilation with different modes
  9578. */
  9579. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9580. useInstances: boolean;
  9581. }>): void;
  9582. /**
  9583. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9584. * @param options Sets of optional options forcing the compilation with different modes
  9585. * @returns A promise that resolves when the compilation completes
  9586. */
  9587. forceCompilationAsync(options?: Partial<{
  9588. useInstances: boolean;
  9589. }>): Promise<void>;
  9590. /**
  9591. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9592. * @param subMesh The submesh we want to render in the shadow map
  9593. * @param useInstances Defines wether will draw in the map using instances
  9594. * @returns true if ready otherwise, false
  9595. */
  9596. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9597. /**
  9598. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9599. * @param defines Defines of the material we want to update
  9600. * @param lightIndex Index of the light in the enabled light list of the material
  9601. */
  9602. prepareDefines(defines: any, lightIndex: number): void;
  9603. /**
  9604. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9605. * defined in the generator but impacting the effect).
  9606. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9607. * @param effect The effect we are binfing the information for
  9608. */
  9609. bindShadowLight(lightIndex: string, effect: Effect): void;
  9610. /**
  9611. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9612. * (eq to shadow prjection matrix * light transform matrix)
  9613. * @returns The transform matrix used to create the shadow map
  9614. */
  9615. getTransformMatrix(): Matrix;
  9616. /**
  9617. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9618. * Cube and 2D textures for instance.
  9619. */
  9620. recreateShadowMap(): void;
  9621. private _disposeBlurPostProcesses;
  9622. private _disposeRTTandPostProcesses;
  9623. /**
  9624. * Disposes the ShadowGenerator.
  9625. * Returns nothing.
  9626. */
  9627. dispose(): void;
  9628. /**
  9629. * Serializes the shadow generator setup to a json object.
  9630. * @returns The serialized JSON object
  9631. */
  9632. serialize(): any;
  9633. /**
  9634. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9635. * @param parsedShadowGenerator The JSON object to parse
  9636. * @param scene The scene to create the shadow map for
  9637. * @returns The parsed shadow generator
  9638. */
  9639. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9640. }
  9641. }
  9642. declare module BABYLON {
  9643. /**
  9644. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9645. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9646. * 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.
  9647. */
  9648. export abstract class Light extends Node {
  9649. /**
  9650. * Falloff Default: light is falling off following the material specification:
  9651. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9652. */
  9653. static readonly FALLOFF_DEFAULT: number;
  9654. /**
  9655. * Falloff Physical: light is falling off following the inverse squared distance law.
  9656. */
  9657. static readonly FALLOFF_PHYSICAL: number;
  9658. /**
  9659. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9660. * to enhance interoperability with other engines.
  9661. */
  9662. static readonly FALLOFF_GLTF: number;
  9663. /**
  9664. * Falloff Standard: light is falling off like in the standard material
  9665. * to enhance interoperability with other materials.
  9666. */
  9667. static readonly FALLOFF_STANDARD: number;
  9668. /**
  9669. * If every light affecting the material is in this lightmapMode,
  9670. * material.lightmapTexture adds or multiplies
  9671. * (depends on material.useLightmapAsShadowmap)
  9672. * after every other light calculations.
  9673. */
  9674. static readonly LIGHTMAP_DEFAULT: number;
  9675. /**
  9676. * material.lightmapTexture as only diffuse lighting from this light
  9677. * adds only specular lighting from this light
  9678. * adds dynamic shadows
  9679. */
  9680. static readonly LIGHTMAP_SPECULAR: number;
  9681. /**
  9682. * material.lightmapTexture as only lighting
  9683. * no light calculation from this light
  9684. * only adds dynamic shadows from this light
  9685. */
  9686. static readonly LIGHTMAP_SHADOWSONLY: number;
  9687. /**
  9688. * Each light type uses the default quantity according to its type:
  9689. * point/spot lights use luminous intensity
  9690. * directional lights use illuminance
  9691. */
  9692. static readonly INTENSITYMODE_AUTOMATIC: number;
  9693. /**
  9694. * lumen (lm)
  9695. */
  9696. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9697. /**
  9698. * candela (lm/sr)
  9699. */
  9700. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9701. /**
  9702. * lux (lm/m^2)
  9703. */
  9704. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9705. /**
  9706. * nit (cd/m^2)
  9707. */
  9708. static readonly INTENSITYMODE_LUMINANCE: number;
  9709. /**
  9710. * Light type const id of the point light.
  9711. */
  9712. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9713. /**
  9714. * Light type const id of the directional light.
  9715. */
  9716. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9717. /**
  9718. * Light type const id of the spot light.
  9719. */
  9720. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9721. /**
  9722. * Light type const id of the hemispheric light.
  9723. */
  9724. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9725. /**
  9726. * Diffuse gives the basic color to an object.
  9727. */
  9728. diffuse: Color3;
  9729. /**
  9730. * Specular produces a highlight color on an object.
  9731. * Note: This is note affecting PBR materials.
  9732. */
  9733. specular: Color3;
  9734. /**
  9735. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9736. * falling off base on range or angle.
  9737. * This can be set to any values in Light.FALLOFF_x.
  9738. *
  9739. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9740. * other types of materials.
  9741. */
  9742. falloffType: number;
  9743. /**
  9744. * Strength of the light.
  9745. * Note: By default it is define in the framework own unit.
  9746. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9747. */
  9748. intensity: number;
  9749. private _range;
  9750. protected _inverseSquaredRange: number;
  9751. /**
  9752. * Defines how far from the source the light is impacting in scene units.
  9753. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9754. */
  9755. /**
  9756. * Defines how far from the source the light is impacting in scene units.
  9757. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9758. */
  9759. range: number;
  9760. /**
  9761. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9762. * of light.
  9763. */
  9764. private _photometricScale;
  9765. private _intensityMode;
  9766. /**
  9767. * Gets the photometric scale used to interpret the intensity.
  9768. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9769. */
  9770. /**
  9771. * Sets the photometric scale used to interpret the intensity.
  9772. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9773. */
  9774. intensityMode: number;
  9775. private _radius;
  9776. /**
  9777. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9778. */
  9779. /**
  9780. * sets the light radius used by PBR Materials to simulate soft area lights.
  9781. */
  9782. radius: number;
  9783. private _renderPriority;
  9784. /**
  9785. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9786. * exceeding the number allowed of the materials.
  9787. */
  9788. renderPriority: number;
  9789. private _shadowEnabled;
  9790. /**
  9791. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9792. * the current shadow generator.
  9793. */
  9794. /**
  9795. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9796. * the current shadow generator.
  9797. */
  9798. shadowEnabled: boolean;
  9799. private _includedOnlyMeshes;
  9800. /**
  9801. * Gets the only meshes impacted by this light.
  9802. */
  9803. /**
  9804. * Sets the only meshes impacted by this light.
  9805. */
  9806. includedOnlyMeshes: AbstractMesh[];
  9807. private _excludedMeshes;
  9808. /**
  9809. * Gets the meshes not impacted by this light.
  9810. */
  9811. /**
  9812. * Sets the meshes not impacted by this light.
  9813. */
  9814. excludedMeshes: AbstractMesh[];
  9815. private _excludeWithLayerMask;
  9816. /**
  9817. * Gets the layer id use to find what meshes are not impacted by the light.
  9818. * Inactive if 0
  9819. */
  9820. /**
  9821. * Sets the layer id use to find what meshes are not impacted by the light.
  9822. * Inactive if 0
  9823. */
  9824. excludeWithLayerMask: number;
  9825. private _includeOnlyWithLayerMask;
  9826. /**
  9827. * Gets the layer id use to find what meshes are impacted by the light.
  9828. * Inactive if 0
  9829. */
  9830. /**
  9831. * Sets the layer id use to find what meshes are impacted by the light.
  9832. * Inactive if 0
  9833. */
  9834. includeOnlyWithLayerMask: number;
  9835. private _lightmapMode;
  9836. /**
  9837. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9838. */
  9839. /**
  9840. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9841. */
  9842. lightmapMode: number;
  9843. /**
  9844. * Shadow generator associted to the light.
  9845. * @hidden Internal use only.
  9846. */
  9847. _shadowGenerator: Nullable<IShadowGenerator>;
  9848. /**
  9849. * @hidden Internal use only.
  9850. */
  9851. _excludedMeshesIds: string[];
  9852. /**
  9853. * @hidden Internal use only.
  9854. */
  9855. _includedOnlyMeshesIds: string[];
  9856. /**
  9857. * The current light unifom buffer.
  9858. * @hidden Internal use only.
  9859. */
  9860. _uniformBuffer: UniformBuffer;
  9861. /** @hidden */
  9862. _renderId: number;
  9863. /**
  9864. * Creates a Light object in the scene.
  9865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9866. * @param name The firendly name of the light
  9867. * @param scene The scene the light belongs too
  9868. */
  9869. constructor(name: string, scene: Scene);
  9870. protected abstract _buildUniformLayout(): void;
  9871. /**
  9872. * Sets the passed Effect "effect" with the Light information.
  9873. * @param effect The effect to update
  9874. * @param lightIndex The index of the light in the effect to update
  9875. * @returns The light
  9876. */
  9877. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9878. /**
  9879. * Sets the passed Effect "effect" with the Light information.
  9880. * @param effect The effect to update
  9881. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9882. * @returns The light
  9883. */
  9884. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9885. /**
  9886. * Returns the string "Light".
  9887. * @returns the class name
  9888. */
  9889. getClassName(): string;
  9890. /** @hidden */
  9891. readonly _isLight: boolean;
  9892. /**
  9893. * Converts the light information to a readable string for debug purpose.
  9894. * @param fullDetails Supports for multiple levels of logging within scene loading
  9895. * @returns the human readable light info
  9896. */
  9897. toString(fullDetails?: boolean): string;
  9898. /** @hidden */
  9899. protected _syncParentEnabledState(): void;
  9900. /**
  9901. * Set the enabled state of this node.
  9902. * @param value - the new enabled state
  9903. */
  9904. setEnabled(value: boolean): void;
  9905. /**
  9906. * Returns the Light associated shadow generator if any.
  9907. * @return the associated shadow generator.
  9908. */
  9909. getShadowGenerator(): Nullable<IShadowGenerator>;
  9910. /**
  9911. * Returns a Vector3, the absolute light position in the World.
  9912. * @returns the world space position of the light
  9913. */
  9914. getAbsolutePosition(): Vector3;
  9915. /**
  9916. * Specifies if the light will affect the passed mesh.
  9917. * @param mesh The mesh to test against the light
  9918. * @return true the mesh is affected otherwise, false.
  9919. */
  9920. canAffectMesh(mesh: AbstractMesh): boolean;
  9921. /**
  9922. * Sort function to order lights for rendering.
  9923. * @param a First Light object to compare to second.
  9924. * @param b Second Light object to compare first.
  9925. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9926. */
  9927. static CompareLightsPriority(a: Light, b: Light): number;
  9928. /**
  9929. * Releases resources associated with this node.
  9930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9932. */
  9933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9934. /**
  9935. * Returns the light type ID (integer).
  9936. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9937. */
  9938. getTypeID(): number;
  9939. /**
  9940. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9941. * @returns the scaled intensity in intensity mode unit
  9942. */
  9943. getScaledIntensity(): number;
  9944. /**
  9945. * Returns a new Light object, named "name", from the current one.
  9946. * @param name The name of the cloned light
  9947. * @returns the new created light
  9948. */
  9949. clone(name: string): Nullable<Light>;
  9950. /**
  9951. * Serializes the current light into a Serialization object.
  9952. * @returns the serialized object.
  9953. */
  9954. serialize(): any;
  9955. /**
  9956. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9957. * This new light is named "name" and added to the passed scene.
  9958. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9959. * @param name The friendly name of the light
  9960. * @param scene The scene the new light will belong to
  9961. * @returns the constructor function
  9962. */
  9963. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9964. /**
  9965. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9966. * @param parsedLight The JSON representation of the light
  9967. * @param scene The scene to create the parsed light in
  9968. * @returns the created light after parsing
  9969. */
  9970. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9971. private _hookArrayForExcluded;
  9972. private _hookArrayForIncludedOnly;
  9973. private _resyncMeshes;
  9974. /**
  9975. * Forces the meshes to update their light related information in their rendering used effects
  9976. * @hidden Internal Use Only
  9977. */
  9978. _markMeshesAsLightDirty(): void;
  9979. /**
  9980. * Recomputes the cached photometric scale if needed.
  9981. */
  9982. private _computePhotometricScale;
  9983. /**
  9984. * Returns the Photometric Scale according to the light type and intensity mode.
  9985. */
  9986. private _getPhotometricScale;
  9987. /**
  9988. * Reorder the light in the scene according to their defined priority.
  9989. * @hidden Internal Use Only
  9990. */
  9991. _reorderLightsInScene(): void;
  9992. /**
  9993. * Prepares the list of defines specific to the light type.
  9994. * @param defines the list of defines
  9995. * @param lightIndex defines the index of the light for the effect
  9996. */
  9997. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9998. }
  9999. }
  10000. declare module BABYLON {
  10001. /**
  10002. * Interface used to define Action
  10003. */
  10004. export interface IAction {
  10005. /**
  10006. * Trigger for the action
  10007. */
  10008. trigger: number;
  10009. /** Options of the trigger */
  10010. triggerOptions: any;
  10011. /**
  10012. * Gets the trigger parameters
  10013. * @returns the trigger parameters
  10014. */
  10015. getTriggerParameter(): any;
  10016. /**
  10017. * Internal only - executes current action event
  10018. * @hidden
  10019. */
  10020. _executeCurrent(evt?: ActionEvent): void;
  10021. /**
  10022. * Serialize placeholder for child classes
  10023. * @param parent of child
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. /**
  10028. * Internal only
  10029. * @hidden
  10030. */
  10031. _prepare(): void;
  10032. /**
  10033. * Internal only - manager for action
  10034. * @hidden
  10035. */
  10036. _actionManager: AbstractActionManager;
  10037. /**
  10038. * Adds action to chain of actions, may be a DoNothingAction
  10039. * @param action defines the next action to execute
  10040. * @returns The action passed in
  10041. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10042. */
  10043. then(action: IAction): IAction;
  10044. }
  10045. /**
  10046. * The action to be carried out following a trigger
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10048. */
  10049. export class Action implements IAction {
  10050. /** the trigger, with or without parameters, for the action */
  10051. triggerOptions: any;
  10052. /**
  10053. * Trigger for the action
  10054. */
  10055. trigger: number;
  10056. /**
  10057. * Internal only - manager for action
  10058. * @hidden
  10059. */
  10060. _actionManager: ActionManager;
  10061. private _nextActiveAction;
  10062. private _child;
  10063. private _condition?;
  10064. private _triggerParameter;
  10065. /**
  10066. * An event triggered prior to action being executed.
  10067. */
  10068. onBeforeExecuteObservable: Observable<Action>;
  10069. /**
  10070. * Creates a new Action
  10071. * @param triggerOptions the trigger, with or without parameters, for the action
  10072. * @param condition an optional determinant of action
  10073. */
  10074. constructor(
  10075. /** the trigger, with or without parameters, for the action */
  10076. triggerOptions: any, condition?: Condition);
  10077. /**
  10078. * Internal only
  10079. * @hidden
  10080. */
  10081. _prepare(): void;
  10082. /**
  10083. * Gets the trigger parameters
  10084. * @returns the trigger parameters
  10085. */
  10086. getTriggerParameter(): any;
  10087. /**
  10088. * Internal only - executes current action event
  10089. * @hidden
  10090. */
  10091. _executeCurrent(evt?: ActionEvent): void;
  10092. /**
  10093. * Execute placeholder for child classes
  10094. * @param evt optional action event
  10095. */
  10096. execute(evt?: ActionEvent): void;
  10097. /**
  10098. * Skips to next active action
  10099. */
  10100. skipToNextActiveAction(): void;
  10101. /**
  10102. * Adds action to chain of actions, may be a DoNothingAction
  10103. * @param action defines the next action to execute
  10104. * @returns The action passed in
  10105. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10106. */
  10107. then(action: Action): Action;
  10108. /**
  10109. * Internal only
  10110. * @hidden
  10111. */
  10112. _getProperty(propertyPath: string): string;
  10113. /**
  10114. * Internal only
  10115. * @hidden
  10116. */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /**
  10119. * Serialize placeholder for child classes
  10120. * @param parent of child
  10121. * @returns the serialized object
  10122. */
  10123. serialize(parent: any): any;
  10124. /**
  10125. * Internal only called by serialize
  10126. * @hidden
  10127. */
  10128. protected _serialize(serializedAction: any, parent?: any): any;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. static _SerializeValueAsString: (value: any) => string;
  10134. /**
  10135. * Internal only
  10136. * @hidden
  10137. */
  10138. static _GetTargetProperty: (target: Node | Scene) => {
  10139. name: string;
  10140. targetType: string;
  10141. value: string;
  10142. };
  10143. }
  10144. }
  10145. declare module BABYLON {
  10146. /**
  10147. * A Condition applied to an Action
  10148. */
  10149. export class Condition {
  10150. /**
  10151. * Internal only - manager for action
  10152. * @hidden
  10153. */
  10154. _actionManager: ActionManager;
  10155. /**
  10156. * Internal only
  10157. * @hidden
  10158. */
  10159. _evaluationId: number;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _currentResult: boolean;
  10165. /**
  10166. * Creates a new Condition
  10167. * @param actionManager the manager of the action the condition is applied to
  10168. */
  10169. constructor(actionManager: ActionManager);
  10170. /**
  10171. * Check if the current condition is valid
  10172. * @returns a boolean
  10173. */
  10174. isValid(): boolean;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. _getProperty(propertyPath: string): string;
  10180. /**
  10181. * Internal only
  10182. * @hidden
  10183. */
  10184. _getEffectiveTarget(target: any, propertyPath: string): any;
  10185. /**
  10186. * Serialize placeholder for child classes
  10187. * @returns the serialized object
  10188. */
  10189. serialize(): any;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. protected _serialize(serializedCondition: any): any;
  10195. }
  10196. /**
  10197. * Defines specific conditional operators as extensions of Condition
  10198. */
  10199. export class ValueCondition extends Condition {
  10200. /** path to specify the property of the target the conditional operator uses */
  10201. propertyPath: string;
  10202. /** the value compared by the conditional operator against the current value of the property */
  10203. value: any;
  10204. /** the conditional operator, default ValueCondition.IsEqual */
  10205. operator: number;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsEqual;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. private static _IsDifferent;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. private static _IsGreater;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. private static _IsLesser;
  10226. /**
  10227. * returns the number for IsEqual
  10228. */
  10229. static readonly IsEqual: number;
  10230. /**
  10231. * Returns the number for IsDifferent
  10232. */
  10233. static readonly IsDifferent: number;
  10234. /**
  10235. * Returns the number for IsGreater
  10236. */
  10237. static readonly IsGreater: number;
  10238. /**
  10239. * Returns the number for IsLesser
  10240. */
  10241. static readonly IsLesser: number;
  10242. /**
  10243. * Internal only The action manager for the condition
  10244. * @hidden
  10245. */
  10246. _actionManager: ActionManager;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. private _target;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. private _effectiveTarget;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. private _property;
  10262. /**
  10263. * Creates a new ValueCondition
  10264. * @param actionManager manager for the action the condition applies to
  10265. * @param target for the action
  10266. * @param propertyPath path to specify the property of the target the conditional operator uses
  10267. * @param value the value compared by the conditional operator against the current value of the property
  10268. * @param operator the conditional operator, default ValueCondition.IsEqual
  10269. */
  10270. constructor(actionManager: ActionManager, target: any,
  10271. /** path to specify the property of the target the conditional operator uses */
  10272. propertyPath: string,
  10273. /** the value compared by the conditional operator against the current value of the property */
  10274. value: any,
  10275. /** the conditional operator, default ValueCondition.IsEqual */
  10276. operator?: number);
  10277. /**
  10278. * Compares the given value with the property value for the specified conditional operator
  10279. * @returns the result of the comparison
  10280. */
  10281. isValid(): boolean;
  10282. /**
  10283. * Serialize the ValueCondition into a JSON compatible object
  10284. * @returns serialization object
  10285. */
  10286. serialize(): any;
  10287. /**
  10288. * Gets the name of the conditional operator for the ValueCondition
  10289. * @param operator the conditional operator
  10290. * @returns the name
  10291. */
  10292. static GetOperatorName(operator: number): string;
  10293. }
  10294. /**
  10295. * Defines a predicate condition as an extension of Condition
  10296. */
  10297. export class PredicateCondition extends Condition {
  10298. /** defines the predicate function used to validate the condition */
  10299. predicate: () => boolean;
  10300. /**
  10301. * Internal only - manager for action
  10302. * @hidden
  10303. */
  10304. _actionManager: ActionManager;
  10305. /**
  10306. * Creates a new PredicateCondition
  10307. * @param actionManager manager for the action the condition applies to
  10308. * @param predicate defines the predicate function used to validate the condition
  10309. */
  10310. constructor(actionManager: ActionManager,
  10311. /** defines the predicate function used to validate the condition */
  10312. predicate: () => boolean);
  10313. /**
  10314. * @returns the validity of the predicate condition
  10315. */
  10316. isValid(): boolean;
  10317. }
  10318. /**
  10319. * Defines a state condition as an extension of Condition
  10320. */
  10321. export class StateCondition extends Condition {
  10322. /** Value to compare with target state */
  10323. value: string;
  10324. /**
  10325. * Internal only - manager for action
  10326. * @hidden
  10327. */
  10328. _actionManager: ActionManager;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _target;
  10334. /**
  10335. * Creates a new StateCondition
  10336. * @param actionManager manager for the action the condition applies to
  10337. * @param target of the condition
  10338. * @param value to compare with target state
  10339. */
  10340. constructor(actionManager: ActionManager, target: any,
  10341. /** Value to compare with target state */
  10342. value: string);
  10343. /**
  10344. * Gets a boolean indicating if the current condition is met
  10345. * @returns the validity of the state
  10346. */
  10347. isValid(): boolean;
  10348. /**
  10349. * Serialize the StateCondition into a JSON compatible object
  10350. * @returns serialization object
  10351. */
  10352. serialize(): any;
  10353. }
  10354. }
  10355. declare module BABYLON {
  10356. /**
  10357. * This defines an action responsible to toggle a boolean once triggered.
  10358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10359. */
  10360. export class SwitchBooleanAction extends Action {
  10361. /**
  10362. * The path to the boolean property in the target object
  10363. */
  10364. propertyPath: string;
  10365. private _target;
  10366. private _effectiveTarget;
  10367. private _property;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the boolean
  10372. * @param propertyPath defines the path to the boolean property in the target object
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10376. /** @hidden */
  10377. _prepare(): void;
  10378. /**
  10379. * Execute the action toggle the boolean value.
  10380. */
  10381. execute(): void;
  10382. /**
  10383. * Serializes the actions and its related information.
  10384. * @param parent defines the object to serialize in
  10385. * @returns the serialized object
  10386. */
  10387. serialize(parent: any): any;
  10388. }
  10389. /**
  10390. * This defines an action responsible to set a the state field of the target
  10391. * to a desired value once triggered.
  10392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10393. */
  10394. export class SetStateAction extends Action {
  10395. /**
  10396. * The value to store in the state field.
  10397. */
  10398. value: string;
  10399. private _target;
  10400. /**
  10401. * Instantiate the action
  10402. * @param triggerOptions defines the trigger options
  10403. * @param target defines the object containing the state property
  10404. * @param value defines the value to store in the state field
  10405. * @param condition defines the trigger related conditions
  10406. */
  10407. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10408. /**
  10409. * Execute the action and store the value on the target state property.
  10410. */
  10411. execute(): void;
  10412. /**
  10413. * Serializes the actions and its related information.
  10414. * @param parent defines the object to serialize in
  10415. * @returns the serialized object
  10416. */
  10417. serialize(parent: any): any;
  10418. }
  10419. /**
  10420. * This defines an action responsible to set a property of the target
  10421. * to a desired value once triggered.
  10422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10423. */
  10424. export class SetValueAction extends Action {
  10425. /**
  10426. * The path of the property to set in the target.
  10427. */
  10428. propertyPath: string;
  10429. /**
  10430. * The value to set in the property
  10431. */
  10432. value: any;
  10433. private _target;
  10434. private _effectiveTarget;
  10435. private _property;
  10436. /**
  10437. * Instantiate the action
  10438. * @param triggerOptions defines the trigger options
  10439. * @param target defines the object containing the property
  10440. * @param propertyPath defines the path of the property to set in the target
  10441. * @param value defines the value to set in the property
  10442. * @param condition defines the trigger related conditions
  10443. */
  10444. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10445. /** @hidden */
  10446. _prepare(): void;
  10447. /**
  10448. * Execute the action and set the targetted property to the desired value.
  10449. */
  10450. execute(): void;
  10451. /**
  10452. * Serializes the actions and its related information.
  10453. * @param parent defines the object to serialize in
  10454. * @returns the serialized object
  10455. */
  10456. serialize(parent: any): any;
  10457. }
  10458. /**
  10459. * This defines an action responsible to increment the target value
  10460. * to a desired value once triggered.
  10461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10462. */
  10463. export class IncrementValueAction extends Action {
  10464. /**
  10465. * The path of the property to increment in the target.
  10466. */
  10467. propertyPath: string;
  10468. /**
  10469. * The value we should increment the property by.
  10470. */
  10471. value: any;
  10472. private _target;
  10473. private _effectiveTarget;
  10474. private _property;
  10475. /**
  10476. * Instantiate the action
  10477. * @param triggerOptions defines the trigger options
  10478. * @param target defines the object containing the property
  10479. * @param propertyPath defines the path of the property to increment in the target
  10480. * @param value defines the value value we should increment the property by
  10481. * @param condition defines the trigger related conditions
  10482. */
  10483. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10484. /** @hidden */
  10485. _prepare(): void;
  10486. /**
  10487. * Execute the action and increment the target of the value amount.
  10488. */
  10489. execute(): void;
  10490. /**
  10491. * Serializes the actions and its related information.
  10492. * @param parent defines the object to serialize in
  10493. * @returns the serialized object
  10494. */
  10495. serialize(parent: any): any;
  10496. }
  10497. /**
  10498. * This defines an action responsible to start an animation once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class PlayAnimationAction extends Action {
  10502. /**
  10503. * Where the animation should start (animation frame)
  10504. */
  10505. from: number;
  10506. /**
  10507. * Where the animation should stop (animation frame)
  10508. */
  10509. to: number;
  10510. /**
  10511. * Define if the animation should loop or stop after the first play.
  10512. */
  10513. loop?: boolean;
  10514. private _target;
  10515. /**
  10516. * Instantiate the action
  10517. * @param triggerOptions defines the trigger options
  10518. * @param target defines the target animation or animation name
  10519. * @param from defines from where the animation should start (animation frame)
  10520. * @param end defines where the animation should stop (animation frame)
  10521. * @param loop defines if the animation should loop or stop after the first play
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10525. /** @hidden */
  10526. _prepare(): void;
  10527. /**
  10528. * Execute the action and play the animation.
  10529. */
  10530. execute(): void;
  10531. /**
  10532. * Serializes the actions and its related information.
  10533. * @param parent defines the object to serialize in
  10534. * @returns the serialized object
  10535. */
  10536. serialize(parent: any): any;
  10537. }
  10538. /**
  10539. * This defines an action responsible to stop an animation once triggered.
  10540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10541. */
  10542. export class StopAnimationAction extends Action {
  10543. private _target;
  10544. /**
  10545. * Instantiate the action
  10546. * @param triggerOptions defines the trigger options
  10547. * @param target defines the target animation or animation name
  10548. * @param condition defines the trigger related conditions
  10549. */
  10550. constructor(triggerOptions: any, target: any, condition?: Condition);
  10551. /** @hidden */
  10552. _prepare(): void;
  10553. /**
  10554. * Execute the action and stop the animation.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible that does nothing once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class DoNothingAction extends Action {
  10569. /**
  10570. * Instantiate the action
  10571. * @param triggerOptions defines the trigger options
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions?: any, condition?: Condition);
  10575. /**
  10576. * Execute the action and do nothing.
  10577. */
  10578. execute(): void;
  10579. /**
  10580. * Serializes the actions and its related information.
  10581. * @param parent defines the object to serialize in
  10582. * @returns the serialized object
  10583. */
  10584. serialize(parent: any): any;
  10585. }
  10586. /**
  10587. * This defines an action responsible to trigger several actions once triggered.
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10589. */
  10590. export class CombineAction extends Action {
  10591. /**
  10592. * The list of aggregated animations to run.
  10593. */
  10594. children: Action[];
  10595. /**
  10596. * Instantiate the action
  10597. * @param triggerOptions defines the trigger options
  10598. * @param children defines the list of aggregated animations to run
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and executes all the aggregated actions.
  10606. */
  10607. execute(evt: ActionEvent): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to run code (external event) once triggered.
  10617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class ExecuteCodeAction extends Action {
  10620. /**
  10621. * The callback function to run.
  10622. */
  10623. func: (evt: ActionEvent) => void;
  10624. /**
  10625. * Instantiate the action
  10626. * @param triggerOptions defines the trigger options
  10627. * @param func defines the callback function to run
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10631. /**
  10632. * Execute the action and run the attached code.
  10633. */
  10634. execute(evt: ActionEvent): void;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set the parent property of the target once triggered.
  10638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class SetParentAction extends Action {
  10641. private _parent;
  10642. private _target;
  10643. /**
  10644. * Instantiate the action
  10645. * @param triggerOptions defines the trigger options
  10646. * @param target defines the target containing the parent property
  10647. * @param parent defines from where the animation should start (animation frame)
  10648. * @param condition defines the trigger related conditions
  10649. */
  10650. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10651. /** @hidden */
  10652. _prepare(): void;
  10653. /**
  10654. * Execute the action and set the parent property.
  10655. */
  10656. execute(): void;
  10657. /**
  10658. * Serializes the actions and its related information.
  10659. * @param parent defines the object to serialize in
  10660. * @returns the serialized object
  10661. */
  10662. serialize(parent: any): any;
  10663. }
  10664. }
  10665. declare module BABYLON {
  10666. /**
  10667. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10668. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class ActionManager extends AbstractActionManager {
  10672. /**
  10673. * Nothing
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly NothingTrigger: number;
  10677. /**
  10678. * On pick
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnPickTrigger: number;
  10682. /**
  10683. * On left pick
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnLeftPickTrigger: number;
  10687. /**
  10688. * On right pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnRightPickTrigger: number;
  10692. /**
  10693. * On center pick
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnCenterPickTrigger: number;
  10697. /**
  10698. * On pick down
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10700. */
  10701. static readonly OnPickDownTrigger: number;
  10702. /**
  10703. * On double pick
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly OnDoublePickTrigger: number;
  10707. /**
  10708. * On pick up
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnPickUpTrigger: number;
  10712. /**
  10713. * On pick out.
  10714. * This trigger will only be raised if you also declared a OnPickDown
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPickOutTrigger: number;
  10718. /**
  10719. * On long press
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnLongPressTrigger: number;
  10723. /**
  10724. * On pointer over
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnPointerOverTrigger: number;
  10728. /**
  10729. * On pointer out
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnPointerOutTrigger: number;
  10733. /**
  10734. * On every frame
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnEveryFrameTrigger: number;
  10738. /**
  10739. * On intersection enter
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnIntersectionEnterTrigger: number;
  10743. /**
  10744. * On intersection exit
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnIntersectionExitTrigger: number;
  10748. /**
  10749. * On key down
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnKeyDownTrigger: number;
  10753. /**
  10754. * On key up
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnKeyUpTrigger: number;
  10758. private _scene;
  10759. /**
  10760. * Creates a new action manager
  10761. * @param scene defines the hosting scene
  10762. */
  10763. constructor(scene: Scene);
  10764. /**
  10765. * Releases all associated resources
  10766. */
  10767. dispose(): void;
  10768. /**
  10769. * Gets hosting scene
  10770. * @returns the hosting scene
  10771. */
  10772. getScene(): Scene;
  10773. /**
  10774. * Does this action manager handles actions of any of the given triggers
  10775. * @param triggers defines the triggers to be tested
  10776. * @return a boolean indicating whether one (or more) of the triggers is handled
  10777. */
  10778. hasSpecificTriggers(triggers: number[]): boolean;
  10779. /**
  10780. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10781. * speed.
  10782. * @param triggerA defines the trigger to be tested
  10783. * @param triggerB defines the trigger to be tested
  10784. * @return a boolean indicating whether one (or more) of the triggers is handled
  10785. */
  10786. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10787. /**
  10788. * Does this action manager handles actions of a given trigger
  10789. * @param trigger defines the trigger to be tested
  10790. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10791. * @return whether the trigger is handled
  10792. */
  10793. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10794. /**
  10795. * Does this action manager has pointer triggers
  10796. */
  10797. readonly hasPointerTriggers: boolean;
  10798. /**
  10799. * Does this action manager has pick triggers
  10800. */
  10801. readonly hasPickTriggers: boolean;
  10802. /**
  10803. * Registers an action to this action manager
  10804. * @param action defines the action to be registered
  10805. * @return the action amended (prepared) after registration
  10806. */
  10807. registerAction(action: IAction): Nullable<IAction>;
  10808. /**
  10809. * Unregisters an action to this action manager
  10810. * @param action defines the action to be unregistered
  10811. * @return a boolean indicating whether the action has been unregistered
  10812. */
  10813. unregisterAction(action: IAction): Boolean;
  10814. /**
  10815. * Process a specific trigger
  10816. * @param trigger defines the trigger to process
  10817. * @param evt defines the event details to be processed
  10818. */
  10819. processTrigger(trigger: number, evt?: IActionEvent): void;
  10820. /** @hidden */
  10821. _getEffectiveTarget(target: any, propertyPath: string): any;
  10822. /** @hidden */
  10823. _getProperty(propertyPath: string): string;
  10824. /**
  10825. * Serialize this manager to a JSON object
  10826. * @param name defines the property name to store this manager
  10827. * @returns a JSON representation of this manager
  10828. */
  10829. serialize(name: string): any;
  10830. /**
  10831. * Creates a new ActionManager from a JSON data
  10832. * @param parsedActions defines the JSON data to read from
  10833. * @param object defines the hosting mesh
  10834. * @param scene defines the hosting scene
  10835. */
  10836. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10837. /**
  10838. * Get a trigger name by index
  10839. * @param trigger defines the trigger index
  10840. * @returns a trigger name
  10841. */
  10842. static GetTriggerName(trigger: number): string;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Class representing a ray with position and direction
  10848. */
  10849. export class Ray {
  10850. /** origin point */
  10851. origin: Vector3;
  10852. /** direction */
  10853. direction: Vector3;
  10854. /** length of the ray */
  10855. length: number;
  10856. private static readonly TmpVector3;
  10857. private _tmpRay;
  10858. /**
  10859. * Creates a new ray
  10860. * @param origin origin point
  10861. * @param direction direction
  10862. * @param length length of the ray
  10863. */
  10864. constructor(
  10865. /** origin point */
  10866. origin: Vector3,
  10867. /** direction */
  10868. direction: Vector3,
  10869. /** length of the ray */
  10870. length?: number);
  10871. /**
  10872. * Checks if the ray intersects a box
  10873. * @param minimum bound of the box
  10874. * @param maximum bound of the box
  10875. * @param intersectionTreshold extra extend to be added to the box in all direction
  10876. * @returns if the box was hit
  10877. */
  10878. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10879. /**
  10880. * Checks if the ray intersects a box
  10881. * @param box the bounding box to check
  10882. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10883. * @returns if the box was hit
  10884. */
  10885. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10886. /**
  10887. * If the ray hits a sphere
  10888. * @param sphere the bounding sphere to check
  10889. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10890. * @returns true if it hits the sphere
  10891. */
  10892. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10893. /**
  10894. * If the ray hits a triange
  10895. * @param vertex0 triangle vertex
  10896. * @param vertex1 triangle vertex
  10897. * @param vertex2 triangle vertex
  10898. * @returns intersection information if hit
  10899. */
  10900. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10901. /**
  10902. * Checks if ray intersects a plane
  10903. * @param plane the plane to check
  10904. * @returns the distance away it was hit
  10905. */
  10906. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10907. /**
  10908. * Calculate the intercept of a ray on a given axis
  10909. * @param axis to check 'x' | 'y' | 'z'
  10910. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10911. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10912. */
  10913. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10914. /**
  10915. * Checks if ray intersects a mesh
  10916. * @param mesh the mesh to check
  10917. * @param fastCheck if only the bounding box should checked
  10918. * @returns picking info of the intersecton
  10919. */
  10920. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10921. /**
  10922. * Checks if ray intersects a mesh
  10923. * @param meshes the meshes to check
  10924. * @param fastCheck if only the bounding box should checked
  10925. * @param results array to store result in
  10926. * @returns Array of picking infos
  10927. */
  10928. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10929. private _comparePickingInfo;
  10930. private static smallnum;
  10931. private static rayl;
  10932. /**
  10933. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10934. * @param sega the first point of the segment to test the intersection against
  10935. * @param segb the second point of the segment to test the intersection against
  10936. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10937. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10938. */
  10939. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10940. /**
  10941. * Update the ray from viewport position
  10942. * @param x position
  10943. * @param y y position
  10944. * @param viewportWidth viewport width
  10945. * @param viewportHeight viewport height
  10946. * @param world world matrix
  10947. * @param view view matrix
  10948. * @param projection projection matrix
  10949. * @returns this ray updated
  10950. */
  10951. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10952. /**
  10953. * Creates a ray with origin and direction of 0,0,0
  10954. * @returns the new ray
  10955. */
  10956. static Zero(): Ray;
  10957. /**
  10958. * Creates a new ray from screen space and viewport
  10959. * @param x position
  10960. * @param y y position
  10961. * @param viewportWidth viewport width
  10962. * @param viewportHeight viewport height
  10963. * @param world world matrix
  10964. * @param view view matrix
  10965. * @param projection projection matrix
  10966. * @returns new ray
  10967. */
  10968. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10969. /**
  10970. * 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
  10971. * transformed to the given world matrix.
  10972. * @param origin The origin point
  10973. * @param end The end point
  10974. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10975. * @returns the new ray
  10976. */
  10977. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10978. /**
  10979. * Transforms a ray by a matrix
  10980. * @param ray ray to transform
  10981. * @param matrix matrix to apply
  10982. * @returns the resulting new ray
  10983. */
  10984. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10985. /**
  10986. * Transforms a ray by a matrix
  10987. * @param ray ray to transform
  10988. * @param matrix matrix to apply
  10989. * @param result ray to store result in
  10990. */
  10991. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10992. /**
  10993. * Unproject a ray from screen space to object space
  10994. * @param sourceX defines the screen space x coordinate to use
  10995. * @param sourceY defines the screen space y coordinate to use
  10996. * @param viewportWidth defines the current width of the viewport
  10997. * @param viewportHeight defines the current height of the viewport
  10998. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10999. * @param view defines the view matrix to use
  11000. * @param projection defines the projection matrix to use
  11001. */
  11002. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11003. }
  11004. /**
  11005. * Type used to define predicate used to select faces when a mesh intersection is detected
  11006. */
  11007. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11008. interface Scene {
  11009. /** @hidden */
  11010. _tempPickingRay: Nullable<Ray>;
  11011. /** @hidden */
  11012. _cachedRayForTransform: Ray;
  11013. /** @hidden */
  11014. _pickWithRayInverseMatrix: Matrix;
  11015. /** @hidden */
  11016. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11017. /** @hidden */
  11018. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11019. }
  11020. }
  11021. declare module BABYLON {
  11022. /**
  11023. * Groups all the scene component constants in one place to ease maintenance.
  11024. * @hidden
  11025. */
  11026. export class SceneComponentConstants {
  11027. static readonly NAME_EFFECTLAYER: string;
  11028. static readonly NAME_LAYER: string;
  11029. static readonly NAME_LENSFLARESYSTEM: string;
  11030. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11031. static readonly NAME_PARTICLESYSTEM: string;
  11032. static readonly NAME_GAMEPAD: string;
  11033. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11034. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11035. static readonly NAME_DEPTHRENDERER: string;
  11036. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11037. static readonly NAME_SPRITE: string;
  11038. static readonly NAME_OUTLINERENDERER: string;
  11039. static readonly NAME_PROCEDURALTEXTURE: string;
  11040. static readonly NAME_SHADOWGENERATOR: string;
  11041. static readonly NAME_OCTREE: string;
  11042. static readonly NAME_PHYSICSENGINE: string;
  11043. static readonly NAME_AUDIO: string;
  11044. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11045. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11046. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11047. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11048. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11049. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11050. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11051. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11052. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11053. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11054. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11055. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11056. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11057. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11058. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11059. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11060. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11061. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11062. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11063. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11064. static readonly STEP_AFTERRENDER_AUDIO: number;
  11065. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11066. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11067. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11068. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11069. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11070. static readonly STEP_POINTERMOVE_SPRITE: number;
  11071. static readonly STEP_POINTERDOWN_SPRITE: number;
  11072. static readonly STEP_POINTERUP_SPRITE: number;
  11073. }
  11074. /**
  11075. * This represents a scene component.
  11076. *
  11077. * This is used to decouple the dependency the scene is having on the different workloads like
  11078. * layers, post processes...
  11079. */
  11080. export interface ISceneComponent {
  11081. /**
  11082. * The name of the component. Each component must have a unique name.
  11083. */
  11084. name: string;
  11085. /**
  11086. * The scene the component belongs to.
  11087. */
  11088. scene: Scene;
  11089. /**
  11090. * Register the component to one instance of a scene.
  11091. */
  11092. register(): void;
  11093. /**
  11094. * Rebuilds the elements related to this component in case of
  11095. * context lost for instance.
  11096. */
  11097. rebuild(): void;
  11098. /**
  11099. * Disposes the component and the associated ressources.
  11100. */
  11101. dispose(): void;
  11102. }
  11103. /**
  11104. * This represents a SERIALIZABLE scene component.
  11105. *
  11106. * This extends Scene Component to add Serialization methods on top.
  11107. */
  11108. export interface ISceneSerializableComponent extends ISceneComponent {
  11109. /**
  11110. * Adds all the elements from the container to the scene
  11111. * @param container the container holding the elements
  11112. */
  11113. addFromContainer(container: AbstractScene): void;
  11114. /**
  11115. * Removes all the elements in the container from the scene
  11116. * @param container contains the elements to remove
  11117. * @param dispose if the removed element should be disposed (default: false)
  11118. */
  11119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11120. /**
  11121. * Serializes the component data to the specified json object
  11122. * @param serializationObject The object to serialize to
  11123. */
  11124. serialize(serializationObject: any): void;
  11125. }
  11126. /**
  11127. * Strong typing of a Mesh related stage step action
  11128. */
  11129. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11130. /**
  11131. * Strong typing of a Evaluate Sub Mesh related stage step action
  11132. */
  11133. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11134. /**
  11135. * Strong typing of a Active Mesh related stage step action
  11136. */
  11137. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11138. /**
  11139. * Strong typing of a Camera related stage step action
  11140. */
  11141. export type CameraStageAction = (camera: Camera) => void;
  11142. /**
  11143. * Strong typing of a Camera Frame buffer related stage step action
  11144. */
  11145. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11146. /**
  11147. * Strong typing of a Render Target related stage step action
  11148. */
  11149. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11150. /**
  11151. * Strong typing of a RenderingGroup related stage step action
  11152. */
  11153. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11154. /**
  11155. * Strong typing of a Mesh Render related stage step action
  11156. */
  11157. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11158. /**
  11159. * Strong typing of a simple stage step action
  11160. */
  11161. export type SimpleStageAction = () => void;
  11162. /**
  11163. * Strong typing of a render target action.
  11164. */
  11165. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11166. /**
  11167. * Strong typing of a pointer move action.
  11168. */
  11169. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11170. /**
  11171. * Strong typing of a pointer up/down action.
  11172. */
  11173. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11174. /**
  11175. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11176. * @hidden
  11177. */
  11178. export class Stage<T extends Function> extends Array<{
  11179. index: number;
  11180. component: ISceneComponent;
  11181. action: T;
  11182. }> {
  11183. /**
  11184. * Hide ctor from the rest of the world.
  11185. * @param items The items to add.
  11186. */
  11187. private constructor();
  11188. /**
  11189. * Creates a new Stage.
  11190. * @returns A new instance of a Stage
  11191. */
  11192. static Create<T extends Function>(): Stage<T>;
  11193. /**
  11194. * Registers a step in an ordered way in the targeted stage.
  11195. * @param index Defines the position to register the step in
  11196. * @param component Defines the component attached to the step
  11197. * @param action Defines the action to launch during the step
  11198. */
  11199. registerStep(index: number, component: ISceneComponent, action: T): void;
  11200. /**
  11201. * Clears all the steps from the stage.
  11202. */
  11203. clear(): void;
  11204. }
  11205. }
  11206. declare module BABYLON {
  11207. interface Scene {
  11208. /** @hidden */
  11209. _pointerOverSprite: Nullable<Sprite>;
  11210. /** @hidden */
  11211. _pickedDownSprite: Nullable<Sprite>;
  11212. /** @hidden */
  11213. _tempSpritePickingRay: Nullable<Ray>;
  11214. /**
  11215. * All of the sprite managers added to this scene
  11216. * @see http://doc.babylonjs.com/babylon101/sprites
  11217. */
  11218. spriteManagers: Array<ISpriteManager>;
  11219. /**
  11220. * An event triggered when sprites rendering is about to start
  11221. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11222. */
  11223. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11224. /**
  11225. * An event triggered when sprites rendering is done
  11226. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11227. */
  11228. onAfterSpritesRenderingObservable: Observable<Scene>;
  11229. /** @hidden */
  11230. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11231. /** Launch a ray to try to pick a sprite in the scene
  11232. * @param x position on screen
  11233. * @param y position on screen
  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 for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11237. * @returns a PickingInfo
  11238. */
  11239. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11240. /** Use the given ray to pick a sprite in the scene
  11241. * @param ray The ray (in world space) to use to pick meshes
  11242. * @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
  11243. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11244. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11245. * @returns a PickingInfo
  11246. */
  11247. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11248. /** @hidden */
  11249. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /** Launch a ray to try to pick sprites in the scene
  11251. * @param x position on screen
  11252. * @param y position on screen
  11253. * @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
  11254. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11255. * @returns a PickingInfo array
  11256. */
  11257. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11258. /** Use the given ray to pick sprites in the scene
  11259. * @param ray The ray (in world space) to use to pick meshes
  11260. * @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
  11261. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11262. * @returns a PickingInfo array
  11263. */
  11264. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11265. /**
  11266. * Force the sprite under the pointer
  11267. * @param sprite defines the sprite to use
  11268. */
  11269. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11270. /**
  11271. * Gets the sprite under the pointer
  11272. * @returns a Sprite or null if no sprite is under the pointer
  11273. */
  11274. getPointerOverSprite(): Nullable<Sprite>;
  11275. }
  11276. /**
  11277. * Defines the sprite scene component responsible to manage sprites
  11278. * in a given scene.
  11279. */
  11280. export class SpriteSceneComponent implements ISceneComponent {
  11281. /**
  11282. * The component name helpfull to identify the component in the list of scene components.
  11283. */
  11284. readonly name: string;
  11285. /**
  11286. * The scene the component belongs to.
  11287. */
  11288. scene: Scene;
  11289. /** @hidden */
  11290. private _spritePredicate;
  11291. /**
  11292. * Creates a new instance of the component for the given scene
  11293. * @param scene Defines the scene to register the component in
  11294. */
  11295. constructor(scene: Scene);
  11296. /**
  11297. * Registers the component in a given scene
  11298. */
  11299. register(): void;
  11300. /**
  11301. * Rebuilds the elements related to this component in case of
  11302. * context lost for instance.
  11303. */
  11304. rebuild(): void;
  11305. /**
  11306. * Disposes the component and the associated ressources.
  11307. */
  11308. dispose(): void;
  11309. private _pickSpriteButKeepRay;
  11310. private _pointerMove;
  11311. private _pointerDown;
  11312. private _pointerUp;
  11313. }
  11314. }
  11315. declare module BABYLON {
  11316. /** @hidden */
  11317. export var fogFragmentDeclaration: {
  11318. name: string;
  11319. shader: string;
  11320. };
  11321. }
  11322. declare module BABYLON {
  11323. /** @hidden */
  11324. export var fogFragment: {
  11325. name: string;
  11326. shader: string;
  11327. };
  11328. }
  11329. declare module BABYLON {
  11330. /** @hidden */
  11331. export var spritesPixelShader: {
  11332. name: string;
  11333. shader: string;
  11334. };
  11335. }
  11336. declare module BABYLON {
  11337. /** @hidden */
  11338. export var fogVertexDeclaration: {
  11339. name: string;
  11340. shader: string;
  11341. };
  11342. }
  11343. declare module BABYLON {
  11344. /** @hidden */
  11345. export var spritesVertexShader: {
  11346. name: string;
  11347. shader: string;
  11348. };
  11349. }
  11350. declare module BABYLON {
  11351. /**
  11352. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11353. */
  11354. export interface ISpriteManager extends IDisposable {
  11355. /**
  11356. * Restricts the camera to viewing objects with the same layerMask.
  11357. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11358. */
  11359. layerMask: number;
  11360. /**
  11361. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11362. */
  11363. isPickable: boolean;
  11364. /**
  11365. * Specifies the rendering group id for this mesh (0 by default)
  11366. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11367. */
  11368. renderingGroupId: number;
  11369. /**
  11370. * Defines the list of sprites managed by the manager.
  11371. */
  11372. sprites: Array<Sprite>;
  11373. /**
  11374. * Tests the intersection of a sprite with a specific ray.
  11375. * @param ray The ray we are sending to test the collision
  11376. * @param camera The camera space we are sending rays in
  11377. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11378. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11379. * @returns picking info or null.
  11380. */
  11381. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11382. /**
  11383. * Intersects the sprites with a ray
  11384. * @param ray defines the ray to intersect with
  11385. * @param camera defines the current active camera
  11386. * @param predicate defines a predicate used to select candidate sprites
  11387. * @returns null if no hit or a PickingInfo array
  11388. */
  11389. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11390. /**
  11391. * Renders the list of sprites on screen.
  11392. */
  11393. render(): void;
  11394. }
  11395. /**
  11396. * Class used to manage multiple sprites on the same spritesheet
  11397. * @see http://doc.babylonjs.com/babylon101/sprites
  11398. */
  11399. export class SpriteManager implements ISpriteManager {
  11400. /** defines the manager's name */
  11401. name: string;
  11402. /** Gets the list of sprites */
  11403. sprites: Sprite[];
  11404. /** Gets or sets the rendering group id (0 by default) */
  11405. renderingGroupId: number;
  11406. /** Gets or sets camera layer mask */
  11407. layerMask: number;
  11408. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11409. fogEnabled: boolean;
  11410. /** Gets or sets a boolean indicating if the sprites are pickable */
  11411. isPickable: boolean;
  11412. /** Defines the default width of a cell in the spritesheet */
  11413. cellWidth: number;
  11414. /** Defines the default height of a cell in the spritesheet */
  11415. cellHeight: number;
  11416. /** Associative array from JSON sprite data file */
  11417. private _cellData;
  11418. /** Array of sprite names from JSON sprite data file */
  11419. private _spriteMap;
  11420. /** True when packed cell data from JSON file is ready*/
  11421. private _packedAndReady;
  11422. /**
  11423. * An event triggered when the manager is disposed.
  11424. */
  11425. onDisposeObservable: Observable<SpriteManager>;
  11426. private _onDisposeObserver;
  11427. /**
  11428. * Callback called when the manager is disposed
  11429. */
  11430. onDispose: () => void;
  11431. private _capacity;
  11432. private _fromPacked;
  11433. private _spriteTexture;
  11434. private _epsilon;
  11435. private _scene;
  11436. private _vertexData;
  11437. private _buffer;
  11438. private _vertexBuffers;
  11439. private _indexBuffer;
  11440. private _effectBase;
  11441. private _effectFog;
  11442. /**
  11443. * Gets or sets the spritesheet texture
  11444. */
  11445. texture: Texture;
  11446. /**
  11447. * Creates a new sprite manager
  11448. * @param name defines the manager's name
  11449. * @param imgUrl defines the sprite sheet url
  11450. * @param capacity defines the maximum allowed number of sprites
  11451. * @param cellSize defines the size of a sprite cell
  11452. * @param scene defines the hosting scene
  11453. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11454. * @param samplingMode defines the smapling mode to use with spritesheet
  11455. * @param fromPacked set to false; do not alter
  11456. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11457. */
  11458. constructor(
  11459. /** defines the manager's name */
  11460. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11461. private _makePacked;
  11462. private _appendSpriteVertex;
  11463. /**
  11464. * Intersects the sprites with a ray
  11465. * @param ray defines the ray to intersect with
  11466. * @param camera defines the current active camera
  11467. * @param predicate defines a predicate used to select candidate sprites
  11468. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11469. * @returns null if no hit or a PickingInfo
  11470. */
  11471. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11472. /**
  11473. * Intersects the sprites with a ray
  11474. * @param ray defines the ray to intersect with
  11475. * @param camera defines the current active camera
  11476. * @param predicate defines a predicate used to select candidate sprites
  11477. * @returns null if no hit or a PickingInfo array
  11478. */
  11479. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11480. /**
  11481. * Render all child sprites
  11482. */
  11483. render(): void;
  11484. /**
  11485. * Release associated resources
  11486. */
  11487. dispose(): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Class used to represent a sprite
  11493. * @see http://doc.babylonjs.com/babylon101/sprites
  11494. */
  11495. export class Sprite {
  11496. /** defines the name */
  11497. name: string;
  11498. /** Gets or sets the current world position */
  11499. position: Vector3;
  11500. /** Gets or sets the main color */
  11501. color: Color4;
  11502. /** Gets or sets the width */
  11503. width: number;
  11504. /** Gets or sets the height */
  11505. height: number;
  11506. /** Gets or sets rotation angle */
  11507. angle: number;
  11508. /** Gets or sets the cell index in the sprite sheet */
  11509. cellIndex: number;
  11510. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11511. cellRef: string;
  11512. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11513. invertU: number;
  11514. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11515. invertV: number;
  11516. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11517. disposeWhenFinishedAnimating: boolean;
  11518. /** Gets the list of attached animations */
  11519. animations: Animation[];
  11520. /** Gets or sets a boolean indicating if the sprite can be picked */
  11521. isPickable: boolean;
  11522. /**
  11523. * Gets or sets the associated action manager
  11524. */
  11525. actionManager: Nullable<ActionManager>;
  11526. private _animationStarted;
  11527. private _loopAnimation;
  11528. private _fromIndex;
  11529. private _toIndex;
  11530. private _delay;
  11531. private _direction;
  11532. private _manager;
  11533. private _time;
  11534. private _onAnimationEnd;
  11535. /**
  11536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11537. */
  11538. isVisible: boolean;
  11539. /**
  11540. * Gets or sets the sprite size
  11541. */
  11542. size: number;
  11543. /**
  11544. * Creates a new Sprite
  11545. * @param name defines the name
  11546. * @param manager defines the manager
  11547. */
  11548. constructor(
  11549. /** defines the name */
  11550. name: string, manager: ISpriteManager);
  11551. /**
  11552. * Starts an animation
  11553. * @param from defines the initial key
  11554. * @param to defines the end key
  11555. * @param loop defines if the animation must loop
  11556. * @param delay defines the start delay (in ms)
  11557. * @param onAnimationEnd defines a callback to call when animation ends
  11558. */
  11559. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11560. /** Stops current animation (if any) */
  11561. stopAnimation(): void;
  11562. /** @hidden */
  11563. _animate(deltaTime: number): void;
  11564. /** Release associated resources */
  11565. dispose(): void;
  11566. }
  11567. }
  11568. declare module BABYLON {
  11569. /**
  11570. * Information about the result of picking within a scene
  11571. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11572. */
  11573. export class PickingInfo {
  11574. /** @hidden */
  11575. _pickingUnavailable: boolean;
  11576. /**
  11577. * If the pick collided with an object
  11578. */
  11579. hit: boolean;
  11580. /**
  11581. * Distance away where the pick collided
  11582. */
  11583. distance: number;
  11584. /**
  11585. * The location of pick collision
  11586. */
  11587. pickedPoint: Nullable<Vector3>;
  11588. /**
  11589. * The mesh corresponding the the pick collision
  11590. */
  11591. pickedMesh: Nullable<AbstractMesh>;
  11592. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11593. bu: number;
  11594. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11595. bv: number;
  11596. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11597. faceId: number;
  11598. /** Id of the the submesh that was picked */
  11599. subMeshId: number;
  11600. /** If a sprite was picked, this will be the sprite the pick collided with */
  11601. pickedSprite: Nullable<Sprite>;
  11602. /**
  11603. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11604. */
  11605. originMesh: Nullable<AbstractMesh>;
  11606. /**
  11607. * The ray that was used to perform the picking.
  11608. */
  11609. ray: Nullable<Ray>;
  11610. /**
  11611. * Gets the normal correspodning to the face the pick collided with
  11612. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11613. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11614. * @returns The normal correspodning to the face the pick collided with
  11615. */
  11616. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11617. /**
  11618. * Gets the texture coordinates of where the pick occured
  11619. * @returns the vector containing the coordnates of the texture
  11620. */
  11621. getTextureCoordinates(): Nullable<Vector2>;
  11622. }
  11623. }
  11624. declare module BABYLON {
  11625. /**
  11626. * Gather the list of pointer event types as constants.
  11627. */
  11628. export class PointerEventTypes {
  11629. /**
  11630. * 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.
  11631. */
  11632. static readonly POINTERDOWN: number;
  11633. /**
  11634. * The pointerup event is fired when a pointer is no longer active.
  11635. */
  11636. static readonly POINTERUP: number;
  11637. /**
  11638. * The pointermove event is fired when a pointer changes coordinates.
  11639. */
  11640. static readonly POINTERMOVE: number;
  11641. /**
  11642. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11643. */
  11644. static readonly POINTERWHEEL: number;
  11645. /**
  11646. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11647. */
  11648. static readonly POINTERPICK: number;
  11649. /**
  11650. * The pointertap event is fired when a the object has been touched and released without drag.
  11651. */
  11652. static readonly POINTERTAP: number;
  11653. /**
  11654. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11655. */
  11656. static readonly POINTERDOUBLETAP: number;
  11657. }
  11658. /**
  11659. * Base class of pointer info types.
  11660. */
  11661. export class PointerInfoBase {
  11662. /**
  11663. * Defines the type of event (PointerEventTypes)
  11664. */
  11665. type: number;
  11666. /**
  11667. * Defines the related dom event
  11668. */
  11669. event: PointerEvent | MouseWheelEvent;
  11670. /**
  11671. * Instantiates the base class of pointers info.
  11672. * @param type Defines the type of event (PointerEventTypes)
  11673. * @param event Defines the related dom event
  11674. */
  11675. constructor(
  11676. /**
  11677. * Defines the type of event (PointerEventTypes)
  11678. */
  11679. type: number,
  11680. /**
  11681. * Defines the related dom event
  11682. */
  11683. event: PointerEvent | MouseWheelEvent);
  11684. }
  11685. /**
  11686. * This class is used to store pointer related info for the onPrePointerObservable event.
  11687. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11688. */
  11689. export class PointerInfoPre extends PointerInfoBase {
  11690. /**
  11691. * Ray from a pointer if availible (eg. 6dof controller)
  11692. */
  11693. ray: Nullable<Ray>;
  11694. /**
  11695. * Defines the local position of the pointer on the canvas.
  11696. */
  11697. localPosition: Vector2;
  11698. /**
  11699. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11700. */
  11701. skipOnPointerObservable: boolean;
  11702. /**
  11703. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11704. * @param type Defines the type of event (PointerEventTypes)
  11705. * @param event Defines the related dom event
  11706. * @param localX Defines the local x coordinates of the pointer when the event occured
  11707. * @param localY Defines the local y coordinates of the pointer when the event occured
  11708. */
  11709. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11710. }
  11711. /**
  11712. * This type contains all the data related to a pointer event in Babylon.js.
  11713. * 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.
  11714. */
  11715. export class PointerInfo extends PointerInfoBase {
  11716. /**
  11717. * Defines the picking info associated to the info (if any)\
  11718. */
  11719. pickInfo: Nullable<PickingInfo>;
  11720. /**
  11721. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11722. * @param type Defines the type of event (PointerEventTypes)
  11723. * @param event Defines the related dom event
  11724. * @param pickInfo Defines the picking info associated to the info (if any)\
  11725. */
  11726. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11727. /**
  11728. * Defines the picking info associated to the info (if any)\
  11729. */
  11730. pickInfo: Nullable<PickingInfo>);
  11731. }
  11732. /**
  11733. * Data relating to a touch event on the screen.
  11734. */
  11735. export interface PointerTouch {
  11736. /**
  11737. * X coordinate of touch.
  11738. */
  11739. x: number;
  11740. /**
  11741. * Y coordinate of touch.
  11742. */
  11743. y: number;
  11744. /**
  11745. * Id of touch. Unique for each finger.
  11746. */
  11747. pointerId: number;
  11748. /**
  11749. * Event type passed from DOM.
  11750. */
  11751. type: any;
  11752. }
  11753. }
  11754. declare module BABYLON {
  11755. /**
  11756. * Manage the mouse inputs to control the movement of a free camera.
  11757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11758. */
  11759. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11760. /**
  11761. * Define if touch is enabled in the mouse input
  11762. */
  11763. touchEnabled: boolean;
  11764. /**
  11765. * Defines the camera the input is attached to.
  11766. */
  11767. camera: FreeCamera;
  11768. /**
  11769. * Defines the buttons associated with the input to handle camera move.
  11770. */
  11771. buttons: number[];
  11772. /**
  11773. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11774. */
  11775. angularSensibility: number;
  11776. private _pointerInput;
  11777. private _onMouseMove;
  11778. private _observer;
  11779. private previousPosition;
  11780. /**
  11781. * Observable for when a pointer move event occurs containing the move offset
  11782. */
  11783. onPointerMovedObservable: Observable<{
  11784. offsetX: number;
  11785. offsetY: number;
  11786. }>;
  11787. /**
  11788. * @hidden
  11789. * If the camera should be rotated automatically based on pointer movement
  11790. */
  11791. _allowCameraRotation: boolean;
  11792. /**
  11793. * Manage the mouse inputs to control the movement of a free camera.
  11794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11795. * @param touchEnabled Defines if touch is enabled or not
  11796. */
  11797. constructor(
  11798. /**
  11799. * Define if touch is enabled in the mouse input
  11800. */
  11801. touchEnabled?: boolean);
  11802. /**
  11803. * Attach the input controls to a specific dom element to get the input from.
  11804. * @param element Defines the element the controls should be listened from
  11805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11806. */
  11807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11808. /**
  11809. * Called on JS contextmenu event.
  11810. * Override this method to provide functionality.
  11811. */
  11812. protected onContextMenu(evt: PointerEvent): void;
  11813. /**
  11814. * Detach the current controls from the specified dom element.
  11815. * @param element Defines the element to stop listening the inputs from
  11816. */
  11817. detachControl(element: Nullable<HTMLElement>): void;
  11818. /**
  11819. * Gets the class name of the current intput.
  11820. * @returns the class name
  11821. */
  11822. getClassName(): string;
  11823. /**
  11824. * Get the friendly name associated with the input class.
  11825. * @returns the input friendly name
  11826. */
  11827. getSimpleName(): string;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /**
  11832. * Manage the touch inputs to control the movement of a free camera.
  11833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11834. */
  11835. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11836. /**
  11837. * Defines the camera the input is attached to.
  11838. */
  11839. camera: FreeCamera;
  11840. /**
  11841. * Defines the touch sensibility for rotation.
  11842. * The higher the faster.
  11843. */
  11844. touchAngularSensibility: number;
  11845. /**
  11846. * Defines the touch sensibility for move.
  11847. * The higher the faster.
  11848. */
  11849. touchMoveSensibility: number;
  11850. private _offsetX;
  11851. private _offsetY;
  11852. private _pointerPressed;
  11853. private _pointerInput;
  11854. private _observer;
  11855. private _onLostFocus;
  11856. /**
  11857. * Attach the input controls to a specific dom element to get the input from.
  11858. * @param element Defines the element the controls should be listened from
  11859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11860. */
  11861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11862. /**
  11863. * Detach the current controls from the specified dom element.
  11864. * @param element Defines the element to stop listening the inputs from
  11865. */
  11866. detachControl(element: Nullable<HTMLElement>): void;
  11867. /**
  11868. * Update the current camera state depending on the inputs that have been used this frame.
  11869. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11870. */
  11871. checkInputs(): void;
  11872. /**
  11873. * Gets the class name of the current intput.
  11874. * @returns the class name
  11875. */
  11876. getClassName(): string;
  11877. /**
  11878. * Get the friendly name associated with the input class.
  11879. * @returns the input friendly name
  11880. */
  11881. getSimpleName(): string;
  11882. }
  11883. }
  11884. declare module BABYLON {
  11885. /**
  11886. * Default Inputs manager for the FreeCamera.
  11887. * It groups all the default supported inputs for ease of use.
  11888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11889. */
  11890. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11891. /**
  11892. * @hidden
  11893. */
  11894. _mouseInput: Nullable<FreeCameraMouseInput>;
  11895. /**
  11896. * Instantiates a new FreeCameraInputsManager.
  11897. * @param camera Defines the camera the inputs belong to
  11898. */
  11899. constructor(camera: FreeCamera);
  11900. /**
  11901. * Add keyboard input support to the input manager.
  11902. * @returns the current input manager
  11903. */
  11904. addKeyboard(): FreeCameraInputsManager;
  11905. /**
  11906. * Add mouse input support to the input manager.
  11907. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11908. * @returns the current input manager
  11909. */
  11910. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11911. /**
  11912. * Removes the mouse input support from the manager
  11913. * @returns the current input manager
  11914. */
  11915. removeMouse(): FreeCameraInputsManager;
  11916. /**
  11917. * Add touch input support to the input manager.
  11918. * @returns the current input manager
  11919. */
  11920. addTouch(): FreeCameraInputsManager;
  11921. /**
  11922. * Remove all attached input methods from a camera
  11923. */
  11924. clear(): void;
  11925. }
  11926. }
  11927. declare module BABYLON {
  11928. /**
  11929. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11930. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11932. */
  11933. export class FreeCamera extends TargetCamera {
  11934. /**
  11935. * Define the collision ellipsoid of the camera.
  11936. * This is helpful to simulate a camera body like the player body around the camera
  11937. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11938. */
  11939. ellipsoid: Vector3;
  11940. /**
  11941. * Define an offset for the position of the ellipsoid around the camera.
  11942. * This can be helpful to determine the center of the body near the gravity center of the body
  11943. * instead of its head.
  11944. */
  11945. ellipsoidOffset: Vector3;
  11946. /**
  11947. * Enable or disable collisions of the camera with the rest of the scene objects.
  11948. */
  11949. checkCollisions: boolean;
  11950. /**
  11951. * Enable or disable gravity on the camera.
  11952. */
  11953. applyGravity: boolean;
  11954. /**
  11955. * Define the input manager associated to the camera.
  11956. */
  11957. inputs: FreeCameraInputsManager;
  11958. /**
  11959. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11960. * Higher values reduce sensitivity.
  11961. */
  11962. /**
  11963. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11964. * Higher values reduce sensitivity.
  11965. */
  11966. angularSensibility: number;
  11967. /**
  11968. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11969. */
  11970. keysUp: number[];
  11971. /**
  11972. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11973. */
  11974. keysDown: number[];
  11975. /**
  11976. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11977. */
  11978. keysLeft: number[];
  11979. /**
  11980. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11981. */
  11982. keysRight: number[];
  11983. /**
  11984. * Event raised when the camera collide with a mesh in the scene.
  11985. */
  11986. onCollide: (collidedMesh: AbstractMesh) => void;
  11987. private _collider;
  11988. private _needMoveForGravity;
  11989. private _oldPosition;
  11990. private _diffPosition;
  11991. private _newPosition;
  11992. /** @hidden */
  11993. _localDirection: Vector3;
  11994. /** @hidden */
  11995. _transformedDirection: Vector3;
  11996. /**
  11997. * Instantiates a Free Camera.
  11998. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11999. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12001. * @param name Define the name of the camera in the scene
  12002. * @param position Define the start position of the camera in the scene
  12003. * @param scene Define the scene the camera belongs to
  12004. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12005. */
  12006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12007. /**
  12008. * Attached controls to the current camera.
  12009. * @param element Defines the element the controls should be listened from
  12010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12011. */
  12012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12013. /**
  12014. * Detach the current controls from the camera.
  12015. * The camera will stop reacting to inputs.
  12016. * @param element Defines the element to stop listening the inputs from
  12017. */
  12018. detachControl(element: HTMLElement): void;
  12019. private _collisionMask;
  12020. /**
  12021. * Define a collision mask to limit the list of object the camera can collide with
  12022. */
  12023. collisionMask: number;
  12024. /** @hidden */
  12025. _collideWithWorld(displacement: Vector3): void;
  12026. private _onCollisionPositionChange;
  12027. /** @hidden */
  12028. _checkInputs(): void;
  12029. /** @hidden */
  12030. _decideIfNeedsToMove(): boolean;
  12031. /** @hidden */
  12032. _updatePosition(): void;
  12033. /**
  12034. * Destroy the camera and release the current resources hold by it.
  12035. */
  12036. dispose(): void;
  12037. /**
  12038. * Gets the current object class name.
  12039. * @return the class name
  12040. */
  12041. getClassName(): string;
  12042. }
  12043. }
  12044. declare module BABYLON {
  12045. /**
  12046. * Represents a gamepad control stick position
  12047. */
  12048. export class StickValues {
  12049. /**
  12050. * The x component of the control stick
  12051. */
  12052. x: number;
  12053. /**
  12054. * The y component of the control stick
  12055. */
  12056. y: number;
  12057. /**
  12058. * Initializes the gamepad x and y control stick values
  12059. * @param x The x component of the gamepad control stick value
  12060. * @param y The y component of the gamepad control stick value
  12061. */
  12062. constructor(
  12063. /**
  12064. * The x component of the control stick
  12065. */
  12066. x: number,
  12067. /**
  12068. * The y component of the control stick
  12069. */
  12070. y: number);
  12071. }
  12072. /**
  12073. * An interface which manages callbacks for gamepad button changes
  12074. */
  12075. export interface GamepadButtonChanges {
  12076. /**
  12077. * Called when a gamepad has been changed
  12078. */
  12079. changed: boolean;
  12080. /**
  12081. * Called when a gamepad press event has been triggered
  12082. */
  12083. pressChanged: boolean;
  12084. /**
  12085. * Called when a touch event has been triggered
  12086. */
  12087. touchChanged: boolean;
  12088. /**
  12089. * Called when a value has changed
  12090. */
  12091. valueChanged: boolean;
  12092. }
  12093. /**
  12094. * Represents a gamepad
  12095. */
  12096. export class Gamepad {
  12097. /**
  12098. * The id of the gamepad
  12099. */
  12100. id: string;
  12101. /**
  12102. * The index of the gamepad
  12103. */
  12104. index: number;
  12105. /**
  12106. * The browser gamepad
  12107. */
  12108. browserGamepad: any;
  12109. /**
  12110. * Specifies what type of gamepad this represents
  12111. */
  12112. type: number;
  12113. private _leftStick;
  12114. private _rightStick;
  12115. /** @hidden */
  12116. _isConnected: boolean;
  12117. private _leftStickAxisX;
  12118. private _leftStickAxisY;
  12119. private _rightStickAxisX;
  12120. private _rightStickAxisY;
  12121. /**
  12122. * Triggered when the left control stick has been changed
  12123. */
  12124. private _onleftstickchanged;
  12125. /**
  12126. * Triggered when the right control stick has been changed
  12127. */
  12128. private _onrightstickchanged;
  12129. /**
  12130. * Represents a gamepad controller
  12131. */
  12132. static GAMEPAD: number;
  12133. /**
  12134. * Represents a generic controller
  12135. */
  12136. static GENERIC: number;
  12137. /**
  12138. * Represents an XBox controller
  12139. */
  12140. static XBOX: number;
  12141. /**
  12142. * Represents a pose-enabled controller
  12143. */
  12144. static POSE_ENABLED: number;
  12145. /**
  12146. * Represents an Dual Shock controller
  12147. */
  12148. static DUALSHOCK: number;
  12149. /**
  12150. * Specifies whether the left control stick should be Y-inverted
  12151. */
  12152. protected _invertLeftStickY: boolean;
  12153. /**
  12154. * Specifies if the gamepad has been connected
  12155. */
  12156. readonly isConnected: boolean;
  12157. /**
  12158. * Initializes the gamepad
  12159. * @param id The id of the gamepad
  12160. * @param index The index of the gamepad
  12161. * @param browserGamepad The browser gamepad
  12162. * @param leftStickX The x component of the left joystick
  12163. * @param leftStickY The y component of the left joystick
  12164. * @param rightStickX The x component of the right joystick
  12165. * @param rightStickY The y component of the right joystick
  12166. */
  12167. constructor(
  12168. /**
  12169. * The id of the gamepad
  12170. */
  12171. id: string,
  12172. /**
  12173. * The index of the gamepad
  12174. */
  12175. index: number,
  12176. /**
  12177. * The browser gamepad
  12178. */
  12179. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12180. /**
  12181. * Callback triggered when the left joystick has changed
  12182. * @param callback
  12183. */
  12184. onleftstickchanged(callback: (values: StickValues) => void): void;
  12185. /**
  12186. * Callback triggered when the right joystick has changed
  12187. * @param callback
  12188. */
  12189. onrightstickchanged(callback: (values: StickValues) => void): void;
  12190. /**
  12191. * Gets the left joystick
  12192. */
  12193. /**
  12194. * Sets the left joystick values
  12195. */
  12196. leftStick: StickValues;
  12197. /**
  12198. * Gets the right joystick
  12199. */
  12200. /**
  12201. * Sets the right joystick value
  12202. */
  12203. rightStick: StickValues;
  12204. /**
  12205. * Updates the gamepad joystick positions
  12206. */
  12207. update(): void;
  12208. /**
  12209. * Disposes the gamepad
  12210. */
  12211. dispose(): void;
  12212. }
  12213. /**
  12214. * Represents a generic gamepad
  12215. */
  12216. export class GenericPad extends Gamepad {
  12217. private _buttons;
  12218. private _onbuttondown;
  12219. private _onbuttonup;
  12220. /**
  12221. * Observable triggered when a button has been pressed
  12222. */
  12223. onButtonDownObservable: Observable<number>;
  12224. /**
  12225. * Observable triggered when a button has been released
  12226. */
  12227. onButtonUpObservable: Observable<number>;
  12228. /**
  12229. * Callback triggered when a button has been pressed
  12230. * @param callback Called when a button has been pressed
  12231. */
  12232. onbuttondown(callback: (buttonPressed: number) => void): void;
  12233. /**
  12234. * Callback triggered when a button has been released
  12235. * @param callback Called when a button has been released
  12236. */
  12237. onbuttonup(callback: (buttonReleased: number) => void): void;
  12238. /**
  12239. * Initializes the generic gamepad
  12240. * @param id The id of the generic gamepad
  12241. * @param index The index of the generic gamepad
  12242. * @param browserGamepad The browser gamepad
  12243. */
  12244. constructor(id: string, index: number, browserGamepad: any);
  12245. private _setButtonValue;
  12246. /**
  12247. * Updates the generic gamepad
  12248. */
  12249. update(): void;
  12250. /**
  12251. * Disposes the generic gamepad
  12252. */
  12253. dispose(): void;
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. interface Engine {
  12258. /**
  12259. * Creates a raw texture
  12260. * @param data defines the data to store in the texture
  12261. * @param width defines the width of the texture
  12262. * @param height defines the height of the texture
  12263. * @param format defines the format of the data
  12264. * @param generateMipMaps defines if the engine should generate the mip levels
  12265. * @param invertY defines if data must be stored with Y axis inverted
  12266. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12267. * @param compression defines the compression used (null by default)
  12268. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12269. * @returns the raw texture inside an InternalTexture
  12270. */
  12271. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  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. */
  12279. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12280. /**
  12281. * Update a raw texture
  12282. * @param texture defines the texture to update
  12283. * @param data defines the data to store in the texture
  12284. * @param format defines the format of the data
  12285. * @param invertY defines if data must be stored with Y axis inverted
  12286. * @param compression defines the compression used (null by default)
  12287. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12288. */
  12289. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12290. /**
  12291. * Creates a new raw cube texture
  12292. * @param data defines the array of data to use to create each face
  12293. * @param size defines the size of the textures
  12294. * @param format defines the format of the data
  12295. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12296. * @param generateMipMaps defines if the engine should generate the mip levels
  12297. * @param invertY defines if data must be stored with Y axis inverted
  12298. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12299. * @param compression defines the compression used (null by default)
  12300. * @returns the cube texture as an InternalTexture
  12301. */
  12302. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12303. /**
  12304. * Update a raw cube texture
  12305. * @param texture defines the texture to udpdate
  12306. * @param data defines the data to store
  12307. * @param format defines the data format
  12308. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12309. * @param invertY defines if data must be stored with Y axis inverted
  12310. */
  12311. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12312. /**
  12313. * Update a raw cube texture
  12314. * @param texture defines the texture to udpdate
  12315. * @param data defines the data to store
  12316. * @param format defines the data format
  12317. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12318. * @param invertY defines if data must be stored with Y axis inverted
  12319. * @param compression defines the compression used (null by default)
  12320. */
  12321. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12322. /**
  12323. * Update a raw cube texture
  12324. * @param texture defines the texture to udpdate
  12325. * @param data defines the data to store
  12326. * @param format defines the data format
  12327. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12328. * @param invertY defines if data must be stored with Y axis inverted
  12329. * @param compression defines the compression used (null by default)
  12330. * @param level defines which level of the texture to update
  12331. */
  12332. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12333. /**
  12334. * Creates a new raw cube texture from a specified url
  12335. * @param url defines the url where the data is located
  12336. * @param scene defines the current scene
  12337. * @param size defines the size of the textures
  12338. * @param format defines the format of the data
  12339. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12340. * @param noMipmap defines if the engine should avoid generating the mip levels
  12341. * @param callback defines a callback used to extract texture data from loaded data
  12342. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12343. * @param onLoad defines a callback called when texture is loaded
  12344. * @param onError defines a callback called if there is an error
  12345. * @returns the cube texture as an InternalTexture
  12346. */
  12347. 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;
  12348. /**
  12349. * Creates a new raw cube texture from a specified url
  12350. * @param url defines the url where the data is located
  12351. * @param scene defines the current scene
  12352. * @param size defines the size of the textures
  12353. * @param format defines the format of the data
  12354. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12355. * @param noMipmap defines if the engine should avoid generating the mip levels
  12356. * @param callback defines a callback used to extract texture data from loaded data
  12357. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12358. * @param onLoad defines a callback called when texture is loaded
  12359. * @param onError defines a callback called if there is an error
  12360. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12361. * @param invertY defines if data must be stored with Y axis inverted
  12362. * @returns the cube texture as an InternalTexture
  12363. */
  12364. 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;
  12365. /**
  12366. * Creates a new raw 3D texture
  12367. * @param data defines the data used to create the texture
  12368. * @param width defines the width of the texture
  12369. * @param height defines the height of the texture
  12370. * @param depth defines the depth of the texture
  12371. * @param format defines the format of the texture
  12372. * @param generateMipMaps defines if the engine must generate mip levels
  12373. * @param invertY defines if data must be stored with Y axis inverted
  12374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12375. * @param compression defines the compressed used (can be null)
  12376. * @param textureType defines the compressed used (can be null)
  12377. * @returns a new raw 3D texture (stored in an InternalTexture)
  12378. */
  12379. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  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. */
  12387. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12388. /**
  12389. * Update a raw 3D texture
  12390. * @param texture defines the texture to update
  12391. * @param data defines the data to store
  12392. * @param format defines the data format
  12393. * @param invertY defines if data must be stored with Y axis inverted
  12394. * @param compression defines the used compression (can be null)
  12395. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12396. */
  12397. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12398. }
  12399. }
  12400. declare module BABYLON {
  12401. /**
  12402. * Raw texture can help creating a texture directly from an array of data.
  12403. * This can be super useful if you either get the data from an uncompressed source or
  12404. * if you wish to create your texture pixel by pixel.
  12405. */
  12406. export class RawTexture extends Texture {
  12407. /**
  12408. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12409. */
  12410. format: number;
  12411. private _engine;
  12412. /**
  12413. * Instantiates a new RawTexture.
  12414. * Raw texture can help creating a texture directly from an array of data.
  12415. * This can be super useful if you either get the data from an uncompressed source or
  12416. * if you wish to create your texture pixel by pixel.
  12417. * @param data define the array of data to use to create the texture
  12418. * @param width define the width of the texture
  12419. * @param height define the height of the texture
  12420. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12421. * @param scene define the scene the texture belongs to
  12422. * @param generateMipMaps define whether mip maps should be generated or not
  12423. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12424. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12425. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12426. */
  12427. constructor(data: ArrayBufferView, width: number, height: number,
  12428. /**
  12429. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12430. */
  12431. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12432. /**
  12433. * Updates the texture underlying data.
  12434. * @param data Define the new data of the texture
  12435. */
  12436. update(data: ArrayBufferView): void;
  12437. /**
  12438. * Creates a luminance texture from some data.
  12439. * @param data Define the texture data
  12440. * @param width Define the width of the texture
  12441. * @param height Define the height of the texture
  12442. * @param scene Define the scene the texture belongs to
  12443. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12444. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12445. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12446. * @returns the luminance texture
  12447. */
  12448. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12449. /**
  12450. * Creates a luminance alpha texture from some data.
  12451. * @param data Define the texture data
  12452. * @param width Define the width of the texture
  12453. * @param height Define the height of the texture
  12454. * @param scene Define the scene the texture belongs to
  12455. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12456. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12457. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12458. * @returns the luminance alpha texture
  12459. */
  12460. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12461. /**
  12462. * Creates an alpha texture from some data.
  12463. * @param data Define the texture data
  12464. * @param width Define the width of the texture
  12465. * @param height Define the height of the texture
  12466. * @param scene Define the scene the texture belongs to
  12467. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12468. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12469. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12470. * @returns the alpha texture
  12471. */
  12472. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12473. /**
  12474. * Creates a RGB texture from some data.
  12475. * @param data Define the texture data
  12476. * @param width Define the width of the texture
  12477. * @param height Define the height of the texture
  12478. * @param scene Define the scene the texture belongs to
  12479. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12480. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12481. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12482. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12483. * @returns the RGB alpha texture
  12484. */
  12485. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12486. /**
  12487. * Creates a RGBA texture from some data.
  12488. * @param data Define the texture data
  12489. * @param width Define the width of the texture
  12490. * @param height Define the height of the texture
  12491. * @param scene Define the scene the texture belongs to
  12492. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12493. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12494. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12495. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12496. * @returns the RGBA texture
  12497. */
  12498. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12499. /**
  12500. * Creates a R texture from some data.
  12501. * @param data Define the texture data
  12502. * @param width Define the width of the texture
  12503. * @param height Define the height of the texture
  12504. * @param scene Define the scene the texture belongs to
  12505. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12506. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12507. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12508. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12509. * @returns the R texture
  12510. */
  12511. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12512. }
  12513. }
  12514. declare module BABYLON {
  12515. /**
  12516. * Interface for the size containing width and height
  12517. */
  12518. export interface ISize {
  12519. /**
  12520. * Width
  12521. */
  12522. width: number;
  12523. /**
  12524. * Heighht
  12525. */
  12526. height: number;
  12527. }
  12528. /**
  12529. * Size containing widht and height
  12530. */
  12531. export class Size implements ISize {
  12532. /**
  12533. * Width
  12534. */
  12535. width: number;
  12536. /**
  12537. * Height
  12538. */
  12539. height: number;
  12540. /**
  12541. * Creates a Size object from the given width and height (floats).
  12542. * @param width width of the new size
  12543. * @param height height of the new size
  12544. */
  12545. constructor(width: number, height: number);
  12546. /**
  12547. * Returns a string with the Size width and height
  12548. * @returns a string with the Size width and height
  12549. */
  12550. toString(): string;
  12551. /**
  12552. * "Size"
  12553. * @returns the string "Size"
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * Returns the Size hash code.
  12558. * @returns a hash code for a unique width and height
  12559. */
  12560. getHashCode(): number;
  12561. /**
  12562. * Updates the current size from the given one.
  12563. * @param src the given size
  12564. */
  12565. copyFrom(src: Size): void;
  12566. /**
  12567. * Updates in place the current Size from the given floats.
  12568. * @param width width of the new size
  12569. * @param height height of the new size
  12570. * @returns the updated Size.
  12571. */
  12572. copyFromFloats(width: number, height: number): Size;
  12573. /**
  12574. * Updates in place the current Size from the given floats.
  12575. * @param width width to set
  12576. * @param height height to set
  12577. * @returns the updated Size.
  12578. */
  12579. set(width: number, height: number): Size;
  12580. /**
  12581. * Multiplies the width and height by numbers
  12582. * @param w factor to multiple the width by
  12583. * @param h factor to multiple the height by
  12584. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12585. */
  12586. multiplyByFloats(w: number, h: number): Size;
  12587. /**
  12588. * Clones the size
  12589. * @returns a new Size copied from the given one.
  12590. */
  12591. clone(): Size;
  12592. /**
  12593. * True if the current Size and the given one width and height are strictly equal.
  12594. * @param other the other size to compare against
  12595. * @returns True if the current Size and the given one width and height are strictly equal.
  12596. */
  12597. equals(other: Size): boolean;
  12598. /**
  12599. * The surface of the Size : width * height (float).
  12600. */
  12601. readonly surface: number;
  12602. /**
  12603. * Create a new size of zero
  12604. * @returns a new Size set to (0.0, 0.0)
  12605. */
  12606. static Zero(): Size;
  12607. /**
  12608. * Sums the width and height of two sizes
  12609. * @param otherSize size to add to this size
  12610. * @returns a new Size set as the addition result of the current Size and the given one.
  12611. */
  12612. add(otherSize: Size): Size;
  12613. /**
  12614. * Subtracts the width and height of two
  12615. * @param otherSize size to subtract to this size
  12616. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12617. */
  12618. subtract(otherSize: Size): Size;
  12619. /**
  12620. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12621. * @param start starting size to lerp between
  12622. * @param end end size to lerp between
  12623. * @param amount amount to lerp between the start and end values
  12624. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12625. */
  12626. static Lerp(start: Size, end: Size, amount: number): Size;
  12627. }
  12628. }
  12629. declare module BABYLON {
  12630. /**
  12631. * Defines a runtime animation
  12632. */
  12633. export class RuntimeAnimation {
  12634. private _events;
  12635. /**
  12636. * The current frame of the runtime animation
  12637. */
  12638. private _currentFrame;
  12639. /**
  12640. * The animation used by the runtime animation
  12641. */
  12642. private _animation;
  12643. /**
  12644. * The target of the runtime animation
  12645. */
  12646. private _target;
  12647. /**
  12648. * The initiating animatable
  12649. */
  12650. private _host;
  12651. /**
  12652. * The original value of the runtime animation
  12653. */
  12654. private _originalValue;
  12655. /**
  12656. * The original blend value of the runtime animation
  12657. */
  12658. private _originalBlendValue;
  12659. /**
  12660. * The offsets cache of the runtime animation
  12661. */
  12662. private _offsetsCache;
  12663. /**
  12664. * The high limits cache of the runtime animation
  12665. */
  12666. private _highLimitsCache;
  12667. /**
  12668. * Specifies if the runtime animation has been stopped
  12669. */
  12670. private _stopped;
  12671. /**
  12672. * The blending factor of the runtime animation
  12673. */
  12674. private _blendingFactor;
  12675. /**
  12676. * The BabylonJS scene
  12677. */
  12678. private _scene;
  12679. /**
  12680. * The current value of the runtime animation
  12681. */
  12682. private _currentValue;
  12683. /** @hidden */
  12684. _animationState: _IAnimationState;
  12685. /**
  12686. * The active target of the runtime animation
  12687. */
  12688. private _activeTargets;
  12689. private _currentActiveTarget;
  12690. private _directTarget;
  12691. /**
  12692. * The target path of the runtime animation
  12693. */
  12694. private _targetPath;
  12695. /**
  12696. * The weight of the runtime animation
  12697. */
  12698. private _weight;
  12699. /**
  12700. * The ratio offset of the runtime animation
  12701. */
  12702. private _ratioOffset;
  12703. /**
  12704. * The previous delay of the runtime animation
  12705. */
  12706. private _previousDelay;
  12707. /**
  12708. * The previous ratio of the runtime animation
  12709. */
  12710. private _previousRatio;
  12711. private _enableBlending;
  12712. private _keys;
  12713. private _minFrame;
  12714. private _maxFrame;
  12715. private _minValue;
  12716. private _maxValue;
  12717. private _targetIsArray;
  12718. /**
  12719. * Gets the current frame of the runtime animation
  12720. */
  12721. readonly currentFrame: number;
  12722. /**
  12723. * Gets the weight of the runtime animation
  12724. */
  12725. readonly weight: number;
  12726. /**
  12727. * Gets the current value of the runtime animation
  12728. */
  12729. readonly currentValue: any;
  12730. /**
  12731. * Gets the target path of the runtime animation
  12732. */
  12733. readonly targetPath: string;
  12734. /**
  12735. * Gets the actual target of the runtime animation
  12736. */
  12737. readonly target: any;
  12738. /** @hidden */
  12739. _onLoop: () => void;
  12740. /**
  12741. * Create a new RuntimeAnimation object
  12742. * @param target defines the target of the animation
  12743. * @param animation defines the source animation object
  12744. * @param scene defines the hosting scene
  12745. * @param host defines the initiating Animatable
  12746. */
  12747. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12748. private _preparePath;
  12749. /**
  12750. * Gets the animation from the runtime animation
  12751. */
  12752. readonly animation: Animation;
  12753. /**
  12754. * Resets the runtime animation to the beginning
  12755. * @param restoreOriginal defines whether to restore the target property to the original value
  12756. */
  12757. reset(restoreOriginal?: boolean): void;
  12758. /**
  12759. * Specifies if the runtime animation is stopped
  12760. * @returns Boolean specifying if the runtime animation is stopped
  12761. */
  12762. isStopped(): boolean;
  12763. /**
  12764. * Disposes of the runtime animation
  12765. */
  12766. dispose(): void;
  12767. /**
  12768. * Apply the interpolated value to the target
  12769. * @param currentValue defines the value computed by the animation
  12770. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12771. */
  12772. setValue(currentValue: any, weight: number): void;
  12773. private _getOriginalValues;
  12774. private _setValue;
  12775. /**
  12776. * Gets the loop pmode of the runtime animation
  12777. * @returns Loop Mode
  12778. */
  12779. private _getCorrectLoopMode;
  12780. /**
  12781. * Move the current animation to a given frame
  12782. * @param frame defines the frame to move to
  12783. */
  12784. goToFrame(frame: number): void;
  12785. /**
  12786. * @hidden Internal use only
  12787. */
  12788. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12789. /**
  12790. * Execute the current animation
  12791. * @param delay defines the delay to add to the current frame
  12792. * @param from defines the lower bound of the animation range
  12793. * @param to defines the upper bound of the animation range
  12794. * @param loop defines if the current animation must loop
  12795. * @param speedRatio defines the current speed ratio
  12796. * @param weight defines the weight of the animation (default is -1 so no weight)
  12797. * @param onLoop optional callback called when animation loops
  12798. * @returns a boolean indicating if the animation is running
  12799. */
  12800. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12801. }
  12802. }
  12803. declare module BABYLON {
  12804. /**
  12805. * Class used to store an actual running animation
  12806. */
  12807. export class Animatable {
  12808. /** defines the target object */
  12809. target: any;
  12810. /** defines the starting frame number (default is 0) */
  12811. fromFrame: number;
  12812. /** defines the ending frame number (default is 100) */
  12813. toFrame: number;
  12814. /** defines if the animation must loop (default is false) */
  12815. loopAnimation: boolean;
  12816. /** defines a callback to call when animation ends if it is not looping */
  12817. onAnimationEnd?: (() => void) | null | undefined;
  12818. /** defines a callback to call when animation loops */
  12819. onAnimationLoop?: (() => void) | null | undefined;
  12820. private _localDelayOffset;
  12821. private _pausedDelay;
  12822. private _runtimeAnimations;
  12823. private _paused;
  12824. private _scene;
  12825. private _speedRatio;
  12826. private _weight;
  12827. private _syncRoot;
  12828. /**
  12829. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12830. * This will only apply for non looping animation (default is true)
  12831. */
  12832. disposeOnEnd: boolean;
  12833. /**
  12834. * Gets a boolean indicating if the animation has started
  12835. */
  12836. animationStarted: boolean;
  12837. /**
  12838. * Observer raised when the animation ends
  12839. */
  12840. onAnimationEndObservable: Observable<Animatable>;
  12841. /**
  12842. * Observer raised when the animation loops
  12843. */
  12844. onAnimationLoopObservable: Observable<Animatable>;
  12845. /**
  12846. * Gets the root Animatable used to synchronize and normalize animations
  12847. */
  12848. readonly syncRoot: Nullable<Animatable>;
  12849. /**
  12850. * Gets the current frame of the first RuntimeAnimation
  12851. * Used to synchronize Animatables
  12852. */
  12853. readonly masterFrame: number;
  12854. /**
  12855. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12856. */
  12857. weight: number;
  12858. /**
  12859. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12860. */
  12861. speedRatio: number;
  12862. /**
  12863. * Creates a new Animatable
  12864. * @param scene defines the hosting scene
  12865. * @param target defines the target object
  12866. * @param fromFrame defines the starting frame number (default is 0)
  12867. * @param toFrame defines the ending frame number (default is 100)
  12868. * @param loopAnimation defines if the animation must loop (default is false)
  12869. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12870. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12871. * @param animations defines a group of animation to add to the new Animatable
  12872. * @param onAnimationLoop defines a callback to call when animation loops
  12873. */
  12874. constructor(scene: Scene,
  12875. /** defines the target object */
  12876. target: any,
  12877. /** defines the starting frame number (default is 0) */
  12878. fromFrame?: number,
  12879. /** defines the ending frame number (default is 100) */
  12880. toFrame?: number,
  12881. /** defines if the animation must loop (default is false) */
  12882. loopAnimation?: boolean, speedRatio?: number,
  12883. /** defines a callback to call when animation ends if it is not looping */
  12884. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12885. /** defines a callback to call when animation loops */
  12886. onAnimationLoop?: (() => void) | null | undefined);
  12887. /**
  12888. * Synchronize and normalize current Animatable with a source Animatable
  12889. * This is useful when using animation weights and when animations are not of the same length
  12890. * @param root defines the root Animatable to synchronize with
  12891. * @returns the current Animatable
  12892. */
  12893. syncWith(root: Animatable): Animatable;
  12894. /**
  12895. * Gets the list of runtime animations
  12896. * @returns an array of RuntimeAnimation
  12897. */
  12898. getAnimations(): RuntimeAnimation[];
  12899. /**
  12900. * Adds more animations to the current animatable
  12901. * @param target defines the target of the animations
  12902. * @param animations defines the new animations to add
  12903. */
  12904. appendAnimations(target: any, animations: Animation[]): void;
  12905. /**
  12906. * Gets the source animation for a specific property
  12907. * @param property defines the propertyu to look for
  12908. * @returns null or the source animation for the given property
  12909. */
  12910. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12911. /**
  12912. * Gets the runtime animation for a specific property
  12913. * @param property defines the propertyu to look for
  12914. * @returns null or the runtime animation for the given property
  12915. */
  12916. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12917. /**
  12918. * Resets the animatable to its original state
  12919. */
  12920. reset(): void;
  12921. /**
  12922. * Allows the animatable to blend with current running animations
  12923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12924. * @param blendingSpeed defines the blending speed to use
  12925. */
  12926. enableBlending(blendingSpeed: number): void;
  12927. /**
  12928. * Disable animation blending
  12929. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12930. */
  12931. disableBlending(): void;
  12932. /**
  12933. * Jump directly to a given frame
  12934. * @param frame defines the frame to jump to
  12935. */
  12936. goToFrame(frame: number): void;
  12937. /**
  12938. * Pause the animation
  12939. */
  12940. pause(): void;
  12941. /**
  12942. * Restart the animation
  12943. */
  12944. restart(): void;
  12945. private _raiseOnAnimationEnd;
  12946. /**
  12947. * Stop and delete the current animation
  12948. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12949. * @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)
  12950. */
  12951. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12952. /**
  12953. * Wait asynchronously for the animation to end
  12954. * @returns a promise which will be fullfilled when the animation ends
  12955. */
  12956. waitAsync(): Promise<Animatable>;
  12957. /** @hidden */
  12958. _animate(delay: number): boolean;
  12959. }
  12960. interface Scene {
  12961. /** @hidden */
  12962. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12963. /** @hidden */
  12964. _processLateAnimationBindingsForMatrices(holder: {
  12965. totalWeight: number;
  12966. animations: RuntimeAnimation[];
  12967. originalValue: Matrix;
  12968. }): any;
  12969. /** @hidden */
  12970. _processLateAnimationBindingsForQuaternions(holder: {
  12971. totalWeight: number;
  12972. animations: RuntimeAnimation[];
  12973. originalValue: Quaternion;
  12974. }, refQuaternion: Quaternion): Quaternion;
  12975. /** @hidden */
  12976. _processLateAnimationBindings(): void;
  12977. /**
  12978. * Will start the animation sequence of a given target
  12979. * @param target defines the target
  12980. * @param from defines from which frame should animation start
  12981. * @param to defines until which frame should animation run.
  12982. * @param weight defines the weight to apply to the animation (1.0 by default)
  12983. * @param loop defines if the animation loops
  12984. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12985. * @param onAnimationEnd defines the function to be executed when the animation ends
  12986. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12987. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12988. * @param onAnimationLoop defines the callback to call when an animation loops
  12989. * @returns the animatable object created for this animation
  12990. */
  12991. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12992. /**
  12993. * Will start the animation sequence of a given target
  12994. * @param target defines the target
  12995. * @param from defines from which frame should animation start
  12996. * @param to defines until which frame should animation run.
  12997. * @param loop defines if the animation loops
  12998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12999. * @param onAnimationEnd defines the function to be executed when the animation ends
  13000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13001. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13002. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13003. * @param onAnimationLoop defines the callback to call when an animation loops
  13004. * @returns the animatable object created for this animation
  13005. */
  13006. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13007. /**
  13008. * Will start the animation sequence of a given target and its hierarchy
  13009. * @param target defines the target
  13010. * @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.
  13011. * @param from defines from which frame should animation start
  13012. * @param to defines until which frame should animation run.
  13013. * @param loop defines if the animation loops
  13014. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13015. * @param onAnimationEnd defines the function to be executed when the animation ends
  13016. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13017. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13018. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13019. * @param onAnimationLoop defines the callback to call when an animation loops
  13020. * @returns the list of created animatables
  13021. */
  13022. 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[];
  13023. /**
  13024. * Begin a new animation on a given node
  13025. * @param target defines the target where the animation will take place
  13026. * @param animations defines the list of animations to start
  13027. * @param from defines the initial value
  13028. * @param to defines the final value
  13029. * @param loop defines if you want animation to loop (off by default)
  13030. * @param speedRatio defines the speed ratio to apply to all animations
  13031. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13032. * @param onAnimationLoop defines the callback to call when an animation loops
  13033. * @returns the list of created animatables
  13034. */
  13035. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13036. /**
  13037. * Begin a new animation on a given node and its hierarchy
  13038. * @param target defines the root node where the animation will take place
  13039. * @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.
  13040. * @param animations defines the list of animations to start
  13041. * @param from defines the initial value
  13042. * @param to defines the final value
  13043. * @param loop defines if you want animation to loop (off by default)
  13044. * @param speedRatio defines the speed ratio to apply to all animations
  13045. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13046. * @param onAnimationLoop defines the callback to call when an animation loops
  13047. * @returns the list of animatables created for all nodes
  13048. */
  13049. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13050. /**
  13051. * Gets the animatable associated with a specific target
  13052. * @param target defines the target of the animatable
  13053. * @returns the required animatable if found
  13054. */
  13055. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13056. /**
  13057. * Gets all animatables associated with a given target
  13058. * @param target defines the target to look animatables for
  13059. * @returns an array of Animatables
  13060. */
  13061. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13062. /**
  13063. * Stops and removes all animations that have been applied to the scene
  13064. */
  13065. stopAllAnimations(): void;
  13066. /**
  13067. * Gets the current delta time used by animation engine
  13068. */
  13069. deltaTime: number;
  13070. }
  13071. interface Bone {
  13072. /**
  13073. * Copy an animation range from another bone
  13074. * @param source defines the source bone
  13075. * @param rangeName defines the range name to copy
  13076. * @param frameOffset defines the frame offset
  13077. * @param rescaleAsRequired defines if rescaling must be applied if required
  13078. * @param skelDimensionsRatio defines the scaling ratio
  13079. * @returns true if operation was successful
  13080. */
  13081. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Class used to override all child animations of a given target
  13087. */
  13088. export class AnimationPropertiesOverride {
  13089. /**
  13090. * Gets or sets a value indicating if animation blending must be used
  13091. */
  13092. enableBlending: boolean;
  13093. /**
  13094. * Gets or sets the blending speed to use when enableBlending is true
  13095. */
  13096. blendingSpeed: number;
  13097. /**
  13098. * Gets or sets the default loop mode to use
  13099. */
  13100. loopMode: number;
  13101. }
  13102. }
  13103. declare module BABYLON {
  13104. /**
  13105. * Class used to handle skinning animations
  13106. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13107. */
  13108. export class Skeleton implements IAnimatable {
  13109. /** defines the skeleton name */
  13110. name: string;
  13111. /** defines the skeleton Id */
  13112. id: string;
  13113. /**
  13114. * Defines the list of child bones
  13115. */
  13116. bones: Bone[];
  13117. /**
  13118. * Defines an estimate of the dimension of the skeleton at rest
  13119. */
  13120. dimensionsAtRest: Vector3;
  13121. /**
  13122. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13123. */
  13124. needInitialSkinMatrix: boolean;
  13125. /**
  13126. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13127. */
  13128. overrideMesh: Nullable<AbstractMesh>;
  13129. /**
  13130. * Gets the list of animations attached to this skeleton
  13131. */
  13132. animations: Array<Animation>;
  13133. private _scene;
  13134. private _isDirty;
  13135. private _transformMatrices;
  13136. private _transformMatrixTexture;
  13137. private _meshesWithPoseMatrix;
  13138. private _animatables;
  13139. private _identity;
  13140. private _synchronizedWithMesh;
  13141. private _ranges;
  13142. private _lastAbsoluteTransformsUpdateId;
  13143. private _canUseTextureForBones;
  13144. private _uniqueId;
  13145. /** @hidden */
  13146. _numBonesWithLinkedTransformNode: number;
  13147. /** @hidden */
  13148. _hasWaitingData: Nullable<boolean>;
  13149. /**
  13150. * Specifies if the skeleton should be serialized
  13151. */
  13152. doNotSerialize: boolean;
  13153. private _useTextureToStoreBoneMatrices;
  13154. /**
  13155. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13156. * Please note that this option is not available if the hardware does not support it
  13157. */
  13158. useTextureToStoreBoneMatrices: boolean;
  13159. private _animationPropertiesOverride;
  13160. /**
  13161. * Gets or sets the animation properties override
  13162. */
  13163. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13164. /**
  13165. * List of inspectable custom properties (used by the Inspector)
  13166. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13167. */
  13168. inspectableCustomProperties: IInspectable[];
  13169. /**
  13170. * An observable triggered before computing the skeleton's matrices
  13171. */
  13172. onBeforeComputeObservable: Observable<Skeleton>;
  13173. /**
  13174. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13175. */
  13176. readonly isUsingTextureForMatrices: boolean;
  13177. /**
  13178. * Gets the unique ID of this skeleton
  13179. */
  13180. readonly uniqueId: number;
  13181. /**
  13182. * Creates a new skeleton
  13183. * @param name defines the skeleton name
  13184. * @param id defines the skeleton Id
  13185. * @param scene defines the hosting scene
  13186. */
  13187. constructor(
  13188. /** defines the skeleton name */
  13189. name: string,
  13190. /** defines the skeleton Id */
  13191. id: string, scene: Scene);
  13192. /**
  13193. * Gets the current object class name.
  13194. * @return the class name
  13195. */
  13196. getClassName(): string;
  13197. /**
  13198. * Returns an array containing the root bones
  13199. * @returns an array containing the root bones
  13200. */
  13201. getChildren(): Array<Bone>;
  13202. /**
  13203. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13204. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13205. * @returns a Float32Array containing matrices data
  13206. */
  13207. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13208. /**
  13209. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13210. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13211. * @returns a raw texture containing the data
  13212. */
  13213. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13214. /**
  13215. * Gets the current hosting scene
  13216. * @returns a scene object
  13217. */
  13218. getScene(): Scene;
  13219. /**
  13220. * Gets a string representing the current skeleton data
  13221. * @param fullDetails defines a boolean indicating if we want a verbose version
  13222. * @returns a string representing the current skeleton data
  13223. */
  13224. toString(fullDetails?: boolean): string;
  13225. /**
  13226. * Get bone's index searching by name
  13227. * @param name defines bone's name to search for
  13228. * @return the indice of the bone. Returns -1 if not found
  13229. */
  13230. getBoneIndexByName(name: string): number;
  13231. /**
  13232. * Creater a new animation range
  13233. * @param name defines the name of the range
  13234. * @param from defines the start key
  13235. * @param to defines the end key
  13236. */
  13237. createAnimationRange(name: string, from: number, to: number): void;
  13238. /**
  13239. * Delete a specific animation range
  13240. * @param name defines the name of the range
  13241. * @param deleteFrames defines if frames must be removed as well
  13242. */
  13243. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13244. /**
  13245. * Gets a specific animation range
  13246. * @param name defines the name of the range to look for
  13247. * @returns the requested animation range or null if not found
  13248. */
  13249. getAnimationRange(name: string): Nullable<AnimationRange>;
  13250. /**
  13251. * Gets the list of all animation ranges defined on this skeleton
  13252. * @returns an array
  13253. */
  13254. getAnimationRanges(): Nullable<AnimationRange>[];
  13255. /**
  13256. * Copy animation range from a source skeleton.
  13257. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13258. * @param source defines the source skeleton
  13259. * @param name defines the name of the range to copy
  13260. * @param rescaleAsRequired defines if rescaling must be applied if required
  13261. * @returns true if operation was successful
  13262. */
  13263. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13264. /**
  13265. * Forces the skeleton to go to rest pose
  13266. */
  13267. returnToRest(): void;
  13268. private _getHighestAnimationFrame;
  13269. /**
  13270. * Begin a specific animation range
  13271. * @param name defines the name of the range to start
  13272. * @param loop defines if looping must be turned on (false by default)
  13273. * @param speedRatio defines the speed ratio to apply (1 by default)
  13274. * @param onAnimationEnd defines a callback which will be called when animation will end
  13275. * @returns a new animatable
  13276. */
  13277. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13278. /** @hidden */
  13279. _markAsDirty(): void;
  13280. /** @hidden */
  13281. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13282. /** @hidden */
  13283. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13284. private _computeTransformMatrices;
  13285. /**
  13286. * Build all resources required to render a skeleton
  13287. */
  13288. prepare(): void;
  13289. /**
  13290. * Gets the list of animatables currently running for this skeleton
  13291. * @returns an array of animatables
  13292. */
  13293. getAnimatables(): IAnimatable[];
  13294. /**
  13295. * Clone the current skeleton
  13296. * @param name defines the name of the new skeleton
  13297. * @param id defines the id of the new skeleton
  13298. * @returns the new skeleton
  13299. */
  13300. clone(name: string, id: string): Skeleton;
  13301. /**
  13302. * Enable animation blending for this skeleton
  13303. * @param blendingSpeed defines the blending speed to apply
  13304. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13305. */
  13306. enableBlending(blendingSpeed?: number): void;
  13307. /**
  13308. * Releases all resources associated with the current skeleton
  13309. */
  13310. dispose(): void;
  13311. /**
  13312. * Serialize the skeleton in a JSON object
  13313. * @returns a JSON object
  13314. */
  13315. serialize(): any;
  13316. /**
  13317. * Creates a new skeleton from serialized data
  13318. * @param parsedSkeleton defines the serialized data
  13319. * @param scene defines the hosting scene
  13320. * @returns a new skeleton
  13321. */
  13322. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13323. /**
  13324. * Compute all node absolute transforms
  13325. * @param forceUpdate defines if computation must be done even if cache is up to date
  13326. */
  13327. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13328. /**
  13329. * Gets the root pose matrix
  13330. * @returns a matrix
  13331. */
  13332. getPoseMatrix(): Nullable<Matrix>;
  13333. /**
  13334. * Sorts bones per internal index
  13335. */
  13336. sortBones(): void;
  13337. private _sortBones;
  13338. }
  13339. }
  13340. declare module BABYLON {
  13341. /**
  13342. * Class used to store bone information
  13343. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13344. */
  13345. export class Bone extends Node {
  13346. /**
  13347. * defines the bone name
  13348. */
  13349. name: string;
  13350. private static _tmpVecs;
  13351. private static _tmpQuat;
  13352. private static _tmpMats;
  13353. /**
  13354. * Gets the list of child bones
  13355. */
  13356. children: Bone[];
  13357. /** Gets the animations associated with this bone */
  13358. animations: Animation[];
  13359. /**
  13360. * Gets or sets bone length
  13361. */
  13362. length: number;
  13363. /**
  13364. * @hidden Internal only
  13365. * Set this value to map this bone to a different index in the transform matrices
  13366. * Set this value to -1 to exclude the bone from the transform matrices
  13367. */
  13368. _index: Nullable<number>;
  13369. private _skeleton;
  13370. private _localMatrix;
  13371. private _restPose;
  13372. private _baseMatrix;
  13373. private _absoluteTransform;
  13374. private _invertedAbsoluteTransform;
  13375. private _parent;
  13376. private _scalingDeterminant;
  13377. private _worldTransform;
  13378. private _localScaling;
  13379. private _localRotation;
  13380. private _localPosition;
  13381. private _needToDecompose;
  13382. private _needToCompose;
  13383. /** @hidden */
  13384. _linkedTransformNode: Nullable<TransformNode>;
  13385. /** @hidden */
  13386. _waitingTransformNodeId: Nullable<string>;
  13387. /** @hidden */
  13388. /** @hidden */
  13389. _matrix: Matrix;
  13390. /**
  13391. * Create a new bone
  13392. * @param name defines the bone name
  13393. * @param skeleton defines the parent skeleton
  13394. * @param parentBone defines the parent (can be null if the bone is the root)
  13395. * @param localMatrix defines the local matrix
  13396. * @param restPose defines the rest pose matrix
  13397. * @param baseMatrix defines the base matrix
  13398. * @param index defines index of the bone in the hiearchy
  13399. */
  13400. constructor(
  13401. /**
  13402. * defines the bone name
  13403. */
  13404. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13405. /**
  13406. * Gets the current object class name.
  13407. * @return the class name
  13408. */
  13409. getClassName(): string;
  13410. /**
  13411. * Gets the parent skeleton
  13412. * @returns a skeleton
  13413. */
  13414. getSkeleton(): Skeleton;
  13415. /**
  13416. * Gets parent bone
  13417. * @returns a bone or null if the bone is the root of the bone hierarchy
  13418. */
  13419. getParent(): Nullable<Bone>;
  13420. /**
  13421. * Returns an array containing the root bones
  13422. * @returns an array containing the root bones
  13423. */
  13424. getChildren(): Array<Bone>;
  13425. /**
  13426. * Sets the parent bone
  13427. * @param parent defines the parent (can be null if the bone is the root)
  13428. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13429. */
  13430. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13431. /**
  13432. * Gets the local matrix
  13433. * @returns a matrix
  13434. */
  13435. getLocalMatrix(): Matrix;
  13436. /**
  13437. * Gets the base matrix (initial matrix which remains unchanged)
  13438. * @returns a matrix
  13439. */
  13440. getBaseMatrix(): Matrix;
  13441. /**
  13442. * Gets the rest pose matrix
  13443. * @returns a matrix
  13444. */
  13445. getRestPose(): Matrix;
  13446. /**
  13447. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13448. */
  13449. getWorldMatrix(): Matrix;
  13450. /**
  13451. * Sets the local matrix to rest pose matrix
  13452. */
  13453. returnToRest(): void;
  13454. /**
  13455. * Gets the inverse of the absolute transform matrix.
  13456. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13457. * @returns a matrix
  13458. */
  13459. getInvertedAbsoluteTransform(): Matrix;
  13460. /**
  13461. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13462. * @returns a matrix
  13463. */
  13464. getAbsoluteTransform(): Matrix;
  13465. /**
  13466. * Links with the given transform node.
  13467. * The local matrix of this bone is copied from the transform node every frame.
  13468. * @param transformNode defines the transform node to link to
  13469. */
  13470. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13471. /**
  13472. * Gets the node used to drive the bone's transformation
  13473. * @returns a transform node or null
  13474. */
  13475. getTransformNode(): Nullable<TransformNode>;
  13476. /** Gets or sets current position (in local space) */
  13477. position: Vector3;
  13478. /** Gets or sets current rotation (in local space) */
  13479. rotation: Vector3;
  13480. /** Gets or sets current rotation quaternion (in local space) */
  13481. rotationQuaternion: Quaternion;
  13482. /** Gets or sets current scaling (in local space) */
  13483. scaling: Vector3;
  13484. /**
  13485. * Gets the animation properties override
  13486. */
  13487. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13488. private _decompose;
  13489. private _compose;
  13490. /**
  13491. * Update the base and local matrices
  13492. * @param matrix defines the new base or local matrix
  13493. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13494. * @param updateLocalMatrix defines if the local matrix should be updated
  13495. */
  13496. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13497. /** @hidden */
  13498. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13499. /**
  13500. * Flag the bone as dirty (Forcing it to update everything)
  13501. */
  13502. markAsDirty(): void;
  13503. /** @hidden */
  13504. _markAsDirtyAndCompose(): void;
  13505. private _markAsDirtyAndDecompose;
  13506. /**
  13507. * Translate the bone in local or world space
  13508. * @param vec The amount to translate the bone
  13509. * @param space The space that the translation is in
  13510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13511. */
  13512. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13513. /**
  13514. * Set the postion of the bone in local or world space
  13515. * @param position The position to set the bone
  13516. * @param space The space that the position is in
  13517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13518. */
  13519. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13520. /**
  13521. * Set the absolute position of the bone (world space)
  13522. * @param position The position to set the bone
  13523. * @param mesh The mesh that this bone is attached to
  13524. */
  13525. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13526. /**
  13527. * Scale the bone on the x, y and z axes (in local space)
  13528. * @param x The amount to scale the bone on the x axis
  13529. * @param y The amount to scale the bone on the y axis
  13530. * @param z The amount to scale the bone on the z axis
  13531. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13532. */
  13533. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13534. /**
  13535. * Set the bone scaling in local space
  13536. * @param scale defines the scaling vector
  13537. */
  13538. setScale(scale: Vector3): void;
  13539. /**
  13540. * Gets the current scaling in local space
  13541. * @returns the current scaling vector
  13542. */
  13543. getScale(): Vector3;
  13544. /**
  13545. * Gets the current scaling in local space and stores it in a target vector
  13546. * @param result defines the target vector
  13547. */
  13548. getScaleToRef(result: Vector3): void;
  13549. /**
  13550. * Set the yaw, pitch, and roll of the bone in local or world space
  13551. * @param yaw The rotation of the bone on the y axis
  13552. * @param pitch The rotation of the bone on the x axis
  13553. * @param roll The rotation of the bone on the z axis
  13554. * @param space The space that the axes of rotation are in
  13555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13556. */
  13557. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13558. /**
  13559. * Add a rotation to the bone on an axis in local or world space
  13560. * @param axis The axis to rotate the bone on
  13561. * @param amount The amount to rotate the bone
  13562. * @param space The space that the axis is in
  13563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13564. */
  13565. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13566. /**
  13567. * Set the rotation of the bone to a particular axis angle in local or world space
  13568. * @param axis The axis to rotate the bone on
  13569. * @param angle The angle that the bone should be rotated to
  13570. * @param space The space that the axis is in
  13571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13572. */
  13573. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13574. /**
  13575. * Set the euler rotation of the bone in local of world space
  13576. * @param rotation The euler rotation that the bone should be set to
  13577. * @param space The space that the rotation is in
  13578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13579. */
  13580. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13581. /**
  13582. * Set the quaternion rotation of the bone in local of world space
  13583. * @param quat The quaternion rotation that the bone should be set to
  13584. * @param space The space that the rotation is in
  13585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13586. */
  13587. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13588. /**
  13589. * Set the rotation matrix of the bone in local of world space
  13590. * @param rotMat The rotation matrix that the bone should be set to
  13591. * @param space The space that the rotation is in
  13592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13593. */
  13594. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13595. private _rotateWithMatrix;
  13596. private _getNegativeRotationToRef;
  13597. /**
  13598. * Get the position of the bone in local or world space
  13599. * @param space The space that the returned position is in
  13600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13601. * @returns The position of the bone
  13602. */
  13603. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13604. /**
  13605. * Copy the position of the bone to a vector3 in local or world space
  13606. * @param space The space that the returned position is in
  13607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13608. * @param result The vector3 to copy the position to
  13609. */
  13610. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13611. /**
  13612. * Get the absolute position of the bone (world space)
  13613. * @param mesh The mesh that this bone is attached to
  13614. * @returns The absolute position of the bone
  13615. */
  13616. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13617. /**
  13618. * Copy the absolute position of the bone (world space) to the result param
  13619. * @param mesh The mesh that this bone is attached to
  13620. * @param result The vector3 to copy the absolute position to
  13621. */
  13622. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13623. /**
  13624. * Compute the absolute transforms of this bone and its children
  13625. */
  13626. computeAbsoluteTransforms(): void;
  13627. /**
  13628. * Get the world direction from an axis that is in the local space of the bone
  13629. * @param localAxis The local direction that is used to compute the world direction
  13630. * @param mesh The mesh that this bone is attached to
  13631. * @returns The world direction
  13632. */
  13633. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13634. /**
  13635. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13636. * @param localAxis The local direction that is used to compute the world direction
  13637. * @param mesh The mesh that this bone is attached to
  13638. * @param result The vector3 that the world direction will be copied to
  13639. */
  13640. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13641. /**
  13642. * Get the euler rotation of the bone in local or world space
  13643. * @param space The space that the rotation should be in
  13644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13645. * @returns The euler rotation
  13646. */
  13647. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13648. /**
  13649. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13650. * @param space The space that the rotation should be in
  13651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13652. * @param result The vector3 that the rotation should be copied to
  13653. */
  13654. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13655. /**
  13656. * Get the quaternion rotation of the bone in either local or world space
  13657. * @param space The space that the rotation should be in
  13658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13659. * @returns The quaternion rotation
  13660. */
  13661. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13662. /**
  13663. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13664. * @param space The space that the rotation should be in
  13665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13666. * @param result The quaternion that the rotation should be copied to
  13667. */
  13668. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13669. /**
  13670. * Get the rotation matrix of the bone in local or world space
  13671. * @param space The space that the rotation should be in
  13672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13673. * @returns The rotation matrix
  13674. */
  13675. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13676. /**
  13677. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13678. * @param space The space that the rotation should be in
  13679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13680. * @param result The quaternion that the rotation should be copied to
  13681. */
  13682. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13683. /**
  13684. * Get the world position of a point that is in the local space of the bone
  13685. * @param position The local position
  13686. * @param mesh The mesh that this bone is attached to
  13687. * @returns The world position
  13688. */
  13689. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13690. /**
  13691. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13692. * @param position The local position
  13693. * @param mesh The mesh that this bone is attached to
  13694. * @param result The vector3 that the world position should be copied to
  13695. */
  13696. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13697. /**
  13698. * Get the local position of a point that is in world space
  13699. * @param position The world position
  13700. * @param mesh The mesh that this bone is attached to
  13701. * @returns The local position
  13702. */
  13703. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13704. /**
  13705. * Get the local position of a point that is in world space and copy it to the result param
  13706. * @param position The world position
  13707. * @param mesh The mesh that this bone is attached to
  13708. * @param result The vector3 that the local position should be copied to
  13709. */
  13710. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13711. }
  13712. }
  13713. declare module BABYLON {
  13714. /**
  13715. * 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.
  13716. * @see https://doc.babylonjs.com/how_to/transformnode
  13717. */
  13718. export class TransformNode extends Node {
  13719. /**
  13720. * Object will not rotate to face the camera
  13721. */
  13722. static BILLBOARDMODE_NONE: number;
  13723. /**
  13724. * Object will rotate to face the camera but only on the x axis
  13725. */
  13726. static BILLBOARDMODE_X: number;
  13727. /**
  13728. * Object will rotate to face the camera but only on the y axis
  13729. */
  13730. static BILLBOARDMODE_Y: number;
  13731. /**
  13732. * Object will rotate to face the camera but only on the z axis
  13733. */
  13734. static BILLBOARDMODE_Z: number;
  13735. /**
  13736. * Object will rotate to face the camera
  13737. */
  13738. static BILLBOARDMODE_ALL: number;
  13739. /**
  13740. * Object will rotate to face the camera's position instead of orientation
  13741. */
  13742. static BILLBOARDMODE_USE_POSITION: number;
  13743. private _forward;
  13744. private _forwardInverted;
  13745. private _up;
  13746. private _right;
  13747. private _rightInverted;
  13748. private _position;
  13749. private _rotation;
  13750. private _rotationQuaternion;
  13751. protected _scaling: Vector3;
  13752. protected _isDirty: boolean;
  13753. private _transformToBoneReferal;
  13754. private _isAbsoluteSynced;
  13755. private _billboardMode;
  13756. /**
  13757. * Gets or sets the billboard mode. Default is 0.
  13758. *
  13759. * | Value | Type | Description |
  13760. * | --- | --- | --- |
  13761. * | 0 | BILLBOARDMODE_NONE | |
  13762. * | 1 | BILLBOARDMODE_X | |
  13763. * | 2 | BILLBOARDMODE_Y | |
  13764. * | 4 | BILLBOARDMODE_Z | |
  13765. * | 7 | BILLBOARDMODE_ALL | |
  13766. *
  13767. */
  13768. billboardMode: number;
  13769. private _preserveParentRotationForBillboard;
  13770. /**
  13771. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13772. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13773. */
  13774. preserveParentRotationForBillboard: boolean;
  13775. /**
  13776. * 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
  13777. */
  13778. scalingDeterminant: number;
  13779. private _infiniteDistance;
  13780. /**
  13781. * Gets or sets the distance of the object to max, often used by skybox
  13782. */
  13783. infiniteDistance: boolean;
  13784. /**
  13785. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13786. * By default the system will update normals to compensate
  13787. */
  13788. ignoreNonUniformScaling: boolean;
  13789. /**
  13790. * 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
  13791. */
  13792. reIntegrateRotationIntoRotationQuaternion: boolean;
  13793. /** @hidden */
  13794. _poseMatrix: Nullable<Matrix>;
  13795. /** @hidden */
  13796. _localMatrix: Matrix;
  13797. private _usePivotMatrix;
  13798. private _absolutePosition;
  13799. private _absoluteScaling;
  13800. private _absoluteRotationQuaternion;
  13801. private _pivotMatrix;
  13802. private _pivotMatrixInverse;
  13803. protected _postMultiplyPivotMatrix: boolean;
  13804. protected _isWorldMatrixFrozen: boolean;
  13805. /** @hidden */
  13806. _indexInSceneTransformNodesArray: number;
  13807. /**
  13808. * An event triggered after the world matrix is updated
  13809. */
  13810. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13811. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13812. /**
  13813. * Gets a string identifying the name of the class
  13814. * @returns "TransformNode" string
  13815. */
  13816. getClassName(): string;
  13817. /**
  13818. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13819. */
  13820. position: Vector3;
  13821. /**
  13822. * 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)).
  13823. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13824. */
  13825. rotation: Vector3;
  13826. /**
  13827. * 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)).
  13828. */
  13829. scaling: Vector3;
  13830. /**
  13831. * 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).
  13832. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13833. */
  13834. rotationQuaternion: Nullable<Quaternion>;
  13835. /**
  13836. * The forward direction of that transform in world space.
  13837. */
  13838. readonly forward: Vector3;
  13839. /**
  13840. * The up direction of that transform in world space.
  13841. */
  13842. readonly up: Vector3;
  13843. /**
  13844. * The right direction of that transform in world space.
  13845. */
  13846. readonly right: Vector3;
  13847. /**
  13848. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13849. * @param matrix the matrix to copy the pose from
  13850. * @returns this TransformNode.
  13851. */
  13852. updatePoseMatrix(matrix: Matrix): TransformNode;
  13853. /**
  13854. * Returns the mesh Pose matrix.
  13855. * @returns the pose matrix
  13856. */
  13857. getPoseMatrix(): Matrix;
  13858. /** @hidden */
  13859. _isSynchronized(): boolean;
  13860. /** @hidden */
  13861. _initCache(): void;
  13862. /**
  13863. * Flag the transform node as dirty (Forcing it to update everything)
  13864. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13865. * @returns this transform node
  13866. */
  13867. markAsDirty(property: string): TransformNode;
  13868. /**
  13869. * Returns the current mesh absolute position.
  13870. * Returns a Vector3.
  13871. */
  13872. readonly absolutePosition: Vector3;
  13873. /**
  13874. * Returns the current mesh absolute scaling.
  13875. * Returns a Vector3.
  13876. */
  13877. readonly absoluteScaling: Vector3;
  13878. /**
  13879. * Returns the current mesh absolute rotation.
  13880. * Returns a Quaternion.
  13881. */
  13882. readonly absoluteRotationQuaternion: Quaternion;
  13883. /**
  13884. * Sets a new matrix to apply before all other transformation
  13885. * @param matrix defines the transform matrix
  13886. * @returns the current TransformNode
  13887. */
  13888. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13889. /**
  13890. * Sets a new pivot matrix to the current node
  13891. * @param matrix defines the new pivot matrix to use
  13892. * @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
  13893. * @returns the current TransformNode
  13894. */
  13895. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13896. /**
  13897. * Returns the mesh pivot matrix.
  13898. * Default : Identity.
  13899. * @returns the matrix
  13900. */
  13901. getPivotMatrix(): Matrix;
  13902. /**
  13903. * Instantiate (when possible) or clone that node with its hierarchy
  13904. * @param newParent defines the new parent to use for the instance (or clone)
  13905. * @returns an instance (or a clone) of the current node with its hiearchy
  13906. */
  13907. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13908. /**
  13909. * Prevents the World matrix to be computed any longer
  13910. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13911. * @returns the TransformNode.
  13912. */
  13913. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13914. /**
  13915. * Allows back the World matrix computation.
  13916. * @returns the TransformNode.
  13917. */
  13918. unfreezeWorldMatrix(): this;
  13919. /**
  13920. * True if the World matrix has been frozen.
  13921. */
  13922. readonly isWorldMatrixFrozen: boolean;
  13923. /**
  13924. * Retuns the mesh absolute position in the World.
  13925. * @returns a Vector3.
  13926. */
  13927. getAbsolutePosition(): Vector3;
  13928. /**
  13929. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13930. * @param absolutePosition the absolute position to set
  13931. * @returns the TransformNode.
  13932. */
  13933. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13934. /**
  13935. * Sets the mesh position in its local space.
  13936. * @param vector3 the position to set in localspace
  13937. * @returns the TransformNode.
  13938. */
  13939. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13940. /**
  13941. * Returns the mesh position in the local space from the current World matrix values.
  13942. * @returns a new Vector3.
  13943. */
  13944. getPositionExpressedInLocalSpace(): Vector3;
  13945. /**
  13946. * Translates the mesh along the passed Vector3 in its local space.
  13947. * @param vector3 the distance to translate in localspace
  13948. * @returns the TransformNode.
  13949. */
  13950. locallyTranslate(vector3: Vector3): TransformNode;
  13951. private static _lookAtVectorCache;
  13952. /**
  13953. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13954. * @param targetPoint the position (must be in same space as current mesh) to look at
  13955. * @param yawCor optional yaw (y-axis) correction in radians
  13956. * @param pitchCor optional pitch (x-axis) correction in radians
  13957. * @param rollCor optional roll (z-axis) correction in radians
  13958. * @param space the choosen space of the target
  13959. * @returns the TransformNode.
  13960. */
  13961. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13962. /**
  13963. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13964. * This Vector3 is expressed in the World space.
  13965. * @param localAxis axis to rotate
  13966. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13967. */
  13968. getDirection(localAxis: Vector3): Vector3;
  13969. /**
  13970. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13971. * localAxis is expressed in the mesh local space.
  13972. * result is computed in the Wordl space from the mesh World matrix.
  13973. * @param localAxis axis to rotate
  13974. * @param result the resulting transformnode
  13975. * @returns this TransformNode.
  13976. */
  13977. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13978. /**
  13979. * Sets this transform node rotation to the given local axis.
  13980. * @param localAxis the axis in local space
  13981. * @param yawCor optional yaw (y-axis) correction in radians
  13982. * @param pitchCor optional pitch (x-axis) correction in radians
  13983. * @param rollCor optional roll (z-axis) correction in radians
  13984. * @returns this TransformNode
  13985. */
  13986. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13987. /**
  13988. * Sets a new pivot point to the current node
  13989. * @param point defines the new pivot point to use
  13990. * @param space defines if the point is in world or local space (local by default)
  13991. * @returns the current TransformNode
  13992. */
  13993. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13994. /**
  13995. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13996. * @returns the pivot point
  13997. */
  13998. getPivotPoint(): Vector3;
  13999. /**
  14000. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14001. * @param result the vector3 to store the result
  14002. * @returns this TransformNode.
  14003. */
  14004. getPivotPointToRef(result: Vector3): TransformNode;
  14005. /**
  14006. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14007. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14008. */
  14009. getAbsolutePivotPoint(): Vector3;
  14010. /**
  14011. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14012. * @param result vector3 to store the result
  14013. * @returns this TransformNode.
  14014. */
  14015. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14016. /**
  14017. * Defines the passed node as the parent of the current node.
  14018. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14019. * @see https://doc.babylonjs.com/how_to/parenting
  14020. * @param node the node ot set as the parent
  14021. * @returns this TransformNode.
  14022. */
  14023. setParent(node: Nullable<Node>): TransformNode;
  14024. private _nonUniformScaling;
  14025. /**
  14026. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14027. */
  14028. readonly nonUniformScaling: boolean;
  14029. /** @hidden */
  14030. _updateNonUniformScalingState(value: boolean): boolean;
  14031. /**
  14032. * Attach the current TransformNode to another TransformNode associated with a bone
  14033. * @param bone Bone affecting the TransformNode
  14034. * @param affectedTransformNode TransformNode associated with the bone
  14035. * @returns this object
  14036. */
  14037. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14038. /**
  14039. * Detach the transform node if its associated with a bone
  14040. * @returns this object
  14041. */
  14042. detachFromBone(): TransformNode;
  14043. private static _rotationAxisCache;
  14044. /**
  14045. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14046. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14047. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14048. * The passed axis is also normalized.
  14049. * @param axis the axis to rotate around
  14050. * @param amount the amount to rotate in radians
  14051. * @param space Space to rotate in (Default: local)
  14052. * @returns the TransformNode.
  14053. */
  14054. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14055. /**
  14056. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14058. * The passed axis is also normalized. .
  14059. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14060. * @param point the point to rotate around
  14061. * @param axis the axis to rotate around
  14062. * @param amount the amount to rotate in radians
  14063. * @returns the TransformNode
  14064. */
  14065. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14066. /**
  14067. * Translates the mesh along the axis vector for the passed distance in the given space.
  14068. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14069. * @param axis the axis to translate in
  14070. * @param distance the distance to translate
  14071. * @param space Space to rotate in (Default: local)
  14072. * @returns the TransformNode.
  14073. */
  14074. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14075. /**
  14076. * Adds a rotation step to the mesh current rotation.
  14077. * x, y, z are Euler angles expressed in radians.
  14078. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14079. * This means this rotation is made in the mesh local space only.
  14080. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14081. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14082. * ```javascript
  14083. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14084. * ```
  14085. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14086. * 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.
  14087. * @param x Rotation to add
  14088. * @param y Rotation to add
  14089. * @param z Rotation to add
  14090. * @returns the TransformNode.
  14091. */
  14092. addRotation(x: number, y: number, z: number): TransformNode;
  14093. /**
  14094. * @hidden
  14095. */
  14096. protected _getEffectiveParent(): Nullable<Node>;
  14097. /**
  14098. * Computes the world matrix of the node
  14099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14100. * @returns the world matrix
  14101. */
  14102. computeWorldMatrix(force?: boolean): Matrix;
  14103. protected _afterComputeWorldMatrix(): void;
  14104. /**
  14105. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14106. * @param func callback function to add
  14107. *
  14108. * @returns the TransformNode.
  14109. */
  14110. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14111. /**
  14112. * Removes a registered callback function.
  14113. * @param func callback function to remove
  14114. * @returns the TransformNode.
  14115. */
  14116. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14117. /**
  14118. * Gets the position of the current mesh in camera space
  14119. * @param camera defines the camera to use
  14120. * @returns a position
  14121. */
  14122. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14123. /**
  14124. * Returns the distance from the mesh to the active camera
  14125. * @param camera defines the camera to use
  14126. * @returns the distance
  14127. */
  14128. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14129. /**
  14130. * Clone the current transform node
  14131. * @param name Name of the new clone
  14132. * @param newParent New parent for the clone
  14133. * @param doNotCloneChildren Do not clone children hierarchy
  14134. * @returns the new transform node
  14135. */
  14136. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14137. /**
  14138. * Serializes the objects information.
  14139. * @param currentSerializationObject defines the object to serialize in
  14140. * @returns the serialized object
  14141. */
  14142. serialize(currentSerializationObject?: any): any;
  14143. /**
  14144. * Returns a new TransformNode object parsed from the source provided.
  14145. * @param parsedTransformNode is the source.
  14146. * @param scene the scne the object belongs to
  14147. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14148. * @returns a new TransformNode object parsed from the source provided.
  14149. */
  14150. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14151. /**
  14152. * Get all child-transformNodes of this node
  14153. * @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
  14154. * @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
  14155. * @returns an array of TransformNode
  14156. */
  14157. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14158. /**
  14159. * Releases resources associated with this transform node.
  14160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14162. */
  14163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14164. /**
  14165. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14166. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14167. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14168. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14169. * @returns the current mesh
  14170. */
  14171. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14172. private _syncAbsoluteScalingAndRotation;
  14173. }
  14174. }
  14175. declare module BABYLON {
  14176. /**
  14177. * Defines the types of pose enabled controllers that are supported
  14178. */
  14179. export enum PoseEnabledControllerType {
  14180. /**
  14181. * HTC Vive
  14182. */
  14183. VIVE = 0,
  14184. /**
  14185. * Oculus Rift
  14186. */
  14187. OCULUS = 1,
  14188. /**
  14189. * Windows mixed reality
  14190. */
  14191. WINDOWS = 2,
  14192. /**
  14193. * Samsung gear VR
  14194. */
  14195. GEAR_VR = 3,
  14196. /**
  14197. * Google Daydream
  14198. */
  14199. DAYDREAM = 4,
  14200. /**
  14201. * Generic
  14202. */
  14203. GENERIC = 5
  14204. }
  14205. /**
  14206. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14207. */
  14208. export interface MutableGamepadButton {
  14209. /**
  14210. * Value of the button/trigger
  14211. */
  14212. value: number;
  14213. /**
  14214. * If the button/trigger is currently touched
  14215. */
  14216. touched: boolean;
  14217. /**
  14218. * If the button/trigger is currently pressed
  14219. */
  14220. pressed: boolean;
  14221. }
  14222. /**
  14223. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14224. * @hidden
  14225. */
  14226. export interface ExtendedGamepadButton extends GamepadButton {
  14227. /**
  14228. * If the button/trigger is currently pressed
  14229. */
  14230. readonly pressed: boolean;
  14231. /**
  14232. * If the button/trigger is currently touched
  14233. */
  14234. readonly touched: boolean;
  14235. /**
  14236. * Value of the button/trigger
  14237. */
  14238. readonly value: number;
  14239. }
  14240. /** @hidden */
  14241. export interface _GamePadFactory {
  14242. /**
  14243. * Returns wether or not the current gamepad can be created for this type of controller.
  14244. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14245. * @returns true if it can be created, otherwise false
  14246. */
  14247. canCreate(gamepadInfo: any): boolean;
  14248. /**
  14249. * Creates a new instance of the Gamepad.
  14250. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14251. * @returns the new gamepad instance
  14252. */
  14253. create(gamepadInfo: any): Gamepad;
  14254. }
  14255. /**
  14256. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14257. */
  14258. export class PoseEnabledControllerHelper {
  14259. /** @hidden */
  14260. static _ControllerFactories: _GamePadFactory[];
  14261. /** @hidden */
  14262. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14263. /**
  14264. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14265. * @param vrGamepad the gamepad to initialized
  14266. * @returns a vr controller of the type the gamepad identified as
  14267. */
  14268. static InitiateController(vrGamepad: any): Gamepad;
  14269. }
  14270. /**
  14271. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14272. */
  14273. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14274. /**
  14275. * If the controller is used in a webXR session
  14276. */
  14277. isXR: boolean;
  14278. private _deviceRoomPosition;
  14279. private _deviceRoomRotationQuaternion;
  14280. /**
  14281. * The device position in babylon space
  14282. */
  14283. devicePosition: Vector3;
  14284. /**
  14285. * The device rotation in babylon space
  14286. */
  14287. deviceRotationQuaternion: Quaternion;
  14288. /**
  14289. * The scale factor of the device in babylon space
  14290. */
  14291. deviceScaleFactor: number;
  14292. /**
  14293. * (Likely devicePosition should be used instead) The device position in its room space
  14294. */
  14295. position: Vector3;
  14296. /**
  14297. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14298. */
  14299. rotationQuaternion: Quaternion;
  14300. /**
  14301. * The type of controller (Eg. Windows mixed reality)
  14302. */
  14303. controllerType: PoseEnabledControllerType;
  14304. protected _calculatedPosition: Vector3;
  14305. private _calculatedRotation;
  14306. /**
  14307. * The raw pose from the device
  14308. */
  14309. rawPose: DevicePose;
  14310. private _trackPosition;
  14311. private _maxRotationDistFromHeadset;
  14312. private _draggedRoomRotation;
  14313. /**
  14314. * @hidden
  14315. */
  14316. _disableTrackPosition(fixedPosition: Vector3): void;
  14317. /**
  14318. * Internal, the mesh attached to the controller
  14319. * @hidden
  14320. */
  14321. _mesh: Nullable<AbstractMesh>;
  14322. private _poseControlledCamera;
  14323. private _leftHandSystemQuaternion;
  14324. /**
  14325. * Internal, matrix used to convert room space to babylon space
  14326. * @hidden
  14327. */
  14328. _deviceToWorld: Matrix;
  14329. /**
  14330. * Node to be used when casting a ray from the controller
  14331. * @hidden
  14332. */
  14333. _pointingPoseNode: Nullable<TransformNode>;
  14334. /**
  14335. * Name of the child mesh that can be used to cast a ray from the controller
  14336. */
  14337. static readonly POINTING_POSE: string;
  14338. /**
  14339. * Creates a new PoseEnabledController from a gamepad
  14340. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14341. */
  14342. constructor(browserGamepad: any);
  14343. private _workingMatrix;
  14344. /**
  14345. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14346. */
  14347. update(): void;
  14348. /**
  14349. * Updates only the pose device and mesh without doing any button event checking
  14350. */
  14351. protected _updatePoseAndMesh(): void;
  14352. /**
  14353. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14354. * @param poseData raw pose fromthe device
  14355. */
  14356. updateFromDevice(poseData: DevicePose): void;
  14357. /**
  14358. * @hidden
  14359. */
  14360. _meshAttachedObservable: Observable<AbstractMesh>;
  14361. /**
  14362. * Attaches a mesh to the controller
  14363. * @param mesh the mesh to be attached
  14364. */
  14365. attachToMesh(mesh: AbstractMesh): void;
  14366. /**
  14367. * Attaches the controllers mesh to a camera
  14368. * @param camera the camera the mesh should be attached to
  14369. */
  14370. attachToPoseControlledCamera(camera: TargetCamera): void;
  14371. /**
  14372. * Disposes of the controller
  14373. */
  14374. dispose(): void;
  14375. /**
  14376. * The mesh that is attached to the controller
  14377. */
  14378. readonly mesh: Nullable<AbstractMesh>;
  14379. /**
  14380. * Gets the ray of the controller in the direction the controller is pointing
  14381. * @param length the length the resulting ray should be
  14382. * @returns a ray in the direction the controller is pointing
  14383. */
  14384. getForwardRay(length?: number): Ray;
  14385. }
  14386. }
  14387. declare module BABYLON {
  14388. /**
  14389. * Defines the WebVRController object that represents controllers tracked in 3D space
  14390. */
  14391. export abstract class WebVRController extends PoseEnabledController {
  14392. /**
  14393. * Internal, the default controller model for the controller
  14394. */
  14395. protected _defaultModel: Nullable<AbstractMesh>;
  14396. /**
  14397. * Fired when the trigger state has changed
  14398. */
  14399. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14400. /**
  14401. * Fired when the main button state has changed
  14402. */
  14403. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14404. /**
  14405. * Fired when the secondary button state has changed
  14406. */
  14407. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14408. /**
  14409. * Fired when the pad state has changed
  14410. */
  14411. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14412. /**
  14413. * Fired when controllers stick values have changed
  14414. */
  14415. onPadValuesChangedObservable: Observable<StickValues>;
  14416. /**
  14417. * Array of button availible on the controller
  14418. */
  14419. protected _buttons: Array<MutableGamepadButton>;
  14420. private _onButtonStateChange;
  14421. /**
  14422. * Fired when a controller button's state has changed
  14423. * @param callback the callback containing the button that was modified
  14424. */
  14425. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14426. /**
  14427. * X and Y axis corresponding to the controllers joystick
  14428. */
  14429. pad: StickValues;
  14430. /**
  14431. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14432. */
  14433. hand: string;
  14434. /**
  14435. * The default controller model for the controller
  14436. */
  14437. readonly defaultModel: Nullable<AbstractMesh>;
  14438. /**
  14439. * Creates a new WebVRController from a gamepad
  14440. * @param vrGamepad the gamepad that the WebVRController should be created from
  14441. */
  14442. constructor(vrGamepad: any);
  14443. /**
  14444. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14445. */
  14446. update(): void;
  14447. /**
  14448. * Function to be called when a button is modified
  14449. */
  14450. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14451. /**
  14452. * Loads a mesh and attaches it to the controller
  14453. * @param scene the scene the mesh should be added to
  14454. * @param meshLoaded callback for when the mesh has been loaded
  14455. */
  14456. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14457. private _setButtonValue;
  14458. private _changes;
  14459. private _checkChanges;
  14460. /**
  14461. * Disposes of th webVRCOntroller
  14462. */
  14463. dispose(): void;
  14464. }
  14465. }
  14466. declare module BABYLON {
  14467. /**
  14468. * The HemisphericLight simulates the ambient environment light,
  14469. * so the passed direction is the light reflection direction, not the incoming direction.
  14470. */
  14471. export class HemisphericLight extends Light {
  14472. /**
  14473. * The groundColor is the light in the opposite direction to the one specified during creation.
  14474. * 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.
  14475. */
  14476. groundColor: Color3;
  14477. /**
  14478. * The light reflection direction, not the incoming direction.
  14479. */
  14480. direction: Vector3;
  14481. /**
  14482. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14483. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14484. * The HemisphericLight can't cast shadows.
  14485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14486. * @param name The friendly name of the light
  14487. * @param direction The direction of the light reflection
  14488. * @param scene The scene the light belongs to
  14489. */
  14490. constructor(name: string, direction: Vector3, scene: Scene);
  14491. protected _buildUniformLayout(): void;
  14492. /**
  14493. * Returns the string "HemisphericLight".
  14494. * @return The class name
  14495. */
  14496. getClassName(): string;
  14497. /**
  14498. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14499. * Returns the updated direction.
  14500. * @param target The target the direction should point to
  14501. * @return The computed direction
  14502. */
  14503. setDirectionToTarget(target: Vector3): Vector3;
  14504. /**
  14505. * Returns the shadow generator associated to the light.
  14506. * @returns Always null for hemispheric lights because it does not support shadows.
  14507. */
  14508. getShadowGenerator(): Nullable<IShadowGenerator>;
  14509. /**
  14510. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14511. * @param effect The effect to update
  14512. * @param lightIndex The index of the light in the effect to update
  14513. * @returns The hemispheric light
  14514. */
  14515. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14516. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14517. /**
  14518. * Computes the world matrix of the node
  14519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14520. * @param useWasUpdatedFlag defines a reserved property
  14521. * @returns the world matrix
  14522. */
  14523. computeWorldMatrix(): Matrix;
  14524. /**
  14525. * Returns the integer 3.
  14526. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14527. */
  14528. getTypeID(): number;
  14529. /**
  14530. * Prepares the list of defines specific to the light type.
  14531. * @param defines the list of defines
  14532. * @param lightIndex defines the index of the light for the effect
  14533. */
  14534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14535. }
  14536. }
  14537. declare module BABYLON {
  14538. /** @hidden */
  14539. export var vrMultiviewToSingleviewPixelShader: {
  14540. name: string;
  14541. shader: string;
  14542. };
  14543. }
  14544. declare module BABYLON {
  14545. /**
  14546. * Renders to multiple views with a single draw call
  14547. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14548. */
  14549. export class MultiviewRenderTarget extends RenderTargetTexture {
  14550. /**
  14551. * Creates a multiview render target
  14552. * @param scene scene used with the render target
  14553. * @param size the size of the render target (used for each view)
  14554. */
  14555. constructor(scene: Scene, size?: number | {
  14556. width: number;
  14557. height: number;
  14558. } | {
  14559. ratio: number;
  14560. });
  14561. /**
  14562. * @hidden
  14563. * @param faceIndex the face index, if its a cube texture
  14564. */
  14565. _bindFrameBuffer(faceIndex?: number): void;
  14566. /**
  14567. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14568. * @returns the view count
  14569. */
  14570. getViewCount(): number;
  14571. }
  14572. }
  14573. declare module BABYLON {
  14574. /**
  14575. * Represents a camera frustum
  14576. */
  14577. export class Frustum {
  14578. /**
  14579. * Gets the planes representing the frustum
  14580. * @param transform matrix to be applied to the returned planes
  14581. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14582. */
  14583. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14584. /**
  14585. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14590. /**
  14591. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14596. /**
  14597. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14602. /**
  14603. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14608. /**
  14609. * Gets the top frustum plane transformed by the transform matrix
  14610. * @param transform transformation matrix to be applied to the resulting frustum plane
  14611. * @param frustumPlane the resuling frustum plane
  14612. */
  14613. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14614. /**
  14615. * Gets the bottom frustum plane transformed by the transform matrix
  14616. * @param transform transformation matrix to be applied to the resulting frustum plane
  14617. * @param frustumPlane the resuling frustum plane
  14618. */
  14619. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14620. /**
  14621. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14622. * @param transform transformation matrix to be applied to the resulting frustum planes
  14623. * @param frustumPlanes the resuling frustum planes
  14624. */
  14625. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14626. }
  14627. }
  14628. declare module BABYLON {
  14629. interface Engine {
  14630. /**
  14631. * Creates a new multiview render target
  14632. * @param width defines the width of the texture
  14633. * @param height defines the height of the texture
  14634. * @returns the created multiview texture
  14635. */
  14636. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14637. /**
  14638. * Binds a multiview framebuffer to be drawn to
  14639. * @param multiviewTexture texture to bind
  14640. */
  14641. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14642. }
  14643. interface Camera {
  14644. /**
  14645. * @hidden
  14646. * 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)
  14647. */
  14648. _useMultiviewToSingleView: boolean;
  14649. /**
  14650. * @hidden
  14651. * 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)
  14652. */
  14653. _multiviewTexture: Nullable<RenderTargetTexture>;
  14654. /**
  14655. * @hidden
  14656. * ensures the multiview texture of the camera exists and has the specified width/height
  14657. * @param width height to set on the multiview texture
  14658. * @param height width to set on the multiview texture
  14659. */
  14660. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14661. }
  14662. interface Scene {
  14663. /** @hidden */
  14664. _transformMatrixR: Matrix;
  14665. /** @hidden */
  14666. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14667. /** @hidden */
  14668. _createMultiviewUbo(): void;
  14669. /** @hidden */
  14670. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14671. /** @hidden */
  14672. _renderMultiviewToSingleView(camera: Camera): void;
  14673. }
  14674. }
  14675. declare module BABYLON {
  14676. /**
  14677. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14678. * This will not be used for webXR as it supports displaying texture arrays directly
  14679. */
  14680. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14681. /**
  14682. * Initializes a VRMultiviewToSingleview
  14683. * @param name name of the post process
  14684. * @param camera camera to be applied to
  14685. * @param scaleFactor scaling factor to the size of the output texture
  14686. */
  14687. constructor(name: string, camera: Camera, scaleFactor: number);
  14688. }
  14689. }
  14690. declare module BABYLON {
  14691. interface Engine {
  14692. /** @hidden */
  14693. _vrDisplay: any;
  14694. /** @hidden */
  14695. _vrSupported: boolean;
  14696. /** @hidden */
  14697. _oldSize: Size;
  14698. /** @hidden */
  14699. _oldHardwareScaleFactor: number;
  14700. /** @hidden */
  14701. _vrExclusivePointerMode: boolean;
  14702. /** @hidden */
  14703. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14704. /** @hidden */
  14705. _onVRDisplayPointerRestricted: () => void;
  14706. /** @hidden */
  14707. _onVRDisplayPointerUnrestricted: () => void;
  14708. /** @hidden */
  14709. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14710. /** @hidden */
  14711. _onVrDisplayDisconnect: Nullable<() => void>;
  14712. /** @hidden */
  14713. _onVrDisplayPresentChange: Nullable<() => void>;
  14714. /**
  14715. * Observable signaled when VR display mode changes
  14716. */
  14717. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14718. /**
  14719. * Observable signaled when VR request present is complete
  14720. */
  14721. onVRRequestPresentComplete: Observable<boolean>;
  14722. /**
  14723. * Observable signaled when VR request present starts
  14724. */
  14725. onVRRequestPresentStart: Observable<Engine>;
  14726. /**
  14727. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14728. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14729. */
  14730. isInVRExclusivePointerMode: boolean;
  14731. /**
  14732. * Gets a boolean indicating if a webVR device was detected
  14733. * @returns true if a webVR device was detected
  14734. */
  14735. isVRDevicePresent(): boolean;
  14736. /**
  14737. * Gets the current webVR device
  14738. * @returns the current webVR device (or null)
  14739. */
  14740. getVRDevice(): any;
  14741. /**
  14742. * Initializes a webVR display and starts listening to display change events
  14743. * The onVRDisplayChangedObservable will be notified upon these changes
  14744. * @returns A promise containing a VRDisplay and if vr is supported
  14745. */
  14746. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14747. /** @hidden */
  14748. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14749. /**
  14750. * Call this function to switch to webVR mode
  14751. * Will do nothing if webVR is not supported or if there is no webVR device
  14752. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14753. */
  14754. enableVR(): void;
  14755. /** @hidden */
  14756. _onVRFullScreenTriggered(): void;
  14757. }
  14758. }
  14759. declare module BABYLON {
  14760. /**
  14761. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14762. * IMPORTANT!! The data is right-hand data.
  14763. * @export
  14764. * @interface DevicePose
  14765. */
  14766. export interface DevicePose {
  14767. /**
  14768. * The position of the device, values in array are [x,y,z].
  14769. */
  14770. readonly position: Nullable<Float32Array>;
  14771. /**
  14772. * The linearVelocity of the device, values in array are [x,y,z].
  14773. */
  14774. readonly linearVelocity: Nullable<Float32Array>;
  14775. /**
  14776. * The linearAcceleration of the device, values in array are [x,y,z].
  14777. */
  14778. readonly linearAcceleration: Nullable<Float32Array>;
  14779. /**
  14780. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14781. */
  14782. readonly orientation: Nullable<Float32Array>;
  14783. /**
  14784. * The angularVelocity of the device, values in array are [x,y,z].
  14785. */
  14786. readonly angularVelocity: Nullable<Float32Array>;
  14787. /**
  14788. * The angularAcceleration of the device, values in array are [x,y,z].
  14789. */
  14790. readonly angularAcceleration: Nullable<Float32Array>;
  14791. }
  14792. /**
  14793. * Interface representing a pose controlled object in Babylon.
  14794. * A pose controlled object has both regular pose values as well as pose values
  14795. * from an external device such as a VR head mounted display
  14796. */
  14797. export interface PoseControlled {
  14798. /**
  14799. * The position of the object in babylon space.
  14800. */
  14801. position: Vector3;
  14802. /**
  14803. * The rotation quaternion of the object in babylon space.
  14804. */
  14805. rotationQuaternion: Quaternion;
  14806. /**
  14807. * The position of the device in babylon space.
  14808. */
  14809. devicePosition?: Vector3;
  14810. /**
  14811. * The rotation quaternion of the device in babylon space.
  14812. */
  14813. deviceRotationQuaternion: Quaternion;
  14814. /**
  14815. * The raw pose coming from the device.
  14816. */
  14817. rawPose: Nullable<DevicePose>;
  14818. /**
  14819. * The scale of the device to be used when translating from device space to babylon space.
  14820. */
  14821. deviceScaleFactor: number;
  14822. /**
  14823. * Updates the poseControlled values based on the input device pose.
  14824. * @param poseData the pose data to update the object with
  14825. */
  14826. updateFromDevice(poseData: DevicePose): void;
  14827. }
  14828. /**
  14829. * Set of options to customize the webVRCamera
  14830. */
  14831. export interface WebVROptions {
  14832. /**
  14833. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14834. */
  14835. trackPosition?: boolean;
  14836. /**
  14837. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14838. */
  14839. positionScale?: number;
  14840. /**
  14841. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14842. */
  14843. displayName?: string;
  14844. /**
  14845. * Should the native controller meshes be initialized. (default: true)
  14846. */
  14847. controllerMeshes?: boolean;
  14848. /**
  14849. * Creating a default HemiLight only on controllers. (default: true)
  14850. */
  14851. defaultLightingOnControllers?: boolean;
  14852. /**
  14853. * If you don't want to use the default VR button of the helper. (default: false)
  14854. */
  14855. useCustomVRButton?: boolean;
  14856. /**
  14857. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14858. */
  14859. customVRButton?: HTMLButtonElement;
  14860. /**
  14861. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14862. */
  14863. rayLength?: number;
  14864. /**
  14865. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14866. */
  14867. defaultHeight?: number;
  14868. /**
  14869. * If multiview should be used if availible (default: false)
  14870. */
  14871. useMultiview?: boolean;
  14872. }
  14873. /**
  14874. * This represents a WebVR camera.
  14875. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14876. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14877. */
  14878. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14879. private webVROptions;
  14880. /**
  14881. * @hidden
  14882. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14883. */
  14884. _vrDevice: any;
  14885. /**
  14886. * The rawPose of the vrDevice.
  14887. */
  14888. rawPose: Nullable<DevicePose>;
  14889. private _onVREnabled;
  14890. private _specsVersion;
  14891. private _attached;
  14892. private _frameData;
  14893. protected _descendants: Array<Node>;
  14894. private _deviceRoomPosition;
  14895. /** @hidden */
  14896. _deviceRoomRotationQuaternion: Quaternion;
  14897. private _standingMatrix;
  14898. /**
  14899. * Represents device position in babylon space.
  14900. */
  14901. devicePosition: Vector3;
  14902. /**
  14903. * Represents device rotation in babylon space.
  14904. */
  14905. deviceRotationQuaternion: Quaternion;
  14906. /**
  14907. * The scale of the device to be used when translating from device space to babylon space.
  14908. */
  14909. deviceScaleFactor: number;
  14910. private _deviceToWorld;
  14911. private _worldToDevice;
  14912. /**
  14913. * References to the webVR controllers for the vrDevice.
  14914. */
  14915. controllers: Array<WebVRController>;
  14916. /**
  14917. * Emits an event when a controller is attached.
  14918. */
  14919. onControllersAttachedObservable: Observable<WebVRController[]>;
  14920. /**
  14921. * Emits an event when a controller's mesh has been loaded;
  14922. */
  14923. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14924. /**
  14925. * Emits an event when the HMD's pose has been updated.
  14926. */
  14927. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14928. private _poseSet;
  14929. /**
  14930. * If the rig cameras be used as parent instead of this camera.
  14931. */
  14932. rigParenting: boolean;
  14933. private _lightOnControllers;
  14934. private _defaultHeight?;
  14935. /**
  14936. * Instantiates a WebVRFreeCamera.
  14937. * @param name The name of the WebVRFreeCamera
  14938. * @param position The starting anchor position for the camera
  14939. * @param scene The scene the camera belongs to
  14940. * @param webVROptions a set of customizable options for the webVRCamera
  14941. */
  14942. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14943. /**
  14944. * Gets the device distance from the ground in meters.
  14945. * @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.
  14946. */
  14947. deviceDistanceToRoomGround(): number;
  14948. /**
  14949. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14950. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14951. */
  14952. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14953. /**
  14954. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14955. * @returns A promise with a boolean set to if the standing matrix is supported.
  14956. */
  14957. useStandingMatrixAsync(): Promise<boolean>;
  14958. /**
  14959. * Disposes the camera
  14960. */
  14961. dispose(): void;
  14962. /**
  14963. * Gets a vrController by name.
  14964. * @param name The name of the controller to retreive
  14965. * @returns the controller matching the name specified or null if not found
  14966. */
  14967. getControllerByName(name: string): Nullable<WebVRController>;
  14968. private _leftController;
  14969. /**
  14970. * The controller corresponding to the users left hand.
  14971. */
  14972. readonly leftController: Nullable<WebVRController>;
  14973. private _rightController;
  14974. /**
  14975. * The controller corresponding to the users right hand.
  14976. */
  14977. readonly rightController: Nullable<WebVRController>;
  14978. /**
  14979. * Casts a ray forward from the vrCamera's gaze.
  14980. * @param length Length of the ray (default: 100)
  14981. * @returns the ray corresponding to the gaze
  14982. */
  14983. getForwardRay(length?: number): Ray;
  14984. /**
  14985. * @hidden
  14986. * Updates the camera based on device's frame data
  14987. */
  14988. _checkInputs(): void;
  14989. /**
  14990. * Updates the poseControlled values based on the input device pose.
  14991. * @param poseData Pose coming from the device
  14992. */
  14993. updateFromDevice(poseData: DevicePose): void;
  14994. private _htmlElementAttached;
  14995. private _detachIfAttached;
  14996. /**
  14997. * WebVR's attach control will start broadcasting frames to the device.
  14998. * Note that in certain browsers (chrome for example) this function must be called
  14999. * within a user-interaction callback. Example:
  15000. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15001. *
  15002. * @param element html element to attach the vrDevice to
  15003. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15004. */
  15005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15006. /**
  15007. * Detaches the camera from the html element and disables VR
  15008. *
  15009. * @param element html element to detach from
  15010. */
  15011. detachControl(element: HTMLElement): void;
  15012. /**
  15013. * @returns the name of this class
  15014. */
  15015. getClassName(): string;
  15016. /**
  15017. * Calls resetPose on the vrDisplay
  15018. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15019. */
  15020. resetToCurrentRotation(): void;
  15021. /**
  15022. * @hidden
  15023. * Updates the rig cameras (left and right eye)
  15024. */
  15025. _updateRigCameras(): void;
  15026. private _workingVector;
  15027. private _oneVector;
  15028. private _workingMatrix;
  15029. private updateCacheCalled;
  15030. private _correctPositionIfNotTrackPosition;
  15031. /**
  15032. * @hidden
  15033. * Updates the cached values of the camera
  15034. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15035. */
  15036. _updateCache(ignoreParentClass?: boolean): void;
  15037. /**
  15038. * @hidden
  15039. * Get current device position in babylon world
  15040. */
  15041. _computeDevicePosition(): void;
  15042. /**
  15043. * Updates the current device position and rotation in the babylon world
  15044. */
  15045. update(): void;
  15046. /**
  15047. * @hidden
  15048. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15049. * @returns an identity matrix
  15050. */
  15051. _getViewMatrix(): Matrix;
  15052. private _tmpMatrix;
  15053. /**
  15054. * This function is called by the two RIG cameras.
  15055. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15056. * @hidden
  15057. */
  15058. _getWebVRViewMatrix(): Matrix;
  15059. /** @hidden */
  15060. _getWebVRProjectionMatrix(): Matrix;
  15061. private _onGamepadConnectedObserver;
  15062. private _onGamepadDisconnectedObserver;
  15063. private _updateCacheWhenTrackingDisabledObserver;
  15064. /**
  15065. * Initializes the controllers and their meshes
  15066. */
  15067. initControllers(): void;
  15068. }
  15069. }
  15070. declare module BABYLON {
  15071. /**
  15072. * Size options for a post process
  15073. */
  15074. export type PostProcessOptions = {
  15075. width: number;
  15076. height: number;
  15077. };
  15078. /**
  15079. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15080. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15081. */
  15082. export class PostProcess {
  15083. /** Name of the PostProcess. */
  15084. name: string;
  15085. /**
  15086. * Gets or sets the unique id of the post process
  15087. */
  15088. uniqueId: number;
  15089. /**
  15090. * Width of the texture to apply the post process on
  15091. */
  15092. width: number;
  15093. /**
  15094. * Height of the texture to apply the post process on
  15095. */
  15096. height: number;
  15097. /**
  15098. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15099. * @hidden
  15100. */
  15101. _outputTexture: Nullable<InternalTexture>;
  15102. /**
  15103. * Sampling mode used by the shader
  15104. * See https://doc.babylonjs.com/classes/3.1/texture
  15105. */
  15106. renderTargetSamplingMode: number;
  15107. /**
  15108. * Clear color to use when screen clearing
  15109. */
  15110. clearColor: Color4;
  15111. /**
  15112. * If the buffer needs to be cleared before applying the post process. (default: true)
  15113. * Should be set to false if shader will overwrite all previous pixels.
  15114. */
  15115. autoClear: boolean;
  15116. /**
  15117. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15118. */
  15119. alphaMode: number;
  15120. /**
  15121. * Sets the setAlphaBlendConstants of the babylon engine
  15122. */
  15123. alphaConstants: Color4;
  15124. /**
  15125. * Animations to be used for the post processing
  15126. */
  15127. animations: Animation[];
  15128. /**
  15129. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15130. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15131. */
  15132. enablePixelPerfectMode: boolean;
  15133. /**
  15134. * Force the postprocess to be applied without taking in account viewport
  15135. */
  15136. forceFullscreenViewport: boolean;
  15137. /**
  15138. * List of inspectable custom properties (used by the Inspector)
  15139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15140. */
  15141. inspectableCustomProperties: IInspectable[];
  15142. /**
  15143. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15144. *
  15145. * | Value | Type | Description |
  15146. * | ----- | ----------------------------------- | ----------- |
  15147. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15148. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15149. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15150. *
  15151. */
  15152. scaleMode: number;
  15153. /**
  15154. * Force textures to be a power of two (default: false)
  15155. */
  15156. alwaysForcePOT: boolean;
  15157. private _samples;
  15158. /**
  15159. * Number of sample textures (default: 1)
  15160. */
  15161. samples: number;
  15162. /**
  15163. * Modify the scale of the post process to be the same as the viewport (default: false)
  15164. */
  15165. adaptScaleToCurrentViewport: boolean;
  15166. private _camera;
  15167. private _scene;
  15168. private _engine;
  15169. private _options;
  15170. private _reusable;
  15171. private _textureType;
  15172. /**
  15173. * Smart array of input and output textures for the post process.
  15174. * @hidden
  15175. */
  15176. _textures: SmartArray<InternalTexture>;
  15177. /**
  15178. * The index in _textures that corresponds to the output texture.
  15179. * @hidden
  15180. */
  15181. _currentRenderTextureInd: number;
  15182. private _effect;
  15183. private _samplers;
  15184. private _fragmentUrl;
  15185. private _vertexUrl;
  15186. private _parameters;
  15187. private _scaleRatio;
  15188. protected _indexParameters: any;
  15189. private _shareOutputWithPostProcess;
  15190. private _texelSize;
  15191. private _forcedOutputTexture;
  15192. /**
  15193. * Returns the fragment url or shader name used in the post process.
  15194. * @returns the fragment url or name in the shader store.
  15195. */
  15196. getEffectName(): string;
  15197. /**
  15198. * An event triggered when the postprocess is activated.
  15199. */
  15200. onActivateObservable: Observable<Camera>;
  15201. private _onActivateObserver;
  15202. /**
  15203. * A function that is added to the onActivateObservable
  15204. */
  15205. onActivate: Nullable<(camera: Camera) => void>;
  15206. /**
  15207. * An event triggered when the postprocess changes its size.
  15208. */
  15209. onSizeChangedObservable: Observable<PostProcess>;
  15210. private _onSizeChangedObserver;
  15211. /**
  15212. * A function that is added to the onSizeChangedObservable
  15213. */
  15214. onSizeChanged: (postProcess: PostProcess) => void;
  15215. /**
  15216. * An event triggered when the postprocess applies its effect.
  15217. */
  15218. onApplyObservable: Observable<Effect>;
  15219. private _onApplyObserver;
  15220. /**
  15221. * A function that is added to the onApplyObservable
  15222. */
  15223. onApply: (effect: Effect) => void;
  15224. /**
  15225. * An event triggered before rendering the postprocess
  15226. */
  15227. onBeforeRenderObservable: Observable<Effect>;
  15228. private _onBeforeRenderObserver;
  15229. /**
  15230. * A function that is added to the onBeforeRenderObservable
  15231. */
  15232. onBeforeRender: (effect: Effect) => void;
  15233. /**
  15234. * An event triggered after rendering the postprocess
  15235. */
  15236. onAfterRenderObservable: Observable<Effect>;
  15237. private _onAfterRenderObserver;
  15238. /**
  15239. * A function that is added to the onAfterRenderObservable
  15240. */
  15241. onAfterRender: (efect: Effect) => void;
  15242. /**
  15243. * 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
  15244. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15245. */
  15246. inputTexture: InternalTexture;
  15247. /**
  15248. * Gets the camera which post process is applied to.
  15249. * @returns The camera the post process is applied to.
  15250. */
  15251. getCamera(): Camera;
  15252. /**
  15253. * Gets the texel size of the postprocess.
  15254. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15255. */
  15256. readonly texelSize: Vector2;
  15257. /**
  15258. * Creates a new instance PostProcess
  15259. * @param name The name of the PostProcess.
  15260. * @param fragmentUrl The url of the fragment shader to be used.
  15261. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15262. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15263. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15264. * @param camera The camera to apply the render pass to.
  15265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15266. * @param engine The engine which the post process will be applied. (default: current engine)
  15267. * @param reusable If the post process can be reused on the same frame. (default: false)
  15268. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15269. * @param textureType Type of textures used when performing the post process. (default: 0)
  15270. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15271. * @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
  15272. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15273. */
  15274. constructor(
  15275. /** Name of the PostProcess. */
  15276. 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);
  15277. /**
  15278. * Gets a string idenfifying the name of the class
  15279. * @returns "PostProcess" string
  15280. */
  15281. getClassName(): string;
  15282. /**
  15283. * Gets the engine which this post process belongs to.
  15284. * @returns The engine the post process was enabled with.
  15285. */
  15286. getEngine(): Engine;
  15287. /**
  15288. * The effect that is created when initializing the post process.
  15289. * @returns The created effect corresponding the the postprocess.
  15290. */
  15291. getEffect(): Effect;
  15292. /**
  15293. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15294. * @param postProcess The post process to share the output with.
  15295. * @returns This post process.
  15296. */
  15297. shareOutputWith(postProcess: PostProcess): PostProcess;
  15298. /**
  15299. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15300. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15301. */
  15302. useOwnOutput(): void;
  15303. /**
  15304. * Updates the effect with the current post process compile time values and recompiles the shader.
  15305. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15306. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15307. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15308. * @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
  15309. * @param onCompiled Called when the shader has been compiled.
  15310. * @param onError Called if there is an error when compiling a shader.
  15311. */
  15312. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15313. /**
  15314. * The post process is reusable if it can be used multiple times within one frame.
  15315. * @returns If the post process is reusable
  15316. */
  15317. isReusable(): boolean;
  15318. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15319. markTextureDirty(): void;
  15320. /**
  15321. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15322. * 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.
  15323. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15324. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15325. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15326. * @returns The target texture that was bound to be written to.
  15327. */
  15328. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15329. /**
  15330. * If the post process is supported.
  15331. */
  15332. readonly isSupported: boolean;
  15333. /**
  15334. * The aspect ratio of the output texture.
  15335. */
  15336. readonly aspectRatio: number;
  15337. /**
  15338. * Get a value indicating if the post-process is ready to be used
  15339. * @returns true if the post-process is ready (shader is compiled)
  15340. */
  15341. isReady(): boolean;
  15342. /**
  15343. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15344. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15345. */
  15346. apply(): Nullable<Effect>;
  15347. private _disposeTextures;
  15348. /**
  15349. * Disposes the post process.
  15350. * @param camera The camera to dispose the post process on.
  15351. */
  15352. dispose(camera?: Camera): void;
  15353. }
  15354. }
  15355. declare module BABYLON {
  15356. /** @hidden */
  15357. export var kernelBlurVaryingDeclaration: {
  15358. name: string;
  15359. shader: string;
  15360. };
  15361. }
  15362. declare module BABYLON {
  15363. /** @hidden */
  15364. export var kernelBlurFragment: {
  15365. name: string;
  15366. shader: string;
  15367. };
  15368. }
  15369. declare module BABYLON {
  15370. /** @hidden */
  15371. export var kernelBlurFragment2: {
  15372. name: string;
  15373. shader: string;
  15374. };
  15375. }
  15376. declare module BABYLON {
  15377. /** @hidden */
  15378. export var kernelBlurPixelShader: {
  15379. name: string;
  15380. shader: string;
  15381. };
  15382. }
  15383. declare module BABYLON {
  15384. /** @hidden */
  15385. export var kernelBlurVertex: {
  15386. name: string;
  15387. shader: string;
  15388. };
  15389. }
  15390. declare module BABYLON {
  15391. /** @hidden */
  15392. export var kernelBlurVertexShader: {
  15393. name: string;
  15394. shader: string;
  15395. };
  15396. }
  15397. declare module BABYLON {
  15398. /**
  15399. * The Blur Post Process which blurs an image based on a kernel and direction.
  15400. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15401. */
  15402. export class BlurPostProcess extends PostProcess {
  15403. /** The direction in which to blur the image. */
  15404. direction: Vector2;
  15405. private blockCompilation;
  15406. protected _kernel: number;
  15407. protected _idealKernel: number;
  15408. protected _packedFloat: boolean;
  15409. private _staticDefines;
  15410. /**
  15411. * Sets the length in pixels of the blur sample region
  15412. */
  15413. /**
  15414. * Gets the length in pixels of the blur sample region
  15415. */
  15416. kernel: number;
  15417. /**
  15418. * Sets wether or not the blur needs to unpack/repack floats
  15419. */
  15420. /**
  15421. * Gets wether or not the blur is unpacking/repacking floats
  15422. */
  15423. packedFloat: boolean;
  15424. /**
  15425. * Creates a new instance BlurPostProcess
  15426. * @param name The name of the effect.
  15427. * @param direction The direction in which to blur the image.
  15428. * @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.
  15429. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15430. * @param camera The camera to apply the render pass to.
  15431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15432. * @param engine The engine which the post process will be applied. (default: current engine)
  15433. * @param reusable If the post process can be reused on the same frame. (default: false)
  15434. * @param textureType Type of textures used when performing the post process. (default: 0)
  15435. * @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)
  15436. */
  15437. constructor(name: string,
  15438. /** The direction in which to blur the image. */
  15439. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15440. /**
  15441. * Updates the effect with the current post process compile time values and recompiles the shader.
  15442. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15443. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15444. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15445. * @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
  15446. * @param onCompiled Called when the shader has been compiled.
  15447. * @param onError Called if there is an error when compiling a shader.
  15448. */
  15449. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15450. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15451. /**
  15452. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15453. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15454. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15455. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15456. * The gaps between physical kernels are compensated for in the weighting of the samples
  15457. * @param idealKernel Ideal blur kernel.
  15458. * @return Nearest best kernel.
  15459. */
  15460. protected _nearestBestKernel(idealKernel: number): number;
  15461. /**
  15462. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15463. * @param x The point on the Gaussian distribution to sample.
  15464. * @return the value of the Gaussian function at x.
  15465. */
  15466. protected _gaussianWeight(x: number): number;
  15467. /**
  15468. * Generates a string that can be used as a floating point number in GLSL.
  15469. * @param x Value to print.
  15470. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15471. * @return GLSL float string.
  15472. */
  15473. protected _glslFloat(x: number, decimalFigures?: number): string;
  15474. }
  15475. }
  15476. declare module BABYLON {
  15477. /**
  15478. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15479. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15480. * You can then easily use it as a reflectionTexture on a flat surface.
  15481. * In case the surface is not a plane, please consider relying on reflection probes.
  15482. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15483. */
  15484. export class MirrorTexture extends RenderTargetTexture {
  15485. private scene;
  15486. /**
  15487. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15488. * 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.
  15489. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15490. */
  15491. mirrorPlane: Plane;
  15492. /**
  15493. * Define the blur ratio used to blur the reflection if needed.
  15494. */
  15495. blurRatio: number;
  15496. /**
  15497. * Define the adaptive blur kernel used to blur the reflection if needed.
  15498. * This will autocompute the closest best match for the `blurKernel`
  15499. */
  15500. adaptiveBlurKernel: number;
  15501. /**
  15502. * Define the blur kernel used to blur the reflection if needed.
  15503. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15504. */
  15505. blurKernel: number;
  15506. /**
  15507. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15508. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15509. */
  15510. blurKernelX: number;
  15511. /**
  15512. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15513. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15514. */
  15515. blurKernelY: number;
  15516. private _autoComputeBlurKernel;
  15517. protected _onRatioRescale(): void;
  15518. private _updateGammaSpace;
  15519. private _imageProcessingConfigChangeObserver;
  15520. private _transformMatrix;
  15521. private _mirrorMatrix;
  15522. private _savedViewMatrix;
  15523. private _blurX;
  15524. private _blurY;
  15525. private _adaptiveBlurKernel;
  15526. private _blurKernelX;
  15527. private _blurKernelY;
  15528. private _blurRatio;
  15529. /**
  15530. * Instantiates a Mirror Texture.
  15531. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15532. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15533. * You can then easily use it as a reflectionTexture on a flat surface.
  15534. * In case the surface is not a plane, please consider relying on reflection probes.
  15535. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15536. * @param name
  15537. * @param size
  15538. * @param scene
  15539. * @param generateMipMaps
  15540. * @param type
  15541. * @param samplingMode
  15542. * @param generateDepthBuffer
  15543. */
  15544. constructor(name: string, size: number | {
  15545. width: number;
  15546. height: number;
  15547. } | {
  15548. ratio: number;
  15549. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15550. private _preparePostProcesses;
  15551. /**
  15552. * Clone the mirror texture.
  15553. * @returns the cloned texture
  15554. */
  15555. clone(): MirrorTexture;
  15556. /**
  15557. * Serialize the texture to a JSON representation you could use in Parse later on
  15558. * @returns the serialized JSON representation
  15559. */
  15560. serialize(): any;
  15561. /**
  15562. * Dispose the texture and release its associated resources.
  15563. */
  15564. dispose(): void;
  15565. }
  15566. }
  15567. declare module BABYLON {
  15568. /**
  15569. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15570. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15571. */
  15572. export class Texture extends BaseTexture {
  15573. /**
  15574. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15575. */
  15576. static SerializeBuffers: boolean;
  15577. /** @hidden */
  15578. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15579. /** @hidden */
  15580. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15581. /** @hidden */
  15582. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15583. /** nearest is mag = nearest and min = nearest and mip = linear */
  15584. static readonly NEAREST_SAMPLINGMODE: number;
  15585. /** nearest is mag = nearest and min = nearest and mip = linear */
  15586. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15588. static readonly BILINEAR_SAMPLINGMODE: number;
  15589. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15590. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15591. /** Trilinear is mag = linear and min = linear and mip = linear */
  15592. static readonly TRILINEAR_SAMPLINGMODE: number;
  15593. /** Trilinear is mag = linear and min = linear and mip = linear */
  15594. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15595. /** mag = nearest and min = nearest and mip = nearest */
  15596. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15597. /** mag = nearest and min = linear and mip = nearest */
  15598. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15599. /** mag = nearest and min = linear and mip = linear */
  15600. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15601. /** mag = nearest and min = linear and mip = none */
  15602. static readonly NEAREST_LINEAR: number;
  15603. /** mag = nearest and min = nearest and mip = none */
  15604. static readonly NEAREST_NEAREST: number;
  15605. /** mag = linear and min = nearest and mip = nearest */
  15606. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15607. /** mag = linear and min = nearest and mip = linear */
  15608. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15609. /** mag = linear and min = linear and mip = none */
  15610. static readonly LINEAR_LINEAR: number;
  15611. /** mag = linear and min = nearest and mip = none */
  15612. static readonly LINEAR_NEAREST: number;
  15613. /** Explicit coordinates mode */
  15614. static readonly EXPLICIT_MODE: number;
  15615. /** Spherical coordinates mode */
  15616. static readonly SPHERICAL_MODE: number;
  15617. /** Planar coordinates mode */
  15618. static readonly PLANAR_MODE: number;
  15619. /** Cubic coordinates mode */
  15620. static readonly CUBIC_MODE: number;
  15621. /** Projection coordinates mode */
  15622. static readonly PROJECTION_MODE: number;
  15623. /** Inverse Cubic coordinates mode */
  15624. static readonly SKYBOX_MODE: number;
  15625. /** Inverse Cubic coordinates mode */
  15626. static readonly INVCUBIC_MODE: number;
  15627. /** Equirectangular coordinates mode */
  15628. static readonly EQUIRECTANGULAR_MODE: number;
  15629. /** Equirectangular Fixed coordinates mode */
  15630. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15631. /** Equirectangular Fixed Mirrored coordinates mode */
  15632. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15633. /** Texture is not repeating outside of 0..1 UVs */
  15634. static readonly CLAMP_ADDRESSMODE: number;
  15635. /** Texture is repeating outside of 0..1 UVs */
  15636. static readonly WRAP_ADDRESSMODE: number;
  15637. /** Texture is repeating and mirrored */
  15638. static readonly MIRROR_ADDRESSMODE: number;
  15639. /**
  15640. * 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
  15641. */
  15642. static UseSerializedUrlIfAny: boolean;
  15643. /**
  15644. * Define the url of the texture.
  15645. */
  15646. url: Nullable<string>;
  15647. /**
  15648. * Define an offset on the texture to offset the u coordinates of the UVs
  15649. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15650. */
  15651. uOffset: number;
  15652. /**
  15653. * Define an offset on the texture to offset the v coordinates of the UVs
  15654. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15655. */
  15656. vOffset: number;
  15657. /**
  15658. * Define an offset on the texture to scale the u coordinates of the UVs
  15659. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15660. */
  15661. uScale: number;
  15662. /**
  15663. * Define an offset on the texture to scale the v coordinates of the UVs
  15664. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15665. */
  15666. vScale: number;
  15667. /**
  15668. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15669. * @see http://doc.babylonjs.com/how_to/more_materials
  15670. */
  15671. uAng: number;
  15672. /**
  15673. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15674. * @see http://doc.babylonjs.com/how_to/more_materials
  15675. */
  15676. vAng: number;
  15677. /**
  15678. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15679. * @see http://doc.babylonjs.com/how_to/more_materials
  15680. */
  15681. wAng: number;
  15682. /**
  15683. * Defines the center of rotation (U)
  15684. */
  15685. uRotationCenter: number;
  15686. /**
  15687. * Defines the center of rotation (V)
  15688. */
  15689. vRotationCenter: number;
  15690. /**
  15691. * Defines the center of rotation (W)
  15692. */
  15693. wRotationCenter: number;
  15694. /**
  15695. * Are mip maps generated for this texture or not.
  15696. */
  15697. readonly noMipmap: boolean;
  15698. /**
  15699. * List of inspectable custom properties (used by the Inspector)
  15700. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15701. */
  15702. inspectableCustomProperties: Nullable<IInspectable[]>;
  15703. private _noMipmap;
  15704. /** @hidden */
  15705. _invertY: boolean;
  15706. private _rowGenerationMatrix;
  15707. private _cachedTextureMatrix;
  15708. private _projectionModeMatrix;
  15709. private _t0;
  15710. private _t1;
  15711. private _t2;
  15712. private _cachedUOffset;
  15713. private _cachedVOffset;
  15714. private _cachedUScale;
  15715. private _cachedVScale;
  15716. private _cachedUAng;
  15717. private _cachedVAng;
  15718. private _cachedWAng;
  15719. private _cachedProjectionMatrixId;
  15720. private _cachedCoordinatesMode;
  15721. /** @hidden */
  15722. protected _initialSamplingMode: number;
  15723. /** @hidden */
  15724. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15725. private _deleteBuffer;
  15726. protected _format: Nullable<number>;
  15727. private _delayedOnLoad;
  15728. private _delayedOnError;
  15729. private _mimeType?;
  15730. /**
  15731. * Observable triggered once the texture has been loaded.
  15732. */
  15733. onLoadObservable: Observable<Texture>;
  15734. protected _isBlocking: boolean;
  15735. /**
  15736. * Is the texture preventing material to render while loading.
  15737. * If false, a default texture will be used instead of the loading one during the preparation step.
  15738. */
  15739. isBlocking: boolean;
  15740. /**
  15741. * Get the current sampling mode associated with the texture.
  15742. */
  15743. readonly samplingMode: number;
  15744. /**
  15745. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15746. */
  15747. readonly invertY: boolean;
  15748. /**
  15749. * Instantiates a new texture.
  15750. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15751. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15752. * @param url defines the url of the picture to load as a texture
  15753. * @param scene defines the scene or engine the texture will belong to
  15754. * @param noMipmap defines if the texture will require mip maps or not
  15755. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15756. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15757. * @param onLoad defines a callback triggered when the texture has been loaded
  15758. * @param onError defines a callback triggered when an error occurred during the loading session
  15759. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15760. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15761. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15762. * @param mimeType defines an optional mime type information
  15763. */
  15764. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15765. /**
  15766. * Update the url (and optional buffer) of this texture if url was null during construction.
  15767. * @param url the url of the texture
  15768. * @param buffer the buffer of the texture (defaults to null)
  15769. * @param onLoad callback called when the texture is loaded (defaults to null)
  15770. */
  15771. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15772. /**
  15773. * Finish the loading sequence of a texture flagged as delayed load.
  15774. * @hidden
  15775. */
  15776. delayLoad(): void;
  15777. private _prepareRowForTextureGeneration;
  15778. /**
  15779. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15780. * @returns the transform matrix of the texture.
  15781. */
  15782. getTextureMatrix(): Matrix;
  15783. /**
  15784. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15785. * @returns The reflection texture transform
  15786. */
  15787. getReflectionTextureMatrix(): Matrix;
  15788. /**
  15789. * Clones the texture.
  15790. * @returns the cloned texture
  15791. */
  15792. clone(): Texture;
  15793. /**
  15794. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15795. * @returns The JSON representation of the texture
  15796. */
  15797. serialize(): any;
  15798. /**
  15799. * Get the current class name of the texture useful for serialization or dynamic coding.
  15800. * @returns "Texture"
  15801. */
  15802. getClassName(): string;
  15803. /**
  15804. * Dispose the texture and release its associated resources.
  15805. */
  15806. dispose(): void;
  15807. /**
  15808. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15809. * @param parsedTexture Define the JSON representation of the texture
  15810. * @param scene Define the scene the parsed texture should be instantiated in
  15811. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15812. * @returns The parsed texture if successful
  15813. */
  15814. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15815. /**
  15816. * Creates a texture from its base 64 representation.
  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 scene Define the scene the texture should belong to
  15820. * @param noMipmap Forces the texture to not create mip map information if true
  15821. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15822. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15823. * @param onLoad define a callback triggered when the texture has been loaded
  15824. * @param onError define a callback triggered when an error occurred during the loading session
  15825. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15826. * @returns the created texture
  15827. */
  15828. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15829. /**
  15830. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15831. * @param data Define the base64 payload without the data: prefix
  15832. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15833. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15834. * @param scene Define the scene the texture should belong to
  15835. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15836. * @param noMipmap Forces the texture to not create mip map information if true
  15837. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15838. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15839. * @param onLoad define a callback triggered when the texture has been loaded
  15840. * @param onError define a callback triggered when an error occurred during the loading session
  15841. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15842. * @returns the created texture
  15843. */
  15844. 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;
  15845. }
  15846. }
  15847. declare module BABYLON {
  15848. /**
  15849. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15850. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15851. */
  15852. export class PostProcessManager {
  15853. private _scene;
  15854. private _indexBuffer;
  15855. private _vertexBuffers;
  15856. /**
  15857. * Creates a new instance PostProcess
  15858. * @param scene The scene that the post process is associated with.
  15859. */
  15860. constructor(scene: Scene);
  15861. private _prepareBuffers;
  15862. private _buildIndexBuffer;
  15863. /**
  15864. * Rebuilds the vertex buffers of the manager.
  15865. * @hidden
  15866. */
  15867. _rebuild(): void;
  15868. /**
  15869. * Prepares a frame to be run through a post process.
  15870. * @param sourceTexture The input texture to the post procesess. (default: null)
  15871. * @param postProcesses An array of post processes to be run. (default: null)
  15872. * @returns True if the post processes were able to be run.
  15873. * @hidden
  15874. */
  15875. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15876. /**
  15877. * Manually render a set of post processes to a texture.
  15878. * @param postProcesses An array of post processes to be run.
  15879. * @param targetTexture The target texture to render to.
  15880. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15881. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15882. * @param lodLevel defines which lod of the texture to render to
  15883. */
  15884. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15885. /**
  15886. * Finalize the result of the output of the postprocesses.
  15887. * @param doNotPresent If true the result will not be displayed to the screen.
  15888. * @param targetTexture The target texture to render to.
  15889. * @param faceIndex The index of the face to bind the target texture to.
  15890. * @param postProcesses The array of post processes to render.
  15891. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15892. * @hidden
  15893. */
  15894. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15895. /**
  15896. * Disposes of the post process manager.
  15897. */
  15898. dispose(): void;
  15899. }
  15900. }
  15901. declare module BABYLON {
  15902. /** Interface used by value gradients (color, factor, ...) */
  15903. export interface IValueGradient {
  15904. /**
  15905. * Gets or sets the gradient value (between 0 and 1)
  15906. */
  15907. gradient: number;
  15908. }
  15909. /** Class used to store color4 gradient */
  15910. export class ColorGradient implements IValueGradient {
  15911. /**
  15912. * Gets or sets the gradient value (between 0 and 1)
  15913. */
  15914. gradient: number;
  15915. /**
  15916. * Gets or sets first associated color
  15917. */
  15918. color1: Color4;
  15919. /**
  15920. * Gets or sets second associated color
  15921. */
  15922. color2?: Color4;
  15923. /**
  15924. * Will get a color picked randomly between color1 and color2.
  15925. * If color2 is undefined then color1 will be used
  15926. * @param result defines the target Color4 to store the result in
  15927. */
  15928. getColorToRef(result: Color4): void;
  15929. }
  15930. /** Class used to store color 3 gradient */
  15931. export class Color3Gradient implements IValueGradient {
  15932. /**
  15933. * Gets or sets the gradient value (between 0 and 1)
  15934. */
  15935. gradient: number;
  15936. /**
  15937. * Gets or sets the associated color
  15938. */
  15939. color: Color3;
  15940. }
  15941. /** Class used to store factor gradient */
  15942. export class FactorGradient implements IValueGradient {
  15943. /**
  15944. * Gets or sets the gradient value (between 0 and 1)
  15945. */
  15946. gradient: number;
  15947. /**
  15948. * Gets or sets first associated factor
  15949. */
  15950. factor1: number;
  15951. /**
  15952. * Gets or sets second associated factor
  15953. */
  15954. factor2?: number;
  15955. /**
  15956. * Will get a number picked randomly between factor1 and factor2.
  15957. * If factor2 is undefined then factor1 will be used
  15958. * @returns the picked number
  15959. */
  15960. getFactor(): number;
  15961. }
  15962. /**
  15963. * Helper used to simplify some generic gradient tasks
  15964. */
  15965. export class GradientHelper {
  15966. /**
  15967. * Gets the current gradient from an array of IValueGradient
  15968. * @param ratio defines the current ratio to get
  15969. * @param gradients defines the array of IValueGradient
  15970. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15971. */
  15972. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15973. }
  15974. }
  15975. declare module BABYLON {
  15976. interface ThinEngine {
  15977. /**
  15978. * Creates a dynamic texture
  15979. * @param width defines the width of the texture
  15980. * @param height defines the height of the texture
  15981. * @param generateMipMaps defines if the engine should generate the mip levels
  15982. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15983. * @returns the dynamic texture inside an InternalTexture
  15984. */
  15985. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15986. /**
  15987. * Update the content of a dynamic texture
  15988. * @param texture defines the texture to update
  15989. * @param canvas defines the canvas containing the source
  15990. * @param invertY defines if data must be stored with Y axis inverted
  15991. * @param premulAlpha defines if alpha is stored as premultiplied
  15992. * @param format defines the format of the data
  15993. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15994. */
  15995. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15996. }
  15997. }
  15998. declare module BABYLON {
  15999. /**
  16000. * Helper class used to generate a canvas to manipulate images
  16001. */
  16002. export class CanvasGenerator {
  16003. /**
  16004. * Create a new canvas (or offscreen canvas depending on the context)
  16005. * @param width defines the expected width
  16006. * @param height defines the expected height
  16007. * @return a new canvas or offscreen canvas
  16008. */
  16009. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16010. }
  16011. }
  16012. declare module BABYLON {
  16013. /**
  16014. * A class extending Texture allowing drawing on a texture
  16015. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16016. */
  16017. export class DynamicTexture extends Texture {
  16018. private _generateMipMaps;
  16019. private _canvas;
  16020. private _context;
  16021. private _engine;
  16022. /**
  16023. * Creates a DynamicTexture
  16024. * @param name defines the name of the texture
  16025. * @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
  16026. * @param scene defines the scene where you want the texture
  16027. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16028. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16029. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16030. */
  16031. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16032. /**
  16033. * Get the current class name of the texture useful for serialization or dynamic coding.
  16034. * @returns "DynamicTexture"
  16035. */
  16036. getClassName(): string;
  16037. /**
  16038. * Gets the current state of canRescale
  16039. */
  16040. readonly canRescale: boolean;
  16041. private _recreate;
  16042. /**
  16043. * Scales the texture
  16044. * @param ratio the scale factor to apply to both width and height
  16045. */
  16046. scale(ratio: number): void;
  16047. /**
  16048. * Resizes the texture
  16049. * @param width the new width
  16050. * @param height the new height
  16051. */
  16052. scaleTo(width: number, height: number): void;
  16053. /**
  16054. * Gets the context of the canvas used by the texture
  16055. * @returns the canvas context of the dynamic texture
  16056. */
  16057. getContext(): CanvasRenderingContext2D;
  16058. /**
  16059. * Clears the texture
  16060. */
  16061. clear(): void;
  16062. /**
  16063. * Updates the texture
  16064. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16065. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16066. */
  16067. update(invertY?: boolean, premulAlpha?: boolean): void;
  16068. /**
  16069. * Draws text onto the texture
  16070. * @param text defines the text to be drawn
  16071. * @param x defines the placement of the text from the left
  16072. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16073. * @param font defines the font to be used with font-style, font-size, font-name
  16074. * @param color defines the color used for the text
  16075. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16076. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16077. * @param update defines whether texture is immediately update (default is true)
  16078. */
  16079. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16080. /**
  16081. * Clones the texture
  16082. * @returns the clone of the texture.
  16083. */
  16084. clone(): DynamicTexture;
  16085. /**
  16086. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16087. * @returns a serialized dynamic texture object
  16088. */
  16089. serialize(): any;
  16090. /** @hidden */
  16091. _rebuild(): void;
  16092. }
  16093. }
  16094. declare module BABYLON {
  16095. interface AbstractScene {
  16096. /**
  16097. * The list of procedural textures added to the scene
  16098. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16099. */
  16100. proceduralTextures: Array<ProceduralTexture>;
  16101. }
  16102. /**
  16103. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16104. * in a given scene.
  16105. */
  16106. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16107. /**
  16108. * The component name helpfull to identify the component in the list of scene components.
  16109. */
  16110. readonly name: string;
  16111. /**
  16112. * The scene the component belongs to.
  16113. */
  16114. scene: Scene;
  16115. /**
  16116. * Creates a new instance of the component for the given scene
  16117. * @param scene Defines the scene to register the component in
  16118. */
  16119. constructor(scene: Scene);
  16120. /**
  16121. * Registers the component in a given scene
  16122. */
  16123. register(): void;
  16124. /**
  16125. * Rebuilds the elements related to this component in case of
  16126. * context lost for instance.
  16127. */
  16128. rebuild(): void;
  16129. /**
  16130. * Disposes the component and the associated ressources.
  16131. */
  16132. dispose(): void;
  16133. private _beforeClear;
  16134. }
  16135. }
  16136. declare module BABYLON {
  16137. interface ThinEngine {
  16138. /**
  16139. * Creates a new render target cube texture
  16140. * @param size defines the size of the texture
  16141. * @param options defines the options used to create the texture
  16142. * @returns a new render target cube texture stored in an InternalTexture
  16143. */
  16144. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16145. }
  16146. }
  16147. declare module BABYLON {
  16148. /** @hidden */
  16149. export var proceduralVertexShader: {
  16150. name: string;
  16151. shader: string;
  16152. };
  16153. }
  16154. declare module BABYLON {
  16155. /**
  16156. * 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.
  16157. * This is the base class of any Procedural texture and contains most of the shareable code.
  16158. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16159. */
  16160. export class ProceduralTexture extends Texture {
  16161. isCube: boolean;
  16162. /**
  16163. * Define if the texture is enabled or not (disabled texture will not render)
  16164. */
  16165. isEnabled: boolean;
  16166. /**
  16167. * Define if the texture must be cleared before rendering (default is true)
  16168. */
  16169. autoClear: boolean;
  16170. /**
  16171. * Callback called when the texture is generated
  16172. */
  16173. onGenerated: () => void;
  16174. /**
  16175. * Event raised when the texture is generated
  16176. */
  16177. onGeneratedObservable: Observable<ProceduralTexture>;
  16178. /** @hidden */
  16179. _generateMipMaps: boolean;
  16180. /** @hidden **/
  16181. _effect: Effect;
  16182. /** @hidden */
  16183. _textures: {
  16184. [key: string]: Texture;
  16185. };
  16186. private _size;
  16187. private _currentRefreshId;
  16188. private _refreshRate;
  16189. private _vertexBuffers;
  16190. private _indexBuffer;
  16191. private _uniforms;
  16192. private _samplers;
  16193. private _fragment;
  16194. private _floats;
  16195. private _ints;
  16196. private _floatsArrays;
  16197. private _colors3;
  16198. private _colors4;
  16199. private _vectors2;
  16200. private _vectors3;
  16201. private _matrices;
  16202. private _fallbackTexture;
  16203. private _fallbackTextureUsed;
  16204. private _engine;
  16205. private _cachedDefines;
  16206. private _contentUpdateId;
  16207. private _contentData;
  16208. /**
  16209. * Instantiates a new procedural texture.
  16210. * 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.
  16211. * This is the base class of any Procedural texture and contains most of the shareable code.
  16212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16213. * @param name Define the name of the texture
  16214. * @param size Define the size of the texture to create
  16215. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16216. * @param scene Define the scene the texture belongs to
  16217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16218. * @param generateMipMaps Define if the texture should creates mip maps or not
  16219. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16220. */
  16221. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16222. /**
  16223. * The effect that is created when initializing the post process.
  16224. * @returns The created effect corresponding the the postprocess.
  16225. */
  16226. getEffect(): Effect;
  16227. /**
  16228. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16229. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16230. */
  16231. getContent(): Nullable<ArrayBufferView>;
  16232. private _createIndexBuffer;
  16233. /** @hidden */
  16234. _rebuild(): void;
  16235. /**
  16236. * Resets the texture in order to recreate its associated resources.
  16237. * This can be called in case of context loss
  16238. */
  16239. reset(): void;
  16240. protected _getDefines(): string;
  16241. /**
  16242. * Is the texture ready to be used ? (rendered at least once)
  16243. * @returns true if ready, otherwise, false.
  16244. */
  16245. isReady(): boolean;
  16246. /**
  16247. * Resets the refresh counter of the texture and start bak from scratch.
  16248. * Could be useful to regenerate the texture if it is setup to render only once.
  16249. */
  16250. resetRefreshCounter(): void;
  16251. /**
  16252. * Set the fragment shader to use in order to render the texture.
  16253. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16254. */
  16255. setFragment(fragment: any): void;
  16256. /**
  16257. * Define the refresh rate of the texture or the rendering frequency.
  16258. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16259. */
  16260. refreshRate: number;
  16261. /** @hidden */
  16262. _shouldRender(): boolean;
  16263. /**
  16264. * Get the size the texture is rendering at.
  16265. * @returns the size (texture is always squared)
  16266. */
  16267. getRenderSize(): number;
  16268. /**
  16269. * Resize the texture to new value.
  16270. * @param size Define the new size the texture should have
  16271. * @param generateMipMaps Define whether the new texture should create mip maps
  16272. */
  16273. resize(size: number, generateMipMaps: boolean): void;
  16274. private _checkUniform;
  16275. /**
  16276. * Set a texture in the shader program used to render.
  16277. * @param name Define the name of the uniform samplers as defined in the shader
  16278. * @param texture Define the texture to bind to this sampler
  16279. * @return the texture itself allowing "fluent" like uniform updates
  16280. */
  16281. setTexture(name: string, texture: Texture): ProceduralTexture;
  16282. /**
  16283. * Set a float in the shader.
  16284. * @param name Define the name of the uniform as defined in the shader
  16285. * @param value Define the value to give to the uniform
  16286. * @return the texture itself allowing "fluent" like uniform updates
  16287. */
  16288. setFloat(name: string, value: number): ProceduralTexture;
  16289. /**
  16290. * Set a int in the shader.
  16291. * @param name Define the name of the uniform as defined in the shader
  16292. * @param value Define the value to give to the uniform
  16293. * @return the texture itself allowing "fluent" like uniform updates
  16294. */
  16295. setInt(name: string, value: number): ProceduralTexture;
  16296. /**
  16297. * Set an array of floats in the shader.
  16298. * @param name Define the name of the uniform as defined in the shader
  16299. * @param value Define the value to give to the uniform
  16300. * @return the texture itself allowing "fluent" like uniform updates
  16301. */
  16302. setFloats(name: string, value: number[]): ProceduralTexture;
  16303. /**
  16304. * Set a vec3 in the shader from a Color3.
  16305. * @param name Define the name of the uniform as defined in the shader
  16306. * @param value Define the value to give to the uniform
  16307. * @return the texture itself allowing "fluent" like uniform updates
  16308. */
  16309. setColor3(name: string, value: Color3): ProceduralTexture;
  16310. /**
  16311. * Set a vec4 in the shader from a Color4.
  16312. * @param name Define the name of the uniform as defined in the shader
  16313. * @param value Define the value to give to the uniform
  16314. * @return the texture itself allowing "fluent" like uniform updates
  16315. */
  16316. setColor4(name: string, value: Color4): ProceduralTexture;
  16317. /**
  16318. * Set a vec2 in the shader from a Vector2.
  16319. * @param name Define the name of the uniform as defined in the shader
  16320. * @param value Define the value to give to the uniform
  16321. * @return the texture itself allowing "fluent" like uniform updates
  16322. */
  16323. setVector2(name: string, value: Vector2): ProceduralTexture;
  16324. /**
  16325. * Set a vec3 in the shader from a Vector3.
  16326. * @param name Define the name of the uniform as defined in the shader
  16327. * @param value Define the value to give to the uniform
  16328. * @return the texture itself allowing "fluent" like uniform updates
  16329. */
  16330. setVector3(name: string, value: Vector3): ProceduralTexture;
  16331. /**
  16332. * Set a mat4 in the shader from a MAtrix.
  16333. * @param name Define the name of the uniform as defined in the shader
  16334. * @param value Define the value to give to the uniform
  16335. * @return the texture itself allowing "fluent" like uniform updates
  16336. */
  16337. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16338. /**
  16339. * Render the texture to its associated render target.
  16340. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16341. */
  16342. render(useCameraPostProcess?: boolean): void;
  16343. /**
  16344. * Clone the texture.
  16345. * @returns the cloned texture
  16346. */
  16347. clone(): ProceduralTexture;
  16348. /**
  16349. * Dispose the texture and release its asoociated resources.
  16350. */
  16351. dispose(): void;
  16352. }
  16353. }
  16354. declare module BABYLON {
  16355. /**
  16356. * This represents the base class for particle system in Babylon.
  16357. * 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.
  16358. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16359. * @example https://doc.babylonjs.com/babylon101/particles
  16360. */
  16361. export class BaseParticleSystem {
  16362. /**
  16363. * Source color is added to the destination color without alpha affecting the result
  16364. */
  16365. static BLENDMODE_ONEONE: number;
  16366. /**
  16367. * Blend current color and particle color using particle’s alpha
  16368. */
  16369. static BLENDMODE_STANDARD: number;
  16370. /**
  16371. * Add current color and particle color multiplied by particle’s alpha
  16372. */
  16373. static BLENDMODE_ADD: number;
  16374. /**
  16375. * Multiply current color with particle color
  16376. */
  16377. static BLENDMODE_MULTIPLY: number;
  16378. /**
  16379. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16380. */
  16381. static BLENDMODE_MULTIPLYADD: number;
  16382. /**
  16383. * List of animations used by the particle system.
  16384. */
  16385. animations: Animation[];
  16386. /**
  16387. * The id of the Particle system.
  16388. */
  16389. id: string;
  16390. /**
  16391. * The friendly name of the Particle system.
  16392. */
  16393. name: string;
  16394. /**
  16395. * The rendering group used by the Particle system to chose when to render.
  16396. */
  16397. renderingGroupId: number;
  16398. /**
  16399. * The emitter represents the Mesh or position we are attaching the particle system to.
  16400. */
  16401. emitter: Nullable<AbstractMesh | Vector3>;
  16402. /**
  16403. * The maximum number of particles to emit per frame
  16404. */
  16405. emitRate: number;
  16406. /**
  16407. * If you want to launch only a few particles at once, that can be done, as well.
  16408. */
  16409. manualEmitCount: number;
  16410. /**
  16411. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16412. */
  16413. updateSpeed: number;
  16414. /**
  16415. * The amount of time the particle system is running (depends of the overall update speed).
  16416. */
  16417. targetStopDuration: number;
  16418. /**
  16419. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16420. */
  16421. disposeOnStop: boolean;
  16422. /**
  16423. * Minimum power of emitting particles.
  16424. */
  16425. minEmitPower: number;
  16426. /**
  16427. * Maximum power of emitting particles.
  16428. */
  16429. maxEmitPower: number;
  16430. /**
  16431. * Minimum life time of emitting particles.
  16432. */
  16433. minLifeTime: number;
  16434. /**
  16435. * Maximum life time of emitting particles.
  16436. */
  16437. maxLifeTime: number;
  16438. /**
  16439. * Minimum Size of emitting particles.
  16440. */
  16441. minSize: number;
  16442. /**
  16443. * Maximum Size of emitting particles.
  16444. */
  16445. maxSize: number;
  16446. /**
  16447. * Minimum scale of emitting particles on X axis.
  16448. */
  16449. minScaleX: number;
  16450. /**
  16451. * Maximum scale of emitting particles on X axis.
  16452. */
  16453. maxScaleX: number;
  16454. /**
  16455. * Minimum scale of emitting particles on Y axis.
  16456. */
  16457. minScaleY: number;
  16458. /**
  16459. * Maximum scale of emitting particles on Y axis.
  16460. */
  16461. maxScaleY: number;
  16462. /**
  16463. * Gets or sets the minimal initial rotation in radians.
  16464. */
  16465. minInitialRotation: number;
  16466. /**
  16467. * Gets or sets the maximal initial rotation in radians.
  16468. */
  16469. maxInitialRotation: number;
  16470. /**
  16471. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16472. */
  16473. minAngularSpeed: number;
  16474. /**
  16475. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16476. */
  16477. maxAngularSpeed: number;
  16478. /**
  16479. * The texture used to render each particle. (this can be a spritesheet)
  16480. */
  16481. particleTexture: Nullable<Texture>;
  16482. /**
  16483. * The layer mask we are rendering the particles through.
  16484. */
  16485. layerMask: number;
  16486. /**
  16487. * This can help using your own shader to render the particle system.
  16488. * The according effect will be created
  16489. */
  16490. customShader: any;
  16491. /**
  16492. * By default particle system starts as soon as they are created. This prevents the
  16493. * automatic start to happen and let you decide when to start emitting particles.
  16494. */
  16495. preventAutoStart: boolean;
  16496. private _noiseTexture;
  16497. /**
  16498. * Gets or sets a texture used to add random noise to particle positions
  16499. */
  16500. noiseTexture: Nullable<ProceduralTexture>;
  16501. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16502. noiseStrength: Vector3;
  16503. /**
  16504. * Callback triggered when the particle animation is ending.
  16505. */
  16506. onAnimationEnd: Nullable<() => void>;
  16507. /**
  16508. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16509. */
  16510. blendMode: number;
  16511. /**
  16512. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16513. * to override the particles.
  16514. */
  16515. forceDepthWrite: boolean;
  16516. /** 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 */
  16517. preWarmCycles: number;
  16518. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16519. preWarmStepOffset: number;
  16520. /**
  16521. * 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)
  16522. */
  16523. spriteCellChangeSpeed: number;
  16524. /**
  16525. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16526. */
  16527. startSpriteCellID: number;
  16528. /**
  16529. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16530. */
  16531. endSpriteCellID: number;
  16532. /**
  16533. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16534. */
  16535. spriteCellWidth: number;
  16536. /**
  16537. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16538. */
  16539. spriteCellHeight: number;
  16540. /**
  16541. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16542. */
  16543. spriteRandomStartCell: boolean;
  16544. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16545. translationPivot: Vector2;
  16546. /** @hidden */
  16547. protected _isAnimationSheetEnabled: boolean;
  16548. /**
  16549. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16550. */
  16551. beginAnimationOnStart: boolean;
  16552. /**
  16553. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16554. */
  16555. beginAnimationFrom: number;
  16556. /**
  16557. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16558. */
  16559. beginAnimationTo: number;
  16560. /**
  16561. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16562. */
  16563. beginAnimationLoop: boolean;
  16564. /**
  16565. * Gets or sets a world offset applied to all particles
  16566. */
  16567. worldOffset: Vector3;
  16568. /**
  16569. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16570. */
  16571. isAnimationSheetEnabled: boolean;
  16572. /**
  16573. * Get hosting scene
  16574. * @returns the scene
  16575. */
  16576. getScene(): Scene;
  16577. /**
  16578. * You can use gravity if you want to give an orientation to your particles.
  16579. */
  16580. gravity: Vector3;
  16581. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16582. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16583. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16584. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16585. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16586. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16587. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16588. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16589. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16590. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16591. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16592. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16593. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16594. /**
  16595. * Defines the delay in milliseconds before starting the system (0 by default)
  16596. */
  16597. startDelay: number;
  16598. /**
  16599. * Gets the current list of drag gradients.
  16600. * You must use addDragGradient and removeDragGradient to udpate this list
  16601. * @returns the list of drag gradients
  16602. */
  16603. getDragGradients(): Nullable<Array<FactorGradient>>;
  16604. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16605. limitVelocityDamping: number;
  16606. /**
  16607. * Gets the current list of limit velocity gradients.
  16608. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16609. * @returns the list of limit velocity gradients
  16610. */
  16611. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Gets the current list of color gradients.
  16614. * You must use addColorGradient and removeColorGradient to udpate this list
  16615. * @returns the list of color gradients
  16616. */
  16617. getColorGradients(): Nullable<Array<ColorGradient>>;
  16618. /**
  16619. * Gets the current list of size gradients.
  16620. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16621. * @returns the list of size gradients
  16622. */
  16623. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16624. /**
  16625. * Gets the current list of color remap gradients.
  16626. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16627. * @returns the list of color remap gradients
  16628. */
  16629. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Gets the current list of alpha remap gradients.
  16632. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16633. * @returns the list of alpha remap gradients
  16634. */
  16635. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16636. /**
  16637. * Gets the current list of life time gradients.
  16638. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16639. * @returns the list of life time gradients
  16640. */
  16641. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16642. /**
  16643. * Gets the current list of angular speed gradients.
  16644. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16645. * @returns the list of angular speed gradients
  16646. */
  16647. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16648. /**
  16649. * Gets the current list of velocity gradients.
  16650. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16651. * @returns the list of velocity gradients
  16652. */
  16653. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16654. /**
  16655. * Gets the current list of start size gradients.
  16656. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16657. * @returns the list of start size gradients
  16658. */
  16659. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16660. /**
  16661. * Gets the current list of emit rate gradients.
  16662. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16663. * @returns the list of emit rate gradients
  16664. */
  16665. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16666. /**
  16667. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16668. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16669. */
  16670. direction1: Vector3;
  16671. /**
  16672. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16673. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16674. */
  16675. direction2: Vector3;
  16676. /**
  16677. * 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.
  16678. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16679. */
  16680. minEmitBox: Vector3;
  16681. /**
  16682. * 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.
  16683. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16684. */
  16685. maxEmitBox: Vector3;
  16686. /**
  16687. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16688. */
  16689. color1: Color4;
  16690. /**
  16691. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16692. */
  16693. color2: Color4;
  16694. /**
  16695. * Color the particle will have at the end of its lifetime
  16696. */
  16697. colorDead: Color4;
  16698. /**
  16699. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16700. */
  16701. textureMask: Color4;
  16702. /**
  16703. * The particle emitter type defines the emitter used by the particle system.
  16704. * It can be for example box, sphere, or cone...
  16705. */
  16706. particleEmitterType: IParticleEmitterType;
  16707. /** @hidden */
  16708. _isSubEmitter: boolean;
  16709. /**
  16710. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16711. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16712. */
  16713. billboardMode: number;
  16714. protected _isBillboardBased: boolean;
  16715. /**
  16716. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16717. */
  16718. isBillboardBased: boolean;
  16719. /**
  16720. * The scene the particle system belongs to.
  16721. */
  16722. protected _scene: Scene;
  16723. /**
  16724. * Local cache of defines for image processing.
  16725. */
  16726. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16727. /**
  16728. * Default configuration related to image processing available in the standard Material.
  16729. */
  16730. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16731. /**
  16732. * Gets the image processing configuration used either in this material.
  16733. */
  16734. /**
  16735. * Sets the Default image processing configuration used either in the this material.
  16736. *
  16737. * If sets to null, the scene one is in use.
  16738. */
  16739. imageProcessingConfiguration: ImageProcessingConfiguration;
  16740. /**
  16741. * Attaches a new image processing configuration to the Standard Material.
  16742. * @param configuration
  16743. */
  16744. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16745. /** @hidden */
  16746. protected _reset(): void;
  16747. /** @hidden */
  16748. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16749. /**
  16750. * Instantiates a particle system.
  16751. * 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.
  16752. * @param name The name of the particle system
  16753. */
  16754. constructor(name: string);
  16755. /**
  16756. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16759. * @returns the emitter
  16760. */
  16761. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16762. /**
  16763. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16764. * @param radius The radius of the hemisphere to emit from
  16765. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16766. * @returns the emitter
  16767. */
  16768. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16769. /**
  16770. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16771. * @param radius The radius of the sphere to emit from
  16772. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16773. * @returns the emitter
  16774. */
  16775. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16776. /**
  16777. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16778. * @param radius The radius of the sphere to emit from
  16779. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16780. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16781. * @returns the emitter
  16782. */
  16783. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16784. /**
  16785. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16786. * @param radius The radius of the emission cylinder
  16787. * @param height The height of the emission cylinder
  16788. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16789. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16790. * @returns the emitter
  16791. */
  16792. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16793. /**
  16794. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16795. * @param radius The radius of the cylinder to emit from
  16796. * @param height The height of the emission cylinder
  16797. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16798. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16799. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16800. * @returns the emitter
  16801. */
  16802. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16803. /**
  16804. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16805. * @param radius The radius of the cone to emit from
  16806. * @param angle The base angle of the cone
  16807. * @returns the emitter
  16808. */
  16809. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16810. /**
  16811. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16814. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16815. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16816. * @returns the emitter
  16817. */
  16818. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16819. }
  16820. }
  16821. declare module BABYLON {
  16822. /**
  16823. * Type of sub emitter
  16824. */
  16825. export enum SubEmitterType {
  16826. /**
  16827. * Attached to the particle over it's lifetime
  16828. */
  16829. ATTACHED = 0,
  16830. /**
  16831. * Created when the particle dies
  16832. */
  16833. END = 1
  16834. }
  16835. /**
  16836. * Sub emitter class used to emit particles from an existing particle
  16837. */
  16838. export class SubEmitter {
  16839. /**
  16840. * the particle system to be used by the sub emitter
  16841. */
  16842. particleSystem: ParticleSystem;
  16843. /**
  16844. * Type of the submitter (Default: END)
  16845. */
  16846. type: SubEmitterType;
  16847. /**
  16848. * 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)
  16849. * Note: This only is supported when using an emitter of type Mesh
  16850. */
  16851. inheritDirection: boolean;
  16852. /**
  16853. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16854. */
  16855. inheritedVelocityAmount: number;
  16856. /**
  16857. * Creates a sub emitter
  16858. * @param particleSystem the particle system to be used by the sub emitter
  16859. */
  16860. constructor(
  16861. /**
  16862. * the particle system to be used by the sub emitter
  16863. */
  16864. particleSystem: ParticleSystem);
  16865. /**
  16866. * Clones the sub emitter
  16867. * @returns the cloned sub emitter
  16868. */
  16869. clone(): SubEmitter;
  16870. /**
  16871. * Serialize current object to a JSON object
  16872. * @returns the serialized object
  16873. */
  16874. serialize(): any;
  16875. /** @hidden */
  16876. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16877. /**
  16878. * Creates a new SubEmitter from a serialized JSON version
  16879. * @param serializationObject defines the JSON object to read from
  16880. * @param scene defines the hosting scene
  16881. * @param rootUrl defines the rootUrl for data loading
  16882. * @returns a new SubEmitter
  16883. */
  16884. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16885. /** Release associated resources */
  16886. dispose(): void;
  16887. }
  16888. }
  16889. declare module BABYLON {
  16890. /** @hidden */
  16891. export var clipPlaneFragmentDeclaration: {
  16892. name: string;
  16893. shader: string;
  16894. };
  16895. }
  16896. declare module BABYLON {
  16897. /** @hidden */
  16898. export var imageProcessingDeclaration: {
  16899. name: string;
  16900. shader: string;
  16901. };
  16902. }
  16903. declare module BABYLON {
  16904. /** @hidden */
  16905. export var imageProcessingFunctions: {
  16906. name: string;
  16907. shader: string;
  16908. };
  16909. }
  16910. declare module BABYLON {
  16911. /** @hidden */
  16912. export var clipPlaneFragment: {
  16913. name: string;
  16914. shader: string;
  16915. };
  16916. }
  16917. declare module BABYLON {
  16918. /** @hidden */
  16919. export var particlesPixelShader: {
  16920. name: string;
  16921. shader: string;
  16922. };
  16923. }
  16924. declare module BABYLON {
  16925. /** @hidden */
  16926. export var clipPlaneVertexDeclaration: {
  16927. name: string;
  16928. shader: string;
  16929. };
  16930. }
  16931. declare module BABYLON {
  16932. /** @hidden */
  16933. export var clipPlaneVertex: {
  16934. name: string;
  16935. shader: string;
  16936. };
  16937. }
  16938. declare module BABYLON {
  16939. /** @hidden */
  16940. export var particlesVertexShader: {
  16941. name: string;
  16942. shader: string;
  16943. };
  16944. }
  16945. declare module BABYLON {
  16946. /**
  16947. * This represents a particle system in Babylon.
  16948. * 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.
  16949. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16950. * @example https://doc.babylonjs.com/babylon101/particles
  16951. */
  16952. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16953. /**
  16954. * Billboard mode will only apply to Y axis
  16955. */
  16956. static readonly BILLBOARDMODE_Y: number;
  16957. /**
  16958. * Billboard mode will apply to all axes
  16959. */
  16960. static readonly BILLBOARDMODE_ALL: number;
  16961. /**
  16962. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16963. */
  16964. static readonly BILLBOARDMODE_STRETCHED: number;
  16965. /**
  16966. * This function can be defined to provide custom update for active particles.
  16967. * This function will be called instead of regular update (age, position, color, etc.).
  16968. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16969. */
  16970. updateFunction: (particles: Particle[]) => void;
  16971. private _emitterWorldMatrix;
  16972. /**
  16973. * This function can be defined to specify initial direction for every new particle.
  16974. * It by default use the emitterType defined function
  16975. */
  16976. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16977. /**
  16978. * This function can be defined to specify initial position for every new particle.
  16979. * It by default use the emitterType defined function
  16980. */
  16981. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16982. /**
  16983. * @hidden
  16984. */
  16985. _inheritedVelocityOffset: Vector3;
  16986. /**
  16987. * An event triggered when the system is disposed
  16988. */
  16989. onDisposeObservable: Observable<ParticleSystem>;
  16990. private _onDisposeObserver;
  16991. /**
  16992. * Sets a callback that will be triggered when the system is disposed
  16993. */
  16994. onDispose: () => void;
  16995. private _particles;
  16996. private _epsilon;
  16997. private _capacity;
  16998. private _stockParticles;
  16999. private _newPartsExcess;
  17000. private _vertexData;
  17001. private _vertexBuffer;
  17002. private _vertexBuffers;
  17003. private _spriteBuffer;
  17004. private _indexBuffer;
  17005. private _effect;
  17006. private _customEffect;
  17007. private _cachedDefines;
  17008. private _scaledColorStep;
  17009. private _colorDiff;
  17010. private _scaledDirection;
  17011. private _scaledGravity;
  17012. private _currentRenderId;
  17013. private _alive;
  17014. private _useInstancing;
  17015. private _started;
  17016. private _stopped;
  17017. private _actualFrame;
  17018. private _scaledUpdateSpeed;
  17019. private _vertexBufferSize;
  17020. /** @hidden */
  17021. _currentEmitRateGradient: Nullable<FactorGradient>;
  17022. /** @hidden */
  17023. _currentEmitRate1: number;
  17024. /** @hidden */
  17025. _currentEmitRate2: number;
  17026. /** @hidden */
  17027. _currentStartSizeGradient: Nullable<FactorGradient>;
  17028. /** @hidden */
  17029. _currentStartSize1: number;
  17030. /** @hidden */
  17031. _currentStartSize2: number;
  17032. private readonly _rawTextureWidth;
  17033. private _rampGradientsTexture;
  17034. private _useRampGradients;
  17035. /** Gets or sets a boolean indicating that ramp gradients must be used
  17036. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17037. */
  17038. useRampGradients: boolean;
  17039. /**
  17040. * 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.
  17041. * 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: [])
  17042. */
  17043. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17044. private _subEmitters;
  17045. /**
  17046. * @hidden
  17047. * If the particle systems emitter should be disposed when the particle system is disposed
  17048. */
  17049. _disposeEmitterOnDispose: boolean;
  17050. /**
  17051. * The current active Sub-systems, this property is used by the root particle system only.
  17052. */
  17053. activeSubSystems: Array<ParticleSystem>;
  17054. private _rootParticleSystem;
  17055. /**
  17056. * Gets the current list of active particles
  17057. */
  17058. readonly particles: Particle[];
  17059. /**
  17060. * Returns the string "ParticleSystem"
  17061. * @returns a string containing the class name
  17062. */
  17063. getClassName(): string;
  17064. /**
  17065. * Instantiates a particle system.
  17066. * 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.
  17067. * @param name The name of the particle system
  17068. * @param capacity The max number of particles alive at the same time
  17069. * @param scene The scene the particle system belongs to
  17070. * @param customEffect a custom effect used to change the way particles are rendered by default
  17071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17072. * @param epsilon Offset used to render the particles
  17073. */
  17074. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17075. private _addFactorGradient;
  17076. private _removeFactorGradient;
  17077. /**
  17078. * Adds a new life time gradient
  17079. * @param gradient defines the gradient to use (between 0 and 1)
  17080. * @param factor defines the life time factor to affect to the specified gradient
  17081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17082. * @returns the current particle system
  17083. */
  17084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17085. /**
  17086. * Remove a specific life time gradient
  17087. * @param gradient defines the gradient to remove
  17088. * @returns the current particle system
  17089. */
  17090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17091. /**
  17092. * Adds a new size gradient
  17093. * @param gradient defines the gradient to use (between 0 and 1)
  17094. * @param factor defines the size factor to affect to the specified gradient
  17095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17096. * @returns the current particle system
  17097. */
  17098. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17099. /**
  17100. * Remove a specific size gradient
  17101. * @param gradient defines the gradient to remove
  17102. * @returns the current particle system
  17103. */
  17104. removeSizeGradient(gradient: number): IParticleSystem;
  17105. /**
  17106. * Adds a new color remap gradient
  17107. * @param gradient defines the gradient to use (between 0 and 1)
  17108. * @param min defines the color remap minimal range
  17109. * @param max defines the color remap maximal range
  17110. * @returns the current particle system
  17111. */
  17112. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17113. /**
  17114. * Remove a specific color remap gradient
  17115. * @param gradient defines the gradient to remove
  17116. * @returns the current particle system
  17117. */
  17118. removeColorRemapGradient(gradient: number): IParticleSystem;
  17119. /**
  17120. * Adds a new alpha remap gradient
  17121. * @param gradient defines the gradient to use (between 0 and 1)
  17122. * @param min defines the alpha remap minimal range
  17123. * @param max defines the alpha remap maximal range
  17124. * @returns the current particle system
  17125. */
  17126. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17127. /**
  17128. * Remove a specific alpha remap gradient
  17129. * @param gradient defines the gradient to remove
  17130. * @returns the current particle system
  17131. */
  17132. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17133. /**
  17134. * Adds a new angular speed gradient
  17135. * @param gradient defines the gradient to use (between 0 and 1)
  17136. * @param factor defines the angular speed to affect to the specified gradient
  17137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17138. * @returns the current particle system
  17139. */
  17140. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17141. /**
  17142. * Remove a specific angular speed gradient
  17143. * @param gradient defines the gradient to remove
  17144. * @returns the current particle system
  17145. */
  17146. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17147. /**
  17148. * Adds a new velocity gradient
  17149. * @param gradient defines the gradient to use (between 0 and 1)
  17150. * @param factor defines the velocity to affect to the specified gradient
  17151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17152. * @returns the current particle system
  17153. */
  17154. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17155. /**
  17156. * Remove a specific velocity gradient
  17157. * @param gradient defines the gradient to remove
  17158. * @returns the current particle system
  17159. */
  17160. removeVelocityGradient(gradient: number): IParticleSystem;
  17161. /**
  17162. * Adds a new limit velocity gradient
  17163. * @param gradient defines the gradient to use (between 0 and 1)
  17164. * @param factor defines the limit velocity value to affect to the specified gradient
  17165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17166. * @returns the current particle system
  17167. */
  17168. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17169. /**
  17170. * Remove a specific limit velocity gradient
  17171. * @param gradient defines the gradient to remove
  17172. * @returns the current particle system
  17173. */
  17174. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17175. /**
  17176. * Adds a new drag gradient
  17177. * @param gradient defines the gradient to use (between 0 and 1)
  17178. * @param factor defines the drag value to affect to the specified gradient
  17179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17180. * @returns the current particle system
  17181. */
  17182. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17183. /**
  17184. * Remove a specific drag gradient
  17185. * @param gradient defines the gradient to remove
  17186. * @returns the current particle system
  17187. */
  17188. removeDragGradient(gradient: number): IParticleSystem;
  17189. /**
  17190. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17191. * @param gradient defines the gradient to use (between 0 and 1)
  17192. * @param factor defines the emit rate value to affect to the specified gradient
  17193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17194. * @returns the current particle system
  17195. */
  17196. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17197. /**
  17198. * Remove a specific emit rate gradient
  17199. * @param gradient defines the gradient to remove
  17200. * @returns the current particle system
  17201. */
  17202. removeEmitRateGradient(gradient: number): IParticleSystem;
  17203. /**
  17204. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17205. * @param gradient defines the gradient to use (between 0 and 1)
  17206. * @param factor defines the start size value to affect to the specified gradient
  17207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17208. * @returns the current particle system
  17209. */
  17210. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17211. /**
  17212. * Remove a specific start size gradient
  17213. * @param gradient defines the gradient to remove
  17214. * @returns the current particle system
  17215. */
  17216. removeStartSizeGradient(gradient: number): IParticleSystem;
  17217. private _createRampGradientTexture;
  17218. /**
  17219. * Gets the current list of ramp gradients.
  17220. * You must use addRampGradient and removeRampGradient to udpate this list
  17221. * @returns the list of ramp gradients
  17222. */
  17223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17224. /**
  17225. * Adds a new ramp gradient used to remap particle colors
  17226. * @param gradient defines the gradient to use (between 0 and 1)
  17227. * @param color defines the color to affect to the specified gradient
  17228. * @returns the current particle system
  17229. */
  17230. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17231. /**
  17232. * Remove a specific ramp gradient
  17233. * @param gradient defines the gradient to remove
  17234. * @returns the current particle system
  17235. */
  17236. removeRampGradient(gradient: number): ParticleSystem;
  17237. /**
  17238. * Adds a new color gradient
  17239. * @param gradient defines the gradient to use (between 0 and 1)
  17240. * @param color1 defines the color to affect to the specified gradient
  17241. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17242. * @returns this particle system
  17243. */
  17244. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17245. /**
  17246. * Remove a specific color gradient
  17247. * @param gradient defines the gradient to remove
  17248. * @returns this particle system
  17249. */
  17250. removeColorGradient(gradient: number): IParticleSystem;
  17251. private _fetchR;
  17252. protected _reset(): void;
  17253. private _resetEffect;
  17254. private _createVertexBuffers;
  17255. private _createIndexBuffer;
  17256. /**
  17257. * Gets the maximum number of particles active at the same time.
  17258. * @returns The max number of active particles.
  17259. */
  17260. getCapacity(): number;
  17261. /**
  17262. * Gets whether there are still active particles in the system.
  17263. * @returns True if it is alive, otherwise false.
  17264. */
  17265. isAlive(): boolean;
  17266. /**
  17267. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17268. * @returns True if it has been started, otherwise false.
  17269. */
  17270. isStarted(): boolean;
  17271. private _prepareSubEmitterInternalArray;
  17272. /**
  17273. * Starts the particle system and begins to emit
  17274. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17275. */
  17276. start(delay?: number): void;
  17277. /**
  17278. * Stops the particle system.
  17279. * @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.
  17280. */
  17281. stop(stopSubEmitters?: boolean): void;
  17282. /**
  17283. * Remove all active particles
  17284. */
  17285. reset(): void;
  17286. /**
  17287. * @hidden (for internal use only)
  17288. */
  17289. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17290. /**
  17291. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17292. * Its lifetime will start back at 0.
  17293. */
  17294. recycleParticle: (particle: Particle) => void;
  17295. private _stopSubEmitters;
  17296. private _createParticle;
  17297. private _removeFromRoot;
  17298. private _emitFromParticle;
  17299. private _update;
  17300. /** @hidden */
  17301. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17302. /** @hidden */
  17303. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17304. /** @hidden */
  17305. private _getEffect;
  17306. /**
  17307. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17308. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17309. */
  17310. animate(preWarmOnly?: boolean): void;
  17311. private _appendParticleVertices;
  17312. /**
  17313. * Rebuilds the particle system.
  17314. */
  17315. rebuild(): void;
  17316. /**
  17317. * Is this system ready to be used/rendered
  17318. * @return true if the system is ready
  17319. */
  17320. isReady(): boolean;
  17321. private _render;
  17322. /**
  17323. * Renders the particle system in its current state.
  17324. * @returns the current number of particles
  17325. */
  17326. render(): number;
  17327. /**
  17328. * Disposes the particle system and free the associated resources
  17329. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17330. */
  17331. dispose(disposeTexture?: boolean): void;
  17332. /**
  17333. * Clones the particle system.
  17334. * @param name The name of the cloned object
  17335. * @param newEmitter The new emitter to use
  17336. * @returns the cloned particle system
  17337. */
  17338. clone(name: string, newEmitter: any): ParticleSystem;
  17339. /**
  17340. * Serializes the particle system to a JSON object.
  17341. * @returns the JSON object
  17342. */
  17343. serialize(): any;
  17344. /** @hidden */
  17345. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17346. /** @hidden */
  17347. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17348. /**
  17349. * Parses a JSON object to create a particle system.
  17350. * @param parsedParticleSystem The JSON object to parse
  17351. * @param scene The scene to create the particle system in
  17352. * @param rootUrl The root url to use to load external dependencies like texture
  17353. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17354. * @returns the Parsed particle system
  17355. */
  17356. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17357. }
  17358. }
  17359. declare module BABYLON {
  17360. /**
  17361. * A particle represents one of the element emitted by a particle system.
  17362. * This is mainly define by its coordinates, direction, velocity and age.
  17363. */
  17364. export class Particle {
  17365. /**
  17366. * The particle system the particle belongs to.
  17367. */
  17368. particleSystem: ParticleSystem;
  17369. private static _Count;
  17370. /**
  17371. * Unique ID of the particle
  17372. */
  17373. id: number;
  17374. /**
  17375. * The world position of the particle in the scene.
  17376. */
  17377. position: Vector3;
  17378. /**
  17379. * The world direction of the particle in the scene.
  17380. */
  17381. direction: Vector3;
  17382. /**
  17383. * The color of the particle.
  17384. */
  17385. color: Color4;
  17386. /**
  17387. * The color change of the particle per step.
  17388. */
  17389. colorStep: Color4;
  17390. /**
  17391. * Defines how long will the life of the particle be.
  17392. */
  17393. lifeTime: number;
  17394. /**
  17395. * The current age of the particle.
  17396. */
  17397. age: number;
  17398. /**
  17399. * The current size of the particle.
  17400. */
  17401. size: number;
  17402. /**
  17403. * The current scale of the particle.
  17404. */
  17405. scale: Vector2;
  17406. /**
  17407. * The current angle of the particle.
  17408. */
  17409. angle: number;
  17410. /**
  17411. * Defines how fast is the angle changing.
  17412. */
  17413. angularSpeed: number;
  17414. /**
  17415. * Defines the cell index used by the particle to be rendered from a sprite.
  17416. */
  17417. cellIndex: number;
  17418. /**
  17419. * The information required to support color remapping
  17420. */
  17421. remapData: Vector4;
  17422. /** @hidden */
  17423. _randomCellOffset?: number;
  17424. /** @hidden */
  17425. _initialDirection: Nullable<Vector3>;
  17426. /** @hidden */
  17427. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17428. /** @hidden */
  17429. _initialStartSpriteCellID: number;
  17430. /** @hidden */
  17431. _initialEndSpriteCellID: number;
  17432. /** @hidden */
  17433. _currentColorGradient: Nullable<ColorGradient>;
  17434. /** @hidden */
  17435. _currentColor1: Color4;
  17436. /** @hidden */
  17437. _currentColor2: Color4;
  17438. /** @hidden */
  17439. _currentSizeGradient: Nullable<FactorGradient>;
  17440. /** @hidden */
  17441. _currentSize1: number;
  17442. /** @hidden */
  17443. _currentSize2: number;
  17444. /** @hidden */
  17445. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentAngularSpeed1: number;
  17448. /** @hidden */
  17449. _currentAngularSpeed2: number;
  17450. /** @hidden */
  17451. _currentVelocityGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentVelocity1: number;
  17454. /** @hidden */
  17455. _currentVelocity2: number;
  17456. /** @hidden */
  17457. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17458. /** @hidden */
  17459. _currentLimitVelocity1: number;
  17460. /** @hidden */
  17461. _currentLimitVelocity2: number;
  17462. /** @hidden */
  17463. _currentDragGradient: Nullable<FactorGradient>;
  17464. /** @hidden */
  17465. _currentDrag1: number;
  17466. /** @hidden */
  17467. _currentDrag2: number;
  17468. /** @hidden */
  17469. _randomNoiseCoordinates1: Vector3;
  17470. /** @hidden */
  17471. _randomNoiseCoordinates2: Vector3;
  17472. /**
  17473. * Creates a new instance Particle
  17474. * @param particleSystem the particle system the particle belongs to
  17475. */
  17476. constructor(
  17477. /**
  17478. * The particle system the particle belongs to.
  17479. */
  17480. particleSystem: ParticleSystem);
  17481. private updateCellInfoFromSystem;
  17482. /**
  17483. * Defines how the sprite cell index is updated for the particle
  17484. */
  17485. updateCellIndex(): void;
  17486. /** @hidden */
  17487. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17488. /** @hidden */
  17489. _inheritParticleInfoToSubEmitters(): void;
  17490. /** @hidden */
  17491. _reset(): void;
  17492. /**
  17493. * Copy the properties of particle to another one.
  17494. * @param other the particle to copy the information to.
  17495. */
  17496. copyTo(other: Particle): void;
  17497. }
  17498. }
  17499. declare module BABYLON {
  17500. /**
  17501. * Particle emitter represents a volume emitting particles.
  17502. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17503. */
  17504. export interface IParticleEmitterType {
  17505. /**
  17506. * Called by the particle System when the direction is computed for the created particle.
  17507. * @param worldMatrix is the world matrix of the particle system
  17508. * @param directionToUpdate is the direction vector to update with the result
  17509. * @param particle is the particle we are computed the direction for
  17510. */
  17511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17512. /**
  17513. * Called by the particle System when the position is computed for the created particle.
  17514. * @param worldMatrix is the world matrix of the particle system
  17515. * @param positionToUpdate is the position vector to update with the result
  17516. * @param particle is the particle we are computed the position for
  17517. */
  17518. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17519. /**
  17520. * Clones the current emitter and returns a copy of it
  17521. * @returns the new emitter
  17522. */
  17523. clone(): IParticleEmitterType;
  17524. /**
  17525. * Called by the GPUParticleSystem to setup the update shader
  17526. * @param effect defines the update shader
  17527. */
  17528. applyToShader(effect: Effect): void;
  17529. /**
  17530. * Returns a string to use to update the GPU particles update shader
  17531. * @returns the effect defines string
  17532. */
  17533. getEffectDefines(): string;
  17534. /**
  17535. * Returns a string representing the class name
  17536. * @returns a string containing the class name
  17537. */
  17538. getClassName(): string;
  17539. /**
  17540. * Serializes the particle system to a JSON object.
  17541. * @returns the JSON object
  17542. */
  17543. serialize(): any;
  17544. /**
  17545. * Parse properties from a JSON object
  17546. * @param serializationObject defines the JSON object
  17547. */
  17548. parse(serializationObject: any): void;
  17549. }
  17550. }
  17551. declare module BABYLON {
  17552. /**
  17553. * Particle emitter emitting particles from the inside of a box.
  17554. * It emits the particles randomly between 2 given directions.
  17555. */
  17556. export class BoxParticleEmitter implements IParticleEmitterType {
  17557. /**
  17558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17559. */
  17560. direction1: Vector3;
  17561. /**
  17562. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17563. */
  17564. direction2: Vector3;
  17565. /**
  17566. * 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.
  17567. */
  17568. minEmitBox: Vector3;
  17569. /**
  17570. * 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.
  17571. */
  17572. maxEmitBox: Vector3;
  17573. /**
  17574. * Creates a new instance BoxParticleEmitter
  17575. */
  17576. constructor();
  17577. /**
  17578. * Called by the particle System when the direction is computed for the created particle.
  17579. * @param worldMatrix is the world matrix of the particle system
  17580. * @param directionToUpdate is the direction vector to update with the result
  17581. * @param particle is the particle we are computed the direction for
  17582. */
  17583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17584. /**
  17585. * Called by the particle System when the position is computed for the created particle.
  17586. * @param worldMatrix is the world matrix of the particle system
  17587. * @param positionToUpdate is the position vector to update with the result
  17588. * @param particle is the particle we are computed the position for
  17589. */
  17590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17591. /**
  17592. * Clones the current emitter and returns a copy of it
  17593. * @returns the new emitter
  17594. */
  17595. clone(): BoxParticleEmitter;
  17596. /**
  17597. * Called by the GPUParticleSystem to setup the update shader
  17598. * @param effect defines the update shader
  17599. */
  17600. applyToShader(effect: Effect): void;
  17601. /**
  17602. * Returns a string to use to update the GPU particles update shader
  17603. * @returns a string containng the defines string
  17604. */
  17605. getEffectDefines(): string;
  17606. /**
  17607. * Returns the string "BoxParticleEmitter"
  17608. * @returns a string containing the class name
  17609. */
  17610. getClassName(): string;
  17611. /**
  17612. * Serializes the particle system to a JSON object.
  17613. * @returns the JSON object
  17614. */
  17615. serialize(): any;
  17616. /**
  17617. * Parse properties from a JSON object
  17618. * @param serializationObject defines the JSON object
  17619. */
  17620. parse(serializationObject: any): void;
  17621. }
  17622. }
  17623. declare module BABYLON {
  17624. /**
  17625. * Particle emitter emitting particles from the inside of a cone.
  17626. * It emits the particles alongside the cone volume from the base to the particle.
  17627. * The emission direction might be randomized.
  17628. */
  17629. export class ConeParticleEmitter implements IParticleEmitterType {
  17630. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17631. directionRandomizer: number;
  17632. private _radius;
  17633. private _angle;
  17634. private _height;
  17635. /**
  17636. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17637. */
  17638. radiusRange: number;
  17639. /**
  17640. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17641. */
  17642. heightRange: number;
  17643. /**
  17644. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17645. */
  17646. emitFromSpawnPointOnly: boolean;
  17647. /**
  17648. * Gets or sets the radius of the emission cone
  17649. */
  17650. radius: number;
  17651. /**
  17652. * Gets or sets the angle of the emission cone
  17653. */
  17654. angle: number;
  17655. private _buildHeight;
  17656. /**
  17657. * Creates a new instance ConeParticleEmitter
  17658. * @param radius the radius of the emission cone (1 by default)
  17659. * @param angle the cone base angle (PI by default)
  17660. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17661. */
  17662. constructor(radius?: number, angle?: number,
  17663. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17664. directionRandomizer?: number);
  17665. /**
  17666. * Called by the particle System when the direction is computed for the created particle.
  17667. * @param worldMatrix is the world matrix of the particle system
  17668. * @param directionToUpdate is the direction vector to update with the result
  17669. * @param particle is the particle we are computed the direction for
  17670. */
  17671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17672. /**
  17673. * Called by the particle System when the position is computed for the created particle.
  17674. * @param worldMatrix is the world matrix of the particle system
  17675. * @param positionToUpdate is the position vector to update with the result
  17676. * @param particle is the particle we are computed the position for
  17677. */
  17678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17679. /**
  17680. * Clones the current emitter and returns a copy of it
  17681. * @returns the new emitter
  17682. */
  17683. clone(): ConeParticleEmitter;
  17684. /**
  17685. * Called by the GPUParticleSystem to setup the update shader
  17686. * @param effect defines the update shader
  17687. */
  17688. applyToShader(effect: Effect): void;
  17689. /**
  17690. * Returns a string to use to update the GPU particles update shader
  17691. * @returns a string containng the defines string
  17692. */
  17693. getEffectDefines(): string;
  17694. /**
  17695. * Returns the string "ConeParticleEmitter"
  17696. * @returns a string containing the class name
  17697. */
  17698. getClassName(): string;
  17699. /**
  17700. * Serializes the particle system to a JSON object.
  17701. * @returns the JSON object
  17702. */
  17703. serialize(): any;
  17704. /**
  17705. * Parse properties from a JSON object
  17706. * @param serializationObject defines the JSON object
  17707. */
  17708. parse(serializationObject: any): void;
  17709. }
  17710. }
  17711. declare module BABYLON {
  17712. /**
  17713. * Particle emitter emitting particles from the inside of a cylinder.
  17714. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17715. */
  17716. export class CylinderParticleEmitter implements IParticleEmitterType {
  17717. /**
  17718. * The radius of the emission cylinder.
  17719. */
  17720. radius: number;
  17721. /**
  17722. * The height of the emission cylinder.
  17723. */
  17724. height: number;
  17725. /**
  17726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17727. */
  17728. radiusRange: number;
  17729. /**
  17730. * How much to randomize the particle direction [0-1].
  17731. */
  17732. directionRandomizer: number;
  17733. /**
  17734. * Creates a new instance CylinderParticleEmitter
  17735. * @param radius the radius of the emission cylinder (1 by default)
  17736. * @param height the height of the emission cylinder (1 by default)
  17737. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17738. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17739. */
  17740. constructor(
  17741. /**
  17742. * The radius of the emission cylinder.
  17743. */
  17744. radius?: number,
  17745. /**
  17746. * The height of the emission cylinder.
  17747. */
  17748. height?: number,
  17749. /**
  17750. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17751. */
  17752. radiusRange?: number,
  17753. /**
  17754. * How much to randomize the particle direction [0-1].
  17755. */
  17756. directionRandomizer?: number);
  17757. /**
  17758. * Called by the particle System when the direction is computed for the created particle.
  17759. * @param worldMatrix is the world matrix of the particle system
  17760. * @param directionToUpdate is the direction vector to update with the result
  17761. * @param particle is the particle we are computed the direction for
  17762. */
  17763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17764. /**
  17765. * Called by the particle System when the position is computed for the created particle.
  17766. * @param worldMatrix is the world matrix of the particle system
  17767. * @param positionToUpdate is the position vector to update with the result
  17768. * @param particle is the particle we are computed the position for
  17769. */
  17770. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17771. /**
  17772. * Clones the current emitter and returns a copy of it
  17773. * @returns the new emitter
  17774. */
  17775. clone(): CylinderParticleEmitter;
  17776. /**
  17777. * Called by the GPUParticleSystem to setup the update shader
  17778. * @param effect defines the update shader
  17779. */
  17780. applyToShader(effect: Effect): void;
  17781. /**
  17782. * Returns a string to use to update the GPU particles update shader
  17783. * @returns a string containng the defines string
  17784. */
  17785. getEffectDefines(): string;
  17786. /**
  17787. * Returns the string "CylinderParticleEmitter"
  17788. * @returns a string containing the class name
  17789. */
  17790. getClassName(): string;
  17791. /**
  17792. * Serializes the particle system to a JSON object.
  17793. * @returns the JSON object
  17794. */
  17795. serialize(): any;
  17796. /**
  17797. * Parse properties from a JSON object
  17798. * @param serializationObject defines the JSON object
  17799. */
  17800. parse(serializationObject: any): void;
  17801. }
  17802. /**
  17803. * Particle emitter emitting particles from the inside of a cylinder.
  17804. * It emits the particles randomly between two vectors.
  17805. */
  17806. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17807. /**
  17808. * The min limit of the emission direction.
  17809. */
  17810. direction1: Vector3;
  17811. /**
  17812. * The max limit of the emission direction.
  17813. */
  17814. direction2: Vector3;
  17815. /**
  17816. * Creates a new instance CylinderDirectedParticleEmitter
  17817. * @param radius the radius of the emission cylinder (1 by default)
  17818. * @param height the height of the emission cylinder (1 by default)
  17819. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17820. * @param direction1 the min limit of the emission direction (up vector by default)
  17821. * @param direction2 the max limit of the emission direction (up vector by default)
  17822. */
  17823. constructor(radius?: number, height?: number, radiusRange?: number,
  17824. /**
  17825. * The min limit of the emission direction.
  17826. */
  17827. direction1?: Vector3,
  17828. /**
  17829. * The max limit of the emission direction.
  17830. */
  17831. direction2?: Vector3);
  17832. /**
  17833. * Called by the particle System when the direction is computed for the created particle.
  17834. * @param worldMatrix is the world matrix of the particle system
  17835. * @param directionToUpdate is the direction vector to update with the result
  17836. * @param particle is the particle we are computed the direction for
  17837. */
  17838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17839. /**
  17840. * Clones the current emitter and returns a copy of it
  17841. * @returns the new emitter
  17842. */
  17843. clone(): CylinderDirectedParticleEmitter;
  17844. /**
  17845. * Called by the GPUParticleSystem to setup the update shader
  17846. * @param effect defines the update shader
  17847. */
  17848. applyToShader(effect: Effect): void;
  17849. /**
  17850. * Returns a string to use to update the GPU particles update shader
  17851. * @returns a string containng the defines string
  17852. */
  17853. getEffectDefines(): string;
  17854. /**
  17855. * Returns the string "CylinderDirectedParticleEmitter"
  17856. * @returns a string containing the class name
  17857. */
  17858. getClassName(): string;
  17859. /**
  17860. * Serializes the particle system to a JSON object.
  17861. * @returns the JSON object
  17862. */
  17863. serialize(): any;
  17864. /**
  17865. * Parse properties from a JSON object
  17866. * @param serializationObject defines the JSON object
  17867. */
  17868. parse(serializationObject: any): void;
  17869. }
  17870. }
  17871. declare module BABYLON {
  17872. /**
  17873. * Particle emitter emitting particles from the inside of a hemisphere.
  17874. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17875. */
  17876. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17877. /**
  17878. * The radius of the emission hemisphere.
  17879. */
  17880. radius: number;
  17881. /**
  17882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17883. */
  17884. radiusRange: number;
  17885. /**
  17886. * How much to randomize the particle direction [0-1].
  17887. */
  17888. directionRandomizer: number;
  17889. /**
  17890. * Creates a new instance HemisphericParticleEmitter
  17891. * @param radius the radius of the emission hemisphere (1 by default)
  17892. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17893. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17894. */
  17895. constructor(
  17896. /**
  17897. * The radius of the emission hemisphere.
  17898. */
  17899. radius?: number,
  17900. /**
  17901. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17902. */
  17903. radiusRange?: number,
  17904. /**
  17905. * How much to randomize the particle direction [0-1].
  17906. */
  17907. directionRandomizer?: number);
  17908. /**
  17909. * Called by the particle System when the direction is computed for the created particle.
  17910. * @param worldMatrix is the world matrix of the particle system
  17911. * @param directionToUpdate is the direction vector to update with the result
  17912. * @param particle is the particle we are computed the direction for
  17913. */
  17914. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17915. /**
  17916. * Called by the particle System when the position is computed for the created particle.
  17917. * @param worldMatrix is the world matrix of the particle system
  17918. * @param positionToUpdate is the position vector to update with the result
  17919. * @param particle is the particle we are computed the position for
  17920. */
  17921. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17922. /**
  17923. * Clones the current emitter and returns a copy of it
  17924. * @returns the new emitter
  17925. */
  17926. clone(): HemisphericParticleEmitter;
  17927. /**
  17928. * Called by the GPUParticleSystem to setup the update shader
  17929. * @param effect defines the update shader
  17930. */
  17931. applyToShader(effect: Effect): void;
  17932. /**
  17933. * Returns a string to use to update the GPU particles update shader
  17934. * @returns a string containng the defines string
  17935. */
  17936. getEffectDefines(): string;
  17937. /**
  17938. * Returns the string "HemisphericParticleEmitter"
  17939. * @returns a string containing the class name
  17940. */
  17941. getClassName(): string;
  17942. /**
  17943. * Serializes the particle system to a JSON object.
  17944. * @returns the JSON object
  17945. */
  17946. serialize(): any;
  17947. /**
  17948. * Parse properties from a JSON object
  17949. * @param serializationObject defines the JSON object
  17950. */
  17951. parse(serializationObject: any): void;
  17952. }
  17953. }
  17954. declare module BABYLON {
  17955. /**
  17956. * Particle emitter emitting particles from a point.
  17957. * It emits the particles randomly between 2 given directions.
  17958. */
  17959. export class PointParticleEmitter implements IParticleEmitterType {
  17960. /**
  17961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17962. */
  17963. direction1: Vector3;
  17964. /**
  17965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17966. */
  17967. direction2: Vector3;
  17968. /**
  17969. * Creates a new instance PointParticleEmitter
  17970. */
  17971. constructor();
  17972. /**
  17973. * Called by the particle System when the direction is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param directionToUpdate is the direction vector to update with the result
  17976. * @param particle is the particle we are computed the direction for
  17977. */
  17978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Called by the particle System when the position is computed for the created particle.
  17981. * @param worldMatrix is the world matrix of the particle system
  17982. * @param positionToUpdate is the position vector to update with the result
  17983. * @param particle is the particle we are computed the position for
  17984. */
  17985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17986. /**
  17987. * Clones the current emitter and returns a copy of it
  17988. * @returns the new emitter
  17989. */
  17990. clone(): PointParticleEmitter;
  17991. /**
  17992. * Called by the GPUParticleSystem to setup the update shader
  17993. * @param effect defines the update shader
  17994. */
  17995. applyToShader(effect: Effect): void;
  17996. /**
  17997. * Returns a string to use to update the GPU particles update shader
  17998. * @returns a string containng the defines string
  17999. */
  18000. getEffectDefines(): string;
  18001. /**
  18002. * Returns the string "PointParticleEmitter"
  18003. * @returns a string containing the class name
  18004. */
  18005. getClassName(): string;
  18006. /**
  18007. * Serializes the particle system to a JSON object.
  18008. * @returns the JSON object
  18009. */
  18010. serialize(): any;
  18011. /**
  18012. * Parse properties from a JSON object
  18013. * @param serializationObject defines the JSON object
  18014. */
  18015. parse(serializationObject: any): void;
  18016. }
  18017. }
  18018. declare module BABYLON {
  18019. /**
  18020. * Particle emitter emitting particles from the inside of a sphere.
  18021. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18022. */
  18023. export class SphereParticleEmitter implements IParticleEmitterType {
  18024. /**
  18025. * The radius of the emission sphere.
  18026. */
  18027. radius: number;
  18028. /**
  18029. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18030. */
  18031. radiusRange: number;
  18032. /**
  18033. * How much to randomize the particle direction [0-1].
  18034. */
  18035. directionRandomizer: number;
  18036. /**
  18037. * Creates a new instance SphereParticleEmitter
  18038. * @param radius the radius of the emission sphere (1 by default)
  18039. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18040. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18041. */
  18042. constructor(
  18043. /**
  18044. * The radius of the emission sphere.
  18045. */
  18046. radius?: number,
  18047. /**
  18048. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18049. */
  18050. radiusRange?: number,
  18051. /**
  18052. * How much to randomize the particle direction [0-1].
  18053. */
  18054. directionRandomizer?: number);
  18055. /**
  18056. * Called by the particle System when the direction is computed for the created particle.
  18057. * @param worldMatrix is the world matrix of the particle system
  18058. * @param directionToUpdate is the direction vector to update with the result
  18059. * @param particle is the particle we are computed the direction for
  18060. */
  18061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18062. /**
  18063. * Called by the particle System when the position is computed for the created particle.
  18064. * @param worldMatrix is the world matrix of the particle system
  18065. * @param positionToUpdate is the position vector to update with the result
  18066. * @param particle is the particle we are computed the position for
  18067. */
  18068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18069. /**
  18070. * Clones the current emitter and returns a copy of it
  18071. * @returns the new emitter
  18072. */
  18073. clone(): SphereParticleEmitter;
  18074. /**
  18075. * Called by the GPUParticleSystem to setup the update shader
  18076. * @param effect defines the update shader
  18077. */
  18078. applyToShader(effect: Effect): void;
  18079. /**
  18080. * Returns a string to use to update the GPU particles update shader
  18081. * @returns a string containng the defines string
  18082. */
  18083. getEffectDefines(): string;
  18084. /**
  18085. * Returns the string "SphereParticleEmitter"
  18086. * @returns a string containing the class name
  18087. */
  18088. getClassName(): string;
  18089. /**
  18090. * Serializes the particle system to a JSON object.
  18091. * @returns the JSON object
  18092. */
  18093. serialize(): any;
  18094. /**
  18095. * Parse properties from a JSON object
  18096. * @param serializationObject defines the JSON object
  18097. */
  18098. parse(serializationObject: any): void;
  18099. }
  18100. /**
  18101. * Particle emitter emitting particles from the inside of a sphere.
  18102. * It emits the particles randomly between two vectors.
  18103. */
  18104. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18105. /**
  18106. * The min limit of the emission direction.
  18107. */
  18108. direction1: Vector3;
  18109. /**
  18110. * The max limit of the emission direction.
  18111. */
  18112. direction2: Vector3;
  18113. /**
  18114. * Creates a new instance SphereDirectedParticleEmitter
  18115. * @param radius the radius of the emission sphere (1 by default)
  18116. * @param direction1 the min limit of the emission direction (up vector by default)
  18117. * @param direction2 the max limit of the emission direction (up vector by default)
  18118. */
  18119. constructor(radius?: number,
  18120. /**
  18121. * The min limit of the emission direction.
  18122. */
  18123. direction1?: Vector3,
  18124. /**
  18125. * The max limit of the emission direction.
  18126. */
  18127. direction2?: Vector3);
  18128. /**
  18129. * Called by the particle System when the direction is computed for the created particle.
  18130. * @param worldMatrix is the world matrix of the particle system
  18131. * @param directionToUpdate is the direction vector to update with the result
  18132. * @param particle is the particle we are computed the direction for
  18133. */
  18134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18135. /**
  18136. * Clones the current emitter and returns a copy of it
  18137. * @returns the new emitter
  18138. */
  18139. clone(): SphereDirectedParticleEmitter;
  18140. /**
  18141. * Called by the GPUParticleSystem to setup the update shader
  18142. * @param effect defines the update shader
  18143. */
  18144. applyToShader(effect: Effect): void;
  18145. /**
  18146. * Returns a string to use to update the GPU particles update shader
  18147. * @returns a string containng the defines string
  18148. */
  18149. getEffectDefines(): string;
  18150. /**
  18151. * Returns the string "SphereDirectedParticleEmitter"
  18152. * @returns a string containing the class name
  18153. */
  18154. getClassName(): string;
  18155. /**
  18156. * Serializes the particle system to a JSON object.
  18157. * @returns the JSON object
  18158. */
  18159. serialize(): any;
  18160. /**
  18161. * Parse properties from a JSON object
  18162. * @param serializationObject defines the JSON object
  18163. */
  18164. parse(serializationObject: any): void;
  18165. }
  18166. }
  18167. declare module BABYLON {
  18168. /**
  18169. * Interface representing a particle system in Babylon.js.
  18170. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18171. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18172. */
  18173. export interface IParticleSystem {
  18174. /**
  18175. * List of animations used by the particle system.
  18176. */
  18177. animations: Animation[];
  18178. /**
  18179. * The id of the Particle system.
  18180. */
  18181. id: string;
  18182. /**
  18183. * The name of the Particle system.
  18184. */
  18185. name: string;
  18186. /**
  18187. * The emitter represents the Mesh or position we are attaching the particle system to.
  18188. */
  18189. emitter: Nullable<AbstractMesh | Vector3>;
  18190. /**
  18191. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18192. */
  18193. isBillboardBased: boolean;
  18194. /**
  18195. * The rendering group used by the Particle system to chose when to render.
  18196. */
  18197. renderingGroupId: number;
  18198. /**
  18199. * The layer mask we are rendering the particles through.
  18200. */
  18201. layerMask: number;
  18202. /**
  18203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18204. */
  18205. updateSpeed: number;
  18206. /**
  18207. * The amount of time the particle system is running (depends of the overall update speed).
  18208. */
  18209. targetStopDuration: number;
  18210. /**
  18211. * The texture used to render each particle. (this can be a spritesheet)
  18212. */
  18213. particleTexture: Nullable<Texture>;
  18214. /**
  18215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18216. */
  18217. blendMode: number;
  18218. /**
  18219. * Minimum life time of emitting particles.
  18220. */
  18221. minLifeTime: number;
  18222. /**
  18223. * Maximum life time of emitting particles.
  18224. */
  18225. maxLifeTime: number;
  18226. /**
  18227. * Minimum Size of emitting particles.
  18228. */
  18229. minSize: number;
  18230. /**
  18231. * Maximum Size of emitting particles.
  18232. */
  18233. maxSize: number;
  18234. /**
  18235. * Minimum scale of emitting particles on X axis.
  18236. */
  18237. minScaleX: number;
  18238. /**
  18239. * Maximum scale of emitting particles on X axis.
  18240. */
  18241. maxScaleX: number;
  18242. /**
  18243. * Minimum scale of emitting particles on Y axis.
  18244. */
  18245. minScaleY: number;
  18246. /**
  18247. * Maximum scale of emitting particles on Y axis.
  18248. */
  18249. maxScaleY: number;
  18250. /**
  18251. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18252. */
  18253. color1: Color4;
  18254. /**
  18255. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18256. */
  18257. color2: Color4;
  18258. /**
  18259. * Color the particle will have at the end of its lifetime.
  18260. */
  18261. colorDead: Color4;
  18262. /**
  18263. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18264. */
  18265. emitRate: number;
  18266. /**
  18267. * You can use gravity if you want to give an orientation to your particles.
  18268. */
  18269. gravity: Vector3;
  18270. /**
  18271. * Minimum power of emitting particles.
  18272. */
  18273. minEmitPower: number;
  18274. /**
  18275. * Maximum power of emitting particles.
  18276. */
  18277. maxEmitPower: number;
  18278. /**
  18279. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18280. */
  18281. minAngularSpeed: number;
  18282. /**
  18283. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18284. */
  18285. maxAngularSpeed: number;
  18286. /**
  18287. * Gets or sets the minimal initial rotation in radians.
  18288. */
  18289. minInitialRotation: number;
  18290. /**
  18291. * Gets or sets the maximal initial rotation in radians.
  18292. */
  18293. maxInitialRotation: number;
  18294. /**
  18295. * The particle emitter type defines the emitter used by the particle system.
  18296. * It can be for example box, sphere, or cone...
  18297. */
  18298. particleEmitterType: Nullable<IParticleEmitterType>;
  18299. /**
  18300. * Defines the delay in milliseconds before starting the system (0 by default)
  18301. */
  18302. startDelay: number;
  18303. /**
  18304. * 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
  18305. */
  18306. preWarmCycles: number;
  18307. /**
  18308. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18309. */
  18310. preWarmStepOffset: number;
  18311. /**
  18312. * 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)
  18313. */
  18314. spriteCellChangeSpeed: number;
  18315. /**
  18316. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18317. */
  18318. startSpriteCellID: number;
  18319. /**
  18320. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18321. */
  18322. endSpriteCellID: number;
  18323. /**
  18324. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18325. */
  18326. spriteCellWidth: number;
  18327. /**
  18328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18329. */
  18330. spriteCellHeight: number;
  18331. /**
  18332. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18333. */
  18334. spriteRandomStartCell: boolean;
  18335. /**
  18336. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18337. */
  18338. isAnimationSheetEnabled: boolean;
  18339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18340. translationPivot: Vector2;
  18341. /**
  18342. * Gets or sets a texture used to add random noise to particle positions
  18343. */
  18344. noiseTexture: Nullable<BaseTexture>;
  18345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18346. noiseStrength: Vector3;
  18347. /**
  18348. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18349. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18350. */
  18351. billboardMode: number;
  18352. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18353. limitVelocityDamping: number;
  18354. /**
  18355. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18356. */
  18357. beginAnimationOnStart: boolean;
  18358. /**
  18359. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18360. */
  18361. beginAnimationFrom: number;
  18362. /**
  18363. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18364. */
  18365. beginAnimationTo: number;
  18366. /**
  18367. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18368. */
  18369. beginAnimationLoop: boolean;
  18370. /**
  18371. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18372. */
  18373. disposeOnStop: boolean;
  18374. /**
  18375. * Gets the maximum number of particles active at the same time.
  18376. * @returns The max number of active particles.
  18377. */
  18378. getCapacity(): number;
  18379. /**
  18380. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18381. * @returns True if it has been started, otherwise false.
  18382. */
  18383. isStarted(): boolean;
  18384. /**
  18385. * Animates the particle system for this frame.
  18386. */
  18387. animate(): void;
  18388. /**
  18389. * Renders the particle system in its current state.
  18390. * @returns the current number of particles
  18391. */
  18392. render(): number;
  18393. /**
  18394. * Dispose the particle system and frees its associated resources.
  18395. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18396. */
  18397. dispose(disposeTexture?: boolean): void;
  18398. /**
  18399. * Clones the particle system.
  18400. * @param name The name of the cloned object
  18401. * @param newEmitter The new emitter to use
  18402. * @returns the cloned particle system
  18403. */
  18404. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18405. /**
  18406. * Serializes the particle system to a JSON object.
  18407. * @returns the JSON object
  18408. */
  18409. serialize(): any;
  18410. /**
  18411. * Rebuild the particle system
  18412. */
  18413. rebuild(): void;
  18414. /**
  18415. * Starts the particle system and begins to emit
  18416. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18417. */
  18418. start(delay?: number): void;
  18419. /**
  18420. * Stops the particle system.
  18421. */
  18422. stop(): void;
  18423. /**
  18424. * Remove all active particles
  18425. */
  18426. reset(): void;
  18427. /**
  18428. * Is this system ready to be used/rendered
  18429. * @return true if the system is ready
  18430. */
  18431. isReady(): boolean;
  18432. /**
  18433. * Adds a new color gradient
  18434. * @param gradient defines the gradient to use (between 0 and 1)
  18435. * @param color1 defines the color to affect to the specified gradient
  18436. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18437. * @returns the current particle system
  18438. */
  18439. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18440. /**
  18441. * Remove a specific color gradient
  18442. * @param gradient defines the gradient to remove
  18443. * @returns the current particle system
  18444. */
  18445. removeColorGradient(gradient: number): IParticleSystem;
  18446. /**
  18447. * Adds a new size gradient
  18448. * @param gradient defines the gradient to use (between 0 and 1)
  18449. * @param factor defines the size factor to affect to the specified gradient
  18450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18451. * @returns the current particle system
  18452. */
  18453. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18454. /**
  18455. * Remove a specific size gradient
  18456. * @param gradient defines the gradient to remove
  18457. * @returns the current particle system
  18458. */
  18459. removeSizeGradient(gradient: number): IParticleSystem;
  18460. /**
  18461. * Gets the current list of color gradients.
  18462. * You must use addColorGradient and removeColorGradient to udpate this list
  18463. * @returns the list of color gradients
  18464. */
  18465. getColorGradients(): Nullable<Array<ColorGradient>>;
  18466. /**
  18467. * Gets the current list of size gradients.
  18468. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18469. * @returns the list of size gradients
  18470. */
  18471. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18472. /**
  18473. * Gets the current list of angular speed gradients.
  18474. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18475. * @returns the list of angular speed gradients
  18476. */
  18477. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18478. /**
  18479. * Adds a new angular speed gradient
  18480. * @param gradient defines the gradient to use (between 0 and 1)
  18481. * @param factor defines the angular speed to affect to the specified gradient
  18482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18483. * @returns the current particle system
  18484. */
  18485. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18486. /**
  18487. * Remove a specific angular speed gradient
  18488. * @param gradient defines the gradient to remove
  18489. * @returns the current particle system
  18490. */
  18491. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18492. /**
  18493. * Gets the current list of velocity gradients.
  18494. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18495. * @returns the list of velocity gradients
  18496. */
  18497. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18498. /**
  18499. * Adds a new velocity gradient
  18500. * @param gradient defines the gradient to use (between 0 and 1)
  18501. * @param factor defines the velocity to affect to the specified gradient
  18502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18503. * @returns the current particle system
  18504. */
  18505. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18506. /**
  18507. * Remove a specific velocity gradient
  18508. * @param gradient defines the gradient to remove
  18509. * @returns the current particle system
  18510. */
  18511. removeVelocityGradient(gradient: number): IParticleSystem;
  18512. /**
  18513. * Gets the current list of limit velocity gradients.
  18514. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18515. * @returns the list of limit velocity gradients
  18516. */
  18517. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18518. /**
  18519. * Adds a new limit velocity gradient
  18520. * @param gradient defines the gradient to use (between 0 and 1)
  18521. * @param factor defines the limit velocity to affect to the specified gradient
  18522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18523. * @returns the current particle system
  18524. */
  18525. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18526. /**
  18527. * Remove a specific limit velocity gradient
  18528. * @param gradient defines the gradient to remove
  18529. * @returns the current particle system
  18530. */
  18531. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18532. /**
  18533. * Adds a new drag gradient
  18534. * @param gradient defines the gradient to use (between 0 and 1)
  18535. * @param factor defines the drag to affect to the specified gradient
  18536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18537. * @returns the current particle system
  18538. */
  18539. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18540. /**
  18541. * Remove a specific drag gradient
  18542. * @param gradient defines the gradient to remove
  18543. * @returns the current particle system
  18544. */
  18545. removeDragGradient(gradient: number): IParticleSystem;
  18546. /**
  18547. * Gets the current list of drag gradients.
  18548. * You must use addDragGradient and removeDragGradient to udpate this list
  18549. * @returns the list of drag gradients
  18550. */
  18551. getDragGradients(): Nullable<Array<FactorGradient>>;
  18552. /**
  18553. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18554. * @param gradient defines the gradient to use (between 0 and 1)
  18555. * @param factor defines the emit rate to affect to the specified gradient
  18556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18557. * @returns the current particle system
  18558. */
  18559. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18560. /**
  18561. * Remove a specific emit rate gradient
  18562. * @param gradient defines the gradient to remove
  18563. * @returns the current particle system
  18564. */
  18565. removeEmitRateGradient(gradient: number): IParticleSystem;
  18566. /**
  18567. * Gets the current list of emit rate gradients.
  18568. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18569. * @returns the list of emit rate gradients
  18570. */
  18571. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18572. /**
  18573. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18574. * @param gradient defines the gradient to use (between 0 and 1)
  18575. * @param factor defines the start size to affect to the specified gradient
  18576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18577. * @returns the current particle system
  18578. */
  18579. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18580. /**
  18581. * Remove a specific start size gradient
  18582. * @param gradient defines the gradient to remove
  18583. * @returns the current particle system
  18584. */
  18585. removeStartSizeGradient(gradient: number): IParticleSystem;
  18586. /**
  18587. * Gets the current list of start size gradients.
  18588. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18589. * @returns the list of start size gradients
  18590. */
  18591. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18592. /**
  18593. * Adds a new life time gradient
  18594. * @param gradient defines the gradient to use (between 0 and 1)
  18595. * @param factor defines the life time factor to affect to the specified gradient
  18596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18597. * @returns the current particle system
  18598. */
  18599. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18600. /**
  18601. * Remove a specific life time gradient
  18602. * @param gradient defines the gradient to remove
  18603. * @returns the current particle system
  18604. */
  18605. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18606. /**
  18607. * Gets the current list of life time gradients.
  18608. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18609. * @returns the list of life time gradients
  18610. */
  18611. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18612. /**
  18613. * Gets the current list of color gradients.
  18614. * You must use addColorGradient and removeColorGradient to udpate this list
  18615. * @returns the list of color gradients
  18616. */
  18617. getColorGradients(): Nullable<Array<ColorGradient>>;
  18618. /**
  18619. * Adds a new ramp gradient used to remap particle colors
  18620. * @param gradient defines the gradient to use (between 0 and 1)
  18621. * @param color defines the color to affect to the specified gradient
  18622. * @returns the current particle system
  18623. */
  18624. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18625. /**
  18626. * Gets the current list of ramp gradients.
  18627. * You must use addRampGradient and removeRampGradient to udpate this list
  18628. * @returns the list of ramp gradients
  18629. */
  18630. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18631. /** Gets or sets a boolean indicating that ramp gradients must be used
  18632. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18633. */
  18634. useRampGradients: boolean;
  18635. /**
  18636. * Adds a new color remap gradient
  18637. * @param gradient defines the gradient to use (between 0 and 1)
  18638. * @param min defines the color remap minimal range
  18639. * @param max defines the color remap maximal range
  18640. * @returns the current particle system
  18641. */
  18642. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18643. /**
  18644. * Gets the current list of color remap gradients.
  18645. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18646. * @returns the list of color remap gradients
  18647. */
  18648. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18649. /**
  18650. * Adds a new alpha remap gradient
  18651. * @param gradient defines the gradient to use (between 0 and 1)
  18652. * @param min defines the alpha remap minimal range
  18653. * @param max defines the alpha remap maximal range
  18654. * @returns the current particle system
  18655. */
  18656. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18657. /**
  18658. * Gets the current list of alpha remap gradients.
  18659. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18660. * @returns the list of alpha remap gradients
  18661. */
  18662. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18663. /**
  18664. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18665. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18666. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18667. * @returns the emitter
  18668. */
  18669. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18670. /**
  18671. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18672. * @param radius The radius of the hemisphere to emit from
  18673. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18674. * @returns the emitter
  18675. */
  18676. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18677. /**
  18678. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18679. * @param radius The radius of the sphere to emit from
  18680. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18681. * @returns the emitter
  18682. */
  18683. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18684. /**
  18685. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18686. * @param radius The radius of the sphere to emit from
  18687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18689. * @returns the emitter
  18690. */
  18691. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18692. /**
  18693. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18694. * @param radius The radius of the emission cylinder
  18695. * @param height The height of the emission cylinder
  18696. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18697. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18698. * @returns the emitter
  18699. */
  18700. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18701. /**
  18702. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18703. * @param radius The radius of the cylinder to emit from
  18704. * @param height The height of the emission cylinder
  18705. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18708. * @returns the emitter
  18709. */
  18710. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18711. /**
  18712. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18713. * @param radius The radius of the cone to emit from
  18714. * @param angle The base angle of the cone
  18715. * @returns the emitter
  18716. */
  18717. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18718. /**
  18719. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18720. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18721. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18722. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18723. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18724. * @returns the emitter
  18725. */
  18726. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18727. /**
  18728. * Get hosting scene
  18729. * @returns the scene
  18730. */
  18731. getScene(): Scene;
  18732. }
  18733. }
  18734. declare module BABYLON {
  18735. /**
  18736. * Creates an instance based on a source mesh.
  18737. */
  18738. export class InstancedMesh extends AbstractMesh {
  18739. private _sourceMesh;
  18740. private _currentLOD;
  18741. /** @hidden */
  18742. _indexInSourceMeshInstanceArray: number;
  18743. constructor(name: string, source: Mesh);
  18744. /**
  18745. * Returns the string "InstancedMesh".
  18746. */
  18747. getClassName(): string;
  18748. /** Gets the list of lights affecting that mesh */
  18749. readonly lightSources: Light[];
  18750. _resyncLightSources(): void;
  18751. _resyncLighSource(light: Light): void;
  18752. _removeLightSource(light: Light, dispose: boolean): void;
  18753. /**
  18754. * If the source mesh receives shadows
  18755. */
  18756. readonly receiveShadows: boolean;
  18757. /**
  18758. * The material of the source mesh
  18759. */
  18760. readonly material: Nullable<Material>;
  18761. /**
  18762. * Visibility of the source mesh
  18763. */
  18764. readonly visibility: number;
  18765. /**
  18766. * Skeleton of the source mesh
  18767. */
  18768. readonly skeleton: Nullable<Skeleton>;
  18769. /**
  18770. * Rendering ground id of the source mesh
  18771. */
  18772. renderingGroupId: number;
  18773. /**
  18774. * Returns the total number of vertices (integer).
  18775. */
  18776. getTotalVertices(): number;
  18777. /**
  18778. * Returns a positive integer : the total number of indices in this mesh geometry.
  18779. * @returns the numner of indices or zero if the mesh has no geometry.
  18780. */
  18781. getTotalIndices(): number;
  18782. /**
  18783. * The source mesh of the instance
  18784. */
  18785. readonly sourceMesh: Mesh;
  18786. /**
  18787. * Is this node ready to be used/rendered
  18788. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18789. * @return {boolean} is it ready
  18790. */
  18791. isReady(completeCheck?: boolean): boolean;
  18792. /**
  18793. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18794. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18795. * @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.
  18796. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18797. */
  18798. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18799. /**
  18800. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18801. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18802. * The `data` are either a numeric array either a Float32Array.
  18803. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18804. * 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).
  18805. * Note that a new underlying VertexBuffer object is created each call.
  18806. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18807. *
  18808. * Possible `kind` values :
  18809. * - VertexBuffer.PositionKind
  18810. * - VertexBuffer.UVKind
  18811. * - VertexBuffer.UV2Kind
  18812. * - VertexBuffer.UV3Kind
  18813. * - VertexBuffer.UV4Kind
  18814. * - VertexBuffer.UV5Kind
  18815. * - VertexBuffer.UV6Kind
  18816. * - VertexBuffer.ColorKind
  18817. * - VertexBuffer.MatricesIndicesKind
  18818. * - VertexBuffer.MatricesIndicesExtraKind
  18819. * - VertexBuffer.MatricesWeightsKind
  18820. * - VertexBuffer.MatricesWeightsExtraKind
  18821. *
  18822. * Returns the Mesh.
  18823. */
  18824. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18825. /**
  18826. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18827. * If the mesh has no geometry, it is simply returned as it is.
  18828. * The `data` are either a numeric array either a Float32Array.
  18829. * No new underlying VertexBuffer object is created.
  18830. * 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.
  18831. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18832. *
  18833. * Possible `kind` values :
  18834. * - VertexBuffer.PositionKind
  18835. * - VertexBuffer.UVKind
  18836. * - VertexBuffer.UV2Kind
  18837. * - VertexBuffer.UV3Kind
  18838. * - VertexBuffer.UV4Kind
  18839. * - VertexBuffer.UV5Kind
  18840. * - VertexBuffer.UV6Kind
  18841. * - VertexBuffer.ColorKind
  18842. * - VertexBuffer.MatricesIndicesKind
  18843. * - VertexBuffer.MatricesIndicesExtraKind
  18844. * - VertexBuffer.MatricesWeightsKind
  18845. * - VertexBuffer.MatricesWeightsExtraKind
  18846. *
  18847. * Returns the Mesh.
  18848. */
  18849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18850. /**
  18851. * Sets the mesh indices.
  18852. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18853. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18854. * This method creates a new index buffer each call.
  18855. * Returns the Mesh.
  18856. */
  18857. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18858. /**
  18859. * Boolean : True if the mesh owns the requested kind of data.
  18860. */
  18861. isVerticesDataPresent(kind: string): boolean;
  18862. /**
  18863. * Returns an array of indices (IndicesArray).
  18864. */
  18865. getIndices(): Nullable<IndicesArray>;
  18866. readonly _positions: Nullable<Vector3[]>;
  18867. /**
  18868. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18869. * This means the mesh underlying bounding box and sphere are recomputed.
  18870. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18871. * @returns the current mesh
  18872. */
  18873. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18874. /** @hidden */
  18875. _preActivate(): InstancedMesh;
  18876. /** @hidden */
  18877. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18878. /** @hidden */
  18879. _postActivate(): void;
  18880. getWorldMatrix(): Matrix;
  18881. readonly isAnInstance: boolean;
  18882. /**
  18883. * Returns the current associated LOD AbstractMesh.
  18884. */
  18885. getLOD(camera: Camera): AbstractMesh;
  18886. /** @hidden */
  18887. _syncSubMeshes(): InstancedMesh;
  18888. /** @hidden */
  18889. _generatePointsArray(): boolean;
  18890. /**
  18891. * Creates a new InstancedMesh from the current mesh.
  18892. * - name (string) : the cloned mesh name
  18893. * - newParent (optional Node) : the optional Node to parent the clone to.
  18894. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18895. *
  18896. * Returns the clone.
  18897. */
  18898. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18899. /**
  18900. * Disposes the InstancedMesh.
  18901. * Returns nothing.
  18902. */
  18903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18904. }
  18905. interface Mesh {
  18906. /**
  18907. * Register a custom buffer that will be instanced
  18908. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18909. * @param kind defines the buffer kind
  18910. * @param stride defines the stride in floats
  18911. */
  18912. registerInstancedBuffer(kind: string, stride: number): void;
  18913. /** @hidden */
  18914. _userInstancedBuffersStorage: {
  18915. data: {
  18916. [key: string]: Float32Array;
  18917. };
  18918. sizes: {
  18919. [key: string]: number;
  18920. };
  18921. vertexBuffers: {
  18922. [key: string]: Nullable<VertexBuffer>;
  18923. };
  18924. strides: {
  18925. [key: string]: number;
  18926. };
  18927. };
  18928. }
  18929. interface AbstractMesh {
  18930. /**
  18931. * Object used to store instanced buffers defined by user
  18932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18933. */
  18934. instancedBuffers: {
  18935. [key: string]: any;
  18936. };
  18937. }
  18938. }
  18939. declare module BABYLON {
  18940. /**
  18941. * Defines the options associated with the creation of a shader material.
  18942. */
  18943. export interface IShaderMaterialOptions {
  18944. /**
  18945. * Does the material work in alpha blend mode
  18946. */
  18947. needAlphaBlending: boolean;
  18948. /**
  18949. * Does the material work in alpha test mode
  18950. */
  18951. needAlphaTesting: boolean;
  18952. /**
  18953. * The list of attribute names used in the shader
  18954. */
  18955. attributes: string[];
  18956. /**
  18957. * The list of unifrom names used in the shader
  18958. */
  18959. uniforms: string[];
  18960. /**
  18961. * The list of UBO names used in the shader
  18962. */
  18963. uniformBuffers: string[];
  18964. /**
  18965. * The list of sampler names used in the shader
  18966. */
  18967. samplers: string[];
  18968. /**
  18969. * The list of defines used in the shader
  18970. */
  18971. defines: string[];
  18972. }
  18973. /**
  18974. * 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.
  18975. *
  18976. * This returned material effects how the mesh will look based on the code in the shaders.
  18977. *
  18978. * @see http://doc.babylonjs.com/how_to/shader_material
  18979. */
  18980. export class ShaderMaterial extends Material {
  18981. private _shaderPath;
  18982. private _options;
  18983. private _textures;
  18984. private _textureArrays;
  18985. private _floats;
  18986. private _ints;
  18987. private _floatsArrays;
  18988. private _colors3;
  18989. private _colors3Arrays;
  18990. private _colors4;
  18991. private _colors4Arrays;
  18992. private _vectors2;
  18993. private _vectors3;
  18994. private _vectors4;
  18995. private _matrices;
  18996. private _matrices3x3;
  18997. private _matrices2x2;
  18998. private _vectors2Arrays;
  18999. private _vectors3Arrays;
  19000. private _vectors4Arrays;
  19001. private _cachedWorldViewMatrix;
  19002. private _cachedWorldViewProjectionMatrix;
  19003. private _renderId;
  19004. /**
  19005. * Instantiate a new shader material.
  19006. * 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.
  19007. * This returned material effects how the mesh will look based on the code in the shaders.
  19008. * @see http://doc.babylonjs.com/how_to/shader_material
  19009. * @param name Define the name of the material in the scene
  19010. * @param scene Define the scene the material belongs to
  19011. * @param shaderPath Defines the route to the shader code in one of three ways:
  19012. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19013. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19014. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19015. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19016. * @param options Define the options used to create the shader
  19017. */
  19018. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19019. /**
  19020. * Gets the options used to compile the shader.
  19021. * They can be modified to trigger a new compilation
  19022. */
  19023. readonly options: IShaderMaterialOptions;
  19024. /**
  19025. * Gets the current class name of the material e.g. "ShaderMaterial"
  19026. * Mainly use in serialization.
  19027. * @returns the class name
  19028. */
  19029. getClassName(): string;
  19030. /**
  19031. * Specifies if the material will require alpha blending
  19032. * @returns a boolean specifying if alpha blending is needed
  19033. */
  19034. needAlphaBlending(): boolean;
  19035. /**
  19036. * Specifies if this material should be rendered in alpha test mode
  19037. * @returns a boolean specifying if an alpha test is needed.
  19038. */
  19039. needAlphaTesting(): boolean;
  19040. private _checkUniform;
  19041. /**
  19042. * Set a texture in the shader.
  19043. * @param name Define the name of the uniform samplers as defined in the shader
  19044. * @param texture Define the texture to bind to this sampler
  19045. * @return the material itself allowing "fluent" like uniform updates
  19046. */
  19047. setTexture(name: string, texture: Texture): ShaderMaterial;
  19048. /**
  19049. * Set a texture array in the shader.
  19050. * @param name Define the name of the uniform sampler array as defined in the shader
  19051. * @param textures Define the list of textures to bind to this sampler
  19052. * @return the material itself allowing "fluent" like uniform updates
  19053. */
  19054. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19055. /**
  19056. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  19062. /**
  19063. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  19069. /**
  19070. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  19076. /**
  19077. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  19083. /**
  19084. * Set a vec3 array in the shader from a Color3 array.
  19085. * @param name Define the name of the uniform as defined in the shader
  19086. * @param value Define the value to give to the uniform
  19087. * @return the material itself allowing "fluent" like uniform updates
  19088. */
  19089. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19090. /**
  19091. * Set a vec4 in the shader from a Color4.
  19092. * @param name Define the name of the uniform as defined in the shader
  19093. * @param value Define the value to give to the uniform
  19094. * @return the material itself allowing "fluent" like uniform updates
  19095. */
  19096. setColor4(name: string, value: Color4): ShaderMaterial;
  19097. /**
  19098. * Set a vec4 array in the shader from a Color4 array.
  19099. * @param name Define the name of the uniform as defined in the shader
  19100. * @param value Define the value to give to the uniform
  19101. * @return the material itself allowing "fluent" like uniform updates
  19102. */
  19103. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19104. /**
  19105. * Set a vec2 in the shader from a Vector2.
  19106. * @param name Define the name of the uniform as defined in the shader
  19107. * @param value Define the value to give to the uniform
  19108. * @return the material itself allowing "fluent" like uniform updates
  19109. */
  19110. setVector2(name: string, value: Vector2): ShaderMaterial;
  19111. /**
  19112. * Set a vec3 in the shader from a Vector3.
  19113. * @param name Define the name of the uniform as defined in the shader
  19114. * @param value Define the value to give to the uniform
  19115. * @return the material itself allowing "fluent" like uniform updates
  19116. */
  19117. setVector3(name: string, value: Vector3): ShaderMaterial;
  19118. /**
  19119. * Set a vec4 in the shader from a Vector4.
  19120. * @param name Define the name of the uniform as defined in the shader
  19121. * @param value Define the value to give to the uniform
  19122. * @return the material itself allowing "fluent" like uniform updates
  19123. */
  19124. setVector4(name: string, value: Vector4): ShaderMaterial;
  19125. /**
  19126. * Set a mat4 in the shader from a Matrix.
  19127. * @param name Define the name of the uniform as defined in the shader
  19128. * @param value Define the value to give to the uniform
  19129. * @return the material itself allowing "fluent" like uniform updates
  19130. */
  19131. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19132. /**
  19133. * Set a mat3 in the shader from a Float32Array.
  19134. * @param name Define the name of the uniform as defined in the shader
  19135. * @param value Define the value to give to the uniform
  19136. * @return the material itself allowing "fluent" like uniform updates
  19137. */
  19138. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19139. /**
  19140. * Set a mat2 in the shader from a Float32Array.
  19141. * @param name Define the name of the uniform as defined in the shader
  19142. * @param value Define the value to give to the uniform
  19143. * @return the material itself allowing "fluent" like uniform updates
  19144. */
  19145. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19146. /**
  19147. * Set a vec2 array in the shader from a number array.
  19148. * @param name Define the name of the uniform as defined in the shader
  19149. * @param value Define the value to give to the uniform
  19150. * @return the material itself allowing "fluent" like uniform updates
  19151. */
  19152. setArray2(name: string, value: number[]): ShaderMaterial;
  19153. /**
  19154. * Set a vec3 array in the shader from a number array.
  19155. * @param name Define the name of the uniform as defined in the shader
  19156. * @param value Define the value to give to the uniform
  19157. * @return the material itself allowing "fluent" like uniform updates
  19158. */
  19159. setArray3(name: string, value: number[]): ShaderMaterial;
  19160. /**
  19161. * Set a vec4 array in the shader from a number array.
  19162. * @param name Define the name of the uniform as defined in the shader
  19163. * @param value Define the value to give to the uniform
  19164. * @return the material itself allowing "fluent" like uniform updates
  19165. */
  19166. setArray4(name: string, value: number[]): ShaderMaterial;
  19167. private _checkCache;
  19168. /**
  19169. * Specifies that the submesh is ready to be used
  19170. * @param mesh defines the mesh to check
  19171. * @param subMesh defines which submesh to check
  19172. * @param useInstances specifies that instances should be used
  19173. * @returns a boolean indicating that the submesh is ready or not
  19174. */
  19175. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19176. /**
  19177. * Checks if the material is ready to render the requested mesh
  19178. * @param mesh Define the mesh to render
  19179. * @param useInstances Define whether or not the material is used with instances
  19180. * @returns true if ready, otherwise false
  19181. */
  19182. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19183. /**
  19184. * Binds the world matrix to the material
  19185. * @param world defines the world transformation matrix
  19186. */
  19187. bindOnlyWorldMatrix(world: Matrix): void;
  19188. /**
  19189. * Binds the material to the mesh
  19190. * @param world defines the world transformation matrix
  19191. * @param mesh defines the mesh to bind the material to
  19192. */
  19193. bind(world: Matrix, mesh?: Mesh): void;
  19194. /**
  19195. * Gets the active textures from the material
  19196. * @returns an array of textures
  19197. */
  19198. getActiveTextures(): BaseTexture[];
  19199. /**
  19200. * Specifies if the material uses a texture
  19201. * @param texture defines the texture to check against the material
  19202. * @returns a boolean specifying if the material uses the texture
  19203. */
  19204. hasTexture(texture: BaseTexture): boolean;
  19205. /**
  19206. * Makes a duplicate of the material, and gives it a new name
  19207. * @param name defines the new name for the duplicated material
  19208. * @returns the cloned material
  19209. */
  19210. clone(name: string): ShaderMaterial;
  19211. /**
  19212. * Disposes the material
  19213. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19214. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19215. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19216. */
  19217. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19218. /**
  19219. * Serializes this material in a JSON representation
  19220. * @returns the serialized material object
  19221. */
  19222. serialize(): any;
  19223. /**
  19224. * Creates a shader material from parsed shader material data
  19225. * @param source defines the JSON represnetation of the material
  19226. * @param scene defines the hosting scene
  19227. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19228. * @returns a new material
  19229. */
  19230. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19231. }
  19232. }
  19233. declare module BABYLON {
  19234. /** @hidden */
  19235. export var colorPixelShader: {
  19236. name: string;
  19237. shader: string;
  19238. };
  19239. }
  19240. declare module BABYLON {
  19241. /** @hidden */
  19242. export var colorVertexShader: {
  19243. name: string;
  19244. shader: string;
  19245. };
  19246. }
  19247. declare module BABYLON {
  19248. /**
  19249. * Line mesh
  19250. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19251. */
  19252. export class LinesMesh extends Mesh {
  19253. /**
  19254. * If vertex color should be applied to the mesh
  19255. */
  19256. readonly useVertexColor?: boolean | undefined;
  19257. /**
  19258. * If vertex alpha should be applied to the mesh
  19259. */
  19260. readonly useVertexAlpha?: boolean | undefined;
  19261. /**
  19262. * Color of the line (Default: White)
  19263. */
  19264. color: Color3;
  19265. /**
  19266. * Alpha of the line (Default: 1)
  19267. */
  19268. alpha: number;
  19269. /**
  19270. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19271. * This margin is expressed in world space coordinates, so its value may vary.
  19272. * Default value is 0.1
  19273. */
  19274. intersectionThreshold: number;
  19275. private _colorShader;
  19276. private color4;
  19277. /**
  19278. * Creates a new LinesMesh
  19279. * @param name defines the name
  19280. * @param scene defines the hosting scene
  19281. * @param parent defines the parent mesh if any
  19282. * @param source defines the optional source LinesMesh used to clone data from
  19283. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19284. * When false, achieved by calling a clone(), also passing False.
  19285. * This will make creation of children, recursive.
  19286. * @param useVertexColor defines if this LinesMesh supports vertex color
  19287. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19288. */
  19289. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19290. /**
  19291. * If vertex color should be applied to the mesh
  19292. */
  19293. useVertexColor?: boolean | undefined,
  19294. /**
  19295. * If vertex alpha should be applied to the mesh
  19296. */
  19297. useVertexAlpha?: boolean | undefined);
  19298. private _addClipPlaneDefine;
  19299. private _removeClipPlaneDefine;
  19300. isReady(): boolean;
  19301. /**
  19302. * Returns the string "LineMesh"
  19303. */
  19304. getClassName(): string;
  19305. /**
  19306. * @hidden
  19307. */
  19308. /**
  19309. * @hidden
  19310. */
  19311. material: Material;
  19312. /**
  19313. * @hidden
  19314. */
  19315. readonly checkCollisions: boolean;
  19316. /** @hidden */
  19317. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19318. /** @hidden */
  19319. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19320. /**
  19321. * Disposes of the line mesh
  19322. * @param doNotRecurse If children should be disposed
  19323. */
  19324. dispose(doNotRecurse?: boolean): void;
  19325. /**
  19326. * Returns a new LineMesh object cloned from the current one.
  19327. */
  19328. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19329. /**
  19330. * Creates a new InstancedLinesMesh object from the mesh model.
  19331. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19332. * @param name defines the name of the new instance
  19333. * @returns a new InstancedLinesMesh
  19334. */
  19335. createInstance(name: string): InstancedLinesMesh;
  19336. }
  19337. /**
  19338. * Creates an instance based on a source LinesMesh
  19339. */
  19340. export class InstancedLinesMesh extends InstancedMesh {
  19341. /**
  19342. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19343. * This margin is expressed in world space coordinates, so its value may vary.
  19344. * Initilized with the intersectionThreshold value of the source LinesMesh
  19345. */
  19346. intersectionThreshold: number;
  19347. constructor(name: string, source: LinesMesh);
  19348. /**
  19349. * Returns the string "InstancedLinesMesh".
  19350. */
  19351. getClassName(): string;
  19352. }
  19353. }
  19354. declare module BABYLON {
  19355. /** @hidden */
  19356. export var linePixelShader: {
  19357. name: string;
  19358. shader: string;
  19359. };
  19360. }
  19361. declare module BABYLON {
  19362. /** @hidden */
  19363. export var lineVertexShader: {
  19364. name: string;
  19365. shader: string;
  19366. };
  19367. }
  19368. declare module BABYLON {
  19369. interface AbstractMesh {
  19370. /**
  19371. * Gets the edgesRenderer associated with the mesh
  19372. */
  19373. edgesRenderer: Nullable<EdgesRenderer>;
  19374. }
  19375. interface LinesMesh {
  19376. /**
  19377. * Enables the edge rendering mode on the mesh.
  19378. * This mode makes the mesh edges visible
  19379. * @param epsilon defines the maximal distance between two angles to detect a face
  19380. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19381. * @returns the currentAbstractMesh
  19382. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19383. */
  19384. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19385. }
  19386. interface InstancedLinesMesh {
  19387. /**
  19388. * Enables the edge rendering mode on the mesh.
  19389. * This mode makes the mesh edges visible
  19390. * @param epsilon defines the maximal distance between two angles to detect a face
  19391. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19392. * @returns the current InstancedLinesMesh
  19393. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19394. */
  19395. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19396. }
  19397. /**
  19398. * Defines the minimum contract an Edges renderer should follow.
  19399. */
  19400. export interface IEdgesRenderer extends IDisposable {
  19401. /**
  19402. * Gets or sets a boolean indicating if the edgesRenderer is active
  19403. */
  19404. isEnabled: boolean;
  19405. /**
  19406. * Renders the edges of the attached mesh,
  19407. */
  19408. render(): void;
  19409. /**
  19410. * Checks wether or not the edges renderer is ready to render.
  19411. * @return true if ready, otherwise false.
  19412. */
  19413. isReady(): boolean;
  19414. }
  19415. /**
  19416. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19417. */
  19418. export class EdgesRenderer implements IEdgesRenderer {
  19419. /**
  19420. * Define the size of the edges with an orthographic camera
  19421. */
  19422. edgesWidthScalerForOrthographic: number;
  19423. /**
  19424. * Define the size of the edges with a perspective camera
  19425. */
  19426. edgesWidthScalerForPerspective: number;
  19427. protected _source: AbstractMesh;
  19428. protected _linesPositions: number[];
  19429. protected _linesNormals: number[];
  19430. protected _linesIndices: number[];
  19431. protected _epsilon: number;
  19432. protected _indicesCount: number;
  19433. protected _lineShader: ShaderMaterial;
  19434. protected _ib: DataBuffer;
  19435. protected _buffers: {
  19436. [key: string]: Nullable<VertexBuffer>;
  19437. };
  19438. protected _checkVerticesInsteadOfIndices: boolean;
  19439. private _meshRebuildObserver;
  19440. private _meshDisposeObserver;
  19441. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19442. isEnabled: boolean;
  19443. /**
  19444. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19445. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19446. * @param source Mesh used to create edges
  19447. * @param epsilon sum of angles in adjacency to check for edge
  19448. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19449. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19450. */
  19451. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19452. protected _prepareRessources(): void;
  19453. /** @hidden */
  19454. _rebuild(): void;
  19455. /**
  19456. * Releases the required resources for the edges renderer
  19457. */
  19458. dispose(): void;
  19459. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19460. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19461. /**
  19462. * Checks if the pair of p0 and p1 is en edge
  19463. * @param faceIndex
  19464. * @param edge
  19465. * @param faceNormals
  19466. * @param p0
  19467. * @param p1
  19468. * @private
  19469. */
  19470. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19471. /**
  19472. * push line into the position, normal and index buffer
  19473. * @protected
  19474. */
  19475. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19476. /**
  19477. * Generates lines edges from adjacencjes
  19478. * @private
  19479. */
  19480. _generateEdgesLines(): void;
  19481. /**
  19482. * Checks wether or not the edges renderer is ready to render.
  19483. * @return true if ready, otherwise false.
  19484. */
  19485. isReady(): boolean;
  19486. /**
  19487. * Renders the edges of the attached mesh,
  19488. */
  19489. render(): void;
  19490. }
  19491. /**
  19492. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19493. */
  19494. export class LineEdgesRenderer extends EdgesRenderer {
  19495. /**
  19496. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19497. * @param source LineMesh used to generate edges
  19498. * @param epsilon not important (specified angle for edge detection)
  19499. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19500. */
  19501. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19502. /**
  19503. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19504. */
  19505. _generateEdgesLines(): void;
  19506. }
  19507. }
  19508. declare module BABYLON {
  19509. /**
  19510. * This represents the object necessary to create a rendering group.
  19511. * This is exclusively used and created by the rendering manager.
  19512. * To modify the behavior, you use the available helpers in your scene or meshes.
  19513. * @hidden
  19514. */
  19515. export class RenderingGroup {
  19516. index: number;
  19517. private static _zeroVector;
  19518. private _scene;
  19519. private _opaqueSubMeshes;
  19520. private _transparentSubMeshes;
  19521. private _alphaTestSubMeshes;
  19522. private _depthOnlySubMeshes;
  19523. private _particleSystems;
  19524. private _spriteManagers;
  19525. private _opaqueSortCompareFn;
  19526. private _alphaTestSortCompareFn;
  19527. private _transparentSortCompareFn;
  19528. private _renderOpaque;
  19529. private _renderAlphaTest;
  19530. private _renderTransparent;
  19531. /** @hidden */
  19532. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19533. onBeforeTransparentRendering: () => void;
  19534. /**
  19535. * Set the opaque sort comparison function.
  19536. * If null the sub meshes will be render in the order they were created
  19537. */
  19538. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19539. /**
  19540. * Set the alpha test sort comparison function.
  19541. * If null the sub meshes will be render in the order they were created
  19542. */
  19543. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19544. /**
  19545. * Set the transparent sort comparison function.
  19546. * If null the sub meshes will be render in the order they were created
  19547. */
  19548. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19549. /**
  19550. * Creates a new rendering group.
  19551. * @param index The rendering group index
  19552. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19553. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19554. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19555. */
  19556. 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>);
  19557. /**
  19558. * Render all the sub meshes contained in the group.
  19559. * @param customRenderFunction Used to override the default render behaviour of the group.
  19560. * @returns true if rendered some submeshes.
  19561. */
  19562. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19563. /**
  19564. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19565. * @param subMeshes The submeshes to render
  19566. */
  19567. private renderOpaqueSorted;
  19568. /**
  19569. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19570. * @param subMeshes The submeshes to render
  19571. */
  19572. private renderAlphaTestSorted;
  19573. /**
  19574. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19575. * @param subMeshes The submeshes to render
  19576. */
  19577. private renderTransparentSorted;
  19578. /**
  19579. * Renders the submeshes in a specified order.
  19580. * @param subMeshes The submeshes to sort before render
  19581. * @param sortCompareFn The comparison function use to sort
  19582. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19583. * @param transparent Specifies to activate blending if true
  19584. */
  19585. private static renderSorted;
  19586. /**
  19587. * Renders the submeshes in the order they were dispatched (no sort applied).
  19588. * @param subMeshes The submeshes to render
  19589. */
  19590. private static renderUnsorted;
  19591. /**
  19592. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19593. * are rendered back to front if in the same alpha index.
  19594. *
  19595. * @param a The first submesh
  19596. * @param b The second submesh
  19597. * @returns The result of the comparison
  19598. */
  19599. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19600. /**
  19601. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19602. * are rendered back to front.
  19603. *
  19604. * @param a The first submesh
  19605. * @param b The second submesh
  19606. * @returns The result of the comparison
  19607. */
  19608. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19609. /**
  19610. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19611. * are rendered front to back (prevent overdraw).
  19612. *
  19613. * @param a The first submesh
  19614. * @param b The second submesh
  19615. * @returns The result of the comparison
  19616. */
  19617. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19618. /**
  19619. * Resets the different lists of submeshes to prepare a new frame.
  19620. */
  19621. prepare(): void;
  19622. dispose(): void;
  19623. /**
  19624. * Inserts the submesh in its correct queue depending on its material.
  19625. * @param subMesh The submesh to dispatch
  19626. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19627. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19628. */
  19629. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19630. dispatchSprites(spriteManager: ISpriteManager): void;
  19631. dispatchParticles(particleSystem: IParticleSystem): void;
  19632. private _renderParticles;
  19633. private _renderSprites;
  19634. }
  19635. }
  19636. declare module BABYLON {
  19637. /**
  19638. * Interface describing the different options available in the rendering manager
  19639. * regarding Auto Clear between groups.
  19640. */
  19641. export interface IRenderingManagerAutoClearSetup {
  19642. /**
  19643. * Defines whether or not autoclear is enable.
  19644. */
  19645. autoClear: boolean;
  19646. /**
  19647. * Defines whether or not to autoclear the depth buffer.
  19648. */
  19649. depth: boolean;
  19650. /**
  19651. * Defines whether or not to autoclear the stencil buffer.
  19652. */
  19653. stencil: boolean;
  19654. }
  19655. /**
  19656. * This class is used by the onRenderingGroupObservable
  19657. */
  19658. export class RenderingGroupInfo {
  19659. /**
  19660. * The Scene that being rendered
  19661. */
  19662. scene: Scene;
  19663. /**
  19664. * The camera currently used for the rendering pass
  19665. */
  19666. camera: Nullable<Camera>;
  19667. /**
  19668. * The ID of the renderingGroup being processed
  19669. */
  19670. renderingGroupId: number;
  19671. }
  19672. /**
  19673. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19674. * It is enable to manage the different groups as well as the different necessary sort functions.
  19675. * This should not be used directly aside of the few static configurations
  19676. */
  19677. export class RenderingManager {
  19678. /**
  19679. * The max id used for rendering groups (not included)
  19680. */
  19681. static MAX_RENDERINGGROUPS: number;
  19682. /**
  19683. * The min id used for rendering groups (included)
  19684. */
  19685. static MIN_RENDERINGGROUPS: number;
  19686. /**
  19687. * Used to globally prevent autoclearing scenes.
  19688. */
  19689. static AUTOCLEAR: boolean;
  19690. /**
  19691. * @hidden
  19692. */
  19693. _useSceneAutoClearSetup: boolean;
  19694. private _scene;
  19695. private _renderingGroups;
  19696. private _depthStencilBufferAlreadyCleaned;
  19697. private _autoClearDepthStencil;
  19698. private _customOpaqueSortCompareFn;
  19699. private _customAlphaTestSortCompareFn;
  19700. private _customTransparentSortCompareFn;
  19701. private _renderingGroupInfo;
  19702. /**
  19703. * Instantiates a new rendering group for a particular scene
  19704. * @param scene Defines the scene the groups belongs to
  19705. */
  19706. constructor(scene: Scene);
  19707. private _clearDepthStencilBuffer;
  19708. /**
  19709. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19710. * @hidden
  19711. */
  19712. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19713. /**
  19714. * Resets the different information of the group to prepare a new frame
  19715. * @hidden
  19716. */
  19717. reset(): void;
  19718. /**
  19719. * Dispose and release the group and its associated resources.
  19720. * @hidden
  19721. */
  19722. dispose(): void;
  19723. /**
  19724. * Clear the info related to rendering groups preventing retention points during dispose.
  19725. */
  19726. freeRenderingGroups(): void;
  19727. private _prepareRenderingGroup;
  19728. /**
  19729. * Add a sprite manager to the rendering manager in order to render it this frame.
  19730. * @param spriteManager Define the sprite manager to render
  19731. */
  19732. dispatchSprites(spriteManager: ISpriteManager): void;
  19733. /**
  19734. * Add a particle system to the rendering manager in order to render it this frame.
  19735. * @param particleSystem Define the particle system to render
  19736. */
  19737. dispatchParticles(particleSystem: IParticleSystem): void;
  19738. /**
  19739. * Add a submesh to the manager in order to render it this frame
  19740. * @param subMesh The submesh to dispatch
  19741. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19742. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19743. */
  19744. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19745. /**
  19746. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19747. * This allowed control for front to back rendering or reversly depending of the special needs.
  19748. *
  19749. * @param renderingGroupId The rendering group id corresponding to its index
  19750. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19751. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19752. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19753. */
  19754. 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;
  19755. /**
  19756. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19757. *
  19758. * @param renderingGroupId The rendering group id corresponding to its index
  19759. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19760. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19761. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19762. */
  19763. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19764. /**
  19765. * Gets the current auto clear configuration for one rendering group of the rendering
  19766. * manager.
  19767. * @param index the rendering group index to get the information for
  19768. * @returns The auto clear setup for the requested rendering group
  19769. */
  19770. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19771. }
  19772. }
  19773. declare module BABYLON {
  19774. /**
  19775. * This Helps creating a texture that will be created from a camera in your scene.
  19776. * It is basically a dynamic texture that could be used to create special effects for instance.
  19777. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19778. */
  19779. export class RenderTargetTexture extends Texture {
  19780. isCube: boolean;
  19781. /**
  19782. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19783. */
  19784. static readonly REFRESHRATE_RENDER_ONCE: number;
  19785. /**
  19786. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19787. */
  19788. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19789. /**
  19790. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19791. * the central point of your effect and can save a lot of performances.
  19792. */
  19793. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19794. /**
  19795. * Use this predicate to dynamically define the list of mesh you want to render.
  19796. * If set, the renderList property will be overwritten.
  19797. */
  19798. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19799. private _renderList;
  19800. /**
  19801. * Use this list to define the list of mesh you want to render.
  19802. */
  19803. renderList: Nullable<Array<AbstractMesh>>;
  19804. private _hookArray;
  19805. /**
  19806. * Define if particles should be rendered in your texture.
  19807. */
  19808. renderParticles: boolean;
  19809. /**
  19810. * Define if sprites should be rendered in your texture.
  19811. */
  19812. renderSprites: boolean;
  19813. /**
  19814. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19815. */
  19816. coordinatesMode: number;
  19817. /**
  19818. * Define the camera used to render the texture.
  19819. */
  19820. activeCamera: Nullable<Camera>;
  19821. /**
  19822. * Override the render function of the texture with your own one.
  19823. */
  19824. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19825. /**
  19826. * Define if camera post processes should be use while rendering the texture.
  19827. */
  19828. useCameraPostProcesses: boolean;
  19829. /**
  19830. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19831. */
  19832. ignoreCameraViewport: boolean;
  19833. private _postProcessManager;
  19834. private _postProcesses;
  19835. private _resizeObserver;
  19836. /**
  19837. * An event triggered when the texture is unbind.
  19838. */
  19839. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19840. /**
  19841. * An event triggered when the texture is unbind.
  19842. */
  19843. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19844. private _onAfterUnbindObserver;
  19845. /**
  19846. * Set a after unbind callback in the texture.
  19847. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19848. */
  19849. onAfterUnbind: () => void;
  19850. /**
  19851. * An event triggered before rendering the texture
  19852. */
  19853. onBeforeRenderObservable: Observable<number>;
  19854. private _onBeforeRenderObserver;
  19855. /**
  19856. * Set a before render callback in the texture.
  19857. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19858. */
  19859. onBeforeRender: (faceIndex: number) => void;
  19860. /**
  19861. * An event triggered after rendering the texture
  19862. */
  19863. onAfterRenderObservable: Observable<number>;
  19864. private _onAfterRenderObserver;
  19865. /**
  19866. * Set a after render callback in the texture.
  19867. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19868. */
  19869. onAfterRender: (faceIndex: number) => void;
  19870. /**
  19871. * An event triggered after the texture clear
  19872. */
  19873. onClearObservable: Observable<Engine>;
  19874. private _onClearObserver;
  19875. /**
  19876. * Set a clear callback in the texture.
  19877. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19878. */
  19879. onClear: (Engine: Engine) => void;
  19880. /**
  19881. * An event triggered when the texture is resized.
  19882. */
  19883. onResizeObservable: Observable<RenderTargetTexture>;
  19884. /**
  19885. * Define the clear color of the Render Target if it should be different from the scene.
  19886. */
  19887. clearColor: Color4;
  19888. protected _size: number | {
  19889. width: number;
  19890. height: number;
  19891. };
  19892. protected _initialSizeParameter: number | {
  19893. width: number;
  19894. height: number;
  19895. } | {
  19896. ratio: number;
  19897. };
  19898. protected _sizeRatio: Nullable<number>;
  19899. /** @hidden */
  19900. _generateMipMaps: boolean;
  19901. protected _renderingManager: RenderingManager;
  19902. /** @hidden */
  19903. _waitingRenderList: string[];
  19904. protected _doNotChangeAspectRatio: boolean;
  19905. protected _currentRefreshId: number;
  19906. protected _refreshRate: number;
  19907. protected _textureMatrix: Matrix;
  19908. protected _samples: number;
  19909. protected _renderTargetOptions: RenderTargetCreationOptions;
  19910. /**
  19911. * Gets render target creation options that were used.
  19912. */
  19913. readonly renderTargetOptions: RenderTargetCreationOptions;
  19914. protected _engine: Engine;
  19915. protected _onRatioRescale(): void;
  19916. /**
  19917. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19918. * It must define where the camera used to render the texture is set
  19919. */
  19920. boundingBoxPosition: Vector3;
  19921. private _boundingBoxSize;
  19922. /**
  19923. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19924. * When defined, the cubemap will switch to local mode
  19925. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19926. * @example https://www.babylonjs-playground.com/#RNASML
  19927. */
  19928. boundingBoxSize: Vector3;
  19929. /**
  19930. * In case the RTT has been created with a depth texture, get the associated
  19931. * depth texture.
  19932. * Otherwise, return null.
  19933. */
  19934. depthStencilTexture: Nullable<InternalTexture>;
  19935. /**
  19936. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19937. * or used a shadow, depth texture...
  19938. * @param name The friendly name of the texture
  19939. * @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)
  19940. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19941. * @param generateMipMaps True if mip maps need to be generated after render.
  19942. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19943. * @param type The type of the buffer in the RTT (int, half float, float...)
  19944. * @param isCube True if a cube texture needs to be created
  19945. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19946. * @param generateDepthBuffer True to generate a depth buffer
  19947. * @param generateStencilBuffer True to generate a stencil buffer
  19948. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19949. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19950. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19951. */
  19952. constructor(name: string, size: number | {
  19953. width: number;
  19954. height: number;
  19955. } | {
  19956. ratio: number;
  19957. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19958. /**
  19959. * Creates a depth stencil texture.
  19960. * This is only available in WebGL 2 or with the depth texture extension available.
  19961. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19962. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19963. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19964. */
  19965. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19966. private _processSizeParameter;
  19967. /**
  19968. * Define the number of samples to use in case of MSAA.
  19969. * It defaults to one meaning no MSAA has been enabled.
  19970. */
  19971. samples: number;
  19972. /**
  19973. * Resets the refresh counter of the texture and start bak from scratch.
  19974. * Could be useful to regenerate the texture if it is setup to render only once.
  19975. */
  19976. resetRefreshCounter(): void;
  19977. /**
  19978. * Define the refresh rate of the texture or the rendering frequency.
  19979. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19980. */
  19981. refreshRate: number;
  19982. /**
  19983. * Adds a post process to the render target rendering passes.
  19984. * @param postProcess define the post process to add
  19985. */
  19986. addPostProcess(postProcess: PostProcess): void;
  19987. /**
  19988. * Clear all the post processes attached to the render target
  19989. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19990. */
  19991. clearPostProcesses(dispose?: boolean): void;
  19992. /**
  19993. * Remove one of the post process from the list of attached post processes to the texture
  19994. * @param postProcess define the post process to remove from the list
  19995. */
  19996. removePostProcess(postProcess: PostProcess): void;
  19997. /** @hidden */
  19998. _shouldRender(): boolean;
  19999. /**
  20000. * Gets the actual render size of the texture.
  20001. * @returns the width of the render size
  20002. */
  20003. getRenderSize(): number;
  20004. /**
  20005. * Gets the actual render width of the texture.
  20006. * @returns the width of the render size
  20007. */
  20008. getRenderWidth(): number;
  20009. /**
  20010. * Gets the actual render height of the texture.
  20011. * @returns the height of the render size
  20012. */
  20013. getRenderHeight(): number;
  20014. /**
  20015. * Get if the texture can be rescaled or not.
  20016. */
  20017. readonly canRescale: boolean;
  20018. /**
  20019. * Resize the texture using a ratio.
  20020. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20021. */
  20022. scale(ratio: number): void;
  20023. /**
  20024. * Get the texture reflection matrix used to rotate/transform the reflection.
  20025. * @returns the reflection matrix
  20026. */
  20027. getReflectionTextureMatrix(): Matrix;
  20028. /**
  20029. * Resize the texture to a new desired size.
  20030. * Be carrefull as it will recreate all the data in the new texture.
  20031. * @param size Define the new size. It can be:
  20032. * - a number for squared texture,
  20033. * - an object containing { width: number, height: number }
  20034. * - or an object containing a ratio { ratio: number }
  20035. */
  20036. resize(size: number | {
  20037. width: number;
  20038. height: number;
  20039. } | {
  20040. ratio: number;
  20041. }): void;
  20042. /**
  20043. * Renders all the objects from the render list into the texture.
  20044. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20045. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20046. */
  20047. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20048. private _bestReflectionRenderTargetDimension;
  20049. /**
  20050. * @hidden
  20051. * @param faceIndex face index to bind to if this is a cubetexture
  20052. */
  20053. _bindFrameBuffer(faceIndex?: number): void;
  20054. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20055. private renderToTarget;
  20056. /**
  20057. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20058. * This allowed control for front to back rendering or reversly depending of the special needs.
  20059. *
  20060. * @param renderingGroupId The rendering group id corresponding to its index
  20061. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20062. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20063. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20064. */
  20065. 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;
  20066. /**
  20067. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20068. *
  20069. * @param renderingGroupId The rendering group id corresponding to its index
  20070. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20071. */
  20072. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20073. /**
  20074. * Clones the texture.
  20075. * @returns the cloned texture
  20076. */
  20077. clone(): RenderTargetTexture;
  20078. /**
  20079. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20080. * @returns The JSON representation of the texture
  20081. */
  20082. serialize(): any;
  20083. /**
  20084. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20085. */
  20086. disposeFramebufferObjects(): void;
  20087. /**
  20088. * Dispose the texture and release its associated resources.
  20089. */
  20090. dispose(): void;
  20091. /** @hidden */
  20092. _rebuild(): void;
  20093. /**
  20094. * Clear the info related to rendering groups preventing retention point in material dispose.
  20095. */
  20096. freeRenderingGroups(): void;
  20097. /**
  20098. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20099. * @returns the view count
  20100. */
  20101. getViewCount(): number;
  20102. }
  20103. }
  20104. declare module BABYLON {
  20105. /**
  20106. * Base class for the main features of a material in Babylon.js
  20107. */
  20108. export class Material implements IAnimatable {
  20109. /**
  20110. * Returns the triangle fill mode
  20111. */
  20112. static readonly TriangleFillMode: number;
  20113. /**
  20114. * Returns the wireframe mode
  20115. */
  20116. static readonly WireFrameFillMode: number;
  20117. /**
  20118. * Returns the point fill mode
  20119. */
  20120. static readonly PointFillMode: number;
  20121. /**
  20122. * Returns the point list draw mode
  20123. */
  20124. static readonly PointListDrawMode: number;
  20125. /**
  20126. * Returns the line list draw mode
  20127. */
  20128. static readonly LineListDrawMode: number;
  20129. /**
  20130. * Returns the line loop draw mode
  20131. */
  20132. static readonly LineLoopDrawMode: number;
  20133. /**
  20134. * Returns the line strip draw mode
  20135. */
  20136. static readonly LineStripDrawMode: number;
  20137. /**
  20138. * Returns the triangle strip draw mode
  20139. */
  20140. static readonly TriangleStripDrawMode: number;
  20141. /**
  20142. * Returns the triangle fan draw mode
  20143. */
  20144. static readonly TriangleFanDrawMode: number;
  20145. /**
  20146. * Stores the clock-wise side orientation
  20147. */
  20148. static readonly ClockWiseSideOrientation: number;
  20149. /**
  20150. * Stores the counter clock-wise side orientation
  20151. */
  20152. static readonly CounterClockWiseSideOrientation: number;
  20153. /**
  20154. * The dirty texture flag value
  20155. */
  20156. static readonly TextureDirtyFlag: number;
  20157. /**
  20158. * The dirty light flag value
  20159. */
  20160. static readonly LightDirtyFlag: number;
  20161. /**
  20162. * The dirty fresnel flag value
  20163. */
  20164. static readonly FresnelDirtyFlag: number;
  20165. /**
  20166. * The dirty attribute flag value
  20167. */
  20168. static readonly AttributesDirtyFlag: number;
  20169. /**
  20170. * The dirty misc flag value
  20171. */
  20172. static readonly MiscDirtyFlag: number;
  20173. /**
  20174. * The all dirty flag value
  20175. */
  20176. static readonly AllDirtyFlag: number;
  20177. /**
  20178. * The ID of the material
  20179. */
  20180. id: string;
  20181. /**
  20182. * Gets or sets the unique id of the material
  20183. */
  20184. uniqueId: number;
  20185. /**
  20186. * The name of the material
  20187. */
  20188. name: string;
  20189. /**
  20190. * Gets or sets user defined metadata
  20191. */
  20192. metadata: any;
  20193. /**
  20194. * For internal use only. Please do not use.
  20195. */
  20196. reservedDataStore: any;
  20197. /**
  20198. * Specifies if the ready state should be checked on each call
  20199. */
  20200. checkReadyOnEveryCall: boolean;
  20201. /**
  20202. * Specifies if the ready state should be checked once
  20203. */
  20204. checkReadyOnlyOnce: boolean;
  20205. /**
  20206. * The state of the material
  20207. */
  20208. state: string;
  20209. /**
  20210. * The alpha value of the material
  20211. */
  20212. protected _alpha: number;
  20213. /**
  20214. * List of inspectable custom properties (used by the Inspector)
  20215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20216. */
  20217. inspectableCustomProperties: IInspectable[];
  20218. /**
  20219. * Sets the alpha value of the material
  20220. */
  20221. /**
  20222. * Gets the alpha value of the material
  20223. */
  20224. alpha: number;
  20225. /**
  20226. * Specifies if back face culling is enabled
  20227. */
  20228. protected _backFaceCulling: boolean;
  20229. /**
  20230. * Sets the back-face culling state
  20231. */
  20232. /**
  20233. * Gets the back-face culling state
  20234. */
  20235. backFaceCulling: boolean;
  20236. /**
  20237. * Stores the value for side orientation
  20238. */
  20239. sideOrientation: number;
  20240. /**
  20241. * Callback triggered when the material is compiled
  20242. */
  20243. onCompiled: Nullable<(effect: Effect) => void>;
  20244. /**
  20245. * Callback triggered when an error occurs
  20246. */
  20247. onError: Nullable<(effect: Effect, errors: string) => void>;
  20248. /**
  20249. * Callback triggered to get the render target textures
  20250. */
  20251. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20252. /**
  20253. * Gets a boolean indicating that current material needs to register RTT
  20254. */
  20255. readonly hasRenderTargetTextures: boolean;
  20256. /**
  20257. * Specifies if the material should be serialized
  20258. */
  20259. doNotSerialize: boolean;
  20260. /**
  20261. * @hidden
  20262. */
  20263. _storeEffectOnSubMeshes: boolean;
  20264. /**
  20265. * Stores the animations for the material
  20266. */
  20267. animations: Nullable<Array<Animation>>;
  20268. /**
  20269. * An event triggered when the material is disposed
  20270. */
  20271. onDisposeObservable: Observable<Material>;
  20272. /**
  20273. * An observer which watches for dispose events
  20274. */
  20275. private _onDisposeObserver;
  20276. private _onUnBindObservable;
  20277. /**
  20278. * Called during a dispose event
  20279. */
  20280. onDispose: () => void;
  20281. private _onBindObservable;
  20282. /**
  20283. * An event triggered when the material is bound
  20284. */
  20285. readonly onBindObservable: Observable<AbstractMesh>;
  20286. /**
  20287. * An observer which watches for bind events
  20288. */
  20289. private _onBindObserver;
  20290. /**
  20291. * Called during a bind event
  20292. */
  20293. onBind: (Mesh: AbstractMesh) => void;
  20294. /**
  20295. * An event triggered when the material is unbound
  20296. */
  20297. readonly onUnBindObservable: Observable<Material>;
  20298. /**
  20299. * Stores the value of the alpha mode
  20300. */
  20301. private _alphaMode;
  20302. /**
  20303. * Sets the value of the alpha mode.
  20304. *
  20305. * | Value | Type | Description |
  20306. * | --- | --- | --- |
  20307. * | 0 | ALPHA_DISABLE | |
  20308. * | 1 | ALPHA_ADD | |
  20309. * | 2 | ALPHA_COMBINE | |
  20310. * | 3 | ALPHA_SUBTRACT | |
  20311. * | 4 | ALPHA_MULTIPLY | |
  20312. * | 5 | ALPHA_MAXIMIZED | |
  20313. * | 6 | ALPHA_ONEONE | |
  20314. * | 7 | ALPHA_PREMULTIPLIED | |
  20315. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20316. * | 9 | ALPHA_INTERPOLATE | |
  20317. * | 10 | ALPHA_SCREENMODE | |
  20318. *
  20319. */
  20320. /**
  20321. * Gets the value of the alpha mode
  20322. */
  20323. alphaMode: number;
  20324. /**
  20325. * Stores the state of the need depth pre-pass value
  20326. */
  20327. private _needDepthPrePass;
  20328. /**
  20329. * Sets the need depth pre-pass value
  20330. */
  20331. /**
  20332. * Gets the depth pre-pass value
  20333. */
  20334. needDepthPrePass: boolean;
  20335. /**
  20336. * Specifies if depth writing should be disabled
  20337. */
  20338. disableDepthWrite: boolean;
  20339. /**
  20340. * Specifies if depth writing should be forced
  20341. */
  20342. forceDepthWrite: boolean;
  20343. /**
  20344. * Specifies if there should be a separate pass for culling
  20345. */
  20346. separateCullingPass: boolean;
  20347. /**
  20348. * Stores the state specifing if fog should be enabled
  20349. */
  20350. private _fogEnabled;
  20351. /**
  20352. * Sets the state for enabling fog
  20353. */
  20354. /**
  20355. * Gets the value of the fog enabled state
  20356. */
  20357. fogEnabled: boolean;
  20358. /**
  20359. * Stores the size of points
  20360. */
  20361. pointSize: number;
  20362. /**
  20363. * Stores the z offset value
  20364. */
  20365. zOffset: number;
  20366. /**
  20367. * Gets a value specifying if wireframe mode is enabled
  20368. */
  20369. /**
  20370. * Sets the state of wireframe mode
  20371. */
  20372. wireframe: boolean;
  20373. /**
  20374. * Gets the value specifying if point clouds are enabled
  20375. */
  20376. /**
  20377. * Sets the state of point cloud mode
  20378. */
  20379. pointsCloud: boolean;
  20380. /**
  20381. * Gets the material fill mode
  20382. */
  20383. /**
  20384. * Sets the material fill mode
  20385. */
  20386. fillMode: number;
  20387. /**
  20388. * @hidden
  20389. * Stores the effects for the material
  20390. */
  20391. _effect: Nullable<Effect>;
  20392. /**
  20393. * @hidden
  20394. * Specifies if the material was previously ready
  20395. */
  20396. _wasPreviouslyReady: boolean;
  20397. /**
  20398. * Specifies if uniform buffers should be used
  20399. */
  20400. private _useUBO;
  20401. /**
  20402. * Stores a reference to the scene
  20403. */
  20404. private _scene;
  20405. /**
  20406. * Stores the fill mode state
  20407. */
  20408. private _fillMode;
  20409. /**
  20410. * Specifies if the depth write state should be cached
  20411. */
  20412. private _cachedDepthWriteState;
  20413. /**
  20414. * Stores the uniform buffer
  20415. */
  20416. protected _uniformBuffer: UniformBuffer;
  20417. /** @hidden */
  20418. _indexInSceneMaterialArray: number;
  20419. /** @hidden */
  20420. meshMap: Nullable<{
  20421. [id: string]: AbstractMesh | undefined;
  20422. }>;
  20423. /**
  20424. * Creates a material instance
  20425. * @param name defines the name of the material
  20426. * @param scene defines the scene to reference
  20427. * @param doNotAdd specifies if the material should be added to the scene
  20428. */
  20429. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20430. /**
  20431. * Returns a string representation of the current material
  20432. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20433. * @returns a string with material information
  20434. */
  20435. toString(fullDetails?: boolean): string;
  20436. /**
  20437. * Gets the class name of the material
  20438. * @returns a string with the class name of the material
  20439. */
  20440. getClassName(): string;
  20441. /**
  20442. * Specifies if updates for the material been locked
  20443. */
  20444. readonly isFrozen: boolean;
  20445. /**
  20446. * Locks updates for the material
  20447. */
  20448. freeze(): void;
  20449. /**
  20450. * Unlocks updates for the material
  20451. */
  20452. unfreeze(): void;
  20453. /**
  20454. * Specifies if the material is ready to be used
  20455. * @param mesh defines the mesh to check
  20456. * @param useInstances specifies if instances should be used
  20457. * @returns a boolean indicating if the material is ready to be used
  20458. */
  20459. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20460. /**
  20461. * Specifies that the submesh is ready to be used
  20462. * @param mesh defines the mesh to check
  20463. * @param subMesh defines which submesh to check
  20464. * @param useInstances specifies that instances should be used
  20465. * @returns a boolean indicating that the submesh is ready or not
  20466. */
  20467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20468. /**
  20469. * Returns the material effect
  20470. * @returns the effect associated with the material
  20471. */
  20472. getEffect(): Nullable<Effect>;
  20473. /**
  20474. * Returns the current scene
  20475. * @returns a Scene
  20476. */
  20477. getScene(): Scene;
  20478. /**
  20479. * Specifies if the material will require alpha blending
  20480. * @returns a boolean specifying if alpha blending is needed
  20481. */
  20482. needAlphaBlending(): boolean;
  20483. /**
  20484. * Specifies if the mesh will require alpha blending
  20485. * @param mesh defines the mesh to check
  20486. * @returns a boolean specifying if alpha blending is needed for the mesh
  20487. */
  20488. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20489. /**
  20490. * Specifies if this material should be rendered in alpha test mode
  20491. * @returns a boolean specifying if an alpha test is needed.
  20492. */
  20493. needAlphaTesting(): boolean;
  20494. /**
  20495. * Gets the texture used for the alpha test
  20496. * @returns the texture to use for alpha testing
  20497. */
  20498. getAlphaTestTexture(): Nullable<BaseTexture>;
  20499. /**
  20500. * Marks the material to indicate that it needs to be re-calculated
  20501. */
  20502. markDirty(): void;
  20503. /** @hidden */
  20504. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20505. /**
  20506. * Binds the material to the mesh
  20507. * @param world defines the world transformation matrix
  20508. * @param mesh defines the mesh to bind the material to
  20509. */
  20510. bind(world: Matrix, mesh?: Mesh): void;
  20511. /**
  20512. * Binds the submesh to the material
  20513. * @param world defines the world transformation matrix
  20514. * @param mesh defines the mesh containing the submesh
  20515. * @param subMesh defines the submesh to bind the material to
  20516. */
  20517. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20518. /**
  20519. * Binds the world matrix to the material
  20520. * @param world defines the world transformation matrix
  20521. */
  20522. bindOnlyWorldMatrix(world: Matrix): void;
  20523. /**
  20524. * Binds the scene's uniform buffer to the effect.
  20525. * @param effect defines the effect to bind to the scene uniform buffer
  20526. * @param sceneUbo defines the uniform buffer storing scene data
  20527. */
  20528. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20529. /**
  20530. * Binds the view matrix to the effect
  20531. * @param effect defines the effect to bind the view matrix to
  20532. */
  20533. bindView(effect: Effect): void;
  20534. /**
  20535. * Binds the view projection matrix to the effect
  20536. * @param effect defines the effect to bind the view projection matrix to
  20537. */
  20538. bindViewProjection(effect: Effect): void;
  20539. /**
  20540. * Specifies if material alpha testing should be turned on for the mesh
  20541. * @param mesh defines the mesh to check
  20542. */
  20543. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20544. /**
  20545. * Processes to execute after binding the material to a mesh
  20546. * @param mesh defines the rendered mesh
  20547. */
  20548. protected _afterBind(mesh?: Mesh): void;
  20549. /**
  20550. * Unbinds the material from the mesh
  20551. */
  20552. unbind(): void;
  20553. /**
  20554. * Gets the active textures from the material
  20555. * @returns an array of textures
  20556. */
  20557. getActiveTextures(): BaseTexture[];
  20558. /**
  20559. * Specifies if the material uses a texture
  20560. * @param texture defines the texture to check against the material
  20561. * @returns a boolean specifying if the material uses the texture
  20562. */
  20563. hasTexture(texture: BaseTexture): boolean;
  20564. /**
  20565. * Makes a duplicate of the material, and gives it a new name
  20566. * @param name defines the new name for the duplicated material
  20567. * @returns the cloned material
  20568. */
  20569. clone(name: string): Nullable<Material>;
  20570. /**
  20571. * Gets the meshes bound to the material
  20572. * @returns an array of meshes bound to the material
  20573. */
  20574. getBindedMeshes(): AbstractMesh[];
  20575. /**
  20576. * Force shader compilation
  20577. * @param mesh defines the mesh associated with this material
  20578. * @param onCompiled defines a function to execute once the material is compiled
  20579. * @param options defines the options to configure the compilation
  20580. * @param onError defines a function to execute if the material fails compiling
  20581. */
  20582. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20583. clipPlane: boolean;
  20584. }>, onError?: (reason: string) => void): void;
  20585. /**
  20586. * Force shader compilation
  20587. * @param mesh defines the mesh that will use this material
  20588. * @param options defines additional options for compiling the shaders
  20589. * @returns a promise that resolves when the compilation completes
  20590. */
  20591. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20592. clipPlane: boolean;
  20593. }>): Promise<void>;
  20594. private static readonly _AllDirtyCallBack;
  20595. private static readonly _ImageProcessingDirtyCallBack;
  20596. private static readonly _TextureDirtyCallBack;
  20597. private static readonly _FresnelDirtyCallBack;
  20598. private static readonly _MiscDirtyCallBack;
  20599. private static readonly _LightsDirtyCallBack;
  20600. private static readonly _AttributeDirtyCallBack;
  20601. private static _FresnelAndMiscDirtyCallBack;
  20602. private static _TextureAndMiscDirtyCallBack;
  20603. private static readonly _DirtyCallbackArray;
  20604. private static readonly _RunDirtyCallBacks;
  20605. /**
  20606. * Marks a define in the material to indicate that it needs to be re-computed
  20607. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20608. */
  20609. markAsDirty(flag: number): void;
  20610. /**
  20611. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20612. * @param func defines a function which checks material defines against the submeshes
  20613. */
  20614. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20615. /**
  20616. * Indicates that we need to re-calculated for all submeshes
  20617. */
  20618. protected _markAllSubMeshesAsAllDirty(): void;
  20619. /**
  20620. * Indicates that image processing needs to be re-calculated for all submeshes
  20621. */
  20622. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20623. /**
  20624. * Indicates that textures need to be re-calculated for all submeshes
  20625. */
  20626. protected _markAllSubMeshesAsTexturesDirty(): void;
  20627. /**
  20628. * Indicates that fresnel needs to be re-calculated for all submeshes
  20629. */
  20630. protected _markAllSubMeshesAsFresnelDirty(): void;
  20631. /**
  20632. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20633. */
  20634. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20635. /**
  20636. * Indicates that lights need to be re-calculated for all submeshes
  20637. */
  20638. protected _markAllSubMeshesAsLightsDirty(): void;
  20639. /**
  20640. * Indicates that attributes need to be re-calculated for all submeshes
  20641. */
  20642. protected _markAllSubMeshesAsAttributesDirty(): void;
  20643. /**
  20644. * Indicates that misc needs to be re-calculated for all submeshes
  20645. */
  20646. protected _markAllSubMeshesAsMiscDirty(): void;
  20647. /**
  20648. * Indicates that textures and misc need to be re-calculated for all submeshes
  20649. */
  20650. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20651. /**
  20652. * Disposes the material
  20653. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20654. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20655. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20656. */
  20657. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20658. /** @hidden */
  20659. private releaseVertexArrayObject;
  20660. /**
  20661. * Serializes this material
  20662. * @returns the serialized material object
  20663. */
  20664. serialize(): any;
  20665. /**
  20666. * Creates a material from parsed material data
  20667. * @param parsedMaterial defines parsed material data
  20668. * @param scene defines the hosting scene
  20669. * @param rootUrl defines the root URL to use to load textures
  20670. * @returns a new material
  20671. */
  20672. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20673. }
  20674. }
  20675. declare module BABYLON {
  20676. /**
  20677. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20678. * separate meshes. This can be use to improve performances.
  20679. * @see http://doc.babylonjs.com/how_to/multi_materials
  20680. */
  20681. export class MultiMaterial extends Material {
  20682. private _subMaterials;
  20683. /**
  20684. * Gets or Sets the list of Materials used within the multi material.
  20685. * They need to be ordered according to the submeshes order in the associated mesh
  20686. */
  20687. subMaterials: Nullable<Material>[];
  20688. /**
  20689. * Function used to align with Node.getChildren()
  20690. * @returns the list of Materials used within the multi material
  20691. */
  20692. getChildren(): Nullable<Material>[];
  20693. /**
  20694. * Instantiates a new Multi Material
  20695. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20696. * separate meshes. This can be use to improve performances.
  20697. * @see http://doc.babylonjs.com/how_to/multi_materials
  20698. * @param name Define the name in the scene
  20699. * @param scene Define the scene the material belongs to
  20700. */
  20701. constructor(name: string, scene: Scene);
  20702. private _hookArray;
  20703. /**
  20704. * Get one of the submaterial by its index in the submaterials array
  20705. * @param index The index to look the sub material at
  20706. * @returns The Material if the index has been defined
  20707. */
  20708. getSubMaterial(index: number): Nullable<Material>;
  20709. /**
  20710. * Get the list of active textures for the whole sub materials list.
  20711. * @returns All the textures that will be used during the rendering
  20712. */
  20713. getActiveTextures(): BaseTexture[];
  20714. /**
  20715. * Gets the current class name of the material e.g. "MultiMaterial"
  20716. * Mainly use in serialization.
  20717. * @returns the class name
  20718. */
  20719. getClassName(): string;
  20720. /**
  20721. * Checks if the material is ready to render the requested sub mesh
  20722. * @param mesh Define the mesh the submesh belongs to
  20723. * @param subMesh Define the sub mesh to look readyness for
  20724. * @param useInstances Define whether or not the material is used with instances
  20725. * @returns true if ready, otherwise false
  20726. */
  20727. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20728. /**
  20729. * Clones the current material and its related sub materials
  20730. * @param name Define the name of the newly cloned material
  20731. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20732. * @returns the cloned material
  20733. */
  20734. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20735. /**
  20736. * Serializes the materials into a JSON representation.
  20737. * @returns the JSON representation
  20738. */
  20739. serialize(): any;
  20740. /**
  20741. * Dispose the material and release its associated resources
  20742. * @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)
  20743. * @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)
  20744. * @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)
  20745. */
  20746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20747. /**
  20748. * Creates a MultiMaterial from parsed MultiMaterial data.
  20749. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20750. * @param scene defines the hosting scene
  20751. * @returns a new MultiMaterial
  20752. */
  20753. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20754. }
  20755. }
  20756. declare module BABYLON {
  20757. /**
  20758. * Base class for submeshes
  20759. */
  20760. export class BaseSubMesh {
  20761. /** @hidden */
  20762. _materialDefines: Nullable<MaterialDefines>;
  20763. /** @hidden */
  20764. _materialEffect: Nullable<Effect>;
  20765. /**
  20766. * Gets associated effect
  20767. */
  20768. readonly effect: Nullable<Effect>;
  20769. /**
  20770. * Sets associated effect (effect used to render this submesh)
  20771. * @param effect defines the effect to associate with
  20772. * @param defines defines the set of defines used to compile this effect
  20773. */
  20774. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20775. }
  20776. /**
  20777. * Defines a subdivision inside a mesh
  20778. */
  20779. export class SubMesh extends BaseSubMesh implements ICullable {
  20780. /** the material index to use */
  20781. materialIndex: number;
  20782. /** vertex index start */
  20783. verticesStart: number;
  20784. /** vertices count */
  20785. verticesCount: number;
  20786. /** index start */
  20787. indexStart: number;
  20788. /** indices count */
  20789. indexCount: number;
  20790. /** @hidden */
  20791. _linesIndexCount: number;
  20792. private _mesh;
  20793. private _renderingMesh;
  20794. private _boundingInfo;
  20795. private _linesIndexBuffer;
  20796. /** @hidden */
  20797. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20798. /** @hidden */
  20799. _trianglePlanes: Plane[];
  20800. /** @hidden */
  20801. _lastColliderTransformMatrix: Nullable<Matrix>;
  20802. /** @hidden */
  20803. _renderId: number;
  20804. /** @hidden */
  20805. _alphaIndex: number;
  20806. /** @hidden */
  20807. _distanceToCamera: number;
  20808. /** @hidden */
  20809. _id: number;
  20810. private _currentMaterial;
  20811. /**
  20812. * Add a new submesh to a mesh
  20813. * @param materialIndex defines the material index to use
  20814. * @param verticesStart defines vertex index start
  20815. * @param verticesCount defines vertices count
  20816. * @param indexStart defines index start
  20817. * @param indexCount defines indices count
  20818. * @param mesh defines the parent mesh
  20819. * @param renderingMesh defines an optional rendering mesh
  20820. * @param createBoundingBox defines if bounding box should be created for this submesh
  20821. * @returns the new submesh
  20822. */
  20823. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20824. /**
  20825. * Creates a new submesh
  20826. * @param materialIndex defines the material index to use
  20827. * @param verticesStart defines vertex index start
  20828. * @param verticesCount defines vertices count
  20829. * @param indexStart defines index start
  20830. * @param indexCount defines indices count
  20831. * @param mesh defines the parent mesh
  20832. * @param renderingMesh defines an optional rendering mesh
  20833. * @param createBoundingBox defines if bounding box should be created for this submesh
  20834. */
  20835. constructor(
  20836. /** the material index to use */
  20837. materialIndex: number,
  20838. /** vertex index start */
  20839. verticesStart: number,
  20840. /** vertices count */
  20841. verticesCount: number,
  20842. /** index start */
  20843. indexStart: number,
  20844. /** indices count */
  20845. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20846. /**
  20847. * Returns true if this submesh covers the entire parent mesh
  20848. * @ignorenaming
  20849. */
  20850. readonly IsGlobal: boolean;
  20851. /**
  20852. * Returns the submesh BoudingInfo object
  20853. * @returns current bounding info (or mesh's one if the submesh is global)
  20854. */
  20855. getBoundingInfo(): BoundingInfo;
  20856. /**
  20857. * Sets the submesh BoundingInfo
  20858. * @param boundingInfo defines the new bounding info to use
  20859. * @returns the SubMesh
  20860. */
  20861. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20862. /**
  20863. * Returns the mesh of the current submesh
  20864. * @return the parent mesh
  20865. */
  20866. getMesh(): AbstractMesh;
  20867. /**
  20868. * Returns the rendering mesh of the submesh
  20869. * @returns the rendering mesh (could be different from parent mesh)
  20870. */
  20871. getRenderingMesh(): Mesh;
  20872. /**
  20873. * Returns the submesh material
  20874. * @returns null or the current material
  20875. */
  20876. getMaterial(): Nullable<Material>;
  20877. /**
  20878. * Sets a new updated BoundingInfo object to the submesh
  20879. * @param data defines an optional position array to use to determine the bounding info
  20880. * @returns the SubMesh
  20881. */
  20882. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20883. /** @hidden */
  20884. _checkCollision(collider: Collider): boolean;
  20885. /**
  20886. * Updates the submesh BoundingInfo
  20887. * @param world defines the world matrix to use to update the bounding info
  20888. * @returns the submesh
  20889. */
  20890. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20891. /**
  20892. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20893. * @param frustumPlanes defines the frustum planes
  20894. * @returns true if the submesh is intersecting with the frustum
  20895. */
  20896. isInFrustum(frustumPlanes: Plane[]): boolean;
  20897. /**
  20898. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20899. * @param frustumPlanes defines the frustum planes
  20900. * @returns true if the submesh is inside the frustum
  20901. */
  20902. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20903. /**
  20904. * Renders the submesh
  20905. * @param enableAlphaMode defines if alpha needs to be used
  20906. * @returns the submesh
  20907. */
  20908. render(enableAlphaMode: boolean): SubMesh;
  20909. /**
  20910. * @hidden
  20911. */
  20912. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20913. /**
  20914. * Checks if the submesh intersects with a ray
  20915. * @param ray defines the ray to test
  20916. * @returns true is the passed ray intersects the submesh bounding box
  20917. */
  20918. canIntersects(ray: Ray): boolean;
  20919. /**
  20920. * Intersects current submesh with a ray
  20921. * @param ray defines the ray to test
  20922. * @param positions defines mesh's positions array
  20923. * @param indices defines mesh's indices array
  20924. * @param fastCheck defines if only bounding info should be used
  20925. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20926. * @returns intersection info or null if no intersection
  20927. */
  20928. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20929. /** @hidden */
  20930. private _intersectLines;
  20931. /** @hidden */
  20932. private _intersectUnIndexedLines;
  20933. /** @hidden */
  20934. private _intersectTriangles;
  20935. /** @hidden */
  20936. private _intersectUnIndexedTriangles;
  20937. /** @hidden */
  20938. _rebuild(): void;
  20939. /**
  20940. * Creates a new submesh from the passed mesh
  20941. * @param newMesh defines the new hosting mesh
  20942. * @param newRenderingMesh defines an optional rendering mesh
  20943. * @returns the new submesh
  20944. */
  20945. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20946. /**
  20947. * Release associated resources
  20948. */
  20949. dispose(): void;
  20950. /**
  20951. * Gets the class name
  20952. * @returns the string "SubMesh".
  20953. */
  20954. getClassName(): string;
  20955. /**
  20956. * Creates a new submesh from indices data
  20957. * @param materialIndex the index of the main mesh material
  20958. * @param startIndex the index where to start the copy in the mesh indices array
  20959. * @param indexCount the number of indices to copy then from the startIndex
  20960. * @param mesh the main mesh to create the submesh from
  20961. * @param renderingMesh the optional rendering mesh
  20962. * @returns a new submesh
  20963. */
  20964. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20965. }
  20966. }
  20967. declare module BABYLON {
  20968. /**
  20969. * Class used to represent data loading progression
  20970. */
  20971. export class SceneLoaderFlags {
  20972. private static _ForceFullSceneLoadingForIncremental;
  20973. private static _ShowLoadingScreen;
  20974. private static _CleanBoneMatrixWeights;
  20975. private static _loggingLevel;
  20976. /**
  20977. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20978. */
  20979. static ForceFullSceneLoadingForIncremental: boolean;
  20980. /**
  20981. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20982. */
  20983. static ShowLoadingScreen: boolean;
  20984. /**
  20985. * Defines the current logging level (while loading the scene)
  20986. * @ignorenaming
  20987. */
  20988. static loggingLevel: number;
  20989. /**
  20990. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20991. */
  20992. static CleanBoneMatrixWeights: boolean;
  20993. }
  20994. }
  20995. declare module BABYLON {
  20996. /**
  20997. * Class used to store geometry data (vertex buffers + index buffer)
  20998. */
  20999. export class Geometry implements IGetSetVerticesData {
  21000. /**
  21001. * Gets or sets the ID of the geometry
  21002. */
  21003. id: string;
  21004. /**
  21005. * Gets or sets the unique ID of the geometry
  21006. */
  21007. uniqueId: number;
  21008. /**
  21009. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21010. */
  21011. delayLoadState: number;
  21012. /**
  21013. * Gets the file containing the data to load when running in delay load state
  21014. */
  21015. delayLoadingFile: Nullable<string>;
  21016. /**
  21017. * Callback called when the geometry is updated
  21018. */
  21019. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21020. private _scene;
  21021. private _engine;
  21022. private _meshes;
  21023. private _totalVertices;
  21024. /** @hidden */
  21025. _indices: IndicesArray;
  21026. /** @hidden */
  21027. _vertexBuffers: {
  21028. [key: string]: VertexBuffer;
  21029. };
  21030. private _isDisposed;
  21031. private _extend;
  21032. private _boundingBias;
  21033. /** @hidden */
  21034. _delayInfo: Array<string>;
  21035. private _indexBuffer;
  21036. private _indexBufferIsUpdatable;
  21037. /** @hidden */
  21038. _boundingInfo: Nullable<BoundingInfo>;
  21039. /** @hidden */
  21040. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21041. /** @hidden */
  21042. _softwareSkinningFrameId: number;
  21043. private _vertexArrayObjects;
  21044. private _updatable;
  21045. /** @hidden */
  21046. _positions: Nullable<Vector3[]>;
  21047. /**
  21048. * 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
  21049. */
  21050. /**
  21051. * 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
  21052. */
  21053. boundingBias: Vector2;
  21054. /**
  21055. * Static function used to attach a new empty geometry to a mesh
  21056. * @param mesh defines the mesh to attach the geometry to
  21057. * @returns the new Geometry
  21058. */
  21059. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21060. /**
  21061. * Creates a new geometry
  21062. * @param id defines the unique ID
  21063. * @param scene defines the hosting scene
  21064. * @param vertexData defines the VertexData used to get geometry data
  21065. * @param updatable defines if geometry must be updatable (false by default)
  21066. * @param mesh defines the mesh that will be associated with the geometry
  21067. */
  21068. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21069. /**
  21070. * Gets the current extend of the geometry
  21071. */
  21072. readonly extend: {
  21073. minimum: Vector3;
  21074. maximum: Vector3;
  21075. };
  21076. /**
  21077. * Gets the hosting scene
  21078. * @returns the hosting Scene
  21079. */
  21080. getScene(): Scene;
  21081. /**
  21082. * Gets the hosting engine
  21083. * @returns the hosting Engine
  21084. */
  21085. getEngine(): Engine;
  21086. /**
  21087. * Defines if the geometry is ready to use
  21088. * @returns true if the geometry is ready to be used
  21089. */
  21090. isReady(): boolean;
  21091. /**
  21092. * Gets a value indicating that the geometry should not be serialized
  21093. */
  21094. readonly doNotSerialize: boolean;
  21095. /** @hidden */
  21096. _rebuild(): void;
  21097. /**
  21098. * Affects all geometry data in one call
  21099. * @param vertexData defines the geometry data
  21100. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21101. */
  21102. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21103. /**
  21104. * Set specific vertex data
  21105. * @param kind defines the data kind (Position, normal, etc...)
  21106. * @param data defines the vertex data to use
  21107. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21108. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21109. */
  21110. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21111. /**
  21112. * Removes a specific vertex data
  21113. * @param kind defines the data kind (Position, normal, etc...)
  21114. */
  21115. removeVerticesData(kind: string): void;
  21116. /**
  21117. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21118. * @param buffer defines the vertex buffer to use
  21119. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21120. */
  21121. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21122. /**
  21123. * Update a specific vertex buffer
  21124. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21125. * It will do nothing if the buffer is not updatable
  21126. * @param kind defines the data kind (Position, normal, etc...)
  21127. * @param data defines the data to use
  21128. * @param offset defines the offset in the target buffer where to store the data
  21129. * @param useBytes set to true if the offset is in bytes
  21130. */
  21131. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21132. /**
  21133. * Update a specific vertex buffer
  21134. * This function will create a new buffer if the current one is not updatable
  21135. * @param kind defines the data kind (Position, normal, etc...)
  21136. * @param data defines the data to use
  21137. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21138. */
  21139. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21140. private _updateBoundingInfo;
  21141. /** @hidden */
  21142. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21143. /**
  21144. * Gets total number of vertices
  21145. * @returns the total number of vertices
  21146. */
  21147. getTotalVertices(): number;
  21148. /**
  21149. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21150. * @param kind defines the data kind (Position, normal, etc...)
  21151. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21152. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21153. * @returns a float array containing vertex data
  21154. */
  21155. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21156. /**
  21157. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21158. * @param kind defines the data kind (Position, normal, etc...)
  21159. * @returns true if the vertex buffer with the specified kind is updatable
  21160. */
  21161. isVertexBufferUpdatable(kind: string): boolean;
  21162. /**
  21163. * Gets a specific vertex buffer
  21164. * @param kind defines the data kind (Position, normal, etc...)
  21165. * @returns a VertexBuffer
  21166. */
  21167. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21168. /**
  21169. * Returns all vertex buffers
  21170. * @return an object holding all vertex buffers indexed by kind
  21171. */
  21172. getVertexBuffers(): Nullable<{
  21173. [key: string]: VertexBuffer;
  21174. }>;
  21175. /**
  21176. * Gets a boolean indicating if specific vertex buffer is present
  21177. * @param kind defines the data kind (Position, normal, etc...)
  21178. * @returns true if data is present
  21179. */
  21180. isVerticesDataPresent(kind: string): boolean;
  21181. /**
  21182. * Gets a list of all attached data kinds (Position, normal, etc...)
  21183. * @returns a list of string containing all kinds
  21184. */
  21185. getVerticesDataKinds(): string[];
  21186. /**
  21187. * Update index buffer
  21188. * @param indices defines the indices to store in the index buffer
  21189. * @param offset defines the offset in the target buffer where to store the data
  21190. * @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)
  21191. */
  21192. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21193. /**
  21194. * Creates a new index buffer
  21195. * @param indices defines the indices to store in the index buffer
  21196. * @param totalVertices defines the total number of vertices (could be null)
  21197. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21198. */
  21199. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21200. /**
  21201. * Return the total number of indices
  21202. * @returns the total number of indices
  21203. */
  21204. getTotalIndices(): number;
  21205. /**
  21206. * Gets the index buffer array
  21207. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21208. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21209. * @returns the index buffer array
  21210. */
  21211. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21212. /**
  21213. * Gets the index buffer
  21214. * @return the index buffer
  21215. */
  21216. getIndexBuffer(): Nullable<DataBuffer>;
  21217. /** @hidden */
  21218. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21219. /**
  21220. * Release the associated resources for a specific mesh
  21221. * @param mesh defines the source mesh
  21222. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21223. */
  21224. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21225. /**
  21226. * Apply current geometry to a given mesh
  21227. * @param mesh defines the mesh to apply geometry to
  21228. */
  21229. applyToMesh(mesh: Mesh): void;
  21230. private _updateExtend;
  21231. private _applyToMesh;
  21232. private notifyUpdate;
  21233. /**
  21234. * Load the geometry if it was flagged as delay loaded
  21235. * @param scene defines the hosting scene
  21236. * @param onLoaded defines a callback called when the geometry is loaded
  21237. */
  21238. load(scene: Scene, onLoaded?: () => void): void;
  21239. private _queueLoad;
  21240. /**
  21241. * Invert the geometry to move from a right handed system to a left handed one.
  21242. */
  21243. toLeftHanded(): void;
  21244. /** @hidden */
  21245. _resetPointsArrayCache(): void;
  21246. /** @hidden */
  21247. _generatePointsArray(): boolean;
  21248. /**
  21249. * Gets a value indicating if the geometry is disposed
  21250. * @returns true if the geometry was disposed
  21251. */
  21252. isDisposed(): boolean;
  21253. private _disposeVertexArrayObjects;
  21254. /**
  21255. * Free all associated resources
  21256. */
  21257. dispose(): void;
  21258. /**
  21259. * Clone the current geometry into a new geometry
  21260. * @param id defines the unique ID of the new geometry
  21261. * @returns a new geometry object
  21262. */
  21263. copy(id: string): Geometry;
  21264. /**
  21265. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21266. * @return a JSON representation of the current geometry data (without the vertices data)
  21267. */
  21268. serialize(): any;
  21269. private toNumberArray;
  21270. /**
  21271. * Serialize all vertices data into a JSON oject
  21272. * @returns a JSON representation of the current geometry data
  21273. */
  21274. serializeVerticeData(): any;
  21275. /**
  21276. * Extracts a clone of a mesh geometry
  21277. * @param mesh defines the source mesh
  21278. * @param id defines the unique ID of the new geometry object
  21279. * @returns the new geometry object
  21280. */
  21281. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21282. /**
  21283. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21284. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21285. * Be aware Math.random() could cause collisions, but:
  21286. * "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"
  21287. * @returns a string containing a new GUID
  21288. */
  21289. static RandomId(): string;
  21290. /** @hidden */
  21291. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21292. private static _CleanMatricesWeights;
  21293. /**
  21294. * Create a new geometry from persisted data (Using .babylon file format)
  21295. * @param parsedVertexData defines the persisted data
  21296. * @param scene defines the hosting scene
  21297. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21298. * @returns the new geometry object
  21299. */
  21300. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21301. }
  21302. }
  21303. declare module BABYLON {
  21304. /**
  21305. * Define an interface for all classes that will get and set the data on vertices
  21306. */
  21307. export interface IGetSetVerticesData {
  21308. /**
  21309. * Gets a boolean indicating if specific vertex data is present
  21310. * @param kind defines the vertex data kind to use
  21311. * @returns true is data kind is present
  21312. */
  21313. isVerticesDataPresent(kind: string): boolean;
  21314. /**
  21315. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21316. * @param kind defines the data kind (Position, normal, etc...)
  21317. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21318. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21319. * @returns a float array containing vertex data
  21320. */
  21321. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21322. /**
  21323. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21324. * @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.
  21325. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21326. * @returns the indices array or an empty array if the mesh has no geometry
  21327. */
  21328. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21329. /**
  21330. * Set specific vertex data
  21331. * @param kind defines the data kind (Position, normal, etc...)
  21332. * @param data defines the vertex data to use
  21333. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21334. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21335. */
  21336. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21337. /**
  21338. * Update a specific associated vertex buffer
  21339. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21340. * - VertexBuffer.PositionKind
  21341. * - VertexBuffer.UVKind
  21342. * - VertexBuffer.UV2Kind
  21343. * - VertexBuffer.UV3Kind
  21344. * - VertexBuffer.UV4Kind
  21345. * - VertexBuffer.UV5Kind
  21346. * - VertexBuffer.UV6Kind
  21347. * - VertexBuffer.ColorKind
  21348. * - VertexBuffer.MatricesIndicesKind
  21349. * - VertexBuffer.MatricesIndicesExtraKind
  21350. * - VertexBuffer.MatricesWeightsKind
  21351. * - VertexBuffer.MatricesWeightsExtraKind
  21352. * @param data defines the data source
  21353. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21354. * @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)
  21355. */
  21356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21357. /**
  21358. * Creates a new index buffer
  21359. * @param indices defines the indices to store in the index buffer
  21360. * @param totalVertices defines the total number of vertices (could be null)
  21361. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21362. */
  21363. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21364. }
  21365. /**
  21366. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21367. */
  21368. export class VertexData {
  21369. /**
  21370. * Mesh side orientation : usually the external or front surface
  21371. */
  21372. static readonly FRONTSIDE: number;
  21373. /**
  21374. * Mesh side orientation : usually the internal or back surface
  21375. */
  21376. static readonly BACKSIDE: number;
  21377. /**
  21378. * Mesh side orientation : both internal and external or front and back surfaces
  21379. */
  21380. static readonly DOUBLESIDE: number;
  21381. /**
  21382. * Mesh side orientation : by default, `FRONTSIDE`
  21383. */
  21384. static readonly DEFAULTSIDE: number;
  21385. /**
  21386. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21387. */
  21388. positions: Nullable<FloatArray>;
  21389. /**
  21390. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21391. */
  21392. normals: Nullable<FloatArray>;
  21393. /**
  21394. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21395. */
  21396. tangents: Nullable<FloatArray>;
  21397. /**
  21398. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21399. */
  21400. uvs: Nullable<FloatArray>;
  21401. /**
  21402. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21403. */
  21404. uvs2: Nullable<FloatArray>;
  21405. /**
  21406. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21407. */
  21408. uvs3: Nullable<FloatArray>;
  21409. /**
  21410. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21411. */
  21412. uvs4: Nullable<FloatArray>;
  21413. /**
  21414. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21415. */
  21416. uvs5: Nullable<FloatArray>;
  21417. /**
  21418. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21419. */
  21420. uvs6: Nullable<FloatArray>;
  21421. /**
  21422. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21423. */
  21424. colors: Nullable<FloatArray>;
  21425. /**
  21426. * 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).
  21427. */
  21428. matricesIndices: Nullable<FloatArray>;
  21429. /**
  21430. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21431. */
  21432. matricesWeights: Nullable<FloatArray>;
  21433. /**
  21434. * An array extending the number of possible indices
  21435. */
  21436. matricesIndicesExtra: Nullable<FloatArray>;
  21437. /**
  21438. * An array extending the number of possible weights when the number of indices is extended
  21439. */
  21440. matricesWeightsExtra: Nullable<FloatArray>;
  21441. /**
  21442. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21443. */
  21444. indices: Nullable<IndicesArray>;
  21445. /**
  21446. * Uses the passed data array to set the set the values for the specified kind of data
  21447. * @param data a linear array of floating numbers
  21448. * @param kind the type of data that is being set, eg positions, colors etc
  21449. */
  21450. set(data: FloatArray, kind: string): void;
  21451. /**
  21452. * Associates the vertexData to the passed Mesh.
  21453. * Sets it as updatable or not (default `false`)
  21454. * @param mesh the mesh the vertexData is applied to
  21455. * @param updatable when used and having the value true allows new data to update the vertexData
  21456. * @returns the VertexData
  21457. */
  21458. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21459. /**
  21460. * Associates the vertexData to the passed Geometry.
  21461. * Sets it as updatable or not (default `false`)
  21462. * @param geometry the geometry the vertexData is applied to
  21463. * @param updatable when used and having the value true allows new data to update the vertexData
  21464. * @returns VertexData
  21465. */
  21466. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21467. /**
  21468. * Updates the associated mesh
  21469. * @param mesh the mesh to be updated
  21470. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21471. * @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
  21472. * @returns VertexData
  21473. */
  21474. updateMesh(mesh: Mesh): VertexData;
  21475. /**
  21476. * Updates the associated geometry
  21477. * @param geometry the geometry to be updated
  21478. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21479. * @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
  21480. * @returns VertexData.
  21481. */
  21482. updateGeometry(geometry: Geometry): VertexData;
  21483. private _applyTo;
  21484. private _update;
  21485. /**
  21486. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21487. * @param matrix the transforming matrix
  21488. * @returns the VertexData
  21489. */
  21490. transform(matrix: Matrix): VertexData;
  21491. /**
  21492. * Merges the passed VertexData into the current one
  21493. * @param other the VertexData to be merged into the current one
  21494. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21495. * @returns the modified VertexData
  21496. */
  21497. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21498. private _mergeElement;
  21499. private _validate;
  21500. /**
  21501. * Serializes the VertexData
  21502. * @returns a serialized object
  21503. */
  21504. serialize(): any;
  21505. /**
  21506. * Extracts the vertexData from a mesh
  21507. * @param mesh the mesh from which to extract the VertexData
  21508. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21509. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21510. * @returns the object VertexData associated to the passed mesh
  21511. */
  21512. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21513. /**
  21514. * Extracts the vertexData from the geometry
  21515. * @param geometry the geometry from which to extract the VertexData
  21516. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21517. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21518. * @returns the object VertexData associated to the passed mesh
  21519. */
  21520. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21521. private static _ExtractFrom;
  21522. /**
  21523. * Creates the VertexData for a Ribbon
  21524. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21525. * * pathArray array of paths, each of which an array of successive Vector3
  21526. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21527. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21528. * * 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
  21529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21530. * * 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)
  21531. * * 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)
  21532. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21533. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21534. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21535. * @returns the VertexData of the ribbon
  21536. */
  21537. static CreateRibbon(options: {
  21538. pathArray: Vector3[][];
  21539. closeArray?: boolean;
  21540. closePath?: boolean;
  21541. offset?: number;
  21542. sideOrientation?: number;
  21543. frontUVs?: Vector4;
  21544. backUVs?: Vector4;
  21545. invertUV?: boolean;
  21546. uvs?: Vector2[];
  21547. colors?: Color4[];
  21548. }): VertexData;
  21549. /**
  21550. * Creates the VertexData for a box
  21551. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21552. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21553. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21554. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21555. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21556. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21557. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21559. * * 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)
  21560. * * 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)
  21561. * @returns the VertexData of the box
  21562. */
  21563. static CreateBox(options: {
  21564. size?: number;
  21565. width?: number;
  21566. height?: number;
  21567. depth?: number;
  21568. faceUV?: Vector4[];
  21569. faceColors?: Color4[];
  21570. sideOrientation?: number;
  21571. frontUVs?: Vector4;
  21572. backUVs?: Vector4;
  21573. }): VertexData;
  21574. /**
  21575. * Creates the VertexData for a tiled box
  21576. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21577. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21578. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21579. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21581. * @returns the VertexData of the box
  21582. */
  21583. static CreateTiledBox(options: {
  21584. pattern?: number;
  21585. width?: number;
  21586. height?: number;
  21587. depth?: number;
  21588. tileSize?: number;
  21589. tileWidth?: number;
  21590. tileHeight?: number;
  21591. alignHorizontal?: number;
  21592. alignVertical?: number;
  21593. faceUV?: Vector4[];
  21594. faceColors?: Color4[];
  21595. sideOrientation?: number;
  21596. }): VertexData;
  21597. /**
  21598. * Creates the VertexData for a tiled plane
  21599. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21600. * * pattern a limited pattern arrangement depending on the number
  21601. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21602. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21603. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21605. * * 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)
  21606. * * 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)
  21607. * @returns the VertexData of the tiled plane
  21608. */
  21609. static CreateTiledPlane(options: {
  21610. pattern?: number;
  21611. tileSize?: number;
  21612. tileWidth?: number;
  21613. tileHeight?: number;
  21614. size?: number;
  21615. width?: number;
  21616. height?: number;
  21617. alignHorizontal?: number;
  21618. alignVertical?: number;
  21619. sideOrientation?: number;
  21620. frontUVs?: Vector4;
  21621. backUVs?: Vector4;
  21622. }): VertexData;
  21623. /**
  21624. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21626. * * segments sets the number of horizontal strips optional, default 32
  21627. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21628. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21629. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21630. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21631. * * 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
  21632. * * 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
  21633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21634. * * 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)
  21635. * * 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)
  21636. * @returns the VertexData of the ellipsoid
  21637. */
  21638. static CreateSphere(options: {
  21639. segments?: number;
  21640. diameter?: number;
  21641. diameterX?: number;
  21642. diameterY?: number;
  21643. diameterZ?: number;
  21644. arc?: number;
  21645. slice?: number;
  21646. sideOrientation?: number;
  21647. frontUVs?: Vector4;
  21648. backUVs?: Vector4;
  21649. }): VertexData;
  21650. /**
  21651. * Creates the VertexData for a cylinder, cone or prism
  21652. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21653. * * height sets the height (y direction) of the cylinder, optional, default 2
  21654. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21655. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21656. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21657. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21658. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21659. * * 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
  21660. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21661. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21662. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21663. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21665. * * 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)
  21666. * * 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)
  21667. * @returns the VertexData of the cylinder, cone or prism
  21668. */
  21669. static CreateCylinder(options: {
  21670. height?: number;
  21671. diameterTop?: number;
  21672. diameterBottom?: number;
  21673. diameter?: number;
  21674. tessellation?: number;
  21675. subdivisions?: number;
  21676. arc?: number;
  21677. faceColors?: Color4[];
  21678. faceUV?: Vector4[];
  21679. hasRings?: boolean;
  21680. enclose?: boolean;
  21681. sideOrientation?: number;
  21682. frontUVs?: Vector4;
  21683. backUVs?: Vector4;
  21684. }): VertexData;
  21685. /**
  21686. * Creates the VertexData for a torus
  21687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21688. * * diameter the diameter of the torus, optional default 1
  21689. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21690. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21692. * * 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)
  21693. * * 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)
  21694. * @returns the VertexData of the torus
  21695. */
  21696. static CreateTorus(options: {
  21697. diameter?: number;
  21698. thickness?: number;
  21699. tessellation?: number;
  21700. sideOrientation?: number;
  21701. frontUVs?: Vector4;
  21702. backUVs?: Vector4;
  21703. }): VertexData;
  21704. /**
  21705. * Creates the VertexData of the LineSystem
  21706. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21707. * - lines an array of lines, each line being an array of successive Vector3
  21708. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21709. * @returns the VertexData of the LineSystem
  21710. */
  21711. static CreateLineSystem(options: {
  21712. lines: Vector3[][];
  21713. colors?: Nullable<Color4[][]>;
  21714. }): VertexData;
  21715. /**
  21716. * Create the VertexData for a DashedLines
  21717. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21718. * - points an array successive Vector3
  21719. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21720. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21721. * - dashNb the intended total number of dashes, optional, default 200
  21722. * @returns the VertexData for the DashedLines
  21723. */
  21724. static CreateDashedLines(options: {
  21725. points: Vector3[];
  21726. dashSize?: number;
  21727. gapSize?: number;
  21728. dashNb?: number;
  21729. }): VertexData;
  21730. /**
  21731. * Creates the VertexData for a Ground
  21732. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21733. * - width the width (x direction) of the ground, optional, default 1
  21734. * - height the height (z direction) of the ground, optional, default 1
  21735. * - subdivisions the number of subdivisions per side, optional, default 1
  21736. * @returns the VertexData of the Ground
  21737. */
  21738. static CreateGround(options: {
  21739. width?: number;
  21740. height?: number;
  21741. subdivisions?: number;
  21742. subdivisionsX?: number;
  21743. subdivisionsY?: number;
  21744. }): VertexData;
  21745. /**
  21746. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21747. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21748. * * xmin the ground minimum X coordinate, optional, default -1
  21749. * * zmin the ground minimum Z coordinate, optional, default -1
  21750. * * xmax the ground maximum X coordinate, optional, default 1
  21751. * * zmax the ground maximum Z coordinate, optional, default 1
  21752. * * 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}
  21753. * * 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}
  21754. * @returns the VertexData of the TiledGround
  21755. */
  21756. static CreateTiledGround(options: {
  21757. xmin: number;
  21758. zmin: number;
  21759. xmax: number;
  21760. zmax: number;
  21761. subdivisions?: {
  21762. w: number;
  21763. h: number;
  21764. };
  21765. precision?: {
  21766. w: number;
  21767. h: number;
  21768. };
  21769. }): VertexData;
  21770. /**
  21771. * Creates the VertexData of the Ground designed from a heightmap
  21772. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21773. * * width the width (x direction) of the ground
  21774. * * height the height (z direction) of the ground
  21775. * * subdivisions the number of subdivisions per side
  21776. * * minHeight the minimum altitude on the ground, optional, default 0
  21777. * * maxHeight the maximum altitude on the ground, optional default 1
  21778. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21779. * * buffer the array holding the image color data
  21780. * * bufferWidth the width of image
  21781. * * bufferHeight the height of image
  21782. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21783. * @returns the VertexData of the Ground designed from a heightmap
  21784. */
  21785. static CreateGroundFromHeightMap(options: {
  21786. width: number;
  21787. height: number;
  21788. subdivisions: number;
  21789. minHeight: number;
  21790. maxHeight: number;
  21791. colorFilter: Color3;
  21792. buffer: Uint8Array;
  21793. bufferWidth: number;
  21794. bufferHeight: number;
  21795. alphaFilter: number;
  21796. }): VertexData;
  21797. /**
  21798. * Creates the VertexData for a Plane
  21799. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21800. * * size sets the width and height of the plane to the value of size, optional default 1
  21801. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21802. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21804. * * 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)
  21805. * * 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)
  21806. * @returns the VertexData of the box
  21807. */
  21808. static CreatePlane(options: {
  21809. size?: number;
  21810. width?: number;
  21811. height?: number;
  21812. sideOrientation?: number;
  21813. frontUVs?: Vector4;
  21814. backUVs?: Vector4;
  21815. }): VertexData;
  21816. /**
  21817. * Creates the VertexData of the Disc or regular Polygon
  21818. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21819. * * radius the radius of the disc, optional default 0.5
  21820. * * tessellation the number of polygon sides, optional, default 64
  21821. * * 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
  21822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21823. * * 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)
  21824. * * 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)
  21825. * @returns the VertexData of the box
  21826. */
  21827. static CreateDisc(options: {
  21828. radius?: number;
  21829. tessellation?: number;
  21830. arc?: number;
  21831. sideOrientation?: number;
  21832. frontUVs?: Vector4;
  21833. backUVs?: Vector4;
  21834. }): VertexData;
  21835. /**
  21836. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21837. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21838. * @param polygon a mesh built from polygonTriangulation.build()
  21839. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21840. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21841. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21842. * @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)
  21843. * @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)
  21844. * @returns the VertexData of the Polygon
  21845. */
  21846. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21847. /**
  21848. * Creates the VertexData of the IcoSphere
  21849. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21850. * * radius the radius of the IcoSphere, optional default 1
  21851. * * radiusX allows stretching in the x direction, optional, default radius
  21852. * * radiusY allows stretching in the y direction, optional, default radius
  21853. * * radiusZ allows stretching in the z direction, optional, default radius
  21854. * * flat when true creates a flat shaded mesh, optional, default true
  21855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21857. * * 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)
  21858. * * 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)
  21859. * @returns the VertexData of the IcoSphere
  21860. */
  21861. static CreateIcoSphere(options: {
  21862. radius?: number;
  21863. radiusX?: number;
  21864. radiusY?: number;
  21865. radiusZ?: number;
  21866. flat?: boolean;
  21867. subdivisions?: number;
  21868. sideOrientation?: number;
  21869. frontUVs?: Vector4;
  21870. backUVs?: Vector4;
  21871. }): VertexData;
  21872. /**
  21873. * Creates the VertexData for a Polyhedron
  21874. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21875. * * type provided types are:
  21876. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21877. * * 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)
  21878. * * size the size of the IcoSphere, optional default 1
  21879. * * sizeX allows stretching in the x direction, optional, default size
  21880. * * sizeY allows stretching in the y direction, optional, default size
  21881. * * sizeZ allows stretching in the z direction, optional, default size
  21882. * * 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
  21883. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21884. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21885. * * flat when true creates a flat shaded mesh, optional, default true
  21886. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21888. * * 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)
  21889. * * 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)
  21890. * @returns the VertexData of the Polyhedron
  21891. */
  21892. static CreatePolyhedron(options: {
  21893. type?: number;
  21894. size?: number;
  21895. sizeX?: number;
  21896. sizeY?: number;
  21897. sizeZ?: number;
  21898. custom?: any;
  21899. faceUV?: Vector4[];
  21900. faceColors?: Color4[];
  21901. flat?: boolean;
  21902. sideOrientation?: number;
  21903. frontUVs?: Vector4;
  21904. backUVs?: Vector4;
  21905. }): VertexData;
  21906. /**
  21907. * Creates the VertexData for a TorusKnot
  21908. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21909. * * radius the radius of the torus knot, optional, default 2
  21910. * * tube the thickness of the tube, optional, default 0.5
  21911. * * radialSegments the number of sides on each tube segments, optional, default 32
  21912. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21913. * * p the number of windings around the z axis, optional, default 2
  21914. * * q the number of windings around the x axis, optional, default 3
  21915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21916. * * 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)
  21917. * * 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)
  21918. * @returns the VertexData of the Torus Knot
  21919. */
  21920. static CreateTorusKnot(options: {
  21921. radius?: number;
  21922. tube?: number;
  21923. radialSegments?: number;
  21924. tubularSegments?: number;
  21925. p?: number;
  21926. q?: number;
  21927. sideOrientation?: number;
  21928. frontUVs?: Vector4;
  21929. backUVs?: Vector4;
  21930. }): VertexData;
  21931. /**
  21932. * Compute normals for given positions and indices
  21933. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21934. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21935. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21936. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21937. * * facetNormals : optional array of facet normals (vector3)
  21938. * * facetPositions : optional array of facet positions (vector3)
  21939. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21940. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21941. * * bInfo : optional bounding info, required for facetPartitioning computation
  21942. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21943. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21944. * * useRightHandedSystem: optional boolean to for right handed system computation
  21945. * * depthSort : optional boolean to enable the facet depth sort computation
  21946. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21947. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21948. */
  21949. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21950. facetNormals?: any;
  21951. facetPositions?: any;
  21952. facetPartitioning?: any;
  21953. ratio?: number;
  21954. bInfo?: any;
  21955. bbSize?: Vector3;
  21956. subDiv?: any;
  21957. useRightHandedSystem?: boolean;
  21958. depthSort?: boolean;
  21959. distanceTo?: Vector3;
  21960. depthSortedFacets?: any;
  21961. }): void;
  21962. /** @hidden */
  21963. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21964. /**
  21965. * Applies VertexData created from the imported parameters to the geometry
  21966. * @param parsedVertexData the parsed data from an imported file
  21967. * @param geometry the geometry to apply the VertexData to
  21968. */
  21969. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21970. }
  21971. }
  21972. declare module BABYLON {
  21973. /**
  21974. * Defines a target to use with MorphTargetManager
  21975. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21976. */
  21977. export class MorphTarget implements IAnimatable {
  21978. /** defines the name of the target */
  21979. name: string;
  21980. /**
  21981. * Gets or sets the list of animations
  21982. */
  21983. animations: Animation[];
  21984. private _scene;
  21985. private _positions;
  21986. private _normals;
  21987. private _tangents;
  21988. private _uvs;
  21989. private _influence;
  21990. /**
  21991. * Observable raised when the influence changes
  21992. */
  21993. onInfluenceChanged: Observable<boolean>;
  21994. /** @hidden */
  21995. _onDataLayoutChanged: Observable<void>;
  21996. /**
  21997. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21998. */
  21999. influence: number;
  22000. /**
  22001. * Gets or sets the id of the morph Target
  22002. */
  22003. id: string;
  22004. private _animationPropertiesOverride;
  22005. /**
  22006. * Gets or sets the animation properties override
  22007. */
  22008. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22009. /**
  22010. * Creates a new MorphTarget
  22011. * @param name defines the name of the target
  22012. * @param influence defines the influence to use
  22013. * @param scene defines the scene the morphtarget belongs to
  22014. */
  22015. constructor(
  22016. /** defines the name of the target */
  22017. name: string, influence?: number, scene?: Nullable<Scene>);
  22018. /**
  22019. * Gets a boolean defining if the target contains position data
  22020. */
  22021. readonly hasPositions: boolean;
  22022. /**
  22023. * Gets a boolean defining if the target contains normal data
  22024. */
  22025. readonly hasNormals: boolean;
  22026. /**
  22027. * Gets a boolean defining if the target contains tangent data
  22028. */
  22029. readonly hasTangents: boolean;
  22030. /**
  22031. * Gets a boolean defining if the target contains texture coordinates data
  22032. */
  22033. readonly hasUVs: boolean;
  22034. /**
  22035. * Affects position data to this target
  22036. * @param data defines the position data to use
  22037. */
  22038. setPositions(data: Nullable<FloatArray>): void;
  22039. /**
  22040. * Gets the position data stored in this target
  22041. * @returns a FloatArray containing the position data (or null if not present)
  22042. */
  22043. getPositions(): Nullable<FloatArray>;
  22044. /**
  22045. * Affects normal data to this target
  22046. * @param data defines the normal data to use
  22047. */
  22048. setNormals(data: Nullable<FloatArray>): void;
  22049. /**
  22050. * Gets the normal data stored in this target
  22051. * @returns a FloatArray containing the normal data (or null if not present)
  22052. */
  22053. getNormals(): Nullable<FloatArray>;
  22054. /**
  22055. * Affects tangent data to this target
  22056. * @param data defines the tangent data to use
  22057. */
  22058. setTangents(data: Nullable<FloatArray>): void;
  22059. /**
  22060. * Gets the tangent data stored in this target
  22061. * @returns a FloatArray containing the tangent data (or null if not present)
  22062. */
  22063. getTangents(): Nullable<FloatArray>;
  22064. /**
  22065. * Affects texture coordinates data to this target
  22066. * @param data defines the texture coordinates data to use
  22067. */
  22068. setUVs(data: Nullable<FloatArray>): void;
  22069. /**
  22070. * Gets the texture coordinates data stored in this target
  22071. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22072. */
  22073. getUVs(): Nullable<FloatArray>;
  22074. /**
  22075. * Serializes the current target into a Serialization object
  22076. * @returns the serialized object
  22077. */
  22078. serialize(): any;
  22079. /**
  22080. * Returns the string "MorphTarget"
  22081. * @returns "MorphTarget"
  22082. */
  22083. getClassName(): string;
  22084. /**
  22085. * Creates a new target from serialized data
  22086. * @param serializationObject defines the serialized data to use
  22087. * @returns a new MorphTarget
  22088. */
  22089. static Parse(serializationObject: any): MorphTarget;
  22090. /**
  22091. * Creates a MorphTarget from mesh data
  22092. * @param mesh defines the source mesh
  22093. * @param name defines the name to use for the new target
  22094. * @param influence defines the influence to attach to the target
  22095. * @returns a new MorphTarget
  22096. */
  22097. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22098. }
  22099. }
  22100. declare module BABYLON {
  22101. /**
  22102. * This class is used to deform meshes using morphing between different targets
  22103. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22104. */
  22105. export class MorphTargetManager {
  22106. private _targets;
  22107. private _targetInfluenceChangedObservers;
  22108. private _targetDataLayoutChangedObservers;
  22109. private _activeTargets;
  22110. private _scene;
  22111. private _influences;
  22112. private _supportsNormals;
  22113. private _supportsTangents;
  22114. private _supportsUVs;
  22115. private _vertexCount;
  22116. private _uniqueId;
  22117. private _tempInfluences;
  22118. /**
  22119. * Gets or sets a boolean indicating if normals must be morphed
  22120. */
  22121. enableNormalMorphing: boolean;
  22122. /**
  22123. * Gets or sets a boolean indicating if tangents must be morphed
  22124. */
  22125. enableTangentMorphing: boolean;
  22126. /**
  22127. * Gets or sets a boolean indicating if UV must be morphed
  22128. */
  22129. enableUVMorphing: boolean;
  22130. /**
  22131. * Creates a new MorphTargetManager
  22132. * @param scene defines the current scene
  22133. */
  22134. constructor(scene?: Nullable<Scene>);
  22135. /**
  22136. * Gets the unique ID of this manager
  22137. */
  22138. readonly uniqueId: number;
  22139. /**
  22140. * Gets the number of vertices handled by this manager
  22141. */
  22142. readonly vertexCount: number;
  22143. /**
  22144. * Gets a boolean indicating if this manager supports morphing of normals
  22145. */
  22146. readonly supportsNormals: boolean;
  22147. /**
  22148. * Gets a boolean indicating if this manager supports morphing of tangents
  22149. */
  22150. readonly supportsTangents: boolean;
  22151. /**
  22152. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22153. */
  22154. readonly supportsUVs: boolean;
  22155. /**
  22156. * Gets the number of targets stored in this manager
  22157. */
  22158. readonly numTargets: number;
  22159. /**
  22160. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22161. */
  22162. readonly numInfluencers: number;
  22163. /**
  22164. * Gets the list of influences (one per target)
  22165. */
  22166. readonly influences: Float32Array;
  22167. /**
  22168. * Gets the active target at specified index. An active target is a target with an influence > 0
  22169. * @param index defines the index to check
  22170. * @returns the requested target
  22171. */
  22172. getActiveTarget(index: number): MorphTarget;
  22173. /**
  22174. * Gets the target at specified index
  22175. * @param index defines the index to check
  22176. * @returns the requested target
  22177. */
  22178. getTarget(index: number): MorphTarget;
  22179. /**
  22180. * Add a new target to this manager
  22181. * @param target defines the target to add
  22182. */
  22183. addTarget(target: MorphTarget): void;
  22184. /**
  22185. * Removes a target from the manager
  22186. * @param target defines the target to remove
  22187. */
  22188. removeTarget(target: MorphTarget): void;
  22189. /**
  22190. * Serializes the current manager into a Serialization object
  22191. * @returns the serialized object
  22192. */
  22193. serialize(): any;
  22194. private _syncActiveTargets;
  22195. /**
  22196. * Syncrhonize the targets with all the meshes using this morph target manager
  22197. */
  22198. synchronize(): void;
  22199. /**
  22200. * Creates a new MorphTargetManager from serialized data
  22201. * @param serializationObject defines the serialized data
  22202. * @param scene defines the hosting scene
  22203. * @returns the new MorphTargetManager
  22204. */
  22205. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22206. }
  22207. }
  22208. declare module BABYLON {
  22209. /**
  22210. * Class used to represent a specific level of detail of a mesh
  22211. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22212. */
  22213. export class MeshLODLevel {
  22214. /** Defines the distance where this level should start being displayed */
  22215. distance: number;
  22216. /** Defines the mesh to use to render this level */
  22217. mesh: Nullable<Mesh>;
  22218. /**
  22219. * Creates a new LOD level
  22220. * @param distance defines the distance where this level should star being displayed
  22221. * @param mesh defines the mesh to use to render this level
  22222. */
  22223. constructor(
  22224. /** Defines the distance where this level should start being displayed */
  22225. distance: number,
  22226. /** Defines the mesh to use to render this level */
  22227. mesh: Nullable<Mesh>);
  22228. }
  22229. }
  22230. declare module BABYLON {
  22231. /**
  22232. * Mesh representing the gorund
  22233. */
  22234. export class GroundMesh extends Mesh {
  22235. /** If octree should be generated */
  22236. generateOctree: boolean;
  22237. private _heightQuads;
  22238. /** @hidden */
  22239. _subdivisionsX: number;
  22240. /** @hidden */
  22241. _subdivisionsY: number;
  22242. /** @hidden */
  22243. _width: number;
  22244. /** @hidden */
  22245. _height: number;
  22246. /** @hidden */
  22247. _minX: number;
  22248. /** @hidden */
  22249. _maxX: number;
  22250. /** @hidden */
  22251. _minZ: number;
  22252. /** @hidden */
  22253. _maxZ: number;
  22254. constructor(name: string, scene: Scene);
  22255. /**
  22256. * "GroundMesh"
  22257. * @returns "GroundMesh"
  22258. */
  22259. getClassName(): string;
  22260. /**
  22261. * The minimum of x and y subdivisions
  22262. */
  22263. readonly subdivisions: number;
  22264. /**
  22265. * X subdivisions
  22266. */
  22267. readonly subdivisionsX: number;
  22268. /**
  22269. * Y subdivisions
  22270. */
  22271. readonly subdivisionsY: number;
  22272. /**
  22273. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22274. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22275. * @param chunksCount the number of subdivisions for x and y
  22276. * @param octreeBlocksSize (Default: 32)
  22277. */
  22278. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22279. /**
  22280. * Returns a height (y) value in the Worl system :
  22281. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22282. * @param x x coordinate
  22283. * @param z z coordinate
  22284. * @returns the ground y position if (x, z) are outside the ground surface.
  22285. */
  22286. getHeightAtCoordinates(x: number, z: number): number;
  22287. /**
  22288. * Returns a normalized vector (Vector3) orthogonal to the ground
  22289. * at the ground coordinates (x, z) expressed in the World system.
  22290. * @param x x coordinate
  22291. * @param z z coordinate
  22292. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22293. */
  22294. getNormalAtCoordinates(x: number, z: number): Vector3;
  22295. /**
  22296. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22297. * at the ground coordinates (x, z) expressed in the World system.
  22298. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22299. * @param x x coordinate
  22300. * @param z z coordinate
  22301. * @param ref vector to store the result
  22302. * @returns the GroundMesh.
  22303. */
  22304. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22305. /**
  22306. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22307. * if the ground has been updated.
  22308. * This can be used in the render loop.
  22309. * @returns the GroundMesh.
  22310. */
  22311. updateCoordinateHeights(): GroundMesh;
  22312. private _getFacetAt;
  22313. private _initHeightQuads;
  22314. private _computeHeightQuads;
  22315. /**
  22316. * Serializes this ground mesh
  22317. * @param serializationObject object to write serialization to
  22318. */
  22319. serialize(serializationObject: any): void;
  22320. /**
  22321. * Parses a serialized ground mesh
  22322. * @param parsedMesh the serialized mesh
  22323. * @param scene the scene to create the ground mesh in
  22324. * @returns the created ground mesh
  22325. */
  22326. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22327. }
  22328. }
  22329. declare module BABYLON {
  22330. /**
  22331. * Interface for Physics-Joint data
  22332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22333. */
  22334. export interface PhysicsJointData {
  22335. /**
  22336. * The main pivot of the joint
  22337. */
  22338. mainPivot?: Vector3;
  22339. /**
  22340. * The connected pivot of the joint
  22341. */
  22342. connectedPivot?: Vector3;
  22343. /**
  22344. * The main axis of the joint
  22345. */
  22346. mainAxis?: Vector3;
  22347. /**
  22348. * The connected axis of the joint
  22349. */
  22350. connectedAxis?: Vector3;
  22351. /**
  22352. * The collision of the joint
  22353. */
  22354. collision?: boolean;
  22355. /**
  22356. * Native Oimo/Cannon/Energy data
  22357. */
  22358. nativeParams?: any;
  22359. }
  22360. /**
  22361. * This is a holder class for the physics joint created by the physics plugin
  22362. * It holds a set of functions to control the underlying joint
  22363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22364. */
  22365. export class PhysicsJoint {
  22366. /**
  22367. * The type of the physics joint
  22368. */
  22369. type: number;
  22370. /**
  22371. * The data for the physics joint
  22372. */
  22373. jointData: PhysicsJointData;
  22374. private _physicsJoint;
  22375. protected _physicsPlugin: IPhysicsEnginePlugin;
  22376. /**
  22377. * Initializes the physics joint
  22378. * @param type The type of the physics joint
  22379. * @param jointData The data for the physics joint
  22380. */
  22381. constructor(
  22382. /**
  22383. * The type of the physics joint
  22384. */
  22385. type: number,
  22386. /**
  22387. * The data for the physics joint
  22388. */
  22389. jointData: PhysicsJointData);
  22390. /**
  22391. * Gets the physics joint
  22392. */
  22393. /**
  22394. * Sets the physics joint
  22395. */
  22396. physicsJoint: any;
  22397. /**
  22398. * Sets the physics plugin
  22399. */
  22400. physicsPlugin: IPhysicsEnginePlugin;
  22401. /**
  22402. * Execute a function that is physics-plugin specific.
  22403. * @param {Function} func the function that will be executed.
  22404. * It accepts two parameters: the physics world and the physics joint
  22405. */
  22406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22407. /**
  22408. * Distance-Joint type
  22409. */
  22410. static DistanceJoint: number;
  22411. /**
  22412. * Hinge-Joint type
  22413. */
  22414. static HingeJoint: number;
  22415. /**
  22416. * Ball-and-Socket joint type
  22417. */
  22418. static BallAndSocketJoint: number;
  22419. /**
  22420. * Wheel-Joint type
  22421. */
  22422. static WheelJoint: number;
  22423. /**
  22424. * Slider-Joint type
  22425. */
  22426. static SliderJoint: number;
  22427. /**
  22428. * Prismatic-Joint type
  22429. */
  22430. static PrismaticJoint: number;
  22431. /**
  22432. * Universal-Joint type
  22433. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22434. */
  22435. static UniversalJoint: number;
  22436. /**
  22437. * Hinge-Joint 2 type
  22438. */
  22439. static Hinge2Joint: number;
  22440. /**
  22441. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22442. */
  22443. static PointToPointJoint: number;
  22444. /**
  22445. * Spring-Joint type
  22446. */
  22447. static SpringJoint: number;
  22448. /**
  22449. * Lock-Joint type
  22450. */
  22451. static LockJoint: number;
  22452. }
  22453. /**
  22454. * A class representing a physics distance joint
  22455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22456. */
  22457. export class DistanceJoint extends PhysicsJoint {
  22458. /**
  22459. *
  22460. * @param jointData The data for the Distance-Joint
  22461. */
  22462. constructor(jointData: DistanceJointData);
  22463. /**
  22464. * Update the predefined distance.
  22465. * @param maxDistance The maximum preferred distance
  22466. * @param minDistance The minimum preferred distance
  22467. */
  22468. updateDistance(maxDistance: number, minDistance?: number): void;
  22469. }
  22470. /**
  22471. * Represents a Motor-Enabled Joint
  22472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22473. */
  22474. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22475. /**
  22476. * Initializes the Motor-Enabled Joint
  22477. * @param type The type of the joint
  22478. * @param jointData The physica joint data for the joint
  22479. */
  22480. constructor(type: number, jointData: PhysicsJointData);
  22481. /**
  22482. * Set the motor values.
  22483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22484. * @param force the force to apply
  22485. * @param maxForce max force for this motor.
  22486. */
  22487. setMotor(force?: number, maxForce?: number): void;
  22488. /**
  22489. * Set the motor's limits.
  22490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22491. * @param upperLimit The upper limit of the motor
  22492. * @param lowerLimit The lower limit of the motor
  22493. */
  22494. setLimit(upperLimit: number, lowerLimit?: number): void;
  22495. }
  22496. /**
  22497. * This class represents a single physics Hinge-Joint
  22498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22499. */
  22500. export class HingeJoint extends MotorEnabledJoint {
  22501. /**
  22502. * Initializes the Hinge-Joint
  22503. * @param jointData The joint data for the Hinge-Joint
  22504. */
  22505. constructor(jointData: PhysicsJointData);
  22506. /**
  22507. * Set the motor values.
  22508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22509. * @param {number} force the force to apply
  22510. * @param {number} maxForce max force for this motor.
  22511. */
  22512. setMotor(force?: number, maxForce?: number): void;
  22513. /**
  22514. * Set the motor's limits.
  22515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22516. * @param upperLimit The upper limit of the motor
  22517. * @param lowerLimit The lower limit of the motor
  22518. */
  22519. setLimit(upperLimit: number, lowerLimit?: number): void;
  22520. }
  22521. /**
  22522. * This class represents a dual hinge physics joint (same as wheel joint)
  22523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22524. */
  22525. export class Hinge2Joint extends MotorEnabledJoint {
  22526. /**
  22527. * Initializes the Hinge2-Joint
  22528. * @param jointData The joint data for the Hinge2-Joint
  22529. */
  22530. constructor(jointData: PhysicsJointData);
  22531. /**
  22532. * Set the motor values.
  22533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22534. * @param {number} targetSpeed the speed the motor is to reach
  22535. * @param {number} maxForce max force for this motor.
  22536. * @param {motorIndex} the motor's index, 0 or 1.
  22537. */
  22538. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22539. /**
  22540. * Set the motor limits.
  22541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22542. * @param {number} upperLimit the upper limit
  22543. * @param {number} lowerLimit lower limit
  22544. * @param {motorIndex} the motor's index, 0 or 1.
  22545. */
  22546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22547. }
  22548. /**
  22549. * Interface for a motor enabled joint
  22550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22551. */
  22552. export interface IMotorEnabledJoint {
  22553. /**
  22554. * Physics joint
  22555. */
  22556. physicsJoint: any;
  22557. /**
  22558. * Sets the motor of the motor-enabled joint
  22559. * @param force The force of the motor
  22560. * @param maxForce The maximum force of the motor
  22561. * @param motorIndex The index of the motor
  22562. */
  22563. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22564. /**
  22565. * Sets the limit of the motor
  22566. * @param upperLimit The upper limit of the motor
  22567. * @param lowerLimit The lower limit of the motor
  22568. * @param motorIndex The index of the motor
  22569. */
  22570. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22571. }
  22572. /**
  22573. * Joint data for a Distance-Joint
  22574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22575. */
  22576. export interface DistanceJointData extends PhysicsJointData {
  22577. /**
  22578. * Max distance the 2 joint objects can be apart
  22579. */
  22580. maxDistance: number;
  22581. }
  22582. /**
  22583. * Joint data from a spring joint
  22584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22585. */
  22586. export interface SpringJointData extends PhysicsJointData {
  22587. /**
  22588. * Length of the spring
  22589. */
  22590. length: number;
  22591. /**
  22592. * Stiffness of the spring
  22593. */
  22594. stiffness: number;
  22595. /**
  22596. * Damping of the spring
  22597. */
  22598. damping: number;
  22599. /** this callback will be called when applying the force to the impostors. */
  22600. forceApplicationCallback: () => void;
  22601. }
  22602. }
  22603. declare module BABYLON {
  22604. /**
  22605. * Holds the data for the raycast result
  22606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22607. */
  22608. export class PhysicsRaycastResult {
  22609. private _hasHit;
  22610. private _hitDistance;
  22611. private _hitNormalWorld;
  22612. private _hitPointWorld;
  22613. private _rayFromWorld;
  22614. private _rayToWorld;
  22615. /**
  22616. * Gets if there was a hit
  22617. */
  22618. readonly hasHit: boolean;
  22619. /**
  22620. * Gets the distance from the hit
  22621. */
  22622. readonly hitDistance: number;
  22623. /**
  22624. * Gets the hit normal/direction in the world
  22625. */
  22626. readonly hitNormalWorld: Vector3;
  22627. /**
  22628. * Gets the hit point in the world
  22629. */
  22630. readonly hitPointWorld: Vector3;
  22631. /**
  22632. * Gets the ray "start point" of the ray in the world
  22633. */
  22634. readonly rayFromWorld: Vector3;
  22635. /**
  22636. * Gets the ray "end point" of the ray in the world
  22637. */
  22638. readonly rayToWorld: Vector3;
  22639. /**
  22640. * Sets the hit data (normal & point in world space)
  22641. * @param hitNormalWorld defines the normal in world space
  22642. * @param hitPointWorld defines the point in world space
  22643. */
  22644. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22645. /**
  22646. * Sets the distance from the start point to the hit point
  22647. * @param distance
  22648. */
  22649. setHitDistance(distance: number): void;
  22650. /**
  22651. * Calculates the distance manually
  22652. */
  22653. calculateHitDistance(): void;
  22654. /**
  22655. * Resets all the values to default
  22656. * @param from The from point on world space
  22657. * @param to The to point on world space
  22658. */
  22659. reset(from?: Vector3, to?: Vector3): void;
  22660. }
  22661. /**
  22662. * Interface for the size containing width and height
  22663. */
  22664. interface IXYZ {
  22665. /**
  22666. * X
  22667. */
  22668. x: number;
  22669. /**
  22670. * Y
  22671. */
  22672. y: number;
  22673. /**
  22674. * Z
  22675. */
  22676. z: number;
  22677. }
  22678. }
  22679. declare module BABYLON {
  22680. /**
  22681. * Interface used to describe a physics joint
  22682. */
  22683. export interface PhysicsImpostorJoint {
  22684. /** Defines the main impostor to which the joint is linked */
  22685. mainImpostor: PhysicsImpostor;
  22686. /** Defines the impostor that is connected to the main impostor using this joint */
  22687. connectedImpostor: PhysicsImpostor;
  22688. /** Defines the joint itself */
  22689. joint: PhysicsJoint;
  22690. }
  22691. /** @hidden */
  22692. export interface IPhysicsEnginePlugin {
  22693. world: any;
  22694. name: string;
  22695. setGravity(gravity: Vector3): void;
  22696. setTimeStep(timeStep: number): void;
  22697. getTimeStep(): number;
  22698. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22699. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22700. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22701. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22702. removePhysicsBody(impostor: PhysicsImpostor): void;
  22703. generateJoint(joint: PhysicsImpostorJoint): void;
  22704. removeJoint(joint: PhysicsImpostorJoint): void;
  22705. isSupported(): boolean;
  22706. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22707. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22708. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22709. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22710. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22711. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22712. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22713. getBodyMass(impostor: PhysicsImpostor): number;
  22714. getBodyFriction(impostor: PhysicsImpostor): number;
  22715. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22716. getBodyRestitution(impostor: PhysicsImpostor): number;
  22717. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22718. getBodyPressure?(impostor: PhysicsImpostor): number;
  22719. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22720. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22721. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22722. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22723. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22724. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22725. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22726. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22727. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22728. sleepBody(impostor: PhysicsImpostor): void;
  22729. wakeUpBody(impostor: PhysicsImpostor): void;
  22730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22731. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22732. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22733. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22734. getRadius(impostor: PhysicsImpostor): number;
  22735. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22736. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22737. dispose(): void;
  22738. }
  22739. /**
  22740. * Interface used to define a physics engine
  22741. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22742. */
  22743. export interface IPhysicsEngine {
  22744. /**
  22745. * Gets the gravity vector used by the simulation
  22746. */
  22747. gravity: Vector3;
  22748. /**
  22749. * Sets the gravity vector used by the simulation
  22750. * @param gravity defines the gravity vector to use
  22751. */
  22752. setGravity(gravity: Vector3): void;
  22753. /**
  22754. * Set the time step of the physics engine.
  22755. * Default is 1/60.
  22756. * To slow it down, enter 1/600 for example.
  22757. * To speed it up, 1/30
  22758. * @param newTimeStep the new timestep to apply to this world.
  22759. */
  22760. setTimeStep(newTimeStep: number): void;
  22761. /**
  22762. * Get the time step of the physics engine.
  22763. * @returns the current time step
  22764. */
  22765. getTimeStep(): number;
  22766. /**
  22767. * Release all resources
  22768. */
  22769. dispose(): void;
  22770. /**
  22771. * Gets the name of the current physics plugin
  22772. * @returns the name of the plugin
  22773. */
  22774. getPhysicsPluginName(): string;
  22775. /**
  22776. * Adding a new impostor for the impostor tracking.
  22777. * This will be done by the impostor itself.
  22778. * @param impostor the impostor to add
  22779. */
  22780. addImpostor(impostor: PhysicsImpostor): void;
  22781. /**
  22782. * Remove an impostor from the engine.
  22783. * This impostor and its mesh will not longer be updated by the physics engine.
  22784. * @param impostor the impostor to remove
  22785. */
  22786. removeImpostor(impostor: PhysicsImpostor): void;
  22787. /**
  22788. * Add a joint to the physics engine
  22789. * @param mainImpostor defines the main impostor to which the joint is added.
  22790. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22791. * @param joint defines the joint that will connect both impostors.
  22792. */
  22793. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22794. /**
  22795. * Removes a joint from the simulation
  22796. * @param mainImpostor defines the impostor used with the joint
  22797. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22798. * @param joint defines the joint to remove
  22799. */
  22800. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22801. /**
  22802. * Gets the current plugin used to run the simulation
  22803. * @returns current plugin
  22804. */
  22805. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22806. /**
  22807. * Gets the list of physic impostors
  22808. * @returns an array of PhysicsImpostor
  22809. */
  22810. getImpostors(): Array<PhysicsImpostor>;
  22811. /**
  22812. * Gets the impostor for a physics enabled object
  22813. * @param object defines the object impersonated by the impostor
  22814. * @returns the PhysicsImpostor or null if not found
  22815. */
  22816. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22817. /**
  22818. * Gets the impostor for a physics body object
  22819. * @param body defines physics body used by the impostor
  22820. * @returns the PhysicsImpostor or null if not found
  22821. */
  22822. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22823. /**
  22824. * Does a raycast in the physics world
  22825. * @param from when should the ray start?
  22826. * @param to when should the ray end?
  22827. * @returns PhysicsRaycastResult
  22828. */
  22829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22830. /**
  22831. * Called by the scene. No need to call it.
  22832. * @param delta defines the timespam between frames
  22833. */
  22834. _step(delta: number): void;
  22835. }
  22836. }
  22837. declare module BABYLON {
  22838. /**
  22839. * The interface for the physics imposter parameters
  22840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22841. */
  22842. export interface PhysicsImpostorParameters {
  22843. /**
  22844. * The mass of the physics imposter
  22845. */
  22846. mass: number;
  22847. /**
  22848. * The friction of the physics imposter
  22849. */
  22850. friction?: number;
  22851. /**
  22852. * The coefficient of restitution of the physics imposter
  22853. */
  22854. restitution?: number;
  22855. /**
  22856. * The native options of the physics imposter
  22857. */
  22858. nativeOptions?: any;
  22859. /**
  22860. * Specifies if the parent should be ignored
  22861. */
  22862. ignoreParent?: boolean;
  22863. /**
  22864. * Specifies if bi-directional transformations should be disabled
  22865. */
  22866. disableBidirectionalTransformation?: boolean;
  22867. /**
  22868. * The pressure inside the physics imposter, soft object only
  22869. */
  22870. pressure?: number;
  22871. /**
  22872. * The stiffness the physics imposter, soft object only
  22873. */
  22874. stiffness?: number;
  22875. /**
  22876. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22877. */
  22878. velocityIterations?: number;
  22879. /**
  22880. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22881. */
  22882. positionIterations?: number;
  22883. /**
  22884. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22885. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22886. * Add to fix multiple points
  22887. */
  22888. fixedPoints?: number;
  22889. /**
  22890. * The collision margin around a soft object
  22891. */
  22892. margin?: number;
  22893. /**
  22894. * The collision margin around a soft object
  22895. */
  22896. damping?: number;
  22897. /**
  22898. * The path for a rope based on an extrusion
  22899. */
  22900. path?: any;
  22901. /**
  22902. * The shape of an extrusion used for a rope based on an extrusion
  22903. */
  22904. shape?: any;
  22905. }
  22906. /**
  22907. * Interface for a physics-enabled object
  22908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22909. */
  22910. export interface IPhysicsEnabledObject {
  22911. /**
  22912. * The position of the physics-enabled object
  22913. */
  22914. position: Vector3;
  22915. /**
  22916. * The rotation of the physics-enabled object
  22917. */
  22918. rotationQuaternion: Nullable<Quaternion>;
  22919. /**
  22920. * The scale of the physics-enabled object
  22921. */
  22922. scaling: Vector3;
  22923. /**
  22924. * The rotation of the physics-enabled object
  22925. */
  22926. rotation?: Vector3;
  22927. /**
  22928. * The parent of the physics-enabled object
  22929. */
  22930. parent?: any;
  22931. /**
  22932. * The bounding info of the physics-enabled object
  22933. * @returns The bounding info of the physics-enabled object
  22934. */
  22935. getBoundingInfo(): BoundingInfo;
  22936. /**
  22937. * Computes the world matrix
  22938. * @param force Specifies if the world matrix should be computed by force
  22939. * @returns A world matrix
  22940. */
  22941. computeWorldMatrix(force: boolean): Matrix;
  22942. /**
  22943. * Gets the world matrix
  22944. * @returns A world matrix
  22945. */
  22946. getWorldMatrix?(): Matrix;
  22947. /**
  22948. * Gets the child meshes
  22949. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22950. * @returns An array of abstract meshes
  22951. */
  22952. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22953. /**
  22954. * Gets the vertex data
  22955. * @param kind The type of vertex data
  22956. * @returns A nullable array of numbers, or a float32 array
  22957. */
  22958. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22959. /**
  22960. * Gets the indices from the mesh
  22961. * @returns A nullable array of index arrays
  22962. */
  22963. getIndices?(): Nullable<IndicesArray>;
  22964. /**
  22965. * Gets the scene from the mesh
  22966. * @returns the indices array or null
  22967. */
  22968. getScene?(): Scene;
  22969. /**
  22970. * Gets the absolute position from the mesh
  22971. * @returns the absolute position
  22972. */
  22973. getAbsolutePosition(): Vector3;
  22974. /**
  22975. * Gets the absolute pivot point from the mesh
  22976. * @returns the absolute pivot point
  22977. */
  22978. getAbsolutePivotPoint(): Vector3;
  22979. /**
  22980. * Rotates the mesh
  22981. * @param axis The axis of rotation
  22982. * @param amount The amount of rotation
  22983. * @param space The space of the rotation
  22984. * @returns The rotation transform node
  22985. */
  22986. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22987. /**
  22988. * Translates the mesh
  22989. * @param axis The axis of translation
  22990. * @param distance The distance of translation
  22991. * @param space The space of the translation
  22992. * @returns The transform node
  22993. */
  22994. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22995. /**
  22996. * Sets the absolute position of the mesh
  22997. * @param absolutePosition The absolute position of the mesh
  22998. * @returns The transform node
  22999. */
  23000. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23001. /**
  23002. * Gets the class name of the mesh
  23003. * @returns The class name
  23004. */
  23005. getClassName(): string;
  23006. }
  23007. /**
  23008. * Represents a physics imposter
  23009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23010. */
  23011. export class PhysicsImpostor {
  23012. /**
  23013. * The physics-enabled object used as the physics imposter
  23014. */
  23015. object: IPhysicsEnabledObject;
  23016. /**
  23017. * The type of the physics imposter
  23018. */
  23019. type: number;
  23020. private _options;
  23021. private _scene?;
  23022. /**
  23023. * The default object size of the imposter
  23024. */
  23025. static DEFAULT_OBJECT_SIZE: Vector3;
  23026. /**
  23027. * The identity quaternion of the imposter
  23028. */
  23029. static IDENTITY_QUATERNION: Quaternion;
  23030. /** @hidden */
  23031. _pluginData: any;
  23032. private _physicsEngine;
  23033. private _physicsBody;
  23034. private _bodyUpdateRequired;
  23035. private _onBeforePhysicsStepCallbacks;
  23036. private _onAfterPhysicsStepCallbacks;
  23037. /** @hidden */
  23038. _onPhysicsCollideCallbacks: Array<{
  23039. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23040. otherImpostors: Array<PhysicsImpostor>;
  23041. }>;
  23042. private _deltaPosition;
  23043. private _deltaRotation;
  23044. private _deltaRotationConjugated;
  23045. /** @hidden */
  23046. _isFromLine: boolean;
  23047. private _parent;
  23048. private _isDisposed;
  23049. private static _tmpVecs;
  23050. private static _tmpQuat;
  23051. /**
  23052. * Specifies if the physics imposter is disposed
  23053. */
  23054. readonly isDisposed: boolean;
  23055. /**
  23056. * Gets the mass of the physics imposter
  23057. */
  23058. mass: number;
  23059. /**
  23060. * Gets the coefficient of friction
  23061. */
  23062. /**
  23063. * Sets the coefficient of friction
  23064. */
  23065. friction: number;
  23066. /**
  23067. * Gets the coefficient of restitution
  23068. */
  23069. /**
  23070. * Sets the coefficient of restitution
  23071. */
  23072. restitution: number;
  23073. /**
  23074. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23075. */
  23076. /**
  23077. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23078. */
  23079. pressure: number;
  23080. /**
  23081. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23082. */
  23083. /**
  23084. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23085. */
  23086. stiffness: number;
  23087. /**
  23088. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23089. */
  23090. /**
  23091. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23092. */
  23093. velocityIterations: number;
  23094. /**
  23095. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23096. */
  23097. /**
  23098. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23099. */
  23100. positionIterations: number;
  23101. /**
  23102. * The unique id of the physics imposter
  23103. * set by the physics engine when adding this impostor to the array
  23104. */
  23105. uniqueId: number;
  23106. /**
  23107. * @hidden
  23108. */
  23109. soft: boolean;
  23110. /**
  23111. * @hidden
  23112. */
  23113. segments: number;
  23114. private _joints;
  23115. /**
  23116. * Initializes the physics imposter
  23117. * @param object The physics-enabled object used as the physics imposter
  23118. * @param type The type of the physics imposter
  23119. * @param _options The options for the physics imposter
  23120. * @param _scene The Babylon scene
  23121. */
  23122. constructor(
  23123. /**
  23124. * The physics-enabled object used as the physics imposter
  23125. */
  23126. object: IPhysicsEnabledObject,
  23127. /**
  23128. * The type of the physics imposter
  23129. */
  23130. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23131. /**
  23132. * This function will completly initialize this impostor.
  23133. * It will create a new body - but only if this mesh has no parent.
  23134. * If it has, this impostor will not be used other than to define the impostor
  23135. * of the child mesh.
  23136. * @hidden
  23137. */
  23138. _init(): void;
  23139. private _getPhysicsParent;
  23140. /**
  23141. * Should a new body be generated.
  23142. * @returns boolean specifying if body initialization is required
  23143. */
  23144. isBodyInitRequired(): boolean;
  23145. /**
  23146. * Sets the updated scaling
  23147. * @param updated Specifies if the scaling is updated
  23148. */
  23149. setScalingUpdated(): void;
  23150. /**
  23151. * Force a regeneration of this or the parent's impostor's body.
  23152. * Use under cautious - This will remove all joints already implemented.
  23153. */
  23154. forceUpdate(): void;
  23155. /**
  23156. * Gets the body that holds this impostor. Either its own, or its parent.
  23157. */
  23158. /**
  23159. * Set the physics body. Used mainly by the physics engine/plugin
  23160. */
  23161. physicsBody: any;
  23162. /**
  23163. * Get the parent of the physics imposter
  23164. * @returns Physics imposter or null
  23165. */
  23166. /**
  23167. * Sets the parent of the physics imposter
  23168. */
  23169. parent: Nullable<PhysicsImpostor>;
  23170. /**
  23171. * Resets the update flags
  23172. */
  23173. resetUpdateFlags(): void;
  23174. /**
  23175. * Gets the object extend size
  23176. * @returns the object extend size
  23177. */
  23178. getObjectExtendSize(): Vector3;
  23179. /**
  23180. * Gets the object center
  23181. * @returns The object center
  23182. */
  23183. getObjectCenter(): Vector3;
  23184. /**
  23185. * Get a specific parametes from the options parameter
  23186. * @param paramName The object parameter name
  23187. * @returns The object parameter
  23188. */
  23189. getParam(paramName: string): any;
  23190. /**
  23191. * Sets a specific parameter in the options given to the physics plugin
  23192. * @param paramName The parameter name
  23193. * @param value The value of the parameter
  23194. */
  23195. setParam(paramName: string, value: number): void;
  23196. /**
  23197. * Specifically change the body's mass option. Won't recreate the physics body object
  23198. * @param mass The mass of the physics imposter
  23199. */
  23200. setMass(mass: number): void;
  23201. /**
  23202. * Gets the linear velocity
  23203. * @returns linear velocity or null
  23204. */
  23205. getLinearVelocity(): Nullable<Vector3>;
  23206. /**
  23207. * Sets the linear velocity
  23208. * @param velocity linear velocity or null
  23209. */
  23210. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23211. /**
  23212. * Gets the angular velocity
  23213. * @returns angular velocity or null
  23214. */
  23215. getAngularVelocity(): Nullable<Vector3>;
  23216. /**
  23217. * Sets the angular velocity
  23218. * @param velocity The velocity or null
  23219. */
  23220. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23221. /**
  23222. * Execute a function with the physics plugin native code
  23223. * Provide a function the will have two variables - the world object and the physics body object
  23224. * @param func The function to execute with the physics plugin native code
  23225. */
  23226. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23227. /**
  23228. * Register a function that will be executed before the physics world is stepping forward
  23229. * @param func The function to execute before the physics world is stepped forward
  23230. */
  23231. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23232. /**
  23233. * Unregister a function that will be executed before the physics world is stepping forward
  23234. * @param func The function to execute before the physics world is stepped forward
  23235. */
  23236. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23237. /**
  23238. * Register a function that will be executed after the physics step
  23239. * @param func The function to execute after physics step
  23240. */
  23241. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23242. /**
  23243. * Unregisters a function that will be executed after the physics step
  23244. * @param func The function to execute after physics step
  23245. */
  23246. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23247. /**
  23248. * register a function that will be executed when this impostor collides against a different body
  23249. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23250. * @param func Callback that is executed on collision
  23251. */
  23252. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23253. /**
  23254. * Unregisters the physics imposter on contact
  23255. * @param collideAgainst The physics object to collide against
  23256. * @param func Callback to execute on collision
  23257. */
  23258. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23259. private _tmpQuat;
  23260. private _tmpQuat2;
  23261. /**
  23262. * Get the parent rotation
  23263. * @returns The parent rotation
  23264. */
  23265. getParentsRotation(): Quaternion;
  23266. /**
  23267. * this function is executed by the physics engine.
  23268. */
  23269. beforeStep: () => void;
  23270. /**
  23271. * this function is executed by the physics engine
  23272. */
  23273. afterStep: () => void;
  23274. /**
  23275. * Legacy collision detection event support
  23276. */
  23277. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23278. /**
  23279. * event and body object due to cannon's event-based architecture.
  23280. */
  23281. onCollide: (e: {
  23282. body: any;
  23283. }) => void;
  23284. /**
  23285. * Apply a force
  23286. * @param force The force to apply
  23287. * @param contactPoint The contact point for the force
  23288. * @returns The physics imposter
  23289. */
  23290. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23291. /**
  23292. * Apply an impulse
  23293. * @param force The impulse force
  23294. * @param contactPoint The contact point for the impulse force
  23295. * @returns The physics imposter
  23296. */
  23297. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23298. /**
  23299. * A help function to create a joint
  23300. * @param otherImpostor A physics imposter used to create a joint
  23301. * @param jointType The type of joint
  23302. * @param jointData The data for the joint
  23303. * @returns The physics imposter
  23304. */
  23305. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23306. /**
  23307. * Add a joint to this impostor with a different impostor
  23308. * @param otherImpostor A physics imposter used to add a joint
  23309. * @param joint The joint to add
  23310. * @returns The physics imposter
  23311. */
  23312. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23313. /**
  23314. * Add an anchor to a cloth impostor
  23315. * @param otherImpostor rigid impostor to anchor to
  23316. * @param width ratio across width from 0 to 1
  23317. * @param height ratio up height from 0 to 1
  23318. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23319. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23320. * @returns impostor the soft imposter
  23321. */
  23322. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23323. /**
  23324. * Add a hook to a rope impostor
  23325. * @param otherImpostor rigid impostor to anchor to
  23326. * @param length ratio across rope from 0 to 1
  23327. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23328. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23329. * @returns impostor the rope imposter
  23330. */
  23331. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23332. /**
  23333. * Will keep this body still, in a sleep mode.
  23334. * @returns the physics imposter
  23335. */
  23336. sleep(): PhysicsImpostor;
  23337. /**
  23338. * Wake the body up.
  23339. * @returns The physics imposter
  23340. */
  23341. wakeUp(): PhysicsImpostor;
  23342. /**
  23343. * Clones the physics imposter
  23344. * @param newObject The physics imposter clones to this physics-enabled object
  23345. * @returns A nullable physics imposter
  23346. */
  23347. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23348. /**
  23349. * Disposes the physics imposter
  23350. */
  23351. dispose(): void;
  23352. /**
  23353. * Sets the delta position
  23354. * @param position The delta position amount
  23355. */
  23356. setDeltaPosition(position: Vector3): void;
  23357. /**
  23358. * Sets the delta rotation
  23359. * @param rotation The delta rotation amount
  23360. */
  23361. setDeltaRotation(rotation: Quaternion): void;
  23362. /**
  23363. * Gets the box size of the physics imposter and stores the result in the input parameter
  23364. * @param result Stores the box size
  23365. * @returns The physics imposter
  23366. */
  23367. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23368. /**
  23369. * Gets the radius of the physics imposter
  23370. * @returns Radius of the physics imposter
  23371. */
  23372. getRadius(): number;
  23373. /**
  23374. * Sync a bone with this impostor
  23375. * @param bone The bone to sync to the impostor.
  23376. * @param boneMesh The mesh that the bone is influencing.
  23377. * @param jointPivot The pivot of the joint / bone in local space.
  23378. * @param distToJoint Optional distance from the impostor to the joint.
  23379. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23380. */
  23381. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23382. /**
  23383. * Sync impostor to a bone
  23384. * @param bone The bone that the impostor will be synced to.
  23385. * @param boneMesh The mesh that the bone is influencing.
  23386. * @param jointPivot The pivot of the joint / bone in local space.
  23387. * @param distToJoint Optional distance from the impostor to the joint.
  23388. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23389. * @param boneAxis Optional vector3 axis the bone is aligned with
  23390. */
  23391. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23392. /**
  23393. * No-Imposter type
  23394. */
  23395. static NoImpostor: number;
  23396. /**
  23397. * Sphere-Imposter type
  23398. */
  23399. static SphereImpostor: number;
  23400. /**
  23401. * Box-Imposter type
  23402. */
  23403. static BoxImpostor: number;
  23404. /**
  23405. * Plane-Imposter type
  23406. */
  23407. static PlaneImpostor: number;
  23408. /**
  23409. * Mesh-imposter type
  23410. */
  23411. static MeshImpostor: number;
  23412. /**
  23413. * Capsule-Impostor type (Ammo.js plugin only)
  23414. */
  23415. static CapsuleImpostor: number;
  23416. /**
  23417. * Cylinder-Imposter type
  23418. */
  23419. static CylinderImpostor: number;
  23420. /**
  23421. * Particle-Imposter type
  23422. */
  23423. static ParticleImpostor: number;
  23424. /**
  23425. * Heightmap-Imposter type
  23426. */
  23427. static HeightmapImpostor: number;
  23428. /**
  23429. * ConvexHull-Impostor type (Ammo.js plugin only)
  23430. */
  23431. static ConvexHullImpostor: number;
  23432. /**
  23433. * Rope-Imposter type
  23434. */
  23435. static RopeImpostor: number;
  23436. /**
  23437. * Cloth-Imposter type
  23438. */
  23439. static ClothImpostor: number;
  23440. /**
  23441. * Softbody-Imposter type
  23442. */
  23443. static SoftbodyImpostor: number;
  23444. }
  23445. }
  23446. declare module BABYLON {
  23447. /**
  23448. * @hidden
  23449. **/
  23450. export class _CreationDataStorage {
  23451. closePath?: boolean;
  23452. closeArray?: boolean;
  23453. idx: number[];
  23454. dashSize: number;
  23455. gapSize: number;
  23456. path3D: Path3D;
  23457. pathArray: Vector3[][];
  23458. arc: number;
  23459. radius: number;
  23460. cap: number;
  23461. tessellation: number;
  23462. }
  23463. /**
  23464. * @hidden
  23465. **/
  23466. class _InstanceDataStorage {
  23467. visibleInstances: any;
  23468. batchCache: _InstancesBatch;
  23469. instancesBufferSize: number;
  23470. instancesBuffer: Nullable<Buffer>;
  23471. instancesData: Float32Array;
  23472. overridenInstanceCount: number;
  23473. isFrozen: boolean;
  23474. previousBatch: Nullable<_InstancesBatch>;
  23475. hardwareInstancedRendering: boolean;
  23476. sideOrientation: number;
  23477. }
  23478. /**
  23479. * @hidden
  23480. **/
  23481. export class _InstancesBatch {
  23482. mustReturn: boolean;
  23483. visibleInstances: Nullable<InstancedMesh[]>[];
  23484. renderSelf: boolean[];
  23485. hardwareInstancedRendering: boolean[];
  23486. }
  23487. /**
  23488. * Class used to represent renderable models
  23489. */
  23490. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23491. /**
  23492. * Mesh side orientation : usually the external or front surface
  23493. */
  23494. static readonly FRONTSIDE: number;
  23495. /**
  23496. * Mesh side orientation : usually the internal or back surface
  23497. */
  23498. static readonly BACKSIDE: number;
  23499. /**
  23500. * Mesh side orientation : both internal and external or front and back surfaces
  23501. */
  23502. static readonly DOUBLESIDE: number;
  23503. /**
  23504. * Mesh side orientation : by default, `FRONTSIDE`
  23505. */
  23506. static readonly DEFAULTSIDE: number;
  23507. /**
  23508. * Mesh cap setting : no cap
  23509. */
  23510. static readonly NO_CAP: number;
  23511. /**
  23512. * Mesh cap setting : one cap at the beginning of the mesh
  23513. */
  23514. static readonly CAP_START: number;
  23515. /**
  23516. * Mesh cap setting : one cap at the end of the mesh
  23517. */
  23518. static readonly CAP_END: number;
  23519. /**
  23520. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23521. */
  23522. static readonly CAP_ALL: number;
  23523. /**
  23524. * Mesh pattern setting : no flip or rotate
  23525. */
  23526. static readonly NO_FLIP: number;
  23527. /**
  23528. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23529. */
  23530. static readonly FLIP_TILE: number;
  23531. /**
  23532. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23533. */
  23534. static readonly ROTATE_TILE: number;
  23535. /**
  23536. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23537. */
  23538. static readonly FLIP_ROW: number;
  23539. /**
  23540. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23541. */
  23542. static readonly ROTATE_ROW: number;
  23543. /**
  23544. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23545. */
  23546. static readonly FLIP_N_ROTATE_TILE: number;
  23547. /**
  23548. * Mesh pattern setting : rotate pattern and rotate
  23549. */
  23550. static readonly FLIP_N_ROTATE_ROW: number;
  23551. /**
  23552. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23553. */
  23554. static readonly CENTER: number;
  23555. /**
  23556. * Mesh tile positioning : part tiles on left
  23557. */
  23558. static readonly LEFT: number;
  23559. /**
  23560. * Mesh tile positioning : part tiles on right
  23561. */
  23562. static readonly RIGHT: number;
  23563. /**
  23564. * Mesh tile positioning : part tiles on top
  23565. */
  23566. static readonly TOP: number;
  23567. /**
  23568. * Mesh tile positioning : part tiles on bottom
  23569. */
  23570. static readonly BOTTOM: number;
  23571. /**
  23572. * Gets the default side orientation.
  23573. * @param orientation the orientation to value to attempt to get
  23574. * @returns the default orientation
  23575. * @hidden
  23576. */
  23577. static _GetDefaultSideOrientation(orientation?: number): number;
  23578. private _internalMeshDataInfo;
  23579. /**
  23580. * An event triggered before rendering the mesh
  23581. */
  23582. readonly onBeforeRenderObservable: Observable<Mesh>;
  23583. /**
  23584. * An event triggered before binding the mesh
  23585. */
  23586. readonly onBeforeBindObservable: Observable<Mesh>;
  23587. /**
  23588. * An event triggered after rendering the mesh
  23589. */
  23590. readonly onAfterRenderObservable: Observable<Mesh>;
  23591. /**
  23592. * An event triggered before drawing the mesh
  23593. */
  23594. readonly onBeforeDrawObservable: Observable<Mesh>;
  23595. private _onBeforeDrawObserver;
  23596. /**
  23597. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23598. */
  23599. onBeforeDraw: () => void;
  23600. readonly hasInstances: boolean;
  23601. /**
  23602. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23603. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23604. */
  23605. delayLoadState: number;
  23606. /**
  23607. * Gets the list of instances created from this mesh
  23608. * it is not supposed to be modified manually.
  23609. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23610. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23611. */
  23612. instances: InstancedMesh[];
  23613. /**
  23614. * Gets the file containing delay loading data for this mesh
  23615. */
  23616. delayLoadingFile: string;
  23617. /** @hidden */
  23618. _binaryInfo: any;
  23619. /**
  23620. * User defined function used to change how LOD level selection is done
  23621. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23622. */
  23623. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23624. /**
  23625. * Gets or sets the morph target manager
  23626. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23627. */
  23628. morphTargetManager: Nullable<MorphTargetManager>;
  23629. /** @hidden */
  23630. _creationDataStorage: Nullable<_CreationDataStorage>;
  23631. /** @hidden */
  23632. _geometry: Nullable<Geometry>;
  23633. /** @hidden */
  23634. _delayInfo: Array<string>;
  23635. /** @hidden */
  23636. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23637. /** @hidden */
  23638. _instanceDataStorage: _InstanceDataStorage;
  23639. private _effectiveMaterial;
  23640. /** @hidden */
  23641. _shouldGenerateFlatShading: boolean;
  23642. /** @hidden */
  23643. _originalBuilderSideOrientation: number;
  23644. /**
  23645. * Use this property to change the original side orientation defined at construction time
  23646. */
  23647. overrideMaterialSideOrientation: Nullable<number>;
  23648. /**
  23649. * Gets the source mesh (the one used to clone this one from)
  23650. */
  23651. readonly source: Nullable<Mesh>;
  23652. /**
  23653. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23654. */
  23655. isUnIndexed: boolean;
  23656. /**
  23657. * @constructor
  23658. * @param name The value used by scene.getMeshByName() to do a lookup.
  23659. * @param scene The scene to add this mesh to.
  23660. * @param parent The parent of this mesh, if it has one
  23661. * @param source An optional Mesh from which geometry is shared, cloned.
  23662. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23663. * When false, achieved by calling a clone(), also passing False.
  23664. * This will make creation of children, recursive.
  23665. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23666. */
  23667. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23668. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23669. /**
  23670. * Gets the class name
  23671. * @returns the string "Mesh".
  23672. */
  23673. getClassName(): string;
  23674. /** @hidden */
  23675. readonly _isMesh: boolean;
  23676. /**
  23677. * Returns a description of this mesh
  23678. * @param fullDetails define if full details about this mesh must be used
  23679. * @returns a descriptive string representing this mesh
  23680. */
  23681. toString(fullDetails?: boolean): string;
  23682. /** @hidden */
  23683. _unBindEffect(): void;
  23684. /**
  23685. * Gets a boolean indicating if this mesh has LOD
  23686. */
  23687. readonly hasLODLevels: boolean;
  23688. /**
  23689. * Gets the list of MeshLODLevel associated with the current mesh
  23690. * @returns an array of MeshLODLevel
  23691. */
  23692. getLODLevels(): MeshLODLevel[];
  23693. private _sortLODLevels;
  23694. /**
  23695. * Add a mesh as LOD level triggered at the given distance.
  23696. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23697. * @param distance The distance from the center of the object to show this level
  23698. * @param mesh The mesh to be added as LOD level (can be null)
  23699. * @return This mesh (for chaining)
  23700. */
  23701. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23702. /**
  23703. * Returns the LOD level mesh at the passed distance or null if not found.
  23704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23705. * @param distance The distance from the center of the object to show this level
  23706. * @returns a Mesh or `null`
  23707. */
  23708. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23709. /**
  23710. * Remove a mesh from the LOD array
  23711. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23712. * @param mesh defines the mesh to be removed
  23713. * @return This mesh (for chaining)
  23714. */
  23715. removeLODLevel(mesh: Mesh): Mesh;
  23716. /**
  23717. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23719. * @param camera defines the camera to use to compute distance
  23720. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23721. * @return This mesh (for chaining)
  23722. */
  23723. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23724. /**
  23725. * Gets the mesh internal Geometry object
  23726. */
  23727. readonly geometry: Nullable<Geometry>;
  23728. /**
  23729. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23730. * @returns the total number of vertices
  23731. */
  23732. getTotalVertices(): number;
  23733. /**
  23734. * Returns the content of an associated vertex buffer
  23735. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23736. * - VertexBuffer.PositionKind
  23737. * - VertexBuffer.UVKind
  23738. * - VertexBuffer.UV2Kind
  23739. * - VertexBuffer.UV3Kind
  23740. * - VertexBuffer.UV4Kind
  23741. * - VertexBuffer.UV5Kind
  23742. * - VertexBuffer.UV6Kind
  23743. * - VertexBuffer.ColorKind
  23744. * - VertexBuffer.MatricesIndicesKind
  23745. * - VertexBuffer.MatricesIndicesExtraKind
  23746. * - VertexBuffer.MatricesWeightsKind
  23747. * - VertexBuffer.MatricesWeightsExtraKind
  23748. * @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
  23749. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23750. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23751. */
  23752. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23753. /**
  23754. * Returns the mesh VertexBuffer object from the requested `kind`
  23755. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23756. * - VertexBuffer.PositionKind
  23757. * - VertexBuffer.NormalKind
  23758. * - VertexBuffer.UVKind
  23759. * - VertexBuffer.UV2Kind
  23760. * - VertexBuffer.UV3Kind
  23761. * - VertexBuffer.UV4Kind
  23762. * - VertexBuffer.UV5Kind
  23763. * - VertexBuffer.UV6Kind
  23764. * - VertexBuffer.ColorKind
  23765. * - VertexBuffer.MatricesIndicesKind
  23766. * - VertexBuffer.MatricesIndicesExtraKind
  23767. * - VertexBuffer.MatricesWeightsKind
  23768. * - VertexBuffer.MatricesWeightsExtraKind
  23769. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23770. */
  23771. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23772. /**
  23773. * Tests if a specific vertex buffer is associated with this mesh
  23774. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23775. * - VertexBuffer.PositionKind
  23776. * - VertexBuffer.NormalKind
  23777. * - VertexBuffer.UVKind
  23778. * - VertexBuffer.UV2Kind
  23779. * - VertexBuffer.UV3Kind
  23780. * - VertexBuffer.UV4Kind
  23781. * - VertexBuffer.UV5Kind
  23782. * - VertexBuffer.UV6Kind
  23783. * - VertexBuffer.ColorKind
  23784. * - VertexBuffer.MatricesIndicesKind
  23785. * - VertexBuffer.MatricesIndicesExtraKind
  23786. * - VertexBuffer.MatricesWeightsKind
  23787. * - VertexBuffer.MatricesWeightsExtraKind
  23788. * @returns a boolean
  23789. */
  23790. isVerticesDataPresent(kind: string): boolean;
  23791. /**
  23792. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23793. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23794. * - VertexBuffer.PositionKind
  23795. * - VertexBuffer.UVKind
  23796. * - VertexBuffer.UV2Kind
  23797. * - VertexBuffer.UV3Kind
  23798. * - VertexBuffer.UV4Kind
  23799. * - VertexBuffer.UV5Kind
  23800. * - VertexBuffer.UV6Kind
  23801. * - VertexBuffer.ColorKind
  23802. * - VertexBuffer.MatricesIndicesKind
  23803. * - VertexBuffer.MatricesIndicesExtraKind
  23804. * - VertexBuffer.MatricesWeightsKind
  23805. * - VertexBuffer.MatricesWeightsExtraKind
  23806. * @returns a boolean
  23807. */
  23808. isVertexBufferUpdatable(kind: string): boolean;
  23809. /**
  23810. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23811. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23812. * - VertexBuffer.PositionKind
  23813. * - VertexBuffer.NormalKind
  23814. * - VertexBuffer.UVKind
  23815. * - VertexBuffer.UV2Kind
  23816. * - VertexBuffer.UV3Kind
  23817. * - VertexBuffer.UV4Kind
  23818. * - VertexBuffer.UV5Kind
  23819. * - VertexBuffer.UV6Kind
  23820. * - VertexBuffer.ColorKind
  23821. * - VertexBuffer.MatricesIndicesKind
  23822. * - VertexBuffer.MatricesIndicesExtraKind
  23823. * - VertexBuffer.MatricesWeightsKind
  23824. * - VertexBuffer.MatricesWeightsExtraKind
  23825. * @returns an array of strings
  23826. */
  23827. getVerticesDataKinds(): string[];
  23828. /**
  23829. * Returns a positive integer : the total number of indices in this mesh geometry.
  23830. * @returns the numner of indices or zero if the mesh has no geometry.
  23831. */
  23832. getTotalIndices(): number;
  23833. /**
  23834. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23835. * @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.
  23836. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23837. * @returns the indices array or an empty array if the mesh has no geometry
  23838. */
  23839. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23840. readonly isBlocked: boolean;
  23841. /**
  23842. * Determine if the current mesh is ready to be rendered
  23843. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23844. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23845. * @returns true if all associated assets are ready (material, textures, shaders)
  23846. */
  23847. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23848. /**
  23849. * 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.
  23850. */
  23851. readonly areNormalsFrozen: boolean;
  23852. /**
  23853. * 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.
  23854. * @returns the current mesh
  23855. */
  23856. freezeNormals(): Mesh;
  23857. /**
  23858. * 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
  23859. * @returns the current mesh
  23860. */
  23861. unfreezeNormals(): Mesh;
  23862. /**
  23863. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23864. */
  23865. overridenInstanceCount: number;
  23866. /** @hidden */
  23867. _preActivate(): Mesh;
  23868. /** @hidden */
  23869. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23870. /** @hidden */
  23871. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23872. /**
  23873. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23874. * This means the mesh underlying bounding box and sphere are recomputed.
  23875. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23876. * @returns the current mesh
  23877. */
  23878. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23879. /** @hidden */
  23880. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23881. /**
  23882. * This function will subdivide the mesh into multiple submeshes
  23883. * @param count defines the expected number of submeshes
  23884. */
  23885. subdivide(count: number): void;
  23886. /**
  23887. * Copy a FloatArray into a specific associated vertex buffer
  23888. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23889. * - VertexBuffer.PositionKind
  23890. * - VertexBuffer.UVKind
  23891. * - VertexBuffer.UV2Kind
  23892. * - VertexBuffer.UV3Kind
  23893. * - VertexBuffer.UV4Kind
  23894. * - VertexBuffer.UV5Kind
  23895. * - VertexBuffer.UV6Kind
  23896. * - VertexBuffer.ColorKind
  23897. * - VertexBuffer.MatricesIndicesKind
  23898. * - VertexBuffer.MatricesIndicesExtraKind
  23899. * - VertexBuffer.MatricesWeightsKind
  23900. * - VertexBuffer.MatricesWeightsExtraKind
  23901. * @param data defines the data source
  23902. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23903. * @param stride defines the data stride size (can be null)
  23904. * @returns the current mesh
  23905. */
  23906. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23907. /**
  23908. * Delete a vertex buffer associated with this mesh
  23909. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23910. * - VertexBuffer.PositionKind
  23911. * - VertexBuffer.UVKind
  23912. * - VertexBuffer.UV2Kind
  23913. * - VertexBuffer.UV3Kind
  23914. * - VertexBuffer.UV4Kind
  23915. * - VertexBuffer.UV5Kind
  23916. * - VertexBuffer.UV6Kind
  23917. * - VertexBuffer.ColorKind
  23918. * - VertexBuffer.MatricesIndicesKind
  23919. * - VertexBuffer.MatricesIndicesExtraKind
  23920. * - VertexBuffer.MatricesWeightsKind
  23921. * - VertexBuffer.MatricesWeightsExtraKind
  23922. */
  23923. removeVerticesData(kind: string): void;
  23924. /**
  23925. * Flags an associated vertex buffer as updatable
  23926. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23927. * - VertexBuffer.PositionKind
  23928. * - VertexBuffer.UVKind
  23929. * - VertexBuffer.UV2Kind
  23930. * - VertexBuffer.UV3Kind
  23931. * - VertexBuffer.UV4Kind
  23932. * - VertexBuffer.UV5Kind
  23933. * - VertexBuffer.UV6Kind
  23934. * - VertexBuffer.ColorKind
  23935. * - VertexBuffer.MatricesIndicesKind
  23936. * - VertexBuffer.MatricesIndicesExtraKind
  23937. * - VertexBuffer.MatricesWeightsKind
  23938. * - VertexBuffer.MatricesWeightsExtraKind
  23939. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23940. */
  23941. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23942. /**
  23943. * Sets the mesh global Vertex Buffer
  23944. * @param buffer defines the buffer to use
  23945. * @returns the current mesh
  23946. */
  23947. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23948. /**
  23949. * Update a specific associated vertex buffer
  23950. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23951. * - VertexBuffer.PositionKind
  23952. * - VertexBuffer.UVKind
  23953. * - VertexBuffer.UV2Kind
  23954. * - VertexBuffer.UV3Kind
  23955. * - VertexBuffer.UV4Kind
  23956. * - VertexBuffer.UV5Kind
  23957. * - VertexBuffer.UV6Kind
  23958. * - VertexBuffer.ColorKind
  23959. * - VertexBuffer.MatricesIndicesKind
  23960. * - VertexBuffer.MatricesIndicesExtraKind
  23961. * - VertexBuffer.MatricesWeightsKind
  23962. * - VertexBuffer.MatricesWeightsExtraKind
  23963. * @param data defines the data source
  23964. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23965. * @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)
  23966. * @returns the current mesh
  23967. */
  23968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23969. /**
  23970. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23971. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23972. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23973. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23974. * @returns the current mesh
  23975. */
  23976. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23977. /**
  23978. * Creates a un-shared specific occurence of the geometry for the mesh.
  23979. * @returns the current mesh
  23980. */
  23981. makeGeometryUnique(): Mesh;
  23982. /**
  23983. * Set the index buffer of this mesh
  23984. * @param indices defines the source data
  23985. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23986. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23987. * @returns the current mesh
  23988. */
  23989. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23990. /**
  23991. * Update the current index buffer
  23992. * @param indices defines the source data
  23993. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23994. * @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)
  23995. * @returns the current mesh
  23996. */
  23997. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23998. /**
  23999. * Invert the geometry to move from a right handed system to a left handed one.
  24000. * @returns the current mesh
  24001. */
  24002. toLeftHanded(): Mesh;
  24003. /** @hidden */
  24004. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24005. /** @hidden */
  24006. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24007. /**
  24008. * Registers for this mesh a javascript function called just before the rendering process
  24009. * @param func defines the function to call before rendering this mesh
  24010. * @returns the current mesh
  24011. */
  24012. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24013. /**
  24014. * Disposes a previously registered javascript function called before the rendering
  24015. * @param func defines the function to remove
  24016. * @returns the current mesh
  24017. */
  24018. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24019. /**
  24020. * Registers for this mesh a javascript function called just after the rendering is complete
  24021. * @param func defines the function to call after rendering this mesh
  24022. * @returns the current mesh
  24023. */
  24024. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24025. /**
  24026. * Disposes a previously registered javascript function called after the rendering.
  24027. * @param func defines the function to remove
  24028. * @returns the current mesh
  24029. */
  24030. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24031. /** @hidden */
  24032. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24033. /** @hidden */
  24034. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24035. /** @hidden */
  24036. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24037. /** @hidden */
  24038. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24039. /** @hidden */
  24040. _rebuild(): void;
  24041. /** @hidden */
  24042. _freeze(): void;
  24043. /** @hidden */
  24044. _unFreeze(): void;
  24045. /**
  24046. * 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
  24047. * @param subMesh defines the subMesh to render
  24048. * @param enableAlphaMode defines if alpha mode can be changed
  24049. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24050. * @returns the current mesh
  24051. */
  24052. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24053. private _onBeforeDraw;
  24054. /**
  24055. * Renormalize the mesh and patch it up if there are no weights
  24056. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24057. * However in the case of zero weights then we set just a single influence to 1.
  24058. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24059. */
  24060. cleanMatrixWeights(): void;
  24061. private normalizeSkinFourWeights;
  24062. private normalizeSkinWeightsAndExtra;
  24063. /**
  24064. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24065. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24066. * the user know there was an issue with importing the mesh
  24067. * @returns a validation object with skinned, valid and report string
  24068. */
  24069. validateSkinning(): {
  24070. skinned: boolean;
  24071. valid: boolean;
  24072. report: string;
  24073. };
  24074. /** @hidden */
  24075. _checkDelayState(): Mesh;
  24076. private _queueLoad;
  24077. /**
  24078. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24079. * A mesh is in the frustum if its bounding box intersects the frustum
  24080. * @param frustumPlanes defines the frustum to test
  24081. * @returns true if the mesh is in the frustum planes
  24082. */
  24083. isInFrustum(frustumPlanes: Plane[]): boolean;
  24084. /**
  24085. * Sets the mesh material by the material or multiMaterial `id` property
  24086. * @param id is a string identifying the material or the multiMaterial
  24087. * @returns the current mesh
  24088. */
  24089. setMaterialByID(id: string): Mesh;
  24090. /**
  24091. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24092. * @returns an array of IAnimatable
  24093. */
  24094. getAnimatables(): IAnimatable[];
  24095. /**
  24096. * Modifies the mesh geometry according to the passed transformation matrix.
  24097. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24098. * The mesh normals are modified using the same transformation.
  24099. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24100. * @param transform defines the transform matrix to use
  24101. * @see http://doc.babylonjs.com/resources/baking_transformations
  24102. * @returns the current mesh
  24103. */
  24104. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24105. /**
  24106. * Modifies the mesh geometry according to its own current World Matrix.
  24107. * The mesh World Matrix is then reset.
  24108. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24109. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24110. * @see http://doc.babylonjs.com/resources/baking_transformations
  24111. * @returns the current mesh
  24112. */
  24113. bakeCurrentTransformIntoVertices(): Mesh;
  24114. /** @hidden */
  24115. readonly _positions: Nullable<Vector3[]>;
  24116. /** @hidden */
  24117. _resetPointsArrayCache(): Mesh;
  24118. /** @hidden */
  24119. _generatePointsArray(): boolean;
  24120. /**
  24121. * Returns a new Mesh object generated from the current mesh properties.
  24122. * This method must not get confused with createInstance()
  24123. * @param name is a string, the name given to the new mesh
  24124. * @param newParent can be any Node object (default `null`)
  24125. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24126. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24127. * @returns a new mesh
  24128. */
  24129. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24130. /**
  24131. * Releases resources associated with this mesh.
  24132. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24133. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24134. */
  24135. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24136. /** @hidden */
  24137. _disposeInstanceSpecificData(): void;
  24138. /**
  24139. * Modifies the mesh geometry according to a displacement map.
  24140. * 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.
  24141. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24142. * @param url is a string, the URL from the image file is to be downloaded.
  24143. * @param minHeight is the lower limit of the displacement.
  24144. * @param maxHeight is the upper limit of the displacement.
  24145. * @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.
  24146. * @param uvOffset is an optional vector2 used to offset UV.
  24147. * @param uvScale is an optional vector2 used to scale UV.
  24148. * @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.
  24149. * @returns the Mesh.
  24150. */
  24151. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24152. /**
  24153. * Modifies the mesh geometry according to a displacementMap buffer.
  24154. * 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.
  24155. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24156. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24157. * @param heightMapWidth is the width of the buffer image.
  24158. * @param heightMapHeight is the height of the buffer image.
  24159. * @param minHeight is the lower limit of the displacement.
  24160. * @param maxHeight is the upper limit of the displacement.
  24161. * @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.
  24162. * @param uvOffset is an optional vector2 used to offset UV.
  24163. * @param uvScale is an optional vector2 used to scale UV.
  24164. * @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.
  24165. * @returns the Mesh.
  24166. */
  24167. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24168. /**
  24169. * Modify the mesh to get a flat shading rendering.
  24170. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24171. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24172. * @returns current mesh
  24173. */
  24174. convertToFlatShadedMesh(): Mesh;
  24175. /**
  24176. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24177. * In other words, more vertices, no more indices and a single bigger VBO.
  24178. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24179. * @returns current mesh
  24180. */
  24181. convertToUnIndexedMesh(): Mesh;
  24182. /**
  24183. * Inverses facet orientations.
  24184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24185. * @param flipNormals will also inverts the normals
  24186. * @returns current mesh
  24187. */
  24188. flipFaces(flipNormals?: boolean): Mesh;
  24189. /**
  24190. * Increase the number of facets and hence vertices in a mesh
  24191. * Vertex normals are interpolated from existing vertex normals
  24192. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24193. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24194. */
  24195. increaseVertices(numberPerEdge: number): void;
  24196. /**
  24197. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24198. * This will undo any application of covertToFlatShadedMesh
  24199. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24200. */
  24201. forceSharedVertices(): void;
  24202. /** @hidden */
  24203. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24204. /** @hidden */
  24205. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24206. /**
  24207. * Creates a new InstancedMesh object from the mesh model.
  24208. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24209. * @param name defines the name of the new instance
  24210. * @returns a new InstancedMesh
  24211. */
  24212. createInstance(name: string): InstancedMesh;
  24213. /**
  24214. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24215. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24216. * @returns the current mesh
  24217. */
  24218. synchronizeInstances(): Mesh;
  24219. /**
  24220. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24221. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24222. * This should be used together with the simplification to avoid disappearing triangles.
  24223. * @param successCallback an optional success callback to be called after the optimization finished.
  24224. * @returns the current mesh
  24225. */
  24226. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24227. /**
  24228. * Serialize current mesh
  24229. * @param serializationObject defines the object which will receive the serialization data
  24230. */
  24231. serialize(serializationObject: any): void;
  24232. /** @hidden */
  24233. _syncGeometryWithMorphTargetManager(): void;
  24234. /** @hidden */
  24235. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24236. /**
  24237. * Returns a new Mesh object parsed from the source provided.
  24238. * @param parsedMesh is the source
  24239. * @param scene defines the hosting scene
  24240. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24241. * @returns a new Mesh
  24242. */
  24243. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24244. /**
  24245. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24246. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24247. * @param name defines the name of the mesh to create
  24248. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24249. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24250. * @param closePath creates a seam between the first and the last points of each path of the path array
  24251. * @param offset is taken in account only if the `pathArray` is containing a single path
  24252. * @param scene defines the hosting scene
  24253. * @param updatable defines if the mesh must be flagged as updatable
  24254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24255. * @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)
  24256. * @returns a new Mesh
  24257. */
  24258. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24259. /**
  24260. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24261. * @param name defines the name of the mesh to create
  24262. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24263. * @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
  24264. * @param scene defines the hosting scene
  24265. * @param updatable defines if the mesh must be flagged as updatable
  24266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24267. * @returns a new Mesh
  24268. */
  24269. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24270. /**
  24271. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24272. * @param name defines the name of the mesh to create
  24273. * @param size sets the size (float) of each box side (default 1)
  24274. * @param scene defines the hosting scene
  24275. * @param updatable defines if the mesh must be flagged as updatable
  24276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24277. * @returns a new Mesh
  24278. */
  24279. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24280. /**
  24281. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24282. * @param name defines the name of the mesh to create
  24283. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24284. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24285. * @param scene defines the hosting scene
  24286. * @param updatable defines if the mesh must be flagged as updatable
  24287. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24288. * @returns a new Mesh
  24289. */
  24290. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24291. /**
  24292. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24293. * @param name defines the name of the mesh to create
  24294. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24295. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24296. * @param scene defines the hosting scene
  24297. * @returns a new Mesh
  24298. */
  24299. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24300. /**
  24301. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24302. * @param name defines the name of the mesh to create
  24303. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24304. * @param diameterTop set the top cap diameter (floats, default 1)
  24305. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24306. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24307. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24308. * @param scene defines the hosting scene
  24309. * @param updatable defines if the mesh must be flagged as updatable
  24310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24311. * @returns a new Mesh
  24312. */
  24313. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24314. /**
  24315. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24316. * @param name defines the name of the mesh to create
  24317. * @param diameter sets the diameter size (float) of the torus (default 1)
  24318. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24319. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24320. * @param scene defines the hosting scene
  24321. * @param updatable defines if the mesh must be flagged as updatable
  24322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24323. * @returns a new Mesh
  24324. */
  24325. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24326. /**
  24327. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24328. * @param name defines the name of the mesh to create
  24329. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24330. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24331. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24332. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24333. * @param p the number of windings on X axis (positive integers, default 2)
  24334. * @param q the number of windings on Y axis (positive integers, default 3)
  24335. * @param scene defines the hosting scene
  24336. * @param updatable defines if the mesh must be flagged as updatable
  24337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24338. * @returns a new Mesh
  24339. */
  24340. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24341. /**
  24342. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24343. * @param name defines the name of the mesh to create
  24344. * @param points is an array successive Vector3
  24345. * @param scene defines the hosting scene
  24346. * @param updatable defines if the mesh must be flagged as updatable
  24347. * @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).
  24348. * @returns a new Mesh
  24349. */
  24350. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24351. /**
  24352. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24353. * @param name defines the name of the mesh to create
  24354. * @param points is an array successive Vector3
  24355. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24356. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24357. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24358. * @param scene defines the hosting scene
  24359. * @param updatable defines if the mesh must be flagged as updatable
  24360. * @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)
  24361. * @returns a new Mesh
  24362. */
  24363. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24364. /**
  24365. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24366. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24367. * 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.
  24368. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24370. * Remember you can only change the shape positions, not their number when updating a polygon.
  24371. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24372. * @param name defines the name of the mesh to create
  24373. * @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
  24374. * @param scene defines the hosting scene
  24375. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24376. * @param updatable defines if the mesh must be flagged as updatable
  24377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24378. * @param earcutInjection can be used to inject your own earcut reference
  24379. * @returns a new Mesh
  24380. */
  24381. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24382. /**
  24383. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24384. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24385. * @param name defines the name of the mesh to create
  24386. * @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
  24387. * @param depth defines the height of extrusion
  24388. * @param scene defines the hosting scene
  24389. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24390. * @param updatable defines if the mesh must be flagged as updatable
  24391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24392. * @param earcutInjection can be used to inject your own earcut reference
  24393. * @returns a new Mesh
  24394. */
  24395. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24396. /**
  24397. * Creates an extruded shape mesh.
  24398. * 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
  24399. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24400. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24401. * @param name defines the name of the mesh to create
  24402. * @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
  24403. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24404. * @param scale is the value to scale the shape
  24405. * @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
  24406. * @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
  24407. * @param scene defines the hosting scene
  24408. * @param updatable defines if the mesh must be flagged as updatable
  24409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24410. * @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)
  24411. * @returns a new Mesh
  24412. */
  24413. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24414. /**
  24415. * Creates an custom extruded shape mesh.
  24416. * The custom extrusion is a parametric shape.
  24417. * It has no predefined shape. Its final shape will depend on the input parameters.
  24418. * Please consider using the same method from the MeshBuilder class instead
  24419. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24420. * @param name defines the name of the mesh to create
  24421. * @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
  24422. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24423. * @param scaleFunction is a custom Javascript function called on each path point
  24424. * @param rotationFunction is a custom Javascript function called on each path point
  24425. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24426. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24427. * @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
  24428. * @param scene defines the hosting scene
  24429. * @param updatable defines if the mesh must be flagged as updatable
  24430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24431. * @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)
  24432. * @returns a new Mesh
  24433. */
  24434. 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;
  24435. /**
  24436. * Creates lathe mesh.
  24437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24438. * Please consider using the same method from the MeshBuilder class instead
  24439. * @param name defines the name of the mesh to create
  24440. * @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
  24441. * @param radius is the radius value of the lathe
  24442. * @param tessellation is the side number of the lathe.
  24443. * @param scene defines the hosting scene
  24444. * @param updatable defines if the mesh must be flagged as updatable
  24445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24446. * @returns a new Mesh
  24447. */
  24448. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24449. /**
  24450. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24451. * @param name defines the name of the mesh to create
  24452. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24453. * @param scene defines the hosting scene
  24454. * @param updatable defines if the mesh must be flagged as updatable
  24455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24456. * @returns a new Mesh
  24457. */
  24458. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24459. /**
  24460. * Creates a ground mesh.
  24461. * Please consider using the same method from the MeshBuilder class instead
  24462. * @param name defines the name of the mesh to create
  24463. * @param width set the width of the ground
  24464. * @param height set the height of the ground
  24465. * @param subdivisions sets the number of subdivisions per side
  24466. * @param scene defines the hosting scene
  24467. * @param updatable defines if the mesh must be flagged as updatable
  24468. * @returns a new Mesh
  24469. */
  24470. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24471. /**
  24472. * Creates a tiled ground mesh.
  24473. * Please consider using the same method from the MeshBuilder class instead
  24474. * @param name defines the name of the mesh to create
  24475. * @param xmin set the ground minimum X coordinate
  24476. * @param zmin set the ground minimum Y coordinate
  24477. * @param xmax set the ground maximum X coordinate
  24478. * @param zmax set the ground maximum Z coordinate
  24479. * @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
  24480. * @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
  24481. * @param scene defines the hosting scene
  24482. * @param updatable defines if the mesh must be flagged as updatable
  24483. * @returns a new Mesh
  24484. */
  24485. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24486. w: number;
  24487. h: number;
  24488. }, precision: {
  24489. w: number;
  24490. h: number;
  24491. }, scene: Scene, updatable?: boolean): Mesh;
  24492. /**
  24493. * Creates a ground mesh from a height map.
  24494. * Please consider using the same method from the MeshBuilder class instead
  24495. * @see http://doc.babylonjs.com/babylon101/height_map
  24496. * @param name defines the name of the mesh to create
  24497. * @param url sets the URL of the height map image resource
  24498. * @param width set the ground width size
  24499. * @param height set the ground height size
  24500. * @param subdivisions sets the number of subdivision per side
  24501. * @param minHeight is the minimum altitude on the ground
  24502. * @param maxHeight is the maximum altitude on the ground
  24503. * @param scene defines the hosting scene
  24504. * @param updatable defines if the mesh must be flagged as updatable
  24505. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24506. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24507. * @returns a new Mesh
  24508. */
  24509. 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;
  24510. /**
  24511. * Creates a tube mesh.
  24512. * The tube is a parametric shape.
  24513. * It has no predefined shape. Its final shape will depend on the input parameters.
  24514. * Please consider using the same method from the MeshBuilder class instead
  24515. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24516. * @param name defines the name of the mesh to create
  24517. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24518. * @param radius sets the tube radius size
  24519. * @param tessellation is the number of sides on the tubular surface
  24520. * @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
  24521. * @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
  24522. * @param scene defines the hosting scene
  24523. * @param updatable defines if the mesh must be flagged as updatable
  24524. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24525. * @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)
  24526. * @returns a new Mesh
  24527. */
  24528. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24529. (i: number, distance: number): number;
  24530. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24531. /**
  24532. * Creates a polyhedron mesh.
  24533. * Please consider using the same method from the MeshBuilder class instead.
  24534. * * 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
  24535. * * The parameter `size` (positive float, default 1) sets the polygon size
  24536. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24537. * * 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`
  24538. * * 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
  24539. * * 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)`)
  24540. * * 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
  24541. * * 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
  24542. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24543. * * 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
  24544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24545. * @param name defines the name of the mesh to create
  24546. * @param options defines the options used to create the mesh
  24547. * @param scene defines the hosting scene
  24548. * @returns a new Mesh
  24549. */
  24550. static CreatePolyhedron(name: string, options: {
  24551. type?: number;
  24552. size?: number;
  24553. sizeX?: number;
  24554. sizeY?: number;
  24555. sizeZ?: number;
  24556. custom?: any;
  24557. faceUV?: Vector4[];
  24558. faceColors?: Color4[];
  24559. updatable?: boolean;
  24560. sideOrientation?: number;
  24561. }, scene: Scene): Mesh;
  24562. /**
  24563. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24564. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24565. * * 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`)
  24566. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24567. * * 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
  24568. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24569. * * 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
  24570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24571. * @param name defines the name of the mesh
  24572. * @param options defines the options used to create the mesh
  24573. * @param scene defines the hosting scene
  24574. * @returns a new Mesh
  24575. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24576. */
  24577. static CreateIcoSphere(name: string, options: {
  24578. radius?: number;
  24579. flat?: boolean;
  24580. subdivisions?: number;
  24581. sideOrientation?: number;
  24582. updatable?: boolean;
  24583. }, scene: Scene): Mesh;
  24584. /**
  24585. * Creates a decal mesh.
  24586. * Please consider using the same method from the MeshBuilder class instead.
  24587. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24588. * @param name defines the name of the mesh
  24589. * @param sourceMesh defines the mesh receiving the decal
  24590. * @param position sets the position of the decal in world coordinates
  24591. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24592. * @param size sets the decal scaling
  24593. * @param angle sets the angle to rotate the decal
  24594. * @returns a new Mesh
  24595. */
  24596. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24597. /**
  24598. * Prepare internal position array for software CPU skinning
  24599. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24600. */
  24601. setPositionsForCPUSkinning(): Float32Array;
  24602. /**
  24603. * Prepare internal normal array for software CPU skinning
  24604. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24605. */
  24606. setNormalsForCPUSkinning(): Float32Array;
  24607. /**
  24608. * Updates the vertex buffer by applying transformation from the bones
  24609. * @param skeleton defines the skeleton to apply to current mesh
  24610. * @returns the current mesh
  24611. */
  24612. applySkeleton(skeleton: Skeleton): Mesh;
  24613. /**
  24614. * 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
  24615. * @param meshes defines the list of meshes to scan
  24616. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24617. */
  24618. static MinMax(meshes: AbstractMesh[]): {
  24619. min: Vector3;
  24620. max: Vector3;
  24621. };
  24622. /**
  24623. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24624. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24625. * @returns a vector3
  24626. */
  24627. static Center(meshesOrMinMaxVector: {
  24628. min: Vector3;
  24629. max: Vector3;
  24630. } | AbstractMesh[]): Vector3;
  24631. /**
  24632. * Merge the array of meshes into a single mesh for performance reasons.
  24633. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24634. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24635. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24636. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24637. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24638. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24639. * @returns a new mesh
  24640. */
  24641. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24642. /** @hidden */
  24643. addInstance(instance: InstancedMesh): void;
  24644. /** @hidden */
  24645. removeInstance(instance: InstancedMesh): void;
  24646. }
  24647. }
  24648. declare module BABYLON {
  24649. /**
  24650. * This is the base class of all the camera used in the application.
  24651. * @see http://doc.babylonjs.com/features/cameras
  24652. */
  24653. export class Camera extends Node {
  24654. /** @hidden */
  24655. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24656. /**
  24657. * This is the default projection mode used by the cameras.
  24658. * It helps recreating a feeling of perspective and better appreciate depth.
  24659. * This is the best way to simulate real life cameras.
  24660. */
  24661. static readonly PERSPECTIVE_CAMERA: number;
  24662. /**
  24663. * This helps creating camera with an orthographic mode.
  24664. * 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.
  24665. */
  24666. static readonly ORTHOGRAPHIC_CAMERA: number;
  24667. /**
  24668. * This is the default FOV mode for perspective cameras.
  24669. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24670. */
  24671. static readonly FOVMODE_VERTICAL_FIXED: number;
  24672. /**
  24673. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24674. */
  24675. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24676. /**
  24677. * This specifies ther is no need for a camera rig.
  24678. * Basically only one eye is rendered corresponding to the camera.
  24679. */
  24680. static readonly RIG_MODE_NONE: number;
  24681. /**
  24682. * Simulates a camera Rig with one blue eye and one red eye.
  24683. * This can be use with 3d blue and red glasses.
  24684. */
  24685. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24686. /**
  24687. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24688. */
  24689. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24690. /**
  24691. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24692. */
  24693. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24694. /**
  24695. * Defines that both eyes of the camera will be rendered over under each other.
  24696. */
  24697. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24698. /**
  24699. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24700. */
  24701. static readonly RIG_MODE_VR: number;
  24702. /**
  24703. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24704. */
  24705. static readonly RIG_MODE_WEBVR: number;
  24706. /**
  24707. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24708. */
  24709. static readonly RIG_MODE_CUSTOM: number;
  24710. /**
  24711. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24712. */
  24713. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24714. /**
  24715. * Define the input manager associated with the camera.
  24716. */
  24717. inputs: CameraInputsManager<Camera>;
  24718. /** @hidden */
  24719. _position: Vector3;
  24720. /**
  24721. * Define the current local position of the camera in the scene
  24722. */
  24723. position: Vector3;
  24724. /**
  24725. * The vector the camera should consider as up.
  24726. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24727. */
  24728. upVector: Vector3;
  24729. /**
  24730. * Define the current limit on the left side for an orthographic camera
  24731. * In scene unit
  24732. */
  24733. orthoLeft: Nullable<number>;
  24734. /**
  24735. * Define the current limit on the right side for an orthographic camera
  24736. * In scene unit
  24737. */
  24738. orthoRight: Nullable<number>;
  24739. /**
  24740. * Define the current limit on the bottom side for an orthographic camera
  24741. * In scene unit
  24742. */
  24743. orthoBottom: Nullable<number>;
  24744. /**
  24745. * Define the current limit on the top side for an orthographic camera
  24746. * In scene unit
  24747. */
  24748. orthoTop: Nullable<number>;
  24749. /**
  24750. * Field Of View is set in Radians. (default is 0.8)
  24751. */
  24752. fov: number;
  24753. /**
  24754. * Define the minimum distance the camera can see from.
  24755. * This is important to note that the depth buffer are not infinite and the closer it starts
  24756. * the more your scene might encounter depth fighting issue.
  24757. */
  24758. minZ: number;
  24759. /**
  24760. * Define the maximum distance the camera can see to.
  24761. * This is important to note that the depth buffer are not infinite and the further it end
  24762. * the more your scene might encounter depth fighting issue.
  24763. */
  24764. maxZ: number;
  24765. /**
  24766. * Define the default inertia of the camera.
  24767. * This helps giving a smooth feeling to the camera movement.
  24768. */
  24769. inertia: number;
  24770. /**
  24771. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24772. */
  24773. mode: number;
  24774. /**
  24775. * Define wether the camera is intermediate.
  24776. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24777. */
  24778. isIntermediate: boolean;
  24779. /**
  24780. * Define the viewport of the camera.
  24781. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24782. */
  24783. viewport: Viewport;
  24784. /**
  24785. * Restricts the camera to viewing objects with the same layerMask.
  24786. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24787. */
  24788. layerMask: number;
  24789. /**
  24790. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24791. */
  24792. fovMode: number;
  24793. /**
  24794. * Rig mode of the camera.
  24795. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24796. * This is normally controlled byt the camera themselves as internal use.
  24797. */
  24798. cameraRigMode: number;
  24799. /**
  24800. * Defines the distance between both "eyes" in case of a RIG
  24801. */
  24802. interaxialDistance: number;
  24803. /**
  24804. * Defines if stereoscopic rendering is done side by side or over under.
  24805. */
  24806. isStereoscopicSideBySide: boolean;
  24807. /**
  24808. * 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
  24809. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24810. * else in the scene. (Eg. security camera)
  24811. *
  24812. * 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)
  24813. */
  24814. customRenderTargets: RenderTargetTexture[];
  24815. /**
  24816. * When set, the camera will render to this render target instead of the default canvas
  24817. *
  24818. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24819. */
  24820. outputRenderTarget: Nullable<RenderTargetTexture>;
  24821. /**
  24822. * Observable triggered when the camera view matrix has changed.
  24823. */
  24824. onViewMatrixChangedObservable: Observable<Camera>;
  24825. /**
  24826. * Observable triggered when the camera Projection matrix has changed.
  24827. */
  24828. onProjectionMatrixChangedObservable: Observable<Camera>;
  24829. /**
  24830. * Observable triggered when the inputs have been processed.
  24831. */
  24832. onAfterCheckInputsObservable: Observable<Camera>;
  24833. /**
  24834. * Observable triggered when reset has been called and applied to the camera.
  24835. */
  24836. onRestoreStateObservable: Observable<Camera>;
  24837. /** @hidden */
  24838. _cameraRigParams: any;
  24839. /** @hidden */
  24840. _rigCameras: Camera[];
  24841. /** @hidden */
  24842. _rigPostProcess: Nullable<PostProcess>;
  24843. protected _webvrViewMatrix: Matrix;
  24844. /** @hidden */
  24845. _skipRendering: boolean;
  24846. /** @hidden */
  24847. _projectionMatrix: Matrix;
  24848. /** @hidden */
  24849. _postProcesses: Nullable<PostProcess>[];
  24850. /** @hidden */
  24851. _activeMeshes: SmartArray<AbstractMesh>;
  24852. protected _globalPosition: Vector3;
  24853. /** @hidden */
  24854. _computedViewMatrix: Matrix;
  24855. private _doNotComputeProjectionMatrix;
  24856. private _transformMatrix;
  24857. private _frustumPlanes;
  24858. private _refreshFrustumPlanes;
  24859. private _storedFov;
  24860. private _stateStored;
  24861. /**
  24862. * Instantiates a new camera object.
  24863. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24864. * @see http://doc.babylonjs.com/features/cameras
  24865. * @param name Defines the name of the camera in the scene
  24866. * @param position Defines the position of the camera
  24867. * @param scene Defines the scene the camera belongs too
  24868. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24869. */
  24870. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24871. /**
  24872. * Store current camera state (fov, position, etc..)
  24873. * @returns the camera
  24874. */
  24875. storeState(): Camera;
  24876. /**
  24877. * Restores the camera state values if it has been stored. You must call storeState() first
  24878. */
  24879. protected _restoreStateValues(): boolean;
  24880. /**
  24881. * Restored camera state. You must call storeState() first.
  24882. * @returns true if restored and false otherwise
  24883. */
  24884. restoreState(): boolean;
  24885. /**
  24886. * Gets the class name of the camera.
  24887. * @returns the class name
  24888. */
  24889. getClassName(): string;
  24890. /** @hidden */
  24891. readonly _isCamera: boolean;
  24892. /**
  24893. * Gets a string representation of the camera useful for debug purpose.
  24894. * @param fullDetails Defines that a more verboe level of logging is required
  24895. * @returns the string representation
  24896. */
  24897. toString(fullDetails?: boolean): string;
  24898. /**
  24899. * Gets the current world space position of the camera.
  24900. */
  24901. readonly globalPosition: Vector3;
  24902. /**
  24903. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24904. * @returns the active meshe list
  24905. */
  24906. getActiveMeshes(): SmartArray<AbstractMesh>;
  24907. /**
  24908. * Check wether a mesh is part of the current active mesh list of the camera
  24909. * @param mesh Defines the mesh to check
  24910. * @returns true if active, false otherwise
  24911. */
  24912. isActiveMesh(mesh: Mesh): boolean;
  24913. /**
  24914. * Is this camera ready to be used/rendered
  24915. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24916. * @return true if the camera is ready
  24917. */
  24918. isReady(completeCheck?: boolean): boolean;
  24919. /** @hidden */
  24920. _initCache(): void;
  24921. /** @hidden */
  24922. _updateCache(ignoreParentClass?: boolean): void;
  24923. /** @hidden */
  24924. _isSynchronized(): boolean;
  24925. /** @hidden */
  24926. _isSynchronizedViewMatrix(): boolean;
  24927. /** @hidden */
  24928. _isSynchronizedProjectionMatrix(): boolean;
  24929. /**
  24930. * Attach the input controls to a specific dom element to get the input from.
  24931. * @param element Defines the element the controls should be listened from
  24932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24933. */
  24934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24935. /**
  24936. * Detach the current controls from the specified dom element.
  24937. * @param element Defines the element to stop listening the inputs from
  24938. */
  24939. detachControl(element: HTMLElement): void;
  24940. /**
  24941. * Update the camera state according to the different inputs gathered during the frame.
  24942. */
  24943. update(): void;
  24944. /** @hidden */
  24945. _checkInputs(): void;
  24946. /** @hidden */
  24947. readonly rigCameras: Camera[];
  24948. /**
  24949. * Gets the post process used by the rig cameras
  24950. */
  24951. readonly rigPostProcess: Nullable<PostProcess>;
  24952. /**
  24953. * Internal, gets the first post proces.
  24954. * @returns the first post process to be run on this camera.
  24955. */
  24956. _getFirstPostProcess(): Nullable<PostProcess>;
  24957. private _cascadePostProcessesToRigCams;
  24958. /**
  24959. * Attach a post process to the camera.
  24960. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24961. * @param postProcess The post process to attach to the camera
  24962. * @param insertAt The position of the post process in case several of them are in use in the scene
  24963. * @returns the position the post process has been inserted at
  24964. */
  24965. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24966. /**
  24967. * Detach a post process to the camera.
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24969. * @param postProcess The post process to detach from the camera
  24970. */
  24971. detachPostProcess(postProcess: PostProcess): void;
  24972. /**
  24973. * Gets the current world matrix of the camera
  24974. */
  24975. getWorldMatrix(): Matrix;
  24976. /** @hidden */
  24977. _getViewMatrix(): Matrix;
  24978. /**
  24979. * Gets the current view matrix of the camera.
  24980. * @param force forces the camera to recompute the matrix without looking at the cached state
  24981. * @returns the view matrix
  24982. */
  24983. getViewMatrix(force?: boolean): Matrix;
  24984. /**
  24985. * Freeze the projection matrix.
  24986. * It will prevent the cache check of the camera projection compute and can speed up perf
  24987. * if no parameter of the camera are meant to change
  24988. * @param projection Defines manually a projection if necessary
  24989. */
  24990. freezeProjectionMatrix(projection?: Matrix): void;
  24991. /**
  24992. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24993. */
  24994. unfreezeProjectionMatrix(): void;
  24995. /**
  24996. * Gets the current projection matrix of the camera.
  24997. * @param force forces the camera to recompute the matrix without looking at the cached state
  24998. * @returns the projection matrix
  24999. */
  25000. getProjectionMatrix(force?: boolean): Matrix;
  25001. /**
  25002. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25003. * @returns a Matrix
  25004. */
  25005. getTransformationMatrix(): Matrix;
  25006. private _updateFrustumPlanes;
  25007. /**
  25008. * Checks if a cullable object (mesh...) is in the camera frustum
  25009. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25010. * @param target The object to check
  25011. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25012. * @returns true if the object is in frustum otherwise false
  25013. */
  25014. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25015. /**
  25016. * Checks if a cullable object (mesh...) is in the camera frustum
  25017. * Unlike isInFrustum this cheks the full bounding box
  25018. * @param target The object to check
  25019. * @returns true if the object is in frustum otherwise false
  25020. */
  25021. isCompletelyInFrustum(target: ICullable): boolean;
  25022. /**
  25023. * Gets a ray in the forward direction from the camera.
  25024. * @param length Defines the length of the ray to create
  25025. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25026. * @param origin Defines the start point of the ray which defaults to the camera position
  25027. * @returns the forward ray
  25028. */
  25029. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25030. /**
  25031. * Releases resources associated with this node.
  25032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25034. */
  25035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25036. /** @hidden */
  25037. _isLeftCamera: boolean;
  25038. /**
  25039. * Gets the left camera of a rig setup in case of Rigged Camera
  25040. */
  25041. readonly isLeftCamera: boolean;
  25042. /** @hidden */
  25043. _isRightCamera: boolean;
  25044. /**
  25045. * Gets the right camera of a rig setup in case of Rigged Camera
  25046. */
  25047. readonly isRightCamera: boolean;
  25048. /**
  25049. * Gets the left camera of a rig setup in case of Rigged Camera
  25050. */
  25051. readonly leftCamera: Nullable<FreeCamera>;
  25052. /**
  25053. * Gets the right camera of a rig setup in case of Rigged Camera
  25054. */
  25055. readonly rightCamera: Nullable<FreeCamera>;
  25056. /**
  25057. * Gets the left camera target of a rig setup in case of Rigged Camera
  25058. * @returns the target position
  25059. */
  25060. getLeftTarget(): Nullable<Vector3>;
  25061. /**
  25062. * Gets the right camera target of a rig setup in case of Rigged Camera
  25063. * @returns the target position
  25064. */
  25065. getRightTarget(): Nullable<Vector3>;
  25066. /**
  25067. * @hidden
  25068. */
  25069. setCameraRigMode(mode: number, rigParams: any): void;
  25070. /** @hidden */
  25071. static _setStereoscopicRigMode(camera: Camera): void;
  25072. /** @hidden */
  25073. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25074. /** @hidden */
  25075. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25076. /** @hidden */
  25077. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25078. /** @hidden */
  25079. _getVRProjectionMatrix(): Matrix;
  25080. protected _updateCameraRotationMatrix(): void;
  25081. protected _updateWebVRCameraRotationMatrix(): void;
  25082. /**
  25083. * This function MUST be overwritten by the different WebVR cameras available.
  25084. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25085. * @hidden
  25086. */
  25087. _getWebVRProjectionMatrix(): Matrix;
  25088. /**
  25089. * This function MUST be overwritten by the different WebVR cameras available.
  25090. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25091. * @hidden
  25092. */
  25093. _getWebVRViewMatrix(): Matrix;
  25094. /** @hidden */
  25095. setCameraRigParameter(name: string, value: any): void;
  25096. /**
  25097. * needs to be overridden by children so sub has required properties to be copied
  25098. * @hidden
  25099. */
  25100. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25101. /**
  25102. * May need to be overridden by children
  25103. * @hidden
  25104. */
  25105. _updateRigCameras(): void;
  25106. /** @hidden */
  25107. _setupInputs(): void;
  25108. /**
  25109. * Serialiaze the camera setup to a json represention
  25110. * @returns the JSON representation
  25111. */
  25112. serialize(): any;
  25113. /**
  25114. * Clones the current camera.
  25115. * @param name The cloned camera name
  25116. * @returns the cloned camera
  25117. */
  25118. clone(name: string): Camera;
  25119. /**
  25120. * Gets the direction of the camera relative to a given local axis.
  25121. * @param localAxis Defines the reference axis to provide a relative direction.
  25122. * @return the direction
  25123. */
  25124. getDirection(localAxis: Vector3): Vector3;
  25125. /**
  25126. * Returns the current camera absolute rotation
  25127. */
  25128. readonly absoluteRotation: Quaternion;
  25129. /**
  25130. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25131. * @param localAxis Defines the reference axis to provide a relative direction.
  25132. * @param result Defines the vector to store the result in
  25133. */
  25134. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25135. /**
  25136. * Gets a camera constructor for a given camera type
  25137. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25138. * @param name The name of the camera the result will be able to instantiate
  25139. * @param scene The scene the result will construct the camera in
  25140. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25141. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25142. * @returns a factory method to construc the camera
  25143. */
  25144. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25145. /**
  25146. * Compute the world matrix of the camera.
  25147. * @returns the camera workd matrix
  25148. */
  25149. computeWorldMatrix(): Matrix;
  25150. /**
  25151. * Parse a JSON and creates the camera from the parsed information
  25152. * @param parsedCamera The JSON to parse
  25153. * @param scene The scene to instantiate the camera in
  25154. * @returns the newly constructed camera
  25155. */
  25156. static Parse(parsedCamera: any, scene: Scene): Camera;
  25157. }
  25158. }
  25159. declare module BABYLON {
  25160. /**
  25161. * Class containing static functions to help procedurally build meshes
  25162. */
  25163. export class DiscBuilder {
  25164. /**
  25165. * Creates a plane polygonal mesh. By default, this is a disc
  25166. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25167. * * 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
  25168. * * 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
  25169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25170. * * 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
  25171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25172. * @param name defines the name of the mesh
  25173. * @param options defines the options used to create the mesh
  25174. * @param scene defines the hosting scene
  25175. * @returns the plane polygonal mesh
  25176. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25177. */
  25178. static CreateDisc(name: string, options: {
  25179. radius?: number;
  25180. tessellation?: number;
  25181. arc?: number;
  25182. updatable?: boolean;
  25183. sideOrientation?: number;
  25184. frontUVs?: Vector4;
  25185. backUVs?: Vector4;
  25186. }, scene?: Nullable<Scene>): Mesh;
  25187. }
  25188. }
  25189. declare module BABYLON {
  25190. /**
  25191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25192. *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.
  25193. * The SPS is also a particle system. It provides some methods to manage the particles.
  25194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25195. *
  25196. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25197. */
  25198. export class SolidParticleSystem implements IDisposable {
  25199. /**
  25200. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25201. * Example : var p = SPS.particles[i];
  25202. */
  25203. particles: SolidParticle[];
  25204. /**
  25205. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25206. */
  25207. nbParticles: number;
  25208. /**
  25209. * If the particles must ever face the camera (default false). Useful for planar particles.
  25210. */
  25211. billboard: boolean;
  25212. /**
  25213. * Recompute normals when adding a shape
  25214. */
  25215. recomputeNormals: boolean;
  25216. /**
  25217. * This a counter ofr your own usage. It's not set by any SPS functions.
  25218. */
  25219. counter: number;
  25220. /**
  25221. * The SPS name. This name is also given to the underlying mesh.
  25222. */
  25223. name: string;
  25224. /**
  25225. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25226. */
  25227. mesh: Mesh;
  25228. /**
  25229. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25230. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25231. */
  25232. vars: any;
  25233. /**
  25234. * This array is populated when the SPS is set as 'pickable'.
  25235. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25236. * Each element of this array is an object `{idx: int, faceId: int}`.
  25237. * `idx` is the picked particle index in the `SPS.particles` array
  25238. * `faceId` is the picked face index counted within this particle.
  25239. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25240. */
  25241. pickedParticles: {
  25242. idx: number;
  25243. faceId: number;
  25244. }[];
  25245. /**
  25246. * This array is populated when `enableDepthSort` is set to true.
  25247. * Each element of this array is an instance of the class DepthSortedParticle.
  25248. */
  25249. depthSortedParticles: DepthSortedParticle[];
  25250. /**
  25251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25252. * @hidden
  25253. */
  25254. _bSphereOnly: boolean;
  25255. /**
  25256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25257. * @hidden
  25258. */
  25259. _bSphereRadiusFactor: number;
  25260. private _scene;
  25261. private _positions;
  25262. private _indices;
  25263. private _normals;
  25264. private _colors;
  25265. private _uvs;
  25266. private _indices32;
  25267. private _positions32;
  25268. private _normals32;
  25269. private _fixedNormal32;
  25270. private _colors32;
  25271. private _uvs32;
  25272. private _index;
  25273. private _updatable;
  25274. private _pickable;
  25275. private _isVisibilityBoxLocked;
  25276. private _alwaysVisible;
  25277. private _depthSort;
  25278. private _expandable;
  25279. private _shapeCounter;
  25280. private _copy;
  25281. private _color;
  25282. private _computeParticleColor;
  25283. private _computeParticleTexture;
  25284. private _computeParticleRotation;
  25285. private _computeParticleVertex;
  25286. private _computeBoundingBox;
  25287. private _depthSortParticles;
  25288. private _camera;
  25289. private _mustUnrotateFixedNormals;
  25290. private _particlesIntersect;
  25291. private _needs32Bits;
  25292. private _isNotBuilt;
  25293. /**
  25294. * Creates a SPS (Solid Particle System) object.
  25295. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25296. * @param scene (Scene) is the scene in which the SPS is added.
  25297. * @param options defines the options of the sps e.g.
  25298. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25299. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25300. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25301. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25302. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25303. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25304. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25305. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25306. */
  25307. constructor(name: string, scene: Scene, options?: {
  25308. updatable?: boolean;
  25309. isPickable?: boolean;
  25310. enableDepthSort?: boolean;
  25311. particleIntersection?: boolean;
  25312. boundingSphereOnly?: boolean;
  25313. bSphereRadiusFactor?: number;
  25314. expandable?: boolean;
  25315. });
  25316. /**
  25317. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25318. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25319. * @returns the created mesh
  25320. */
  25321. buildMesh(): Mesh;
  25322. /**
  25323. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25324. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25325. * Thus the particles generated from `digest()` have their property `position` set yet.
  25326. * @param mesh ( Mesh ) is the mesh to be digested
  25327. * @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
  25328. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25329. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25330. * @returns the current SPS
  25331. */
  25332. digest(mesh: Mesh, options?: {
  25333. facetNb?: number;
  25334. number?: number;
  25335. delta?: number;
  25336. }): SolidParticleSystem;
  25337. private _unrotateFixedNormals;
  25338. private _resetCopy;
  25339. private _meshBuilder;
  25340. private _posToShape;
  25341. private _uvsToShapeUV;
  25342. private _addParticle;
  25343. /**
  25344. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25345. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25346. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25347. * @param nb (positive integer) the number of particles to be created from this model
  25348. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25349. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25350. * @returns the number of shapes in the system
  25351. */
  25352. addShape(mesh: Mesh, nb: number, options?: {
  25353. positionFunction?: any;
  25354. vertexFunction?: any;
  25355. }): number;
  25356. private _rebuildParticle;
  25357. /**
  25358. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25359. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25360. * @returns the SPS.
  25361. */
  25362. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25363. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25364. * Returns an array with the removed particles.
  25365. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25366. * The SPS can't be empty so at least one particle needs to remain in place.
  25367. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25368. * @param start index of the first particle to remove
  25369. * @param end index of the last particle to remove (included)
  25370. * @returns an array populated with the removed particles
  25371. */
  25372. removeParticles(start: number, end: number): SolidParticle[];
  25373. /**
  25374. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25375. * This method calls `updateParticle()` for each particle of the SPS.
  25376. * For an animated SPS, it is usually called within the render loop.
  25377. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25378. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25379. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25380. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25381. * @returns the SPS.
  25382. */
  25383. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25384. /**
  25385. * Disposes the SPS.
  25386. */
  25387. dispose(): void;
  25388. /**
  25389. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25390. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25391. * @returns the SPS.
  25392. */
  25393. refreshVisibleSize(): SolidParticleSystem;
  25394. /**
  25395. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25396. * @param size the size (float) of the visibility box
  25397. * note : this doesn't lock the SPS mesh bounding box.
  25398. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25399. */
  25400. setVisibilityBox(size: number): void;
  25401. /**
  25402. * Gets whether the SPS as always visible or not
  25403. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25404. */
  25405. /**
  25406. * Sets the SPS as always visible or not
  25407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25408. */
  25409. isAlwaysVisible: boolean;
  25410. /**
  25411. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25412. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25413. */
  25414. /**
  25415. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25417. */
  25418. isVisibilityBoxLocked: boolean;
  25419. /**
  25420. * Tells to `setParticles()` to compute the particle rotations or not.
  25421. * Default value : true. The SPS is faster when it's set to false.
  25422. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25423. */
  25424. /**
  25425. * Gets if `setParticles()` computes the particle rotations or not.
  25426. * Default value : true. The SPS is faster when it's set to false.
  25427. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25428. */
  25429. computeParticleRotation: boolean;
  25430. /**
  25431. * Tells to `setParticles()` to compute the particle colors or not.
  25432. * Default value : true. The SPS is faster when it's set to false.
  25433. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25434. */
  25435. /**
  25436. * Gets if `setParticles()` computes the particle colors or not.
  25437. * Default value : true. The SPS is faster when it's set to false.
  25438. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25439. */
  25440. computeParticleColor: boolean;
  25441. /**
  25442. * Gets if `setParticles()` computes the particle textures or not.
  25443. * Default value : true. The SPS is faster when it's set to false.
  25444. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25445. */
  25446. computeParticleTexture: boolean;
  25447. /**
  25448. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25449. * Default value : false. The SPS is faster when it's set to false.
  25450. * Note : the particle custom vertex positions aren't stored values.
  25451. */
  25452. /**
  25453. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25454. * Default value : false. The SPS is faster when it's set to false.
  25455. * Note : the particle custom vertex positions aren't stored values.
  25456. */
  25457. computeParticleVertex: boolean;
  25458. /**
  25459. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25460. */
  25461. /**
  25462. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25463. */
  25464. computeBoundingBox: boolean;
  25465. /**
  25466. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25467. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25468. * Default : `true`
  25469. */
  25470. /**
  25471. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25472. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25473. * Default : `true`
  25474. */
  25475. depthSortParticles: boolean;
  25476. /**
  25477. * Gets if the SPS is created as expandable at construction time.
  25478. * Default : `false`
  25479. */
  25480. readonly expandable: boolean;
  25481. /**
  25482. * This function does nothing. It may be overwritten to set all the particle first values.
  25483. * The SPS doesn't call this function, you may have to call it by your own.
  25484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25485. */
  25486. initParticles(): void;
  25487. /**
  25488. * This function does nothing. It may be overwritten to recycle a particle.
  25489. * The SPS doesn't call this function, you may have to call it by your own.
  25490. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25491. * @param particle The particle to recycle
  25492. * @returns the recycled particle
  25493. */
  25494. recycleParticle(particle: SolidParticle): SolidParticle;
  25495. /**
  25496. * Updates a particle : this function should be overwritten by the user.
  25497. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25498. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25499. * @example : just set a particle position or velocity and recycle conditions
  25500. * @param particle The particle to update
  25501. * @returns the updated particle
  25502. */
  25503. updateParticle(particle: SolidParticle): SolidParticle;
  25504. /**
  25505. * Updates a vertex of a particle : it can be overwritten by the user.
  25506. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25507. * @param particle the current particle
  25508. * @param vertex the current index of the current particle
  25509. * @param pt the index of the current vertex in the particle shape
  25510. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25511. * @example : just set a vertex particle position
  25512. * @returns the updated vertex
  25513. */
  25514. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25515. /**
  25516. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25517. * This does nothing and may be overwritten by the user.
  25518. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25519. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25520. * @param update the boolean update value actually passed to setParticles()
  25521. */
  25522. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25523. /**
  25524. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25525. * This will be passed three parameters.
  25526. * This does nothing and may be overwritten by the user.
  25527. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25528. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25529. * @param update the boolean update value actually passed to setParticles()
  25530. */
  25531. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25532. }
  25533. }
  25534. declare module BABYLON {
  25535. /**
  25536. * Represents one particle of a solid particle system.
  25537. */
  25538. export class SolidParticle {
  25539. /**
  25540. * particle global index
  25541. */
  25542. idx: number;
  25543. /**
  25544. * The color of the particle
  25545. */
  25546. color: Nullable<Color4>;
  25547. /**
  25548. * The world space position of the particle.
  25549. */
  25550. position: Vector3;
  25551. /**
  25552. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25553. */
  25554. rotation: Vector3;
  25555. /**
  25556. * The world space rotation quaternion of the particle.
  25557. */
  25558. rotationQuaternion: Nullable<Quaternion>;
  25559. /**
  25560. * The scaling of the particle.
  25561. */
  25562. scaling: Vector3;
  25563. /**
  25564. * The uvs of the particle.
  25565. */
  25566. uvs: Vector4;
  25567. /**
  25568. * The current speed of the particle.
  25569. */
  25570. velocity: Vector3;
  25571. /**
  25572. * The pivot point in the particle local space.
  25573. */
  25574. pivot: Vector3;
  25575. /**
  25576. * Must the particle be translated from its pivot point in its local space ?
  25577. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25578. * Default : false
  25579. */
  25580. translateFromPivot: boolean;
  25581. /**
  25582. * Is the particle active or not ?
  25583. */
  25584. alive: boolean;
  25585. /**
  25586. * Is the particle visible or not ?
  25587. */
  25588. isVisible: boolean;
  25589. /**
  25590. * Index of this particle in the global "positions" array (Internal use)
  25591. * @hidden
  25592. */
  25593. _pos: number;
  25594. /**
  25595. * @hidden Index of this particle in the global "indices" array (Internal use)
  25596. */
  25597. _ind: number;
  25598. /**
  25599. * @hidden ModelShape of this particle (Internal use)
  25600. */
  25601. _model: ModelShape;
  25602. /**
  25603. * ModelShape id of this particle
  25604. */
  25605. shapeId: number;
  25606. /**
  25607. * Index of the particle in its shape id
  25608. */
  25609. idxInShape: number;
  25610. /**
  25611. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25612. */
  25613. _modelBoundingInfo: BoundingInfo;
  25614. /**
  25615. * @hidden Particle BoundingInfo object (Internal use)
  25616. */
  25617. _boundingInfo: BoundingInfo;
  25618. /**
  25619. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25620. */
  25621. _sps: SolidParticleSystem;
  25622. /**
  25623. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25624. */
  25625. _stillInvisible: boolean;
  25626. /**
  25627. * @hidden Last computed particle rotation matrix
  25628. */
  25629. _rotationMatrix: number[];
  25630. /**
  25631. * Parent particle Id, if any.
  25632. * Default null.
  25633. */
  25634. parentId: Nullable<number>;
  25635. /**
  25636. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25637. * The possible values are :
  25638. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25639. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25640. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25641. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25642. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25643. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25644. * */
  25645. cullingStrategy: number;
  25646. /**
  25647. * @hidden Internal global position in the SPS.
  25648. */
  25649. _globalPosition: Vector3;
  25650. /**
  25651. * Creates a Solid Particle object.
  25652. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25653. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25654. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25655. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25656. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25657. * @param shapeId (integer) is the model shape identifier in the SPS.
  25658. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25659. * @param sps defines the sps it is associated to
  25660. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25661. */
  25662. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25663. /**
  25664. * Legacy support, changed scale to scaling
  25665. */
  25666. /**
  25667. * Legacy support, changed scale to scaling
  25668. */
  25669. scale: Vector3;
  25670. /**
  25671. * Legacy support, changed quaternion to rotationQuaternion
  25672. */
  25673. /**
  25674. * Legacy support, changed quaternion to rotationQuaternion
  25675. */
  25676. quaternion: Nullable<Quaternion>;
  25677. /**
  25678. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25679. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25680. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25681. * @returns true if it intersects
  25682. */
  25683. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25684. /**
  25685. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25686. * A particle is in the frustum if its bounding box intersects the frustum
  25687. * @param frustumPlanes defines the frustum to test
  25688. * @returns true if the particle is in the frustum planes
  25689. */
  25690. isInFrustum(frustumPlanes: Plane[]): boolean;
  25691. /**
  25692. * get the rotation matrix of the particle
  25693. * @hidden
  25694. */
  25695. getRotationMatrix(m: Matrix): void;
  25696. }
  25697. /**
  25698. * Represents the shape of the model used by one particle of a solid particle system.
  25699. * SPS internal tool, don't use it manually.
  25700. */
  25701. export class ModelShape {
  25702. /**
  25703. * The shape id
  25704. * @hidden
  25705. */
  25706. shapeID: number;
  25707. /**
  25708. * flat array of model positions (internal use)
  25709. * @hidden
  25710. */
  25711. _shape: Vector3[];
  25712. /**
  25713. * flat array of model UVs (internal use)
  25714. * @hidden
  25715. */
  25716. _shapeUV: number[];
  25717. /**
  25718. * color array of the model
  25719. * @hidden
  25720. */
  25721. _shapeColors: number[];
  25722. /**
  25723. * indices array of the model
  25724. * @hidden
  25725. */
  25726. _indices: number[];
  25727. /**
  25728. * normals array of the model
  25729. * @hidden
  25730. */
  25731. _normals: number[];
  25732. /**
  25733. * length of the shape in the model indices array (internal use)
  25734. * @hidden
  25735. */
  25736. _indicesLength: number;
  25737. /**
  25738. * Custom position function (internal use)
  25739. * @hidden
  25740. */
  25741. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25742. /**
  25743. * Custom vertex function (internal use)
  25744. * @hidden
  25745. */
  25746. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25747. /**
  25748. * 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.
  25749. * SPS internal tool, don't use it manually.
  25750. * @hidden
  25751. */
  25752. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25753. }
  25754. /**
  25755. * Represents a Depth Sorted Particle in the solid particle system.
  25756. */
  25757. export class DepthSortedParticle {
  25758. /**
  25759. * Index of the particle in the "indices" array
  25760. */
  25761. ind: number;
  25762. /**
  25763. * Length of the particle shape in the "indices" array
  25764. */
  25765. indicesLength: number;
  25766. /**
  25767. * Squared distance from the particle to the camera
  25768. */
  25769. sqDistance: number;
  25770. }
  25771. }
  25772. declare module BABYLON {
  25773. /**
  25774. * @hidden
  25775. */
  25776. export class _MeshCollisionData {
  25777. _checkCollisions: boolean;
  25778. _collisionMask: number;
  25779. _collisionGroup: number;
  25780. _collider: Nullable<Collider>;
  25781. _oldPositionForCollisions: Vector3;
  25782. _diffPositionForCollisions: Vector3;
  25783. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25784. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25785. }
  25786. }
  25787. declare module BABYLON {
  25788. /** @hidden */
  25789. class _FacetDataStorage {
  25790. facetPositions: Vector3[];
  25791. facetNormals: Vector3[];
  25792. facetPartitioning: number[][];
  25793. facetNb: number;
  25794. partitioningSubdivisions: number;
  25795. partitioningBBoxRatio: number;
  25796. facetDataEnabled: boolean;
  25797. facetParameters: any;
  25798. bbSize: Vector3;
  25799. subDiv: {
  25800. max: number;
  25801. X: number;
  25802. Y: number;
  25803. Z: number;
  25804. };
  25805. facetDepthSort: boolean;
  25806. facetDepthSortEnabled: boolean;
  25807. depthSortedIndices: IndicesArray;
  25808. depthSortedFacets: {
  25809. ind: number;
  25810. sqDistance: number;
  25811. }[];
  25812. facetDepthSortFunction: (f1: {
  25813. ind: number;
  25814. sqDistance: number;
  25815. }, f2: {
  25816. ind: number;
  25817. sqDistance: number;
  25818. }) => number;
  25819. facetDepthSortFrom: Vector3;
  25820. facetDepthSortOrigin: Vector3;
  25821. invertedMatrix: Matrix;
  25822. }
  25823. /**
  25824. * @hidden
  25825. **/
  25826. class _InternalAbstractMeshDataInfo {
  25827. _hasVertexAlpha: boolean;
  25828. _useVertexColors: boolean;
  25829. _numBoneInfluencers: number;
  25830. _applyFog: boolean;
  25831. _receiveShadows: boolean;
  25832. _facetData: _FacetDataStorage;
  25833. _visibility: number;
  25834. _skeleton: Nullable<Skeleton>;
  25835. _layerMask: number;
  25836. _computeBonesUsingShaders: boolean;
  25837. _isActive: boolean;
  25838. _onlyForInstances: boolean;
  25839. _isActiveIntermediate: boolean;
  25840. _onlyForInstancesIntermediate: boolean;
  25841. _actAsRegularMesh: boolean;
  25842. }
  25843. /**
  25844. * Class used to store all common mesh properties
  25845. */
  25846. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25847. /** No occlusion */
  25848. static OCCLUSION_TYPE_NONE: number;
  25849. /** Occlusion set to optimisitic */
  25850. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25851. /** Occlusion set to strict */
  25852. static OCCLUSION_TYPE_STRICT: number;
  25853. /** Use an accurante occlusion algorithm */
  25854. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25855. /** Use a conservative occlusion algorithm */
  25856. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25857. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25858. * Test order :
  25859. * Is the bounding sphere outside the frustum ?
  25860. * If not, are the bounding box vertices outside the frustum ?
  25861. * It not, then the cullable object is in the frustum.
  25862. */
  25863. static readonly CULLINGSTRATEGY_STANDARD: number;
  25864. /** Culling strategy : Bounding Sphere Only.
  25865. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25866. * It's also less accurate than the standard because some not visible objects can still be selected.
  25867. * Test : is the bounding sphere outside the frustum ?
  25868. * If not, then the cullable object is in the frustum.
  25869. */
  25870. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25871. /** Culling strategy : Optimistic Inclusion.
  25872. * This in an inclusion test first, then the standard exclusion test.
  25873. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25874. * 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.
  25875. * Anyway, it's as accurate as the standard strategy.
  25876. * Test :
  25877. * Is the cullable object bounding sphere center in the frustum ?
  25878. * If not, apply the default culling strategy.
  25879. */
  25880. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25881. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25882. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25883. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25884. * 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.
  25885. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25886. * Test :
  25887. * Is the cullable object bounding sphere center in the frustum ?
  25888. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25889. */
  25890. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25891. /**
  25892. * No billboard
  25893. */
  25894. static readonly BILLBOARDMODE_NONE: number;
  25895. /** Billboard on X axis */
  25896. static readonly BILLBOARDMODE_X: number;
  25897. /** Billboard on Y axis */
  25898. static readonly BILLBOARDMODE_Y: number;
  25899. /** Billboard on Z axis */
  25900. static readonly BILLBOARDMODE_Z: number;
  25901. /** Billboard on all axes */
  25902. static readonly BILLBOARDMODE_ALL: number;
  25903. /** Billboard on using position instead of orientation */
  25904. static readonly BILLBOARDMODE_USE_POSITION: number;
  25905. /** @hidden */
  25906. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25907. /**
  25908. * The culling strategy to use to check whether the mesh must be rendered or not.
  25909. * This value can be changed at any time and will be used on the next render mesh selection.
  25910. * The possible values are :
  25911. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25912. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25915. * Please read each static variable documentation to get details about the culling process.
  25916. * */
  25917. cullingStrategy: number;
  25918. /**
  25919. * Gets the number of facets in the mesh
  25920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25921. */
  25922. readonly facetNb: number;
  25923. /**
  25924. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25926. */
  25927. partitioningSubdivisions: number;
  25928. /**
  25929. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25930. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25932. */
  25933. partitioningBBoxRatio: number;
  25934. /**
  25935. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25936. * Works only for updatable meshes.
  25937. * Doesn't work with multi-materials
  25938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25939. */
  25940. mustDepthSortFacets: boolean;
  25941. /**
  25942. * The location (Vector3) where the facet depth sort must be computed from.
  25943. * By default, the active camera position.
  25944. * Used only when facet depth sort is enabled
  25945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25946. */
  25947. facetDepthSortFrom: Vector3;
  25948. /**
  25949. * gets a boolean indicating if facetData is enabled
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25951. */
  25952. readonly isFacetDataEnabled: boolean;
  25953. /** @hidden */
  25954. _updateNonUniformScalingState(value: boolean): boolean;
  25955. /**
  25956. * An event triggered when this mesh collides with another one
  25957. */
  25958. onCollideObservable: Observable<AbstractMesh>;
  25959. /** Set a function to call when this mesh collides with another one */
  25960. onCollide: () => void;
  25961. /**
  25962. * An event triggered when the collision's position changes
  25963. */
  25964. onCollisionPositionChangeObservable: Observable<Vector3>;
  25965. /** Set a function to call when the collision's position changes */
  25966. onCollisionPositionChange: () => void;
  25967. /**
  25968. * An event triggered when material is changed
  25969. */
  25970. onMaterialChangedObservable: Observable<AbstractMesh>;
  25971. /**
  25972. * Gets or sets the orientation for POV movement & rotation
  25973. */
  25974. definedFacingForward: boolean;
  25975. /** @hidden */
  25976. _occlusionQuery: Nullable<WebGLQuery>;
  25977. /** @hidden */
  25978. _renderingGroup: Nullable<RenderingGroup>;
  25979. /**
  25980. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25981. */
  25982. /**
  25983. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25984. */
  25985. visibility: number;
  25986. /** Gets or sets the alpha index used to sort transparent meshes
  25987. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25988. */
  25989. alphaIndex: number;
  25990. /**
  25991. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25992. */
  25993. isVisible: boolean;
  25994. /**
  25995. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25996. */
  25997. isPickable: boolean;
  25998. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25999. showSubMeshesBoundingBox: boolean;
  26000. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26001. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26002. */
  26003. isBlocker: boolean;
  26004. /**
  26005. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26006. */
  26007. enablePointerMoveEvents: boolean;
  26008. /**
  26009. * Specifies the rendering group id for this mesh (0 by default)
  26010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26011. */
  26012. renderingGroupId: number;
  26013. private _material;
  26014. /** Gets or sets current material */
  26015. material: Nullable<Material>;
  26016. /**
  26017. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26018. * @see http://doc.babylonjs.com/babylon101/shadows
  26019. */
  26020. receiveShadows: boolean;
  26021. /** Defines color to use when rendering outline */
  26022. outlineColor: Color3;
  26023. /** Define width to use when rendering outline */
  26024. outlineWidth: number;
  26025. /** Defines color to use when rendering overlay */
  26026. overlayColor: Color3;
  26027. /** Defines alpha to use when rendering overlay */
  26028. overlayAlpha: number;
  26029. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26030. hasVertexAlpha: boolean;
  26031. /** 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) */
  26032. useVertexColors: boolean;
  26033. /**
  26034. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26035. */
  26036. computeBonesUsingShaders: boolean;
  26037. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26038. numBoneInfluencers: number;
  26039. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26040. applyFog: boolean;
  26041. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26042. useOctreeForRenderingSelection: boolean;
  26043. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26044. useOctreeForPicking: boolean;
  26045. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26046. useOctreeForCollisions: boolean;
  26047. /**
  26048. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26049. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26050. */
  26051. layerMask: number;
  26052. /**
  26053. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26054. */
  26055. alwaysSelectAsActiveMesh: boolean;
  26056. /**
  26057. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26058. */
  26059. doNotSyncBoundingInfo: boolean;
  26060. /**
  26061. * Gets or sets the current action manager
  26062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26063. */
  26064. actionManager: Nullable<AbstractActionManager>;
  26065. private _meshCollisionData;
  26066. /**
  26067. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26069. */
  26070. ellipsoid: Vector3;
  26071. /**
  26072. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26074. */
  26075. ellipsoidOffset: Vector3;
  26076. /**
  26077. * Gets or sets a collision mask used to mask collisions (default is -1).
  26078. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26079. */
  26080. collisionMask: number;
  26081. /**
  26082. * Gets or sets the current collision group mask (-1 by default).
  26083. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26084. */
  26085. collisionGroup: number;
  26086. /**
  26087. * Defines edge width used when edgesRenderer is enabled
  26088. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26089. */
  26090. edgesWidth: number;
  26091. /**
  26092. * Defines edge color used when edgesRenderer is enabled
  26093. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26094. */
  26095. edgesColor: Color4;
  26096. /** @hidden */
  26097. _edgesRenderer: Nullable<IEdgesRenderer>;
  26098. /** @hidden */
  26099. _masterMesh: Nullable<AbstractMesh>;
  26100. /** @hidden */
  26101. _boundingInfo: Nullable<BoundingInfo>;
  26102. /** @hidden */
  26103. _renderId: number;
  26104. /**
  26105. * Gets or sets the list of subMeshes
  26106. * @see http://doc.babylonjs.com/how_to/multi_materials
  26107. */
  26108. subMeshes: SubMesh[];
  26109. /** @hidden */
  26110. _intersectionsInProgress: AbstractMesh[];
  26111. /** @hidden */
  26112. _unIndexed: boolean;
  26113. /** @hidden */
  26114. _lightSources: Light[];
  26115. /** Gets the list of lights affecting that mesh */
  26116. readonly lightSources: Light[];
  26117. /** @hidden */
  26118. readonly _positions: Nullable<Vector3[]>;
  26119. /** @hidden */
  26120. _waitingData: {
  26121. lods: Nullable<any>;
  26122. actions: Nullable<any>;
  26123. freezeWorldMatrix: Nullable<boolean>;
  26124. };
  26125. /** @hidden */
  26126. _bonesTransformMatrices: Nullable<Float32Array>;
  26127. /** @hidden */
  26128. _transformMatrixTexture: Nullable<RawTexture>;
  26129. /**
  26130. * Gets or sets a skeleton to apply skining transformations
  26131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26132. */
  26133. skeleton: Nullable<Skeleton>;
  26134. /**
  26135. * An event triggered when the mesh is rebuilt.
  26136. */
  26137. onRebuildObservable: Observable<AbstractMesh>;
  26138. /**
  26139. * Creates a new AbstractMesh
  26140. * @param name defines the name of the mesh
  26141. * @param scene defines the hosting scene
  26142. */
  26143. constructor(name: string, scene?: Nullable<Scene>);
  26144. /**
  26145. * Returns the string "AbstractMesh"
  26146. * @returns "AbstractMesh"
  26147. */
  26148. getClassName(): string;
  26149. /**
  26150. * Gets a string representation of the current mesh
  26151. * @param fullDetails defines a boolean indicating if full details must be included
  26152. * @returns a string representation of the current mesh
  26153. */
  26154. toString(fullDetails?: boolean): string;
  26155. /**
  26156. * @hidden
  26157. */
  26158. protected _getEffectiveParent(): Nullable<Node>;
  26159. /** @hidden */
  26160. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26161. /** @hidden */
  26162. _rebuild(): void;
  26163. /** @hidden */
  26164. _resyncLightSources(): void;
  26165. /** @hidden */
  26166. _resyncLighSource(light: Light): void;
  26167. /** @hidden */
  26168. _unBindEffect(): void;
  26169. /** @hidden */
  26170. _removeLightSource(light: Light, dispose: boolean): void;
  26171. private _markSubMeshesAsDirty;
  26172. /** @hidden */
  26173. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26174. /** @hidden */
  26175. _markSubMeshesAsAttributesDirty(): void;
  26176. /** @hidden */
  26177. _markSubMeshesAsMiscDirty(): void;
  26178. /**
  26179. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26180. */
  26181. scaling: Vector3;
  26182. /**
  26183. * Returns true if the mesh is blocked. Implemented by child classes
  26184. */
  26185. readonly isBlocked: boolean;
  26186. /**
  26187. * Returns the mesh itself by default. Implemented by child classes
  26188. * @param camera defines the camera to use to pick the right LOD level
  26189. * @returns the currentAbstractMesh
  26190. */
  26191. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26192. /**
  26193. * Returns 0 by default. Implemented by child classes
  26194. * @returns an integer
  26195. */
  26196. getTotalVertices(): number;
  26197. /**
  26198. * Returns a positive integer : the total number of indices in this mesh geometry.
  26199. * @returns the numner of indices or zero if the mesh has no geometry.
  26200. */
  26201. getTotalIndices(): number;
  26202. /**
  26203. * Returns null by default. Implemented by child classes
  26204. * @returns null
  26205. */
  26206. getIndices(): Nullable<IndicesArray>;
  26207. /**
  26208. * Returns the array of the requested vertex data kind. Implemented by child classes
  26209. * @param kind defines the vertex data kind to use
  26210. * @returns null
  26211. */
  26212. getVerticesData(kind: string): Nullable<FloatArray>;
  26213. /**
  26214. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26215. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26216. * Note that a new underlying VertexBuffer object is created each call.
  26217. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26218. * @param kind defines vertex data kind:
  26219. * * VertexBuffer.PositionKind
  26220. * * VertexBuffer.UVKind
  26221. * * VertexBuffer.UV2Kind
  26222. * * VertexBuffer.UV3Kind
  26223. * * VertexBuffer.UV4Kind
  26224. * * VertexBuffer.UV5Kind
  26225. * * VertexBuffer.UV6Kind
  26226. * * VertexBuffer.ColorKind
  26227. * * VertexBuffer.MatricesIndicesKind
  26228. * * VertexBuffer.MatricesIndicesExtraKind
  26229. * * VertexBuffer.MatricesWeightsKind
  26230. * * VertexBuffer.MatricesWeightsExtraKind
  26231. * @param data defines the data source
  26232. * @param updatable defines if the data must be flagged as updatable (or static)
  26233. * @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
  26234. * @returns the current mesh
  26235. */
  26236. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26237. /**
  26238. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26239. * If the mesh has no geometry, it is simply returned as it is.
  26240. * @param kind defines vertex data kind:
  26241. * * VertexBuffer.PositionKind
  26242. * * VertexBuffer.UVKind
  26243. * * VertexBuffer.UV2Kind
  26244. * * VertexBuffer.UV3Kind
  26245. * * VertexBuffer.UV4Kind
  26246. * * VertexBuffer.UV5Kind
  26247. * * VertexBuffer.UV6Kind
  26248. * * VertexBuffer.ColorKind
  26249. * * VertexBuffer.MatricesIndicesKind
  26250. * * VertexBuffer.MatricesIndicesExtraKind
  26251. * * VertexBuffer.MatricesWeightsKind
  26252. * * VertexBuffer.MatricesWeightsExtraKind
  26253. * @param data defines the data source
  26254. * @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
  26255. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26256. * @returns the current mesh
  26257. */
  26258. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26259. /**
  26260. * Sets the mesh indices,
  26261. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26262. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26263. * @param totalVertices Defines the total number of vertices
  26264. * @returns the current mesh
  26265. */
  26266. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26267. /**
  26268. * Gets a boolean indicating if specific vertex data is present
  26269. * @param kind defines the vertex data kind to use
  26270. * @returns true is data kind is present
  26271. */
  26272. isVerticesDataPresent(kind: string): boolean;
  26273. /**
  26274. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26275. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26276. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26277. * @returns a BoundingInfo
  26278. */
  26279. getBoundingInfo(): BoundingInfo;
  26280. /**
  26281. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26282. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26283. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26284. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26285. * @returns the current mesh
  26286. */
  26287. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26288. /**
  26289. * Overwrite the current bounding info
  26290. * @param boundingInfo defines the new bounding info
  26291. * @returns the current mesh
  26292. */
  26293. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26294. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26295. readonly useBones: boolean;
  26296. /** @hidden */
  26297. _preActivate(): void;
  26298. /** @hidden */
  26299. _preActivateForIntermediateRendering(renderId: number): void;
  26300. /** @hidden */
  26301. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26302. /** @hidden */
  26303. _postActivate(): void;
  26304. /** @hidden */
  26305. _freeze(): void;
  26306. /** @hidden */
  26307. _unFreeze(): void;
  26308. /**
  26309. * Gets the current world matrix
  26310. * @returns a Matrix
  26311. */
  26312. getWorldMatrix(): Matrix;
  26313. /** @hidden */
  26314. _getWorldMatrixDeterminant(): number;
  26315. /**
  26316. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26317. */
  26318. readonly isAnInstance: boolean;
  26319. /**
  26320. * Gets a boolean indicating if this mesh has instances
  26321. */
  26322. readonly hasInstances: boolean;
  26323. /**
  26324. * Perform relative position change from the point of view of behind the front of the mesh.
  26325. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26326. * Supports definition of mesh facing forward or backward
  26327. * @param amountRight defines the distance on the right axis
  26328. * @param amountUp defines the distance on the up axis
  26329. * @param amountForward defines the distance on the forward axis
  26330. * @returns the current mesh
  26331. */
  26332. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26333. /**
  26334. * Calculate relative position change from the point of view of behind the front of the mesh.
  26335. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26336. * Supports definition of mesh facing forward or backward
  26337. * @param amountRight defines the distance on the right axis
  26338. * @param amountUp defines the distance on the up axis
  26339. * @param amountForward defines the distance on the forward axis
  26340. * @returns the new displacement vector
  26341. */
  26342. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26343. /**
  26344. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26345. * Supports definition of mesh facing forward or backward
  26346. * @param flipBack defines the flip
  26347. * @param twirlClockwise defines the twirl
  26348. * @param tiltRight defines the tilt
  26349. * @returns the current mesh
  26350. */
  26351. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26352. /**
  26353. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26354. * Supports definition of mesh facing forward or backward.
  26355. * @param flipBack defines the flip
  26356. * @param twirlClockwise defines the twirl
  26357. * @param tiltRight defines the tilt
  26358. * @returns the new rotation vector
  26359. */
  26360. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26361. /**
  26362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26363. * This means the mesh underlying bounding box and sphere are recomputed.
  26364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26365. * @returns the current mesh
  26366. */
  26367. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26368. /** @hidden */
  26369. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26370. /** @hidden */
  26371. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26372. /** @hidden */
  26373. _updateBoundingInfo(): AbstractMesh;
  26374. /** @hidden */
  26375. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26376. /** @hidden */
  26377. protected _afterComputeWorldMatrix(): void;
  26378. /** @hidden */
  26379. readonly _effectiveMesh: AbstractMesh;
  26380. /**
  26381. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26382. * A mesh is in the frustum if its bounding box intersects the frustum
  26383. * @param frustumPlanes defines the frustum to test
  26384. * @returns true if the mesh is in the frustum planes
  26385. */
  26386. isInFrustum(frustumPlanes: Plane[]): boolean;
  26387. /**
  26388. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26389. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26390. * @param frustumPlanes defines the frustum to test
  26391. * @returns true if the mesh is completely in the frustum planes
  26392. */
  26393. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26394. /**
  26395. * True if the mesh intersects another mesh or a SolidParticle object
  26396. * @param mesh defines a target mesh or SolidParticle to test
  26397. * @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)
  26398. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26399. * @returns true if there is an intersection
  26400. */
  26401. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26402. /**
  26403. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26404. * @param point defines the point to test
  26405. * @returns true if there is an intersection
  26406. */
  26407. intersectsPoint(point: Vector3): boolean;
  26408. /**
  26409. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26410. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26411. */
  26412. checkCollisions: boolean;
  26413. /**
  26414. * Gets Collider object used to compute collisions (not physics)
  26415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26416. */
  26417. readonly collider: Nullable<Collider>;
  26418. /**
  26419. * Move the mesh using collision engine
  26420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26421. * @param displacement defines the requested displacement vector
  26422. * @returns the current mesh
  26423. */
  26424. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26425. private _onCollisionPositionChange;
  26426. /** @hidden */
  26427. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26428. /** @hidden */
  26429. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26430. /** @hidden */
  26431. _checkCollision(collider: Collider): AbstractMesh;
  26432. /** @hidden */
  26433. _generatePointsArray(): boolean;
  26434. /**
  26435. * Checks if the passed Ray intersects with the mesh
  26436. * @param ray defines the ray to use
  26437. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26438. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26439. * @returns the picking info
  26440. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26441. */
  26442. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26443. /**
  26444. * Clones the current mesh
  26445. * @param name defines the mesh name
  26446. * @param newParent defines the new mesh parent
  26447. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26448. * @returns the new mesh
  26449. */
  26450. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26451. /**
  26452. * Disposes all the submeshes of the current meshnp
  26453. * @returns the current mesh
  26454. */
  26455. releaseSubMeshes(): AbstractMesh;
  26456. /**
  26457. * Releases resources associated with this abstract mesh.
  26458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26460. */
  26461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26462. /**
  26463. * Adds the passed mesh as a child to the current mesh
  26464. * @param mesh defines the child mesh
  26465. * @returns the current mesh
  26466. */
  26467. addChild(mesh: AbstractMesh): AbstractMesh;
  26468. /**
  26469. * Removes the passed mesh from the current mesh children list
  26470. * @param mesh defines the child mesh
  26471. * @returns the current mesh
  26472. */
  26473. removeChild(mesh: AbstractMesh): AbstractMesh;
  26474. /** @hidden */
  26475. private _initFacetData;
  26476. /**
  26477. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26478. * This method can be called within the render loop.
  26479. * 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
  26480. * @returns the current mesh
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26482. */
  26483. updateFacetData(): AbstractMesh;
  26484. /**
  26485. * Returns the facetLocalNormals array.
  26486. * The normals are expressed in the mesh local spac
  26487. * @returns an array of Vector3
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26489. */
  26490. getFacetLocalNormals(): Vector3[];
  26491. /**
  26492. * Returns the facetLocalPositions array.
  26493. * The facet positions are expressed in the mesh local space
  26494. * @returns an array of Vector3
  26495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26496. */
  26497. getFacetLocalPositions(): Vector3[];
  26498. /**
  26499. * Returns the facetLocalPartioning array
  26500. * @returns an array of array of numbers
  26501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26502. */
  26503. getFacetLocalPartitioning(): number[][];
  26504. /**
  26505. * Returns the i-th facet position in the world system.
  26506. * This method allocates a new Vector3 per call
  26507. * @param i defines the facet index
  26508. * @returns a new Vector3
  26509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26510. */
  26511. getFacetPosition(i: number): Vector3;
  26512. /**
  26513. * Sets the reference Vector3 with the i-th facet position in the world system
  26514. * @param i defines the facet index
  26515. * @param ref defines the target vector
  26516. * @returns the current mesh
  26517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26518. */
  26519. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26520. /**
  26521. * Returns the i-th facet normal in the world system.
  26522. * This method allocates a new Vector3 per call
  26523. * @param i defines the facet index
  26524. * @returns a new Vector3
  26525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26526. */
  26527. getFacetNormal(i: number): Vector3;
  26528. /**
  26529. * Sets the reference Vector3 with the i-th facet normal in the world system
  26530. * @param i defines the facet index
  26531. * @param ref defines the target vector
  26532. * @returns the current mesh
  26533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26534. */
  26535. getFacetNormalToRef(i: number, ref: Vector3): this;
  26536. /**
  26537. * 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)
  26538. * @param x defines x coordinate
  26539. * @param y defines y coordinate
  26540. * @param z defines z coordinate
  26541. * @returns the array of facet indexes
  26542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26543. */
  26544. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26545. /**
  26546. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26547. * @param projected sets as the (x,y,z) world projection on the facet
  26548. * @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
  26549. * @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
  26550. * @param x defines x coordinate
  26551. * @param y defines y coordinate
  26552. * @param z defines z coordinate
  26553. * @returns the face index if found (or null instead)
  26554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26555. */
  26556. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26557. /**
  26558. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26559. * @param projected sets as the (x,y,z) local projection on the facet
  26560. * @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
  26561. * @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
  26562. * @param x defines x coordinate
  26563. * @param y defines y coordinate
  26564. * @param z defines z coordinate
  26565. * @returns the face index if found (or null instead)
  26566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26567. */
  26568. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26569. /**
  26570. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26571. * @returns the parameters
  26572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26573. */
  26574. getFacetDataParameters(): any;
  26575. /**
  26576. * Disables the feature FacetData and frees the related memory
  26577. * @returns the current mesh
  26578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26579. */
  26580. disableFacetData(): AbstractMesh;
  26581. /**
  26582. * Updates the AbstractMesh indices array
  26583. * @param indices defines the data source
  26584. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26585. * @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)
  26586. * @returns the current mesh
  26587. */
  26588. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26589. /**
  26590. * Creates new normals data for the mesh
  26591. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26592. * @returns the current mesh
  26593. */
  26594. createNormals(updatable: boolean): AbstractMesh;
  26595. /**
  26596. * Align the mesh with a normal
  26597. * @param normal defines the normal to use
  26598. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26599. * @returns the current mesh
  26600. */
  26601. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26602. /** @hidden */
  26603. _checkOcclusionQuery(): boolean;
  26604. /**
  26605. * Disables the mesh edge rendering mode
  26606. * @returns the currentAbstractMesh
  26607. */
  26608. disableEdgesRendering(): AbstractMesh;
  26609. /**
  26610. * Enables the edge rendering mode on the mesh.
  26611. * This mode makes the mesh edges visible
  26612. * @param epsilon defines the maximal distance between two angles to detect a face
  26613. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26614. * @returns the currentAbstractMesh
  26615. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26616. */
  26617. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26618. }
  26619. }
  26620. declare module BABYLON {
  26621. /**
  26622. * Interface used to define ActionEvent
  26623. */
  26624. export interface IActionEvent {
  26625. /** The mesh or sprite that triggered the action */
  26626. source: any;
  26627. /** The X mouse cursor position at the time of the event */
  26628. pointerX: number;
  26629. /** The Y mouse cursor position at the time of the event */
  26630. pointerY: number;
  26631. /** The mesh that is currently pointed at (can be null) */
  26632. meshUnderPointer: Nullable<AbstractMesh>;
  26633. /** the original (browser) event that triggered the ActionEvent */
  26634. sourceEvent?: any;
  26635. /** additional data for the event */
  26636. additionalData?: any;
  26637. }
  26638. /**
  26639. * ActionEvent is the event being sent when an action is triggered.
  26640. */
  26641. export class ActionEvent implements IActionEvent {
  26642. /** The mesh or sprite that triggered the action */
  26643. source: any;
  26644. /** The X mouse cursor position at the time of the event */
  26645. pointerX: number;
  26646. /** The Y mouse cursor position at the time of the event */
  26647. pointerY: number;
  26648. /** The mesh that is currently pointed at (can be null) */
  26649. meshUnderPointer: Nullable<AbstractMesh>;
  26650. /** the original (browser) event that triggered the ActionEvent */
  26651. sourceEvent?: any;
  26652. /** additional data for the event */
  26653. additionalData?: any;
  26654. /**
  26655. * Creates a new ActionEvent
  26656. * @param source The mesh or sprite that triggered the action
  26657. * @param pointerX The X mouse cursor position at the time of the event
  26658. * @param pointerY The Y mouse cursor position at the time of the event
  26659. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26660. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26661. * @param additionalData additional data for the event
  26662. */
  26663. constructor(
  26664. /** The mesh or sprite that triggered the action */
  26665. source: any,
  26666. /** The X mouse cursor position at the time of the event */
  26667. pointerX: number,
  26668. /** The Y mouse cursor position at the time of the event */
  26669. pointerY: number,
  26670. /** The mesh that is currently pointed at (can be null) */
  26671. meshUnderPointer: Nullable<AbstractMesh>,
  26672. /** the original (browser) event that triggered the ActionEvent */
  26673. sourceEvent?: any,
  26674. /** additional data for the event */
  26675. additionalData?: any);
  26676. /**
  26677. * Helper function to auto-create an ActionEvent from a source mesh.
  26678. * @param source The source mesh that triggered the event
  26679. * @param evt The original (browser) event
  26680. * @param additionalData additional data for the event
  26681. * @returns the new ActionEvent
  26682. */
  26683. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26684. /**
  26685. * Helper function to auto-create an ActionEvent from a source sprite
  26686. * @param source The source sprite that triggered the event
  26687. * @param scene Scene associated with the sprite
  26688. * @param evt The original (browser) event
  26689. * @param additionalData additional data for the event
  26690. * @returns the new ActionEvent
  26691. */
  26692. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26693. /**
  26694. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26695. * @param scene the scene where the event occurred
  26696. * @param evt The original (browser) event
  26697. * @returns the new ActionEvent
  26698. */
  26699. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26700. /**
  26701. * Helper function to auto-create an ActionEvent from a primitive
  26702. * @param prim defines the target primitive
  26703. * @param pointerPos defines the pointer position
  26704. * @param evt The original (browser) event
  26705. * @param additionalData additional data for the event
  26706. * @returns the new ActionEvent
  26707. */
  26708. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26709. }
  26710. }
  26711. declare module BABYLON {
  26712. /**
  26713. * Abstract class used to decouple action Manager from scene and meshes.
  26714. * Do not instantiate.
  26715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26716. */
  26717. export abstract class AbstractActionManager implements IDisposable {
  26718. /** Gets the list of active triggers */
  26719. static Triggers: {
  26720. [key: string]: number;
  26721. };
  26722. /** Gets the cursor to use when hovering items */
  26723. hoverCursor: string;
  26724. /** Gets the list of actions */
  26725. actions: IAction[];
  26726. /**
  26727. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26728. */
  26729. isRecursive: boolean;
  26730. /**
  26731. * Releases all associated resources
  26732. */
  26733. abstract dispose(): void;
  26734. /**
  26735. * Does this action manager has pointer triggers
  26736. */
  26737. abstract readonly hasPointerTriggers: boolean;
  26738. /**
  26739. * Does this action manager has pick triggers
  26740. */
  26741. abstract readonly hasPickTriggers: boolean;
  26742. /**
  26743. * Process a specific trigger
  26744. * @param trigger defines the trigger to process
  26745. * @param evt defines the event details to be processed
  26746. */
  26747. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26748. /**
  26749. * Does this action manager handles actions of any of the given triggers
  26750. * @param triggers defines the triggers to be tested
  26751. * @return a boolean indicating whether one (or more) of the triggers is handled
  26752. */
  26753. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26754. /**
  26755. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26756. * speed.
  26757. * @param triggerA defines the trigger to be tested
  26758. * @param triggerB defines the trigger to be tested
  26759. * @return a boolean indicating whether one (or more) of the triggers is handled
  26760. */
  26761. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26762. /**
  26763. * Does this action manager handles actions of a given trigger
  26764. * @param trigger defines the trigger to be tested
  26765. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26766. * @return whether the trigger is handled
  26767. */
  26768. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26769. /**
  26770. * Serialize this manager to a JSON object
  26771. * @param name defines the property name to store this manager
  26772. * @returns a JSON representation of this manager
  26773. */
  26774. abstract serialize(name: string): any;
  26775. /**
  26776. * Registers an action to this action manager
  26777. * @param action defines the action to be registered
  26778. * @return the action amended (prepared) after registration
  26779. */
  26780. abstract registerAction(action: IAction): Nullable<IAction>;
  26781. /**
  26782. * Unregisters an action to this action manager
  26783. * @param action defines the action to be unregistered
  26784. * @return a boolean indicating whether the action has been unregistered
  26785. */
  26786. abstract unregisterAction(action: IAction): Boolean;
  26787. /**
  26788. * Does exist one action manager with at least one trigger
  26789. **/
  26790. static readonly HasTriggers: boolean;
  26791. /**
  26792. * Does exist one action manager with at least one pick trigger
  26793. **/
  26794. static readonly HasPickTriggers: boolean;
  26795. /**
  26796. * Does exist one action manager that handles actions of a given trigger
  26797. * @param trigger defines the trigger to be tested
  26798. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26799. **/
  26800. static HasSpecificTrigger(trigger: number): boolean;
  26801. }
  26802. }
  26803. declare module BABYLON {
  26804. /**
  26805. * Defines how a node can be built from a string name.
  26806. */
  26807. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26808. /**
  26809. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26810. */
  26811. export class Node implements IBehaviorAware<Node> {
  26812. /** @hidden */
  26813. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26814. private static _NodeConstructors;
  26815. /**
  26816. * Add a new node constructor
  26817. * @param type defines the type name of the node to construct
  26818. * @param constructorFunc defines the constructor function
  26819. */
  26820. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26821. /**
  26822. * Returns a node constructor based on type name
  26823. * @param type defines the type name
  26824. * @param name defines the new node name
  26825. * @param scene defines the hosting scene
  26826. * @param options defines optional options to transmit to constructors
  26827. * @returns the new constructor or null
  26828. */
  26829. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26830. /**
  26831. * Gets or sets the name of the node
  26832. */
  26833. name: string;
  26834. /**
  26835. * Gets or sets the id of the node
  26836. */
  26837. id: string;
  26838. /**
  26839. * Gets or sets the unique id of the node
  26840. */
  26841. uniqueId: number;
  26842. /**
  26843. * Gets or sets a string used to store user defined state for the node
  26844. */
  26845. state: string;
  26846. /**
  26847. * Gets or sets an object used to store user defined information for the node
  26848. */
  26849. metadata: any;
  26850. /**
  26851. * For internal use only. Please do not use.
  26852. */
  26853. reservedDataStore: any;
  26854. /**
  26855. * List of inspectable custom properties (used by the Inspector)
  26856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26857. */
  26858. inspectableCustomProperties: IInspectable[];
  26859. private _doNotSerialize;
  26860. /**
  26861. * Gets or sets a boolean used to define if the node must be serialized
  26862. */
  26863. doNotSerialize: boolean;
  26864. /** @hidden */
  26865. _isDisposed: boolean;
  26866. /**
  26867. * Gets a list of Animations associated with the node
  26868. */
  26869. animations: Animation[];
  26870. protected _ranges: {
  26871. [name: string]: Nullable<AnimationRange>;
  26872. };
  26873. /**
  26874. * Callback raised when the node is ready to be used
  26875. */
  26876. onReady: Nullable<(node: Node) => void>;
  26877. private _isEnabled;
  26878. private _isParentEnabled;
  26879. private _isReady;
  26880. /** @hidden */
  26881. _currentRenderId: number;
  26882. private _parentUpdateId;
  26883. /** @hidden */
  26884. _childUpdateId: number;
  26885. /** @hidden */
  26886. _waitingParentId: Nullable<string>;
  26887. /** @hidden */
  26888. _scene: Scene;
  26889. /** @hidden */
  26890. _cache: any;
  26891. private _parentNode;
  26892. private _children;
  26893. /** @hidden */
  26894. _worldMatrix: Matrix;
  26895. /** @hidden */
  26896. _worldMatrixDeterminant: number;
  26897. /** @hidden */
  26898. _worldMatrixDeterminantIsDirty: boolean;
  26899. /** @hidden */
  26900. private _sceneRootNodesIndex;
  26901. /**
  26902. * Gets a boolean indicating if the node has been disposed
  26903. * @returns true if the node was disposed
  26904. */
  26905. isDisposed(): boolean;
  26906. /**
  26907. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26908. * @see https://doc.babylonjs.com/how_to/parenting
  26909. */
  26910. parent: Nullable<Node>;
  26911. private addToSceneRootNodes;
  26912. private removeFromSceneRootNodes;
  26913. private _animationPropertiesOverride;
  26914. /**
  26915. * Gets or sets the animation properties override
  26916. */
  26917. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26918. /**
  26919. * Gets a string idenfifying the name of the class
  26920. * @returns "Node" string
  26921. */
  26922. getClassName(): string;
  26923. /** @hidden */
  26924. readonly _isNode: boolean;
  26925. /**
  26926. * An event triggered when the mesh is disposed
  26927. */
  26928. onDisposeObservable: Observable<Node>;
  26929. private _onDisposeObserver;
  26930. /**
  26931. * Sets a callback that will be raised when the node will be disposed
  26932. */
  26933. onDispose: () => void;
  26934. /**
  26935. * Creates a new Node
  26936. * @param name the name and id to be given to this node
  26937. * @param scene the scene this node will be added to
  26938. * @param addToRootNodes the node will be added to scene.rootNodes
  26939. */
  26940. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26941. /**
  26942. * Gets the scene of the node
  26943. * @returns a scene
  26944. */
  26945. getScene(): Scene;
  26946. /**
  26947. * Gets the engine of the node
  26948. * @returns a Engine
  26949. */
  26950. getEngine(): Engine;
  26951. private _behaviors;
  26952. /**
  26953. * Attach a behavior to the node
  26954. * @see http://doc.babylonjs.com/features/behaviour
  26955. * @param behavior defines the behavior to attach
  26956. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26957. * @returns the current Node
  26958. */
  26959. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26960. /**
  26961. * Remove an attached behavior
  26962. * @see http://doc.babylonjs.com/features/behaviour
  26963. * @param behavior defines the behavior to attach
  26964. * @returns the current Node
  26965. */
  26966. removeBehavior(behavior: Behavior<Node>): Node;
  26967. /**
  26968. * Gets the list of attached behaviors
  26969. * @see http://doc.babylonjs.com/features/behaviour
  26970. */
  26971. readonly behaviors: Behavior<Node>[];
  26972. /**
  26973. * Gets an attached behavior by name
  26974. * @param name defines the name of the behavior to look for
  26975. * @see http://doc.babylonjs.com/features/behaviour
  26976. * @returns null if behavior was not found else the requested behavior
  26977. */
  26978. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26979. /**
  26980. * Returns the latest update of the World matrix
  26981. * @returns a Matrix
  26982. */
  26983. getWorldMatrix(): Matrix;
  26984. /** @hidden */
  26985. _getWorldMatrixDeterminant(): number;
  26986. /**
  26987. * Returns directly the latest state of the mesh World matrix.
  26988. * A Matrix is returned.
  26989. */
  26990. readonly worldMatrixFromCache: Matrix;
  26991. /** @hidden */
  26992. _initCache(): void;
  26993. /** @hidden */
  26994. updateCache(force?: boolean): void;
  26995. /** @hidden */
  26996. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26997. /** @hidden */
  26998. _updateCache(ignoreParentClass?: boolean): void;
  26999. /** @hidden */
  27000. _isSynchronized(): boolean;
  27001. /** @hidden */
  27002. _markSyncedWithParent(): void;
  27003. /** @hidden */
  27004. isSynchronizedWithParent(): boolean;
  27005. /** @hidden */
  27006. isSynchronized(): boolean;
  27007. /**
  27008. * Is this node ready to be used/rendered
  27009. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27010. * @return true if the node is ready
  27011. */
  27012. isReady(completeCheck?: boolean): boolean;
  27013. /**
  27014. * Is this node enabled?
  27015. * 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
  27016. * @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
  27017. * @return whether this node (and its parent) is enabled
  27018. */
  27019. isEnabled(checkAncestors?: boolean): boolean;
  27020. /** @hidden */
  27021. protected _syncParentEnabledState(): void;
  27022. /**
  27023. * Set the enabled state of this node
  27024. * @param value defines the new enabled state
  27025. */
  27026. setEnabled(value: boolean): void;
  27027. /**
  27028. * Is this node a descendant of the given node?
  27029. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27030. * @param ancestor defines the parent node to inspect
  27031. * @returns a boolean indicating if this node is a descendant of the given node
  27032. */
  27033. isDescendantOf(ancestor: Node): boolean;
  27034. /** @hidden */
  27035. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27036. /**
  27037. * Will return all nodes that have this node as ascendant
  27038. * @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
  27039. * @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
  27040. * @return all children nodes of all types
  27041. */
  27042. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27043. /**
  27044. * Get all child-meshes of this node
  27045. * @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)
  27046. * @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
  27047. * @returns an array of AbstractMesh
  27048. */
  27049. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27050. /**
  27051. * Get all direct children of this node
  27052. * @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
  27053. * @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)
  27054. * @returns an array of Node
  27055. */
  27056. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27057. /** @hidden */
  27058. _setReady(state: boolean): void;
  27059. /**
  27060. * Get an animation by name
  27061. * @param name defines the name of the animation to look for
  27062. * @returns null if not found else the requested animation
  27063. */
  27064. getAnimationByName(name: string): Nullable<Animation>;
  27065. /**
  27066. * Creates an animation range for this node
  27067. * @param name defines the name of the range
  27068. * @param from defines the starting key
  27069. * @param to defines the end key
  27070. */
  27071. createAnimationRange(name: string, from: number, to: number): void;
  27072. /**
  27073. * Delete a specific animation range
  27074. * @param name defines the name of the range to delete
  27075. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27076. */
  27077. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27078. /**
  27079. * Get an animation range by name
  27080. * @param name defines the name of the animation range to look for
  27081. * @returns null if not found else the requested animation range
  27082. */
  27083. getAnimationRange(name: string): Nullable<AnimationRange>;
  27084. /**
  27085. * Gets the list of all animation ranges defined on this node
  27086. * @returns an array
  27087. */
  27088. getAnimationRanges(): Nullable<AnimationRange>[];
  27089. /**
  27090. * Will start the animation sequence
  27091. * @param name defines the range frames for animation sequence
  27092. * @param loop defines if the animation should loop (false by default)
  27093. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27094. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27095. * @returns the object created for this animation. If range does not exist, it will return null
  27096. */
  27097. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27098. /**
  27099. * Serialize animation ranges into a JSON compatible object
  27100. * @returns serialization object
  27101. */
  27102. serializeAnimationRanges(): any;
  27103. /**
  27104. * Computes the world matrix of the node
  27105. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27106. * @returns the world matrix
  27107. */
  27108. computeWorldMatrix(force?: boolean): Matrix;
  27109. /**
  27110. * Releases resources associated with this node.
  27111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27113. */
  27114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27115. /**
  27116. * Parse animation range data from a serialization object and store them into a given node
  27117. * @param node defines where to store the animation ranges
  27118. * @param parsedNode defines the serialization object to read data from
  27119. * @param scene defines the hosting scene
  27120. */
  27121. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27122. /**
  27123. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27124. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27125. * @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
  27126. * @returns the new bounding vectors
  27127. */
  27128. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27129. min: Vector3;
  27130. max: Vector3;
  27131. };
  27132. }
  27133. }
  27134. declare module BABYLON {
  27135. /**
  27136. * @hidden
  27137. */
  27138. export class _IAnimationState {
  27139. key: number;
  27140. repeatCount: number;
  27141. workValue?: any;
  27142. loopMode?: number;
  27143. offsetValue?: any;
  27144. highLimitValue?: any;
  27145. }
  27146. /**
  27147. * Class used to store any kind of animation
  27148. */
  27149. export class Animation {
  27150. /**Name of the animation */
  27151. name: string;
  27152. /**Property to animate */
  27153. targetProperty: string;
  27154. /**The frames per second of the animation */
  27155. framePerSecond: number;
  27156. /**The data type of the animation */
  27157. dataType: number;
  27158. /**The loop mode of the animation */
  27159. loopMode?: number | undefined;
  27160. /**Specifies if blending should be enabled */
  27161. enableBlending?: boolean | undefined;
  27162. /**
  27163. * Use matrix interpolation instead of using direct key value when animating matrices
  27164. */
  27165. static AllowMatricesInterpolation: boolean;
  27166. /**
  27167. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27168. */
  27169. static AllowMatrixDecomposeForInterpolation: boolean;
  27170. /**
  27171. * Stores the key frames of the animation
  27172. */
  27173. private _keys;
  27174. /**
  27175. * Stores the easing function of the animation
  27176. */
  27177. private _easingFunction;
  27178. /**
  27179. * @hidden Internal use only
  27180. */
  27181. _runtimeAnimations: RuntimeAnimation[];
  27182. /**
  27183. * The set of event that will be linked to this animation
  27184. */
  27185. private _events;
  27186. /**
  27187. * Stores an array of target property paths
  27188. */
  27189. targetPropertyPath: string[];
  27190. /**
  27191. * Stores the blending speed of the animation
  27192. */
  27193. blendingSpeed: number;
  27194. /**
  27195. * Stores the animation ranges for the animation
  27196. */
  27197. private _ranges;
  27198. /**
  27199. * @hidden Internal use
  27200. */
  27201. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27202. /**
  27203. * Sets up an animation
  27204. * @param property The property to animate
  27205. * @param animationType The animation type to apply
  27206. * @param framePerSecond The frames per second of the animation
  27207. * @param easingFunction The easing function used in the animation
  27208. * @returns The created animation
  27209. */
  27210. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27211. /**
  27212. * Create and start an animation on a node
  27213. * @param name defines the name of the global animation that will be run on all nodes
  27214. * @param node defines the root node where the animation will take place
  27215. * @param targetProperty defines property to animate
  27216. * @param framePerSecond defines the number of frame per second yo use
  27217. * @param totalFrame defines the number of frames in total
  27218. * @param from defines the initial value
  27219. * @param to defines the final value
  27220. * @param loopMode defines which loop mode you want to use (off by default)
  27221. * @param easingFunction defines the easing function to use (linear by default)
  27222. * @param onAnimationEnd defines the callback to call when animation end
  27223. * @returns the animatable created for this animation
  27224. */
  27225. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27226. /**
  27227. * Create and start an animation on a node and its descendants
  27228. * @param name defines the name of the global animation that will be run on all nodes
  27229. * @param node defines the root node where the animation will take place
  27230. * @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
  27231. * @param targetProperty defines property to animate
  27232. * @param framePerSecond defines the number of frame per second to use
  27233. * @param totalFrame defines the number of frames in total
  27234. * @param from defines the initial value
  27235. * @param to defines the final value
  27236. * @param loopMode defines which loop mode you want to use (off by default)
  27237. * @param easingFunction defines the easing function to use (linear by default)
  27238. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27239. * @returns the list of animatables created for all nodes
  27240. * @example https://www.babylonjs-playground.com/#MH0VLI
  27241. */
  27242. 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[]>;
  27243. /**
  27244. * Creates a new animation, merges it with the existing animations and starts it
  27245. * @param name Name of the animation
  27246. * @param node Node which contains the scene that begins the animations
  27247. * @param targetProperty Specifies which property to animate
  27248. * @param framePerSecond The frames per second of the animation
  27249. * @param totalFrame The total number of frames
  27250. * @param from The frame at the beginning of the animation
  27251. * @param to The frame at the end of the animation
  27252. * @param loopMode Specifies the loop mode of the animation
  27253. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27254. * @param onAnimationEnd Callback to run once the animation is complete
  27255. * @returns Nullable animation
  27256. */
  27257. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27258. /**
  27259. * Transition property of an host to the target Value
  27260. * @param property The property to transition
  27261. * @param targetValue The target Value of the property
  27262. * @param host The object where the property to animate belongs
  27263. * @param scene Scene used to run the animation
  27264. * @param frameRate Framerate (in frame/s) to use
  27265. * @param transition The transition type we want to use
  27266. * @param duration The duration of the animation, in milliseconds
  27267. * @param onAnimationEnd Callback trigger at the end of the animation
  27268. * @returns Nullable animation
  27269. */
  27270. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27271. /**
  27272. * Return the array of runtime animations currently using this animation
  27273. */
  27274. readonly runtimeAnimations: RuntimeAnimation[];
  27275. /**
  27276. * Specifies if any of the runtime animations are currently running
  27277. */
  27278. readonly hasRunningRuntimeAnimations: boolean;
  27279. /**
  27280. * Initializes the animation
  27281. * @param name Name of the animation
  27282. * @param targetProperty Property to animate
  27283. * @param framePerSecond The frames per second of the animation
  27284. * @param dataType The data type of the animation
  27285. * @param loopMode The loop mode of the animation
  27286. * @param enableBlending Specifies if blending should be enabled
  27287. */
  27288. constructor(
  27289. /**Name of the animation */
  27290. name: string,
  27291. /**Property to animate */
  27292. targetProperty: string,
  27293. /**The frames per second of the animation */
  27294. framePerSecond: number,
  27295. /**The data type of the animation */
  27296. dataType: number,
  27297. /**The loop mode of the animation */
  27298. loopMode?: number | undefined,
  27299. /**Specifies if blending should be enabled */
  27300. enableBlending?: boolean | undefined);
  27301. /**
  27302. * Converts the animation to a string
  27303. * @param fullDetails support for multiple levels of logging within scene loading
  27304. * @returns String form of the animation
  27305. */
  27306. toString(fullDetails?: boolean): string;
  27307. /**
  27308. * Add an event to this animation
  27309. * @param event Event to add
  27310. */
  27311. addEvent(event: AnimationEvent): void;
  27312. /**
  27313. * Remove all events found at the given frame
  27314. * @param frame The frame to remove events from
  27315. */
  27316. removeEvents(frame: number): void;
  27317. /**
  27318. * Retrieves all the events from the animation
  27319. * @returns Events from the animation
  27320. */
  27321. getEvents(): AnimationEvent[];
  27322. /**
  27323. * Creates an animation range
  27324. * @param name Name of the animation range
  27325. * @param from Starting frame of the animation range
  27326. * @param to Ending frame of the animation
  27327. */
  27328. createRange(name: string, from: number, to: number): void;
  27329. /**
  27330. * Deletes an animation range by name
  27331. * @param name Name of the animation range to delete
  27332. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27333. */
  27334. deleteRange(name: string, deleteFrames?: boolean): void;
  27335. /**
  27336. * Gets the animation range by name, or null if not defined
  27337. * @param name Name of the animation range
  27338. * @returns Nullable animation range
  27339. */
  27340. getRange(name: string): Nullable<AnimationRange>;
  27341. /**
  27342. * Gets the key frames from the animation
  27343. * @returns The key frames of the animation
  27344. */
  27345. getKeys(): Array<IAnimationKey>;
  27346. /**
  27347. * Gets the highest frame rate of the animation
  27348. * @returns Highest frame rate of the animation
  27349. */
  27350. getHighestFrame(): number;
  27351. /**
  27352. * Gets the easing function of the animation
  27353. * @returns Easing function of the animation
  27354. */
  27355. getEasingFunction(): IEasingFunction;
  27356. /**
  27357. * Sets the easing function of the animation
  27358. * @param easingFunction A custom mathematical formula for animation
  27359. */
  27360. setEasingFunction(easingFunction: EasingFunction): void;
  27361. /**
  27362. * Interpolates a scalar linearly
  27363. * @param startValue Start value of the animation curve
  27364. * @param endValue End value of the animation curve
  27365. * @param gradient Scalar amount to interpolate
  27366. * @returns Interpolated scalar value
  27367. */
  27368. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27369. /**
  27370. * Interpolates a scalar cubically
  27371. * @param startValue Start value of the animation curve
  27372. * @param outTangent End tangent of the animation
  27373. * @param endValue End value of the animation curve
  27374. * @param inTangent Start tangent of the animation curve
  27375. * @param gradient Scalar amount to interpolate
  27376. * @returns Interpolated scalar value
  27377. */
  27378. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27379. /**
  27380. * Interpolates a quaternion using a spherical linear interpolation
  27381. * @param startValue Start value of the animation curve
  27382. * @param endValue End value of the animation curve
  27383. * @param gradient Scalar amount to interpolate
  27384. * @returns Interpolated quaternion value
  27385. */
  27386. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27387. /**
  27388. * Interpolates a quaternion cubically
  27389. * @param startValue Start value of the animation curve
  27390. * @param outTangent End tangent of the animation curve
  27391. * @param endValue End value of the animation curve
  27392. * @param inTangent Start tangent of the animation curve
  27393. * @param gradient Scalar amount to interpolate
  27394. * @returns Interpolated quaternion value
  27395. */
  27396. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27397. /**
  27398. * Interpolates a Vector3 linearl
  27399. * @param startValue Start value of the animation curve
  27400. * @param endValue End value of the animation curve
  27401. * @param gradient Scalar amount to interpolate
  27402. * @returns Interpolated scalar value
  27403. */
  27404. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27405. /**
  27406. * Interpolates a Vector3 cubically
  27407. * @param startValue Start value of the animation curve
  27408. * @param outTangent End tangent of the animation
  27409. * @param endValue End value of the animation curve
  27410. * @param inTangent Start tangent of the animation curve
  27411. * @param gradient Scalar amount to interpolate
  27412. * @returns InterpolatedVector3 value
  27413. */
  27414. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27415. /**
  27416. * Interpolates a Vector2 linearly
  27417. * @param startValue Start value of the animation curve
  27418. * @param endValue End value of the animation curve
  27419. * @param gradient Scalar amount to interpolate
  27420. * @returns Interpolated Vector2 value
  27421. */
  27422. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27423. /**
  27424. * Interpolates a Vector2 cubically
  27425. * @param startValue Start value of the animation curve
  27426. * @param outTangent End tangent of the animation
  27427. * @param endValue End value of the animation curve
  27428. * @param inTangent Start tangent of the animation curve
  27429. * @param gradient Scalar amount to interpolate
  27430. * @returns Interpolated Vector2 value
  27431. */
  27432. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27433. /**
  27434. * Interpolates a size linearly
  27435. * @param startValue Start value of the animation curve
  27436. * @param endValue End value of the animation curve
  27437. * @param gradient Scalar amount to interpolate
  27438. * @returns Interpolated Size value
  27439. */
  27440. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27441. /**
  27442. * Interpolates a Color3 linearly
  27443. * @param startValue Start value of the animation curve
  27444. * @param endValue End value of the animation curve
  27445. * @param gradient Scalar amount to interpolate
  27446. * @returns Interpolated Color3 value
  27447. */
  27448. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27449. /**
  27450. * @hidden Internal use only
  27451. */
  27452. _getKeyValue(value: any): any;
  27453. /**
  27454. * @hidden Internal use only
  27455. */
  27456. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27457. /**
  27458. * Defines the function to use to interpolate matrices
  27459. * @param startValue defines the start matrix
  27460. * @param endValue defines the end matrix
  27461. * @param gradient defines the gradient between both matrices
  27462. * @param result defines an optional target matrix where to store the interpolation
  27463. * @returns the interpolated matrix
  27464. */
  27465. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27466. /**
  27467. * Makes a copy of the animation
  27468. * @returns Cloned animation
  27469. */
  27470. clone(): Animation;
  27471. /**
  27472. * Sets the key frames of the animation
  27473. * @param values The animation key frames to set
  27474. */
  27475. setKeys(values: Array<IAnimationKey>): void;
  27476. /**
  27477. * Serializes the animation to an object
  27478. * @returns Serialized object
  27479. */
  27480. serialize(): any;
  27481. /**
  27482. * Float animation type
  27483. */
  27484. private static _ANIMATIONTYPE_FLOAT;
  27485. /**
  27486. * Vector3 animation type
  27487. */
  27488. private static _ANIMATIONTYPE_VECTOR3;
  27489. /**
  27490. * Quaternion animation type
  27491. */
  27492. private static _ANIMATIONTYPE_QUATERNION;
  27493. /**
  27494. * Matrix animation type
  27495. */
  27496. private static _ANIMATIONTYPE_MATRIX;
  27497. /**
  27498. * Color3 animation type
  27499. */
  27500. private static _ANIMATIONTYPE_COLOR3;
  27501. /**
  27502. * Vector2 animation type
  27503. */
  27504. private static _ANIMATIONTYPE_VECTOR2;
  27505. /**
  27506. * Size animation type
  27507. */
  27508. private static _ANIMATIONTYPE_SIZE;
  27509. /**
  27510. * Relative Loop Mode
  27511. */
  27512. private static _ANIMATIONLOOPMODE_RELATIVE;
  27513. /**
  27514. * Cycle Loop Mode
  27515. */
  27516. private static _ANIMATIONLOOPMODE_CYCLE;
  27517. /**
  27518. * Constant Loop Mode
  27519. */
  27520. private static _ANIMATIONLOOPMODE_CONSTANT;
  27521. /**
  27522. * Get the float animation type
  27523. */
  27524. static readonly ANIMATIONTYPE_FLOAT: number;
  27525. /**
  27526. * Get the Vector3 animation type
  27527. */
  27528. static readonly ANIMATIONTYPE_VECTOR3: number;
  27529. /**
  27530. * Get the Vector2 animation type
  27531. */
  27532. static readonly ANIMATIONTYPE_VECTOR2: number;
  27533. /**
  27534. * Get the Size animation type
  27535. */
  27536. static readonly ANIMATIONTYPE_SIZE: number;
  27537. /**
  27538. * Get the Quaternion animation type
  27539. */
  27540. static readonly ANIMATIONTYPE_QUATERNION: number;
  27541. /**
  27542. * Get the Matrix animation type
  27543. */
  27544. static readonly ANIMATIONTYPE_MATRIX: number;
  27545. /**
  27546. * Get the Color3 animation type
  27547. */
  27548. static readonly ANIMATIONTYPE_COLOR3: number;
  27549. /**
  27550. * Get the Relative Loop Mode
  27551. */
  27552. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27553. /**
  27554. * Get the Cycle Loop Mode
  27555. */
  27556. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27557. /**
  27558. * Get the Constant Loop Mode
  27559. */
  27560. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27561. /** @hidden */
  27562. static _UniversalLerp(left: any, right: any, amount: number): any;
  27563. /**
  27564. * Parses an animation object and creates an animation
  27565. * @param parsedAnimation Parsed animation object
  27566. * @returns Animation object
  27567. */
  27568. static Parse(parsedAnimation: any): Animation;
  27569. /**
  27570. * Appends the serialized animations from the source animations
  27571. * @param source Source containing the animations
  27572. * @param destination Target to store the animations
  27573. */
  27574. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27575. }
  27576. }
  27577. declare module BABYLON {
  27578. /**
  27579. * Interface containing an array of animations
  27580. */
  27581. export interface IAnimatable {
  27582. /**
  27583. * Array of animations
  27584. */
  27585. animations: Nullable<Array<Animation>>;
  27586. }
  27587. }
  27588. declare module BABYLON {
  27589. /**
  27590. * This represents all the required information to add a fresnel effect on a material:
  27591. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27592. */
  27593. export class FresnelParameters {
  27594. private _isEnabled;
  27595. /**
  27596. * Define if the fresnel effect is enable or not.
  27597. */
  27598. isEnabled: boolean;
  27599. /**
  27600. * Define the color used on edges (grazing angle)
  27601. */
  27602. leftColor: Color3;
  27603. /**
  27604. * Define the color used on center
  27605. */
  27606. rightColor: Color3;
  27607. /**
  27608. * Define bias applied to computed fresnel term
  27609. */
  27610. bias: number;
  27611. /**
  27612. * Defined the power exponent applied to fresnel term
  27613. */
  27614. power: number;
  27615. /**
  27616. * Clones the current fresnel and its valuues
  27617. * @returns a clone fresnel configuration
  27618. */
  27619. clone(): FresnelParameters;
  27620. /**
  27621. * Serializes the current fresnel parameters to a JSON representation.
  27622. * @return the JSON serialization
  27623. */
  27624. serialize(): any;
  27625. /**
  27626. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27627. * @param parsedFresnelParameters Define the JSON representation
  27628. * @returns the parsed parameters
  27629. */
  27630. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27631. }
  27632. }
  27633. declare module BABYLON {
  27634. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27635. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27636. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27637. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27638. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27639. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27640. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27641. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27642. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27643. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27644. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27645. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27646. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27647. /**
  27648. * Decorator used to define property that can be serialized as reference to a camera
  27649. * @param sourceName defines the name of the property to decorate
  27650. */
  27651. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27652. /**
  27653. * Class used to help serialization objects
  27654. */
  27655. export class SerializationHelper {
  27656. /** @hidden */
  27657. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27658. /** @hidden */
  27659. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27660. /** @hidden */
  27661. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27662. /** @hidden */
  27663. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27664. /**
  27665. * Appends the serialized animations from the source animations
  27666. * @param source Source containing the animations
  27667. * @param destination Target to store the animations
  27668. */
  27669. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27670. /**
  27671. * Static function used to serialized a specific entity
  27672. * @param entity defines the entity to serialize
  27673. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27674. * @returns a JSON compatible object representing the serialization of the entity
  27675. */
  27676. static Serialize<T>(entity: T, serializationObject?: any): any;
  27677. /**
  27678. * Creates a new entity from a serialization data object
  27679. * @param creationFunction defines a function used to instanciated the new entity
  27680. * @param source defines the source serialization data
  27681. * @param scene defines the hosting scene
  27682. * @param rootUrl defines the root url for resources
  27683. * @returns a new entity
  27684. */
  27685. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27686. /**
  27687. * Clones an object
  27688. * @param creationFunction defines the function used to instanciate the new object
  27689. * @param source defines the source object
  27690. * @returns the cloned object
  27691. */
  27692. static Clone<T>(creationFunction: () => T, source: T): T;
  27693. /**
  27694. * Instanciates a new object based on a source one (some data will be shared between both object)
  27695. * @param creationFunction defines the function used to instanciate the new object
  27696. * @param source defines the source object
  27697. * @returns the new object
  27698. */
  27699. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27700. }
  27701. }
  27702. declare module BABYLON {
  27703. /**
  27704. * Class used to manipulate GUIDs
  27705. */
  27706. export class GUID {
  27707. /**
  27708. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27709. * Be aware Math.random() could cause collisions, but:
  27710. * "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"
  27711. * @returns a pseudo random id
  27712. */
  27713. static RandomId(): string;
  27714. }
  27715. }
  27716. declare module BABYLON {
  27717. /**
  27718. * Base class of all the textures in babylon.
  27719. * It groups all the common properties the materials, post process, lights... might need
  27720. * in order to make a correct use of the texture.
  27721. */
  27722. export class BaseTexture implements IAnimatable {
  27723. /**
  27724. * Default anisotropic filtering level for the application.
  27725. * It is set to 4 as a good tradeoff between perf and quality.
  27726. */
  27727. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27728. /**
  27729. * Gets or sets the unique id of the texture
  27730. */
  27731. uniqueId: number;
  27732. /**
  27733. * Define the name of the texture.
  27734. */
  27735. name: string;
  27736. /**
  27737. * Gets or sets an object used to store user defined information.
  27738. */
  27739. metadata: any;
  27740. /**
  27741. * For internal use only. Please do not use.
  27742. */
  27743. reservedDataStore: any;
  27744. private _hasAlpha;
  27745. /**
  27746. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27747. */
  27748. hasAlpha: boolean;
  27749. /**
  27750. * Defines if the alpha value should be determined via the rgb values.
  27751. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27752. */
  27753. getAlphaFromRGB: boolean;
  27754. /**
  27755. * Intensity or strength of the texture.
  27756. * It is commonly used by materials to fine tune the intensity of the texture
  27757. */
  27758. level: number;
  27759. /**
  27760. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27761. * This is part of the texture as textures usually maps to one uv set.
  27762. */
  27763. coordinatesIndex: number;
  27764. private _coordinatesMode;
  27765. /**
  27766. * How a texture is mapped.
  27767. *
  27768. * | Value | Type | Description |
  27769. * | ----- | ----------------------------------- | ----------- |
  27770. * | 0 | EXPLICIT_MODE | |
  27771. * | 1 | SPHERICAL_MODE | |
  27772. * | 2 | PLANAR_MODE | |
  27773. * | 3 | CUBIC_MODE | |
  27774. * | 4 | PROJECTION_MODE | |
  27775. * | 5 | SKYBOX_MODE | |
  27776. * | 6 | INVCUBIC_MODE | |
  27777. * | 7 | EQUIRECTANGULAR_MODE | |
  27778. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27779. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27780. */
  27781. coordinatesMode: number;
  27782. /**
  27783. * | Value | Type | Description |
  27784. * | ----- | ------------------ | ----------- |
  27785. * | 0 | CLAMP_ADDRESSMODE | |
  27786. * | 1 | WRAP_ADDRESSMODE | |
  27787. * | 2 | MIRROR_ADDRESSMODE | |
  27788. */
  27789. wrapU: number;
  27790. /**
  27791. * | Value | Type | Description |
  27792. * | ----- | ------------------ | ----------- |
  27793. * | 0 | CLAMP_ADDRESSMODE | |
  27794. * | 1 | WRAP_ADDRESSMODE | |
  27795. * | 2 | MIRROR_ADDRESSMODE | |
  27796. */
  27797. wrapV: number;
  27798. /**
  27799. * | Value | Type | Description |
  27800. * | ----- | ------------------ | ----------- |
  27801. * | 0 | CLAMP_ADDRESSMODE | |
  27802. * | 1 | WRAP_ADDRESSMODE | |
  27803. * | 2 | MIRROR_ADDRESSMODE | |
  27804. */
  27805. wrapR: number;
  27806. /**
  27807. * With compliant hardware and browser (supporting anisotropic filtering)
  27808. * this defines the level of anisotropic filtering in the texture.
  27809. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27810. */
  27811. anisotropicFilteringLevel: number;
  27812. /**
  27813. * Define if the texture is a cube texture or if false a 2d texture.
  27814. */
  27815. isCube: boolean;
  27816. /**
  27817. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27818. */
  27819. is3D: boolean;
  27820. /**
  27821. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27822. * HDR texture are usually stored in linear space.
  27823. * This only impacts the PBR and Background materials
  27824. */
  27825. gammaSpace: boolean;
  27826. /**
  27827. * Gets or sets whether or not the texture contains RGBD data.
  27828. */
  27829. isRGBD: boolean;
  27830. /**
  27831. * Is Z inverted in the texture (useful in a cube texture).
  27832. */
  27833. invertZ: boolean;
  27834. /**
  27835. * Are mip maps generated for this texture or not.
  27836. */
  27837. readonly noMipmap: boolean;
  27838. /**
  27839. * @hidden
  27840. */
  27841. lodLevelInAlpha: boolean;
  27842. /**
  27843. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27844. */
  27845. lodGenerationOffset: number;
  27846. /**
  27847. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27848. */
  27849. lodGenerationScale: number;
  27850. /**
  27851. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27852. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27853. * average roughness values.
  27854. */
  27855. linearSpecularLOD: boolean;
  27856. /**
  27857. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27858. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27859. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27860. */
  27861. irradianceTexture: Nullable<BaseTexture>;
  27862. /**
  27863. * Define if the texture is a render target.
  27864. */
  27865. isRenderTarget: boolean;
  27866. /**
  27867. * Define the unique id of the texture in the scene.
  27868. */
  27869. readonly uid: string;
  27870. /**
  27871. * Return a string representation of the texture.
  27872. * @returns the texture as a string
  27873. */
  27874. toString(): string;
  27875. /**
  27876. * Get the class name of the texture.
  27877. * @returns "BaseTexture"
  27878. */
  27879. getClassName(): string;
  27880. /**
  27881. * Define the list of animation attached to the texture.
  27882. */
  27883. animations: Animation[];
  27884. /**
  27885. * An event triggered when the texture is disposed.
  27886. */
  27887. onDisposeObservable: Observable<BaseTexture>;
  27888. private _onDisposeObserver;
  27889. /**
  27890. * Callback triggered when the texture has been disposed.
  27891. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27892. */
  27893. onDispose: () => void;
  27894. /**
  27895. * Define the current state of the loading sequence when in delayed load mode.
  27896. */
  27897. delayLoadState: number;
  27898. private _scene;
  27899. /** @hidden */
  27900. _texture: Nullable<InternalTexture>;
  27901. private _uid;
  27902. /**
  27903. * Define if the texture is preventinga material to render or not.
  27904. * If not and the texture is not ready, the engine will use a default black texture instead.
  27905. */
  27906. readonly isBlocking: boolean;
  27907. /**
  27908. * Instantiates a new BaseTexture.
  27909. * Base class of all the textures in babylon.
  27910. * It groups all the common properties the materials, post process, lights... might need
  27911. * in order to make a correct use of the texture.
  27912. * @param scene Define the scene the texture blongs to
  27913. */
  27914. constructor(scene: Nullable<Scene>);
  27915. /**
  27916. * Get the scene the texture belongs to.
  27917. * @returns the scene or null if undefined
  27918. */
  27919. getScene(): Nullable<Scene>;
  27920. /**
  27921. * Get the texture transform matrix used to offset tile the texture for istance.
  27922. * @returns the transformation matrix
  27923. */
  27924. getTextureMatrix(): Matrix;
  27925. /**
  27926. * Get the texture reflection matrix used to rotate/transform the reflection.
  27927. * @returns the reflection matrix
  27928. */
  27929. getReflectionTextureMatrix(): Matrix;
  27930. /**
  27931. * Get the underlying lower level texture from Babylon.
  27932. * @returns the insternal texture
  27933. */
  27934. getInternalTexture(): Nullable<InternalTexture>;
  27935. /**
  27936. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27937. * @returns true if ready or not blocking
  27938. */
  27939. isReadyOrNotBlocking(): boolean;
  27940. /**
  27941. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27942. * @returns true if fully ready
  27943. */
  27944. isReady(): boolean;
  27945. private _cachedSize;
  27946. /**
  27947. * Get the size of the texture.
  27948. * @returns the texture size.
  27949. */
  27950. getSize(): ISize;
  27951. /**
  27952. * Get the base size of the texture.
  27953. * It can be different from the size if the texture has been resized for POT for instance
  27954. * @returns the base size
  27955. */
  27956. getBaseSize(): ISize;
  27957. /**
  27958. * Update the sampling mode of the texture.
  27959. * Default is Trilinear mode.
  27960. *
  27961. * | Value | Type | Description |
  27962. * | ----- | ------------------ | ----------- |
  27963. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27964. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27965. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27966. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27967. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27968. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27969. * | 7 | NEAREST_LINEAR | |
  27970. * | 8 | NEAREST_NEAREST | |
  27971. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27972. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27973. * | 11 | LINEAR_LINEAR | |
  27974. * | 12 | LINEAR_NEAREST | |
  27975. *
  27976. * > _mag_: magnification filter (close to the viewer)
  27977. * > _min_: minification filter (far from the viewer)
  27978. * > _mip_: filter used between mip map levels
  27979. *@param samplingMode Define the new sampling mode of the texture
  27980. */
  27981. updateSamplingMode(samplingMode: number): void;
  27982. /**
  27983. * Scales the texture if is `canRescale()`
  27984. * @param ratio the resize factor we want to use to rescale
  27985. */
  27986. scale(ratio: number): void;
  27987. /**
  27988. * Get if the texture can rescale.
  27989. */
  27990. readonly canRescale: boolean;
  27991. /** @hidden */
  27992. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27993. /** @hidden */
  27994. _rebuild(): void;
  27995. /**
  27996. * Triggers the load sequence in delayed load mode.
  27997. */
  27998. delayLoad(): void;
  27999. /**
  28000. * Clones the texture.
  28001. * @returns the cloned texture
  28002. */
  28003. clone(): Nullable<BaseTexture>;
  28004. /**
  28005. * Get the texture underlying type (INT, FLOAT...)
  28006. */
  28007. readonly textureType: number;
  28008. /**
  28009. * Get the texture underlying format (RGB, RGBA...)
  28010. */
  28011. readonly textureFormat: number;
  28012. /**
  28013. * Indicates that textures need to be re-calculated for all materials
  28014. */
  28015. protected _markAllSubMeshesAsTexturesDirty(): void;
  28016. /**
  28017. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28018. * This will returns an RGBA array buffer containing either in values (0-255) or
  28019. * float values (0-1) depending of the underlying buffer type.
  28020. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28021. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28022. * @param buffer defines a user defined buffer to fill with data (can be null)
  28023. * @returns The Array buffer containing the pixels data.
  28024. */
  28025. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28026. /**
  28027. * Release and destroy the underlying lower level texture aka internalTexture.
  28028. */
  28029. releaseInternalTexture(): void;
  28030. /** @hidden */
  28031. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28032. /** @hidden */
  28033. readonly _lodTextureMid: Nullable<BaseTexture>;
  28034. /** @hidden */
  28035. readonly _lodTextureLow: Nullable<BaseTexture>;
  28036. /**
  28037. * Dispose the texture and release its associated resources.
  28038. */
  28039. dispose(): void;
  28040. /**
  28041. * Serialize the texture into a JSON representation that can be parsed later on.
  28042. * @returns the JSON representation of the texture
  28043. */
  28044. serialize(): any;
  28045. /**
  28046. * Helper function to be called back once a list of texture contains only ready textures.
  28047. * @param textures Define the list of textures to wait for
  28048. * @param callback Define the callback triggered once the entire list will be ready
  28049. */
  28050. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28051. }
  28052. }
  28053. declare module BABYLON {
  28054. /**
  28055. * Options to be used when creating an effect.
  28056. */
  28057. export interface IEffectCreationOptions {
  28058. /**
  28059. * Atrributes that will be used in the shader.
  28060. */
  28061. attributes: string[];
  28062. /**
  28063. * Uniform varible names that will be set in the shader.
  28064. */
  28065. uniformsNames: string[];
  28066. /**
  28067. * Uniform buffer varible names that will be set in the shader.
  28068. */
  28069. uniformBuffersNames: string[];
  28070. /**
  28071. * Sampler texture variable names that will be set in the shader.
  28072. */
  28073. samplers: string[];
  28074. /**
  28075. * Define statements that will be set in the shader.
  28076. */
  28077. defines: any;
  28078. /**
  28079. * Possible fallbacks for this effect to improve performance when needed.
  28080. */
  28081. fallbacks: Nullable<IEffectFallbacks>;
  28082. /**
  28083. * Callback that will be called when the shader is compiled.
  28084. */
  28085. onCompiled: Nullable<(effect: Effect) => void>;
  28086. /**
  28087. * Callback that will be called if an error occurs during shader compilation.
  28088. */
  28089. onError: Nullable<(effect: Effect, errors: string) => void>;
  28090. /**
  28091. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28092. */
  28093. indexParameters?: any;
  28094. /**
  28095. * Max number of lights that can be used in the shader.
  28096. */
  28097. maxSimultaneousLights?: number;
  28098. /**
  28099. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28100. */
  28101. transformFeedbackVaryings?: Nullable<string[]>;
  28102. }
  28103. /**
  28104. * Effect containing vertex and fragment shader that can be executed on an object.
  28105. */
  28106. export class Effect implements IDisposable {
  28107. /**
  28108. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28109. */
  28110. static ShadersRepository: string;
  28111. /**
  28112. * Name of the effect.
  28113. */
  28114. name: any;
  28115. /**
  28116. * String container all the define statements that should be set on the shader.
  28117. */
  28118. defines: string;
  28119. /**
  28120. * Callback that will be called when the shader is compiled.
  28121. */
  28122. onCompiled: Nullable<(effect: Effect) => void>;
  28123. /**
  28124. * Callback that will be called if an error occurs during shader compilation.
  28125. */
  28126. onError: Nullable<(effect: Effect, errors: string) => void>;
  28127. /**
  28128. * Callback that will be called when effect is bound.
  28129. */
  28130. onBind: Nullable<(effect: Effect) => void>;
  28131. /**
  28132. * Unique ID of the effect.
  28133. */
  28134. uniqueId: number;
  28135. /**
  28136. * Observable that will be called when the shader is compiled.
  28137. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28138. */
  28139. onCompileObservable: Observable<Effect>;
  28140. /**
  28141. * Observable that will be called if an error occurs during shader compilation.
  28142. */
  28143. onErrorObservable: Observable<Effect>;
  28144. /** @hidden */
  28145. _onBindObservable: Nullable<Observable<Effect>>;
  28146. /**
  28147. * Observable that will be called when effect is bound.
  28148. */
  28149. readonly onBindObservable: Observable<Effect>;
  28150. /** @hidden */
  28151. _bonesComputationForcedToCPU: boolean;
  28152. private static _uniqueIdSeed;
  28153. private _engine;
  28154. private _uniformBuffersNames;
  28155. private _uniformsNames;
  28156. private _samplerList;
  28157. private _samplers;
  28158. private _isReady;
  28159. private _compilationError;
  28160. private _allFallbacksProcessed;
  28161. private _attributesNames;
  28162. private _attributes;
  28163. private _uniforms;
  28164. /**
  28165. * Key for the effect.
  28166. * @hidden
  28167. */
  28168. _key: string;
  28169. private _indexParameters;
  28170. private _fallbacks;
  28171. private _vertexSourceCode;
  28172. private _fragmentSourceCode;
  28173. private _vertexSourceCodeOverride;
  28174. private _fragmentSourceCodeOverride;
  28175. private _transformFeedbackVaryings;
  28176. /**
  28177. * Compiled shader to webGL program.
  28178. * @hidden
  28179. */
  28180. _pipelineContext: Nullable<IPipelineContext>;
  28181. private _valueCache;
  28182. private static _baseCache;
  28183. /**
  28184. * Instantiates an effect.
  28185. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28186. * @param baseName Name of the effect.
  28187. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28188. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28189. * @param samplers List of sampler variables that will be passed to the shader.
  28190. * @param engine Engine to be used to render the effect
  28191. * @param defines Define statements to be added to the shader.
  28192. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28193. * @param onCompiled Callback that will be called when the shader is compiled.
  28194. * @param onError Callback that will be called if an error occurs during shader compilation.
  28195. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28196. */
  28197. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28198. private _useFinalCode;
  28199. /**
  28200. * Unique key for this effect
  28201. */
  28202. readonly key: string;
  28203. /**
  28204. * If the effect has been compiled and prepared.
  28205. * @returns if the effect is compiled and prepared.
  28206. */
  28207. isReady(): boolean;
  28208. private _isReadyInternal;
  28209. /**
  28210. * The engine the effect was initialized with.
  28211. * @returns the engine.
  28212. */
  28213. getEngine(): Engine;
  28214. /**
  28215. * The pipeline context for this effect
  28216. * @returns the associated pipeline context
  28217. */
  28218. getPipelineContext(): Nullable<IPipelineContext>;
  28219. /**
  28220. * The set of names of attribute variables for the shader.
  28221. * @returns An array of attribute names.
  28222. */
  28223. getAttributesNames(): string[];
  28224. /**
  28225. * Returns the attribute at the given index.
  28226. * @param index The index of the attribute.
  28227. * @returns The location of the attribute.
  28228. */
  28229. getAttributeLocation(index: number): number;
  28230. /**
  28231. * Returns the attribute based on the name of the variable.
  28232. * @param name of the attribute to look up.
  28233. * @returns the attribute location.
  28234. */
  28235. getAttributeLocationByName(name: string): number;
  28236. /**
  28237. * The number of attributes.
  28238. * @returns the numnber of attributes.
  28239. */
  28240. getAttributesCount(): number;
  28241. /**
  28242. * Gets the index of a uniform variable.
  28243. * @param uniformName of the uniform to look up.
  28244. * @returns the index.
  28245. */
  28246. getUniformIndex(uniformName: string): number;
  28247. /**
  28248. * Returns the attribute based on the name of the variable.
  28249. * @param uniformName of the uniform to look up.
  28250. * @returns the location of the uniform.
  28251. */
  28252. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28253. /**
  28254. * Returns an array of sampler variable names
  28255. * @returns The array of sampler variable neames.
  28256. */
  28257. getSamplers(): string[];
  28258. /**
  28259. * The error from the last compilation.
  28260. * @returns the error string.
  28261. */
  28262. getCompilationError(): string;
  28263. /**
  28264. * Gets a boolean indicating that all fallbacks were used during compilation
  28265. * @returns true if all fallbacks were used
  28266. */
  28267. allFallbacksProcessed(): boolean;
  28268. /**
  28269. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28270. * @param func The callback to be used.
  28271. */
  28272. executeWhenCompiled(func: (effect: Effect) => void): void;
  28273. private _checkIsReady;
  28274. private _loadShader;
  28275. /**
  28276. * Recompiles the webGL program
  28277. * @param vertexSourceCode The source code for the vertex shader.
  28278. * @param fragmentSourceCode The source code for the fragment shader.
  28279. * @param onCompiled Callback called when completed.
  28280. * @param onError Callback called on error.
  28281. * @hidden
  28282. */
  28283. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28284. /**
  28285. * Prepares the effect
  28286. * @hidden
  28287. */
  28288. _prepareEffect(): void;
  28289. private _processCompilationErrors;
  28290. /**
  28291. * Checks if the effect is supported. (Must be called after compilation)
  28292. */
  28293. readonly isSupported: boolean;
  28294. /**
  28295. * Binds a texture to the engine to be used as output of the shader.
  28296. * @param channel Name of the output variable.
  28297. * @param texture Texture to bind.
  28298. * @hidden
  28299. */
  28300. _bindTexture(channel: string, texture: InternalTexture): void;
  28301. /**
  28302. * Sets a texture on the engine to be used in the shader.
  28303. * @param channel Name of the sampler variable.
  28304. * @param texture Texture to set.
  28305. */
  28306. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28307. /**
  28308. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28309. * @param channel Name of the sampler variable.
  28310. * @param texture Texture to set.
  28311. */
  28312. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28313. /**
  28314. * Sets an array of textures on the engine to be used in the shader.
  28315. * @param channel Name of the variable.
  28316. * @param textures Textures to set.
  28317. */
  28318. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28319. /**
  28320. * 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)
  28321. * @param channel Name of the sampler variable.
  28322. * @param postProcess Post process to get the input texture from.
  28323. */
  28324. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28325. /**
  28326. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28327. * 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)
  28328. * @param channel Name of the sampler variable.
  28329. * @param postProcess Post process to get the output texture from.
  28330. */
  28331. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28332. /** @hidden */
  28333. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28334. /** @hidden */
  28335. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28336. /** @hidden */
  28337. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28338. /** @hidden */
  28339. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28340. /**
  28341. * Binds a buffer to a uniform.
  28342. * @param buffer Buffer to bind.
  28343. * @param name Name of the uniform variable to bind to.
  28344. */
  28345. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28346. /**
  28347. * Binds block to a uniform.
  28348. * @param blockName Name of the block to bind.
  28349. * @param index Index to bind.
  28350. */
  28351. bindUniformBlock(blockName: string, index: number): void;
  28352. /**
  28353. * Sets an interger value on a uniform variable.
  28354. * @param uniformName Name of the variable.
  28355. * @param value Value to be set.
  28356. * @returns this effect.
  28357. */
  28358. setInt(uniformName: string, value: number): Effect;
  28359. /**
  28360. * Sets an int array on a uniform variable.
  28361. * @param uniformName Name of the variable.
  28362. * @param array array to be set.
  28363. * @returns this effect.
  28364. */
  28365. setIntArray(uniformName: string, array: Int32Array): Effect;
  28366. /**
  28367. * 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)
  28368. * @param uniformName Name of the variable.
  28369. * @param array array to be set.
  28370. * @returns this effect.
  28371. */
  28372. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28373. /**
  28374. * 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)
  28375. * @param uniformName Name of the variable.
  28376. * @param array array to be set.
  28377. * @returns this effect.
  28378. */
  28379. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28380. /**
  28381. * 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)
  28382. * @param uniformName Name of the variable.
  28383. * @param array array to be set.
  28384. * @returns this effect.
  28385. */
  28386. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28387. /**
  28388. * Sets an float array on a uniform variable.
  28389. * @param uniformName Name of the variable.
  28390. * @param array array to be set.
  28391. * @returns this effect.
  28392. */
  28393. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28394. /**
  28395. * 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)
  28396. * @param uniformName Name of the variable.
  28397. * @param array array to be set.
  28398. * @returns this effect.
  28399. */
  28400. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28401. /**
  28402. * 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)
  28403. * @param uniformName Name of the variable.
  28404. * @param array array to be set.
  28405. * @returns this effect.
  28406. */
  28407. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28408. /**
  28409. * 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)
  28410. * @param uniformName Name of the variable.
  28411. * @param array array to be set.
  28412. * @returns this effect.
  28413. */
  28414. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28415. /**
  28416. * Sets an array on a uniform variable.
  28417. * @param uniformName Name of the variable.
  28418. * @param array array to be set.
  28419. * @returns this effect.
  28420. */
  28421. setArray(uniformName: string, array: number[]): Effect;
  28422. /**
  28423. * 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)
  28424. * @param uniformName Name of the variable.
  28425. * @param array array to be set.
  28426. * @returns this effect.
  28427. */
  28428. setArray2(uniformName: string, array: number[]): Effect;
  28429. /**
  28430. * 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)
  28431. * @param uniformName Name of the variable.
  28432. * @param array array to be set.
  28433. * @returns this effect.
  28434. */
  28435. setArray3(uniformName: string, array: number[]): Effect;
  28436. /**
  28437. * 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)
  28438. * @param uniformName Name of the variable.
  28439. * @param array array to be set.
  28440. * @returns this effect.
  28441. */
  28442. setArray4(uniformName: string, array: number[]): Effect;
  28443. /**
  28444. * Sets matrices on a uniform variable.
  28445. * @param uniformName Name of the variable.
  28446. * @param matrices matrices to be set.
  28447. * @returns this effect.
  28448. */
  28449. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28450. /**
  28451. * Sets matrix on a uniform variable.
  28452. * @param uniformName Name of the variable.
  28453. * @param matrix matrix to be set.
  28454. * @returns this effect.
  28455. */
  28456. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28457. /**
  28458. * 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)
  28459. * @param uniformName Name of the variable.
  28460. * @param matrix matrix to be set.
  28461. * @returns this effect.
  28462. */
  28463. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28464. /**
  28465. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28466. * @param uniformName Name of the variable.
  28467. * @param matrix matrix to be set.
  28468. * @returns this effect.
  28469. */
  28470. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28471. /**
  28472. * Sets a float on a uniform variable.
  28473. * @param uniformName Name of the variable.
  28474. * @param value value to be set.
  28475. * @returns this effect.
  28476. */
  28477. setFloat(uniformName: string, value: number): Effect;
  28478. /**
  28479. * Sets a boolean on a uniform variable.
  28480. * @param uniformName Name of the variable.
  28481. * @param bool value to be set.
  28482. * @returns this effect.
  28483. */
  28484. setBool(uniformName: string, bool: boolean): Effect;
  28485. /**
  28486. * Sets a Vector2 on a uniform variable.
  28487. * @param uniformName Name of the variable.
  28488. * @param vector2 vector2 to be set.
  28489. * @returns this effect.
  28490. */
  28491. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28492. /**
  28493. * Sets a float2 on a uniform variable.
  28494. * @param uniformName Name of the variable.
  28495. * @param x First float in float2.
  28496. * @param y Second float in float2.
  28497. * @returns this effect.
  28498. */
  28499. setFloat2(uniformName: string, x: number, y: number): Effect;
  28500. /**
  28501. * Sets a Vector3 on a uniform variable.
  28502. * @param uniformName Name of the variable.
  28503. * @param vector3 Value to be set.
  28504. * @returns this effect.
  28505. */
  28506. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28507. /**
  28508. * Sets a float3 on a uniform variable.
  28509. * @param uniformName Name of the variable.
  28510. * @param x First float in float3.
  28511. * @param y Second float in float3.
  28512. * @param z Third float in float3.
  28513. * @returns this effect.
  28514. */
  28515. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28516. /**
  28517. * Sets a Vector4 on a uniform variable.
  28518. * @param uniformName Name of the variable.
  28519. * @param vector4 Value to be set.
  28520. * @returns this effect.
  28521. */
  28522. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28523. /**
  28524. * Sets a float4 on a uniform variable.
  28525. * @param uniformName Name of the variable.
  28526. * @param x First float in float4.
  28527. * @param y Second float in float4.
  28528. * @param z Third float in float4.
  28529. * @param w Fourth float in float4.
  28530. * @returns this effect.
  28531. */
  28532. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28533. /**
  28534. * Sets a Color3 on a uniform variable.
  28535. * @param uniformName Name of the variable.
  28536. * @param color3 Value to be set.
  28537. * @returns this effect.
  28538. */
  28539. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28540. /**
  28541. * Sets a Color4 on a uniform variable.
  28542. * @param uniformName Name of the variable.
  28543. * @param color3 Value to be set.
  28544. * @param alpha Alpha value to be set.
  28545. * @returns this effect.
  28546. */
  28547. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28548. /**
  28549. * Sets a Color4 on a uniform variable
  28550. * @param uniformName defines the name of the variable
  28551. * @param color4 defines the value to be set
  28552. * @returns this effect.
  28553. */
  28554. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28555. /** Release all associated resources */
  28556. dispose(): void;
  28557. /**
  28558. * This function will add a new shader to the shader store
  28559. * @param name the name of the shader
  28560. * @param pixelShader optional pixel shader content
  28561. * @param vertexShader optional vertex shader content
  28562. */
  28563. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28564. /**
  28565. * Store of each shader (The can be looked up using effect.key)
  28566. */
  28567. static ShadersStore: {
  28568. [key: string]: string;
  28569. };
  28570. /**
  28571. * Store of each included file for a shader (The can be looked up using effect.key)
  28572. */
  28573. static IncludesShadersStore: {
  28574. [key: string]: string;
  28575. };
  28576. /**
  28577. * Resets the cache of effects.
  28578. */
  28579. static ResetCache(): void;
  28580. }
  28581. }
  28582. declare module BABYLON {
  28583. /**
  28584. * Class used to describe the capabilities of the engine relatively to the current browser
  28585. */
  28586. export class EngineCapabilities {
  28587. /** Maximum textures units per fragment shader */
  28588. maxTexturesImageUnits: number;
  28589. /** Maximum texture units per vertex shader */
  28590. maxVertexTextureImageUnits: number;
  28591. /** Maximum textures units in the entire pipeline */
  28592. maxCombinedTexturesImageUnits: number;
  28593. /** Maximum texture size */
  28594. maxTextureSize: number;
  28595. /** Maximum cube texture size */
  28596. maxCubemapTextureSize: number;
  28597. /** Maximum render texture size */
  28598. maxRenderTextureSize: number;
  28599. /** Maximum number of vertex attributes */
  28600. maxVertexAttribs: number;
  28601. /** Maximum number of varyings */
  28602. maxVaryingVectors: number;
  28603. /** Maximum number of uniforms per vertex shader */
  28604. maxVertexUniformVectors: number;
  28605. /** Maximum number of uniforms per fragment shader */
  28606. maxFragmentUniformVectors: number;
  28607. /** Defines if standard derivates (dx/dy) are supported */
  28608. standardDerivatives: boolean;
  28609. /** Defines if s3tc texture compression is supported */
  28610. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28611. /** Defines if pvrtc texture compression is supported */
  28612. pvrtc: any;
  28613. /** Defines if etc1 texture compression is supported */
  28614. etc1: any;
  28615. /** Defines if etc2 texture compression is supported */
  28616. etc2: any;
  28617. /** Defines if astc texture compression is supported */
  28618. astc: any;
  28619. /** Defines if float textures are supported */
  28620. textureFloat: boolean;
  28621. /** Defines if vertex array objects are supported */
  28622. vertexArrayObject: boolean;
  28623. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28624. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28625. /** Gets the maximum level of anisotropy supported */
  28626. maxAnisotropy: number;
  28627. /** Defines if instancing is supported */
  28628. instancedArrays: boolean;
  28629. /** Defines if 32 bits indices are supported */
  28630. uintIndices: boolean;
  28631. /** Defines if high precision shaders are supported */
  28632. highPrecisionShaderSupported: boolean;
  28633. /** Defines if depth reading in the fragment shader is supported */
  28634. fragmentDepthSupported: boolean;
  28635. /** Defines if float texture linear filtering is supported*/
  28636. textureFloatLinearFiltering: boolean;
  28637. /** Defines if rendering to float textures is supported */
  28638. textureFloatRender: boolean;
  28639. /** Defines if half float textures are supported*/
  28640. textureHalfFloat: boolean;
  28641. /** Defines if half float texture linear filtering is supported*/
  28642. textureHalfFloatLinearFiltering: boolean;
  28643. /** Defines if rendering to half float textures is supported */
  28644. textureHalfFloatRender: boolean;
  28645. /** Defines if textureLOD shader command is supported */
  28646. textureLOD: boolean;
  28647. /** Defines if draw buffers extension is supported */
  28648. drawBuffersExtension: boolean;
  28649. /** Defines if depth textures are supported */
  28650. depthTextureExtension: boolean;
  28651. /** Defines if float color buffer are supported */
  28652. colorBufferFloat: boolean;
  28653. /** Gets disjoint timer query extension (null if not supported) */
  28654. timerQuery: EXT_disjoint_timer_query;
  28655. /** Defines if timestamp can be used with timer query */
  28656. canUseTimestampForTimerQuery: boolean;
  28657. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28658. multiview: any;
  28659. /** Function used to let the system compiles shaders in background */
  28660. parallelShaderCompile: {
  28661. COMPLETION_STATUS_KHR: number;
  28662. };
  28663. /** Max number of texture samples for MSAA */
  28664. maxMSAASamples: number;
  28665. /** Defines if the blend min max extension is supported */
  28666. blendMinMax: boolean;
  28667. }
  28668. }
  28669. declare module BABYLON {
  28670. /**
  28671. * @hidden
  28672. **/
  28673. export class DepthCullingState {
  28674. private _isDepthTestDirty;
  28675. private _isDepthMaskDirty;
  28676. private _isDepthFuncDirty;
  28677. private _isCullFaceDirty;
  28678. private _isCullDirty;
  28679. private _isZOffsetDirty;
  28680. private _isFrontFaceDirty;
  28681. private _depthTest;
  28682. private _depthMask;
  28683. private _depthFunc;
  28684. private _cull;
  28685. private _cullFace;
  28686. private _zOffset;
  28687. private _frontFace;
  28688. /**
  28689. * Initializes the state.
  28690. */
  28691. constructor();
  28692. readonly isDirty: boolean;
  28693. zOffset: number;
  28694. cullFace: Nullable<number>;
  28695. cull: Nullable<boolean>;
  28696. depthFunc: Nullable<number>;
  28697. depthMask: boolean;
  28698. depthTest: boolean;
  28699. frontFace: Nullable<number>;
  28700. reset(): void;
  28701. apply(gl: WebGLRenderingContext): void;
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. /**
  28706. * @hidden
  28707. **/
  28708. export class StencilState {
  28709. /** 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 */
  28710. static readonly ALWAYS: number;
  28711. /** Passed to stencilOperation to specify that stencil value must be kept */
  28712. static readonly KEEP: number;
  28713. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28714. static readonly REPLACE: number;
  28715. private _isStencilTestDirty;
  28716. private _isStencilMaskDirty;
  28717. private _isStencilFuncDirty;
  28718. private _isStencilOpDirty;
  28719. private _stencilTest;
  28720. private _stencilMask;
  28721. private _stencilFunc;
  28722. private _stencilFuncRef;
  28723. private _stencilFuncMask;
  28724. private _stencilOpStencilFail;
  28725. private _stencilOpDepthFail;
  28726. private _stencilOpStencilDepthPass;
  28727. readonly isDirty: boolean;
  28728. stencilFunc: number;
  28729. stencilFuncRef: number;
  28730. stencilFuncMask: number;
  28731. stencilOpStencilFail: number;
  28732. stencilOpDepthFail: number;
  28733. stencilOpStencilDepthPass: number;
  28734. stencilMask: number;
  28735. stencilTest: boolean;
  28736. constructor();
  28737. reset(): void;
  28738. apply(gl: WebGLRenderingContext): void;
  28739. }
  28740. }
  28741. declare module BABYLON {
  28742. /**
  28743. * @hidden
  28744. **/
  28745. export class AlphaState {
  28746. private _isAlphaBlendDirty;
  28747. private _isBlendFunctionParametersDirty;
  28748. private _isBlendEquationParametersDirty;
  28749. private _isBlendConstantsDirty;
  28750. private _alphaBlend;
  28751. private _blendFunctionParameters;
  28752. private _blendEquationParameters;
  28753. private _blendConstants;
  28754. /**
  28755. * Initializes the state.
  28756. */
  28757. constructor();
  28758. readonly isDirty: boolean;
  28759. alphaBlend: boolean;
  28760. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28761. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28762. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28763. reset(): void;
  28764. apply(gl: WebGLRenderingContext): void;
  28765. }
  28766. }
  28767. declare module BABYLON {
  28768. /** @hidden */
  28769. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28770. attributeProcessor(attribute: string): string;
  28771. varyingProcessor(varying: string, isFragment: boolean): string;
  28772. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28773. }
  28774. }
  28775. declare module BABYLON {
  28776. /**
  28777. * Interface for attribute information associated with buffer instanciation
  28778. */
  28779. export class InstancingAttributeInfo {
  28780. /**
  28781. * Index/offset of the attribute in the vertex shader
  28782. */
  28783. index: number;
  28784. /**
  28785. * size of the attribute, 1, 2, 3 or 4
  28786. */
  28787. attributeSize: number;
  28788. /**
  28789. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28790. * default is FLOAT
  28791. */
  28792. attribyteType: number;
  28793. /**
  28794. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28795. */
  28796. normalized: boolean;
  28797. /**
  28798. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28799. */
  28800. offset: number;
  28801. /**
  28802. * Name of the GLSL attribute, for debugging purpose only
  28803. */
  28804. attributeName: string;
  28805. }
  28806. }
  28807. declare module BABYLON {
  28808. interface ThinEngine {
  28809. /**
  28810. * Update a video texture
  28811. * @param texture defines the texture to update
  28812. * @param video defines the video element to use
  28813. * @param invertY defines if data must be stored with Y axis inverted
  28814. */
  28815. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * Settings for finer control over video usage
  28821. */
  28822. export interface VideoTextureSettings {
  28823. /**
  28824. * Applies `autoplay` to video, if specified
  28825. */
  28826. autoPlay?: boolean;
  28827. /**
  28828. * Applies `loop` to video, if specified
  28829. */
  28830. loop?: boolean;
  28831. /**
  28832. * Automatically updates internal texture from video at every frame in the render loop
  28833. */
  28834. autoUpdateTexture: boolean;
  28835. /**
  28836. * Image src displayed during the video loading or until the user interacts with the video.
  28837. */
  28838. poster?: string;
  28839. }
  28840. /**
  28841. * If you want to display a video in your scene, this is the special texture for that.
  28842. * This special texture works similar to other textures, with the exception of a few parameters.
  28843. * @see https://doc.babylonjs.com/how_to/video_texture
  28844. */
  28845. export class VideoTexture extends Texture {
  28846. /**
  28847. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28848. */
  28849. readonly autoUpdateTexture: boolean;
  28850. /**
  28851. * The video instance used by the texture internally
  28852. */
  28853. readonly video: HTMLVideoElement;
  28854. private _onUserActionRequestedObservable;
  28855. /**
  28856. * Event triggerd when a dom action is required by the user to play the video.
  28857. * This happens due to recent changes in browser policies preventing video to auto start.
  28858. */
  28859. readonly onUserActionRequestedObservable: Observable<Texture>;
  28860. private _generateMipMaps;
  28861. private _engine;
  28862. private _stillImageCaptured;
  28863. private _displayingPosterTexture;
  28864. private _settings;
  28865. private _createInternalTextureOnEvent;
  28866. private _frameId;
  28867. /**
  28868. * Creates a video texture.
  28869. * If you want to display a video in your scene, this is the special texture for that.
  28870. * This special texture works similar to other textures, with the exception of a few parameters.
  28871. * @see https://doc.babylonjs.com/how_to/video_texture
  28872. * @param name optional name, will detect from video source, if not defined
  28873. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28874. * @param scene is obviously the current scene.
  28875. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28876. * @param invertY is false by default but can be used to invert video on Y axis
  28877. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28878. * @param settings allows finer control over video usage
  28879. */
  28880. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28881. private _getName;
  28882. private _getVideo;
  28883. private _createInternalTexture;
  28884. private reset;
  28885. /**
  28886. * @hidden Internal method to initiate `update`.
  28887. */
  28888. _rebuild(): void;
  28889. /**
  28890. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28891. */
  28892. update(): void;
  28893. /**
  28894. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28895. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28896. */
  28897. updateTexture(isVisible: boolean): void;
  28898. protected _updateInternalTexture: () => void;
  28899. /**
  28900. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28901. * @param url New url.
  28902. */
  28903. updateURL(url: string): void;
  28904. /**
  28905. * Dispose the texture and release its associated resources.
  28906. */
  28907. dispose(): void;
  28908. /**
  28909. * Creates a video texture straight from a stream.
  28910. * @param scene Define the scene the texture should be created in
  28911. * @param stream Define the stream the texture should be created from
  28912. * @returns The created video texture as a promise
  28913. */
  28914. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28915. /**
  28916. * Creates a video texture straight from your WebCam video feed.
  28917. * @param scene Define the scene the texture should be created in
  28918. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28919. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28920. * @returns The created video texture as a promise
  28921. */
  28922. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28923. minWidth: number;
  28924. maxWidth: number;
  28925. minHeight: number;
  28926. maxHeight: number;
  28927. deviceId: string;
  28928. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28929. /**
  28930. * Creates a video texture straight from your WebCam video feed.
  28931. * @param scene Define the scene the texture should be created in
  28932. * @param onReady Define a callback to triggered once the texture will be ready
  28933. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28934. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28935. */
  28936. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28937. minWidth: number;
  28938. maxWidth: number;
  28939. minHeight: number;
  28940. maxHeight: number;
  28941. deviceId: string;
  28942. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28943. }
  28944. }
  28945. declare module BABYLON {
  28946. /**
  28947. * Defines the interface used by objects working like Scene
  28948. * @hidden
  28949. */
  28950. interface ISceneLike {
  28951. _addPendingData(data: any): void;
  28952. _removePendingData(data: any): void;
  28953. offlineProvider: IOfflineProvider;
  28954. }
  28955. /** Interface defining initialization parameters for Engine class */
  28956. export interface EngineOptions extends WebGLContextAttributes {
  28957. /**
  28958. * Defines if the engine should no exceed a specified device ratio
  28959. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28960. */
  28961. limitDeviceRatio?: number;
  28962. /**
  28963. * Defines if webvr should be enabled automatically
  28964. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28965. */
  28966. autoEnableWebVR?: boolean;
  28967. /**
  28968. * Defines if webgl2 should be turned off even if supported
  28969. * @see http://doc.babylonjs.com/features/webgl2
  28970. */
  28971. disableWebGL2Support?: boolean;
  28972. /**
  28973. * Defines if webaudio should be initialized as well
  28974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28975. */
  28976. audioEngine?: boolean;
  28977. /**
  28978. * Defines if animations should run using a deterministic lock step
  28979. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28980. */
  28981. deterministicLockstep?: boolean;
  28982. /** Defines the maximum steps to use with deterministic lock step mode */
  28983. lockstepMaxSteps?: number;
  28984. /**
  28985. * Defines that engine should ignore context lost events
  28986. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28987. */
  28988. doNotHandleContextLost?: boolean;
  28989. /**
  28990. * Defines that engine should ignore modifying touch action attribute and style
  28991. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28992. */
  28993. doNotHandleTouchAction?: boolean;
  28994. /**
  28995. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28996. */
  28997. useHighPrecisionFloats?: boolean;
  28998. }
  28999. /**
  29000. * The base engine class (root of all engines)
  29001. */
  29002. export class ThinEngine {
  29003. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29004. static ExceptionList: ({
  29005. key: string;
  29006. capture: string;
  29007. captureConstraint: number;
  29008. targets: string[];
  29009. } | {
  29010. key: string;
  29011. capture: null;
  29012. captureConstraint: null;
  29013. targets: string[];
  29014. })[];
  29015. /** @hidden */
  29016. static _TextureLoaders: IInternalTextureLoader[];
  29017. /**
  29018. * Returns the current npm package of the sdk
  29019. */
  29020. static readonly NpmPackage: string;
  29021. /**
  29022. * Returns the current version of the framework
  29023. */
  29024. static readonly Version: string;
  29025. /**
  29026. * Returns a string describing the current engine
  29027. */
  29028. readonly description: string;
  29029. /**
  29030. * Gets or sets the epsilon value used by collision engine
  29031. */
  29032. static CollisionsEpsilon: number;
  29033. /**
  29034. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29035. */
  29036. static ShadersRepository: string;
  29037. /** @hidden */
  29038. _shaderProcessor: IShaderProcessor;
  29039. /**
  29040. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29041. */
  29042. forcePOTTextures: boolean;
  29043. /**
  29044. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29045. */
  29046. isFullscreen: boolean;
  29047. /**
  29048. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29049. */
  29050. cullBackFaces: boolean;
  29051. /**
  29052. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29053. */
  29054. renderEvenInBackground: boolean;
  29055. /**
  29056. * Gets or sets a boolean indicating that cache can be kept between frames
  29057. */
  29058. preventCacheWipeBetweenFrames: boolean;
  29059. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29060. validateShaderPrograms: boolean;
  29061. /**
  29062. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29063. */
  29064. disableUniformBuffers: boolean;
  29065. /** @hidden */
  29066. _uniformBuffers: UniformBuffer[];
  29067. /**
  29068. * Gets a boolean indicating that the engine supports uniform buffers
  29069. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29070. */
  29071. readonly supportsUniformBuffers: boolean;
  29072. /** @hidden */
  29073. _gl: WebGLRenderingContext;
  29074. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29075. protected _windowIsBackground: boolean;
  29076. protected _webGLVersion: number;
  29077. protected _highPrecisionShadersAllowed: boolean;
  29078. /** @hidden */
  29079. readonly _shouldUseHighPrecisionShader: boolean;
  29080. /**
  29081. * Gets a boolean indicating that only power of 2 textures are supported
  29082. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29083. */
  29084. readonly needPOTTextures: boolean;
  29085. /** @hidden */
  29086. _badOS: boolean;
  29087. /** @hidden */
  29088. _badDesktopOS: boolean;
  29089. private _hardwareScalingLevel;
  29090. /** @hidden */
  29091. _caps: EngineCapabilities;
  29092. private _isStencilEnable;
  29093. protected _colorWrite: boolean;
  29094. private _glVersion;
  29095. private _glRenderer;
  29096. private _glVendor;
  29097. /** @hidden */
  29098. _videoTextureSupported: boolean;
  29099. protected _renderingQueueLaunched: boolean;
  29100. protected _activeRenderLoops: (() => void)[];
  29101. /**
  29102. * Observable signaled when a context lost event is raised
  29103. */
  29104. onContextLostObservable: Observable<ThinEngine>;
  29105. /**
  29106. * Observable signaled when a context restored event is raised
  29107. */
  29108. onContextRestoredObservable: Observable<ThinEngine>;
  29109. private _onContextLost;
  29110. private _onContextRestored;
  29111. protected _contextWasLost: boolean;
  29112. /** @hidden */
  29113. _doNotHandleContextLost: boolean;
  29114. /**
  29115. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29117. */
  29118. doNotHandleContextLost: boolean;
  29119. /**
  29120. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29121. */
  29122. disableVertexArrayObjects: boolean;
  29123. /** @hidden */
  29124. protected _depthCullingState: DepthCullingState;
  29125. /** @hidden */
  29126. protected _stencilState: StencilState;
  29127. /** @hidden */
  29128. protected _alphaState: AlphaState;
  29129. /** @hidden */
  29130. _internalTexturesCache: InternalTexture[];
  29131. /** @hidden */
  29132. protected _activeChannel: number;
  29133. private _currentTextureChannel;
  29134. /** @hidden */
  29135. protected _boundTexturesCache: {
  29136. [key: string]: Nullable<InternalTexture>;
  29137. };
  29138. /** @hidden */
  29139. protected _currentEffect: Nullable<Effect>;
  29140. /** @hidden */
  29141. protected _currentProgram: Nullable<WebGLProgram>;
  29142. private _compiledEffects;
  29143. private _vertexAttribArraysEnabled;
  29144. /** @hidden */
  29145. protected _cachedViewport: Nullable<IViewportLike>;
  29146. private _cachedVertexArrayObject;
  29147. /** @hidden */
  29148. protected _cachedVertexBuffers: any;
  29149. /** @hidden */
  29150. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29151. /** @hidden */
  29152. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29153. /** @hidden */
  29154. _currentRenderTarget: Nullable<InternalTexture>;
  29155. private _uintIndicesCurrentlySet;
  29156. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29157. /** @hidden */
  29158. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29159. private _currentBufferPointers;
  29160. private _currentInstanceLocations;
  29161. private _currentInstanceBuffers;
  29162. private _textureUnits;
  29163. /** @hidden */
  29164. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29165. /** @hidden */
  29166. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29167. /** @hidden */
  29168. _bindedRenderFunction: any;
  29169. private _vaoRecordInProgress;
  29170. private _mustWipeVertexAttributes;
  29171. private _emptyTexture;
  29172. private _emptyCubeTexture;
  29173. private _emptyTexture3D;
  29174. /** @hidden */
  29175. _frameHandler: number;
  29176. private _nextFreeTextureSlots;
  29177. private _maxSimultaneousTextures;
  29178. private _activeRequests;
  29179. protected _texturesSupported: string[];
  29180. /** @hidden */
  29181. _textureFormatInUse: Nullable<string>;
  29182. protected readonly _supportsHardwareTextureRescaling: boolean;
  29183. /**
  29184. * Gets the list of texture formats supported
  29185. */
  29186. readonly texturesSupported: Array<string>;
  29187. /**
  29188. * Gets the list of texture formats in use
  29189. */
  29190. readonly textureFormatInUse: Nullable<string>;
  29191. /**
  29192. * Gets the current viewport
  29193. */
  29194. readonly currentViewport: Nullable<IViewportLike>;
  29195. /**
  29196. * Gets the default empty texture
  29197. */
  29198. readonly emptyTexture: InternalTexture;
  29199. /**
  29200. * Gets the default empty 3D texture
  29201. */
  29202. readonly emptyTexture3D: InternalTexture;
  29203. /**
  29204. * Gets the default empty cube texture
  29205. */
  29206. readonly emptyCubeTexture: InternalTexture;
  29207. /**
  29208. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29209. */
  29210. readonly premultipliedAlpha: boolean;
  29211. /**
  29212. * Observable event triggered before each texture is initialized
  29213. */
  29214. onBeforeTextureInitObservable: Observable<Texture>;
  29215. /**
  29216. * Creates a new engine
  29217. * @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
  29218. * @param antialias defines enable antialiasing (default: false)
  29219. * @param options defines further options to be sent to the getContext() function
  29220. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29221. */
  29222. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29223. private _rebuildInternalTextures;
  29224. private _rebuildEffects;
  29225. /**
  29226. * Gets a boolean indicating if all created effects are ready
  29227. * @returns true if all effects are ready
  29228. */
  29229. areAllEffectsReady(): boolean;
  29230. protected _rebuildBuffers(): void;
  29231. private _initGLContext;
  29232. /**
  29233. * Gets version of the current webGL context
  29234. */
  29235. readonly webGLVersion: number;
  29236. /**
  29237. * Gets a string idenfifying the name of the class
  29238. * @returns "Engine" string
  29239. */
  29240. getClassName(): string;
  29241. /**
  29242. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29243. */
  29244. readonly isStencilEnable: boolean;
  29245. /** @hidden */
  29246. _prepareWorkingCanvas(): void;
  29247. /**
  29248. * Reset the texture cache to empty state
  29249. */
  29250. resetTextureCache(): void;
  29251. /**
  29252. * Gets an object containing information about the current webGL context
  29253. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29254. */
  29255. getGlInfo(): {
  29256. vendor: string;
  29257. renderer: string;
  29258. version: string;
  29259. };
  29260. /**
  29261. * Defines the hardware scaling level.
  29262. * By default the hardware scaling level is computed from the window device ratio.
  29263. * 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.
  29264. * @param level defines the level to use
  29265. */
  29266. setHardwareScalingLevel(level: number): void;
  29267. /**
  29268. * Gets the current hardware scaling level.
  29269. * By default the hardware scaling level is computed from the window device ratio.
  29270. * 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.
  29271. * @returns a number indicating the current hardware scaling level
  29272. */
  29273. getHardwareScalingLevel(): number;
  29274. /**
  29275. * Gets the list of loaded textures
  29276. * @returns an array containing all loaded textures
  29277. */
  29278. getLoadedTexturesCache(): InternalTexture[];
  29279. /**
  29280. * Gets the object containing all engine capabilities
  29281. * @returns the EngineCapabilities object
  29282. */
  29283. getCaps(): EngineCapabilities;
  29284. /**
  29285. * stop executing a render loop function and remove it from the execution array
  29286. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29287. */
  29288. stopRenderLoop(renderFunction?: () => void): void;
  29289. /** @hidden */
  29290. _renderLoop(): void;
  29291. /**
  29292. * Gets the HTML canvas attached with the current webGL context
  29293. * @returns a HTML canvas
  29294. */
  29295. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29296. /**
  29297. * Gets host window
  29298. * @returns the host window object
  29299. */
  29300. getHostWindow(): Nullable<Window>;
  29301. /**
  29302. * Gets the current render width
  29303. * @param useScreen defines if screen size must be used (or the current render target if any)
  29304. * @returns a number defining the current render width
  29305. */
  29306. getRenderWidth(useScreen?: boolean): number;
  29307. /**
  29308. * Gets the current render height
  29309. * @param useScreen defines if screen size must be used (or the current render target if any)
  29310. * @returns a number defining the current render height
  29311. */
  29312. getRenderHeight(useScreen?: boolean): number;
  29313. /**
  29314. * Can be used to override the current requestAnimationFrame requester.
  29315. * @hidden
  29316. */
  29317. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29318. /**
  29319. * Register and execute a render loop. The engine can have more than one render function
  29320. * @param renderFunction defines the function to continuously execute
  29321. */
  29322. runRenderLoop(renderFunction: () => void): void;
  29323. /**
  29324. * Clear the current render buffer or the current render target (if any is set up)
  29325. * @param color defines the color to use
  29326. * @param backBuffer defines if the back buffer must be cleared
  29327. * @param depth defines if the depth buffer must be cleared
  29328. * @param stencil defines if the stencil buffer must be cleared
  29329. */
  29330. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29331. private _viewportCached;
  29332. /** @hidden */
  29333. _viewport(x: number, y: number, width: number, height: number): void;
  29334. /**
  29335. * Set the WebGL's viewport
  29336. * @param viewport defines the viewport element to be used
  29337. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29338. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29339. */
  29340. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29341. /**
  29342. * Begin a new frame
  29343. */
  29344. beginFrame(): void;
  29345. /**
  29346. * Enf the current frame
  29347. */
  29348. endFrame(): void;
  29349. /**
  29350. * Resize the view according to the canvas' size
  29351. */
  29352. resize(): void;
  29353. /**
  29354. * Force a specific size of the canvas
  29355. * @param width defines the new canvas' width
  29356. * @param height defines the new canvas' height
  29357. */
  29358. setSize(width: number, height: number): void;
  29359. /**
  29360. * Binds the frame buffer to the specified texture.
  29361. * @param texture The texture to render to or null for the default canvas
  29362. * @param faceIndex The face of the texture to render to in case of cube texture
  29363. * @param requiredWidth The width of the target to render to
  29364. * @param requiredHeight The height of the target to render to
  29365. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29366. * @param depthStencilTexture The depth stencil texture to use to render
  29367. * @param lodLevel defines le lod level to bind to the frame buffer
  29368. */
  29369. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29370. /** @hidden */
  29371. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29372. /**
  29373. * Unbind the current render target texture from the webGL context
  29374. * @param texture defines the render target texture to unbind
  29375. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29376. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29377. */
  29378. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29379. /**
  29380. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29381. */
  29382. flushFramebuffer(): void;
  29383. /**
  29384. * Unbind the current render target and bind the default framebuffer
  29385. */
  29386. restoreDefaultFramebuffer(): void;
  29387. private _resetVertexBufferBinding;
  29388. /**
  29389. * Creates a vertex buffer
  29390. * @param data the data for the vertex buffer
  29391. * @returns the new WebGL static buffer
  29392. */
  29393. createVertexBuffer(data: DataArray): DataBuffer;
  29394. private _createVertexBuffer;
  29395. /**
  29396. * Creates a dynamic vertex buffer
  29397. * @param data the data for the dynamic vertex buffer
  29398. * @returns the new WebGL dynamic buffer
  29399. */
  29400. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29401. /**
  29402. * Updates a dynamic vertex buffer.
  29403. * @param vertexBuffer the vertex buffer to update
  29404. * @param data the data used to update the vertex buffer
  29405. * @param byteOffset the byte offset of the data
  29406. * @param byteLength the byte length of the data
  29407. */
  29408. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29409. protected _resetIndexBufferBinding(): void;
  29410. /**
  29411. * Creates a new index buffer
  29412. * @param indices defines the content of the index buffer
  29413. * @param updatable defines if the index buffer must be updatable
  29414. * @returns a new webGL buffer
  29415. */
  29416. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29417. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29418. /**
  29419. * Bind a webGL buffer to the webGL context
  29420. * @param buffer defines the buffer to bind
  29421. */
  29422. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29423. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29424. private bindBuffer;
  29425. /**
  29426. * update the bound buffer with the given data
  29427. * @param data defines the data to update
  29428. */
  29429. updateArrayBuffer(data: Float32Array): void;
  29430. private _vertexAttribPointer;
  29431. private _bindIndexBufferWithCache;
  29432. private _bindVertexBuffersAttributes;
  29433. /**
  29434. * Records a vertex array object
  29435. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29436. * @param vertexBuffers defines the list of vertex buffers to store
  29437. * @param indexBuffer defines the index buffer to store
  29438. * @param effect defines the effect to store
  29439. * @returns the new vertex array object
  29440. */
  29441. recordVertexArrayObject(vertexBuffers: {
  29442. [key: string]: VertexBuffer;
  29443. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29444. /**
  29445. * Bind a specific vertex array object
  29446. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29447. * @param vertexArrayObject defines the vertex array object to bind
  29448. * @param indexBuffer defines the index buffer to bind
  29449. */
  29450. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29451. /**
  29452. * Bind webGl buffers directly to the webGL context
  29453. * @param vertexBuffer defines the vertex buffer to bind
  29454. * @param indexBuffer defines the index buffer to bind
  29455. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29456. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29457. * @param effect defines the effect associated with the vertex buffer
  29458. */
  29459. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29460. private _unbindVertexArrayObject;
  29461. /**
  29462. * Bind a list of vertex buffers to the webGL context
  29463. * @param vertexBuffers defines the list of vertex buffers to bind
  29464. * @param indexBuffer defines the index buffer to bind
  29465. * @param effect defines the effect associated with the vertex buffers
  29466. */
  29467. bindBuffers(vertexBuffers: {
  29468. [key: string]: Nullable<VertexBuffer>;
  29469. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29470. /**
  29471. * Unbind all instance attributes
  29472. */
  29473. unbindInstanceAttributes(): void;
  29474. /**
  29475. * Release and free the memory of a vertex array object
  29476. * @param vao defines the vertex array object to delete
  29477. */
  29478. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29479. /** @hidden */
  29480. _releaseBuffer(buffer: DataBuffer): boolean;
  29481. protected _deleteBuffer(buffer: DataBuffer): void;
  29482. /**
  29483. * Creates a webGL buffer to use with instanciation
  29484. * @param capacity defines the size of the buffer
  29485. * @returns the webGL buffer
  29486. */
  29487. createInstancesBuffer(capacity: number): DataBuffer;
  29488. /**
  29489. * Delete a webGL buffer used with instanciation
  29490. * @param buffer defines the webGL buffer to delete
  29491. */
  29492. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29493. /**
  29494. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29495. * @param instancesBuffer defines the webGL buffer to update and bind
  29496. * @param data defines the data to store in the buffer
  29497. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29498. */
  29499. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29500. /**
  29501. * Apply all cached states (depth, culling, stencil and alpha)
  29502. */
  29503. applyStates(): void;
  29504. /**
  29505. * Send a draw order
  29506. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29507. * @param indexStart defines the starting index
  29508. * @param indexCount defines the number of index to draw
  29509. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29510. */
  29511. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29512. /**
  29513. * Draw a list of points
  29514. * @param verticesStart defines the index of first vertex to draw
  29515. * @param verticesCount defines the count of vertices to draw
  29516. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29517. */
  29518. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29519. /**
  29520. * Draw a list of unindexed primitives
  29521. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29522. * @param verticesStart defines the index of first vertex to draw
  29523. * @param verticesCount defines the count of vertices to draw
  29524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29525. */
  29526. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29527. /**
  29528. * Draw a list of indexed primitives
  29529. * @param fillMode defines the primitive to use
  29530. * @param indexStart defines the starting index
  29531. * @param indexCount defines the number of index to draw
  29532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29533. */
  29534. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29535. /**
  29536. * Draw a list of unindexed primitives
  29537. * @param fillMode defines the primitive to use
  29538. * @param verticesStart defines the index of first vertex to draw
  29539. * @param verticesCount defines the count of vertices to draw
  29540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29541. */
  29542. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29543. private _drawMode;
  29544. /** @hidden */
  29545. protected _reportDrawCall(): void;
  29546. /** @hidden */
  29547. _releaseEffect(effect: Effect): void;
  29548. /** @hidden */
  29549. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29550. /**
  29551. * Create a new effect (used to store vertex/fragment shaders)
  29552. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29553. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29554. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29555. * @param samplers defines an array of string used to represent textures
  29556. * @param defines defines the string containing the defines to use to compile the shaders
  29557. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29558. * @param onCompiled defines a function to call when the effect creation is successful
  29559. * @param onError defines a function to call when the effect creation has failed
  29560. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29561. * @returns the new Effect
  29562. */
  29563. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29564. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29565. private _compileShader;
  29566. private _compileRawShader;
  29567. /**
  29568. * Directly creates a webGL program
  29569. * @param pipelineContext defines the pipeline context to attach to
  29570. * @param vertexCode defines the vertex shader code to use
  29571. * @param fragmentCode defines the fragment shader code to use
  29572. * @param context defines the webGL context to use (if not set, the current one will be used)
  29573. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29574. * @returns the new webGL program
  29575. */
  29576. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29577. /**
  29578. * Creates a webGL program
  29579. * @param pipelineContext defines the pipeline context to attach to
  29580. * @param vertexCode defines the vertex shader code to use
  29581. * @param fragmentCode defines the fragment shader code to use
  29582. * @param defines defines the string containing the defines to use to compile the shaders
  29583. * @param context defines the webGL context to use (if not set, the current one will be used)
  29584. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29585. * @returns the new webGL program
  29586. */
  29587. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29588. /**
  29589. * Creates a new pipeline context
  29590. * @returns the new pipeline
  29591. */
  29592. createPipelineContext(): IPipelineContext;
  29593. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29594. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29595. /** @hidden */
  29596. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29597. /** @hidden */
  29598. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29599. /** @hidden */
  29600. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29601. /**
  29602. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29603. * @param pipelineContext defines the pipeline context to use
  29604. * @param uniformsNames defines the list of uniform names
  29605. * @returns an array of webGL uniform locations
  29606. */
  29607. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29608. /**
  29609. * Gets the lsit of active attributes for a given webGL program
  29610. * @param pipelineContext defines the pipeline context to use
  29611. * @param attributesNames defines the list of attribute names to get
  29612. * @returns an array of indices indicating the offset of each attribute
  29613. */
  29614. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29615. /**
  29616. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29617. * @param effect defines the effect to activate
  29618. */
  29619. enableEffect(effect: Nullable<Effect>): void;
  29620. /**
  29621. * Set the value of an uniform to an array of int32
  29622. * @param uniform defines the webGL uniform location where to store the value
  29623. * @param array defines the array of int32 to store
  29624. */
  29625. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29626. /**
  29627. * Set the value of an uniform to an array of int32 (stored as vec2)
  29628. * @param uniform defines the webGL uniform location where to store the value
  29629. * @param array defines the array of int32 to store
  29630. */
  29631. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29632. /**
  29633. * Set the value of an uniform to an array of int32 (stored as vec3)
  29634. * @param uniform defines the webGL uniform location where to store the value
  29635. * @param array defines the array of int32 to store
  29636. */
  29637. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29638. /**
  29639. * Set the value of an uniform to an array of int32 (stored as vec4)
  29640. * @param uniform defines the webGL uniform location where to store the value
  29641. * @param array defines the array of int32 to store
  29642. */
  29643. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29644. /**
  29645. * Set the value of an uniform to an array of float32
  29646. * @param uniform defines the webGL uniform location where to store the value
  29647. * @param array defines the array of float32 to store
  29648. */
  29649. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29650. /**
  29651. * Set the value of an uniform to an array of float32 (stored as vec2)
  29652. * @param uniform defines the webGL uniform location where to store the value
  29653. * @param array defines the array of float32 to store
  29654. */
  29655. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29656. /**
  29657. * Set the value of an uniform to an array of float32 (stored as vec3)
  29658. * @param uniform defines the webGL uniform location where to store the value
  29659. * @param array defines the array of float32 to store
  29660. */
  29661. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29662. /**
  29663. * Set the value of an uniform to an array of float32 (stored as vec4)
  29664. * @param uniform defines the webGL uniform location where to store the value
  29665. * @param array defines the array of float32 to store
  29666. */
  29667. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29668. /**
  29669. * Set the value of an uniform to an array of number
  29670. * @param uniform defines the webGL uniform location where to store the value
  29671. * @param array defines the array of number to store
  29672. */
  29673. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29674. /**
  29675. * Set the value of an uniform to an array of number (stored as vec2)
  29676. * @param uniform defines the webGL uniform location where to store the value
  29677. * @param array defines the array of number to store
  29678. */
  29679. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29680. /**
  29681. * Set the value of an uniform to an array of number (stored as vec3)
  29682. * @param uniform defines the webGL uniform location where to store the value
  29683. * @param array defines the array of number to store
  29684. */
  29685. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29686. /**
  29687. * Set the value of an uniform to an array of number (stored as vec4)
  29688. * @param uniform defines the webGL uniform location where to store the value
  29689. * @param array defines the array of number to store
  29690. */
  29691. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29692. /**
  29693. * Set the value of an uniform to an array of float32 (stored as matrices)
  29694. * @param uniform defines the webGL uniform location where to store the value
  29695. * @param matrices defines the array of float32 to store
  29696. */
  29697. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29698. /**
  29699. * Set the value of an uniform to a matrix (3x3)
  29700. * @param uniform defines the webGL uniform location where to store the value
  29701. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29702. */
  29703. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29704. /**
  29705. * Set the value of an uniform to a matrix (2x2)
  29706. * @param uniform defines the webGL uniform location where to store the value
  29707. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29708. */
  29709. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29710. /**
  29711. * Set the value of an uniform to a number (int)
  29712. * @param uniform defines the webGL uniform location where to store the value
  29713. * @param value defines the int number to store
  29714. */
  29715. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29716. /**
  29717. * Set the value of an uniform to a number (float)
  29718. * @param uniform defines the webGL uniform location where to store the value
  29719. * @param value defines the float number to store
  29720. */
  29721. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29722. /**
  29723. * Set the value of an uniform to a vec2
  29724. * @param uniform defines the webGL uniform location where to store the value
  29725. * @param x defines the 1st component of the value
  29726. * @param y defines the 2nd component of the value
  29727. */
  29728. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29729. /**
  29730. * Set the value of an uniform to a vec3
  29731. * @param uniform defines the webGL uniform location where to store the value
  29732. * @param x defines the 1st component of the value
  29733. * @param y defines the 2nd component of the value
  29734. * @param z defines the 3rd component of the value
  29735. */
  29736. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29737. /**
  29738. * Set the value of an uniform to a boolean
  29739. * @param uniform defines the webGL uniform location where to store the value
  29740. * @param bool defines the boolean to store
  29741. */
  29742. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29743. /**
  29744. * Set the value of an uniform to a vec4
  29745. * @param uniform defines the webGL uniform location where to store the value
  29746. * @param x defines the 1st component of the value
  29747. * @param y defines the 2nd component of the value
  29748. * @param z defines the 3rd component of the value
  29749. * @param w defines the 4th component of the value
  29750. */
  29751. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29752. /**
  29753. * Sets a Color4 on a uniform variable
  29754. * @param uniform defines the uniform location
  29755. * @param color4 defines the value to be set
  29756. */
  29757. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29758. /**
  29759. * Gets the depth culling state manager
  29760. */
  29761. readonly depthCullingState: DepthCullingState;
  29762. /**
  29763. * Gets the alpha state manager
  29764. */
  29765. readonly alphaState: AlphaState;
  29766. /**
  29767. * Gets the stencil state manager
  29768. */
  29769. readonly stencilState: StencilState;
  29770. /**
  29771. * Clears the list of texture accessible through engine.
  29772. * This can help preventing texture load conflict due to name collision.
  29773. */
  29774. clearInternalTexturesCache(): void;
  29775. /**
  29776. * Force the entire cache to be cleared
  29777. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29778. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29779. */
  29780. wipeCaches(bruteForce?: boolean): void;
  29781. /** @hidden */
  29782. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29783. min: number;
  29784. mag: number;
  29785. };
  29786. /** @hidden */
  29787. _createTexture(): WebGLTexture;
  29788. /**
  29789. * Usually called from Texture.ts.
  29790. * Passed information to create a WebGLTexture
  29791. * @param urlArg defines a value which contains one of the following:
  29792. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29793. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29794. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29795. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29796. * @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)
  29797. * @param scene needed for loading to the correct scene
  29798. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29799. * @param onLoad optional callback to be called upon successful completion
  29800. * @param onError optional callback to be called upon failure
  29801. * @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
  29802. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29803. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29804. * @param forcedExtension defines the extension to use to pick the right loader
  29805. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29806. * @param mimeType defines an optional mime type
  29807. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29808. */
  29809. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29810. /**
  29811. * @hidden
  29812. */
  29813. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29814. /**
  29815. * Creates a raw texture
  29816. * @param data defines the data to store in the texture
  29817. * @param width defines the width of the texture
  29818. * @param height defines the height of the texture
  29819. * @param format defines the format of the data
  29820. * @param generateMipMaps defines if the engine should generate the mip levels
  29821. * @param invertY defines if data must be stored with Y axis inverted
  29822. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29823. * @param compression defines the compression used (null by default)
  29824. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29825. * @returns the raw texture inside an InternalTexture
  29826. */
  29827. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29828. /**
  29829. * Creates a new raw cube texture
  29830. * @param data defines the array of data to use to create each face
  29831. * @param size defines the size of the textures
  29832. * @param format defines the format of the data
  29833. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29834. * @param generateMipMaps defines if the engine should generate the mip levels
  29835. * @param invertY defines if data must be stored with Y axis inverted
  29836. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29837. * @param compression defines the compression used (null by default)
  29838. * @returns the cube texture as an InternalTexture
  29839. */
  29840. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29841. /**
  29842. * Creates a new raw 3D texture
  29843. * @param data defines the data used to create the texture
  29844. * @param width defines the width of the texture
  29845. * @param height defines the height of the texture
  29846. * @param depth defines the depth of the texture
  29847. * @param format defines the format of the texture
  29848. * @param generateMipMaps defines if the engine must generate mip levels
  29849. * @param invertY defines if data must be stored with Y axis inverted
  29850. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29851. * @param compression defines the compressed used (can be null)
  29852. * @param textureType defines the compressed used (can be null)
  29853. * @returns a new raw 3D texture (stored in an InternalTexture)
  29854. */
  29855. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29856. private _unpackFlipYCached;
  29857. /**
  29858. * In case you are sharing the context with other applications, it might
  29859. * be interested to not cache the unpack flip y state to ensure a consistent
  29860. * value would be set.
  29861. */
  29862. enableUnpackFlipYCached: boolean;
  29863. /** @hidden */
  29864. _unpackFlipY(value: boolean): void;
  29865. /** @hidden */
  29866. _getUnpackAlignement(): number;
  29867. /**
  29868. * Update the sampling mode of a given texture
  29869. * @param samplingMode defines the required sampling mode
  29870. * @param texture defines the texture to update
  29871. */
  29872. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29873. /**
  29874. * Updates a depth texture Comparison Mode and Function.
  29875. * If the comparison Function is equal to 0, the mode will be set to none.
  29876. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29877. * @param texture The texture to set the comparison function for
  29878. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29879. */
  29880. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29881. /** @hidden */
  29882. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29883. width: number;
  29884. height: number;
  29885. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29886. /**
  29887. * Creates a depth stencil texture.
  29888. * This is only available in WebGL 2 or with the depth texture extension available.
  29889. * @param size The size of face edge in the texture.
  29890. * @param options The options defining the texture.
  29891. * @returns The texture
  29892. */
  29893. createDepthStencilTexture(size: number | {
  29894. width: number;
  29895. height: number;
  29896. }, options: DepthTextureCreationOptions): InternalTexture;
  29897. /**
  29898. * Creates a depth stencil texture.
  29899. * This is only available in WebGL 2 or with the depth texture extension available.
  29900. * @param size The size of face edge in the texture.
  29901. * @param options The options defining the texture.
  29902. * @returns The texture
  29903. */
  29904. private _createDepthStencilTexture;
  29905. /** @hidden */
  29906. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29907. /** @hidden */
  29908. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29909. /** @hidden */
  29910. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29911. /** @hidden */
  29912. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  29913. /**
  29914. * @hidden
  29915. */
  29916. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29917. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29918. private _prepareWebGLTexture;
  29919. /** @hidden */
  29920. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29921. /** @hidden */
  29922. _releaseFramebufferObjects(texture: InternalTexture): void;
  29923. /** @hidden */
  29924. _releaseTexture(texture: InternalTexture): void;
  29925. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29926. protected _setProgram(program: WebGLProgram): void;
  29927. protected _boundUniforms: {
  29928. [key: number]: WebGLUniformLocation;
  29929. };
  29930. /**
  29931. * Binds an effect to the webGL context
  29932. * @param effect defines the effect to bind
  29933. */
  29934. bindSamplers(effect: Effect): void;
  29935. private _activateCurrentTexture;
  29936. /** @hidden */
  29937. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29938. /** @hidden */
  29939. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29940. /**
  29941. * Unbind all textures from the webGL context
  29942. */
  29943. unbindAllTextures(): void;
  29944. /**
  29945. * Sets a texture to the according uniform.
  29946. * @param channel The texture channel
  29947. * @param uniform The uniform to set
  29948. * @param texture The texture to apply
  29949. */
  29950. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29951. private _bindSamplerUniformToChannel;
  29952. private _getTextureWrapMode;
  29953. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29954. /**
  29955. * Sets an array of texture to the webGL context
  29956. * @param channel defines the channel where the texture array must be set
  29957. * @param uniform defines the associated uniform location
  29958. * @param textures defines the array of textures to bind
  29959. */
  29960. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29961. /** @hidden */
  29962. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29963. private _setTextureParameterFloat;
  29964. private _setTextureParameterInteger;
  29965. /**
  29966. * Unbind all vertex attributes from the webGL context
  29967. */
  29968. unbindAllAttributes(): void;
  29969. /**
  29970. * 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
  29971. */
  29972. releaseEffects(): void;
  29973. /**
  29974. * Dispose and release all associated resources
  29975. */
  29976. dispose(): void;
  29977. /**
  29978. * Attach a new callback raised when context lost event is fired
  29979. * @param callback defines the callback to call
  29980. */
  29981. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29982. /**
  29983. * Attach a new callback raised when context restored event is fired
  29984. * @param callback defines the callback to call
  29985. */
  29986. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29987. /**
  29988. * Get the current error code of the webGL context
  29989. * @returns the error code
  29990. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29991. */
  29992. getError(): number;
  29993. private _canRenderToFloatFramebuffer;
  29994. private _canRenderToHalfFloatFramebuffer;
  29995. private _canRenderToFramebuffer;
  29996. /** @hidden */
  29997. _getWebGLTextureType(type: number): number;
  29998. /** @hidden */
  29999. _getInternalFormat(format: number): number;
  30000. /** @hidden */
  30001. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30002. /** @hidden */
  30003. _getRGBAMultiSampleBufferFormat(type: number): number;
  30004. /** @hidden */
  30005. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30006. /**
  30007. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30008. * @returns true if the engine can be created
  30009. * @ignorenaming
  30010. */
  30011. static isSupported(): boolean;
  30012. /**
  30013. * Find the next highest power of two.
  30014. * @param x Number to start search from.
  30015. * @return Next highest power of two.
  30016. */
  30017. static CeilingPOT(x: number): number;
  30018. /**
  30019. * Find the next lowest power of two.
  30020. * @param x Number to start search from.
  30021. * @return Next lowest power of two.
  30022. */
  30023. static FloorPOT(x: number): number;
  30024. /**
  30025. * Find the nearest power of two.
  30026. * @param x Number to start search from.
  30027. * @return Next nearest power of two.
  30028. */
  30029. static NearestPOT(x: number): number;
  30030. /**
  30031. * Get the closest exponent of two
  30032. * @param value defines the value to approximate
  30033. * @param max defines the maximum value to return
  30034. * @param mode defines how to define the closest value
  30035. * @returns closest exponent of two of the given value
  30036. */
  30037. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30038. /**
  30039. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30040. * @param func - the function to be called
  30041. * @param requester - the object that will request the next frame. Falls back to window.
  30042. * @returns frame number
  30043. */
  30044. static QueueNewFrame(func: () => void, requester?: any): number;
  30045. }
  30046. }
  30047. declare module BABYLON {
  30048. /**
  30049. * Class representing spherical harmonics coefficients to the 3rd degree
  30050. */
  30051. export class SphericalHarmonics {
  30052. /**
  30053. * Defines whether or not the harmonics have been prescaled for rendering.
  30054. */
  30055. preScaled: boolean;
  30056. /**
  30057. * The l0,0 coefficients of the spherical harmonics
  30058. */
  30059. l00: Vector3;
  30060. /**
  30061. * The l1,-1 coefficients of the spherical harmonics
  30062. */
  30063. l1_1: Vector3;
  30064. /**
  30065. * The l1,0 coefficients of the spherical harmonics
  30066. */
  30067. l10: Vector3;
  30068. /**
  30069. * The l1,1 coefficients of the spherical harmonics
  30070. */
  30071. l11: Vector3;
  30072. /**
  30073. * The l2,-2 coefficients of the spherical harmonics
  30074. */
  30075. l2_2: Vector3;
  30076. /**
  30077. * The l2,-1 coefficients of the spherical harmonics
  30078. */
  30079. l2_1: Vector3;
  30080. /**
  30081. * The l2,0 coefficients of the spherical harmonics
  30082. */
  30083. l20: Vector3;
  30084. /**
  30085. * The l2,1 coefficients of the spherical harmonics
  30086. */
  30087. l21: Vector3;
  30088. /**
  30089. * The l2,2 coefficients of the spherical harmonics
  30090. */
  30091. l22: Vector3;
  30092. /**
  30093. * Adds a light to the spherical harmonics
  30094. * @param direction the direction of the light
  30095. * @param color the color of the light
  30096. * @param deltaSolidAngle the delta solid angle of the light
  30097. */
  30098. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30099. /**
  30100. * Scales the spherical harmonics by the given amount
  30101. * @param scale the amount to scale
  30102. */
  30103. scaleInPlace(scale: number): void;
  30104. /**
  30105. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30106. *
  30107. * ```
  30108. * E_lm = A_l * L_lm
  30109. * ```
  30110. *
  30111. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30112. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30113. * the scaling factors are given in equation 9.
  30114. */
  30115. convertIncidentRadianceToIrradiance(): void;
  30116. /**
  30117. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30118. *
  30119. * ```
  30120. * L = (1/pi) * E * rho
  30121. * ```
  30122. *
  30123. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30124. */
  30125. convertIrradianceToLambertianRadiance(): void;
  30126. /**
  30127. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30128. * required operations at run time.
  30129. *
  30130. * This is simply done by scaling back the SH with Ylm constants parameter.
  30131. * The trigonometric part being applied by the shader at run time.
  30132. */
  30133. preScaleForRendering(): void;
  30134. /**
  30135. * Constructs a spherical harmonics from an array.
  30136. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30137. * @returns the spherical harmonics
  30138. */
  30139. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30140. /**
  30141. * Gets the spherical harmonics from polynomial
  30142. * @param polynomial the spherical polynomial
  30143. * @returns the spherical harmonics
  30144. */
  30145. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30146. }
  30147. /**
  30148. * Class representing spherical polynomial coefficients to the 3rd degree
  30149. */
  30150. export class SphericalPolynomial {
  30151. private _harmonics;
  30152. /**
  30153. * The spherical harmonics used to create the polynomials.
  30154. */
  30155. readonly preScaledHarmonics: SphericalHarmonics;
  30156. /**
  30157. * The x coefficients of the spherical polynomial
  30158. */
  30159. x: Vector3;
  30160. /**
  30161. * The y coefficients of the spherical polynomial
  30162. */
  30163. y: Vector3;
  30164. /**
  30165. * The z coefficients of the spherical polynomial
  30166. */
  30167. z: Vector3;
  30168. /**
  30169. * The xx coefficients of the spherical polynomial
  30170. */
  30171. xx: Vector3;
  30172. /**
  30173. * The yy coefficients of the spherical polynomial
  30174. */
  30175. yy: Vector3;
  30176. /**
  30177. * The zz coefficients of the spherical polynomial
  30178. */
  30179. zz: Vector3;
  30180. /**
  30181. * The xy coefficients of the spherical polynomial
  30182. */
  30183. xy: Vector3;
  30184. /**
  30185. * The yz coefficients of the spherical polynomial
  30186. */
  30187. yz: Vector3;
  30188. /**
  30189. * The zx coefficients of the spherical polynomial
  30190. */
  30191. zx: Vector3;
  30192. /**
  30193. * Adds an ambient color to the spherical polynomial
  30194. * @param color the color to add
  30195. */
  30196. addAmbient(color: Color3): void;
  30197. /**
  30198. * Scales the spherical polynomial by the given amount
  30199. * @param scale the amount to scale
  30200. */
  30201. scaleInPlace(scale: number): void;
  30202. /**
  30203. * Gets the spherical polynomial from harmonics
  30204. * @param harmonics the spherical harmonics
  30205. * @returns the spherical polynomial
  30206. */
  30207. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30208. /**
  30209. * Constructs a spherical polynomial from an array.
  30210. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30211. * @returns the spherical polynomial
  30212. */
  30213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30214. }
  30215. }
  30216. declare module BABYLON {
  30217. /**
  30218. * Defines the source of the internal texture
  30219. */
  30220. export enum InternalTextureSource {
  30221. /**
  30222. * The source of the texture data is unknown
  30223. */
  30224. Unknown = 0,
  30225. /**
  30226. * Texture data comes from an URL
  30227. */
  30228. Url = 1,
  30229. /**
  30230. * Texture data is only used for temporary storage
  30231. */
  30232. Temp = 2,
  30233. /**
  30234. * Texture data comes from raw data (ArrayBuffer)
  30235. */
  30236. Raw = 3,
  30237. /**
  30238. * Texture content is dynamic (video or dynamic texture)
  30239. */
  30240. Dynamic = 4,
  30241. /**
  30242. * Texture content is generated by rendering to it
  30243. */
  30244. RenderTarget = 5,
  30245. /**
  30246. * Texture content is part of a multi render target process
  30247. */
  30248. MultiRenderTarget = 6,
  30249. /**
  30250. * Texture data comes from a cube data file
  30251. */
  30252. Cube = 7,
  30253. /**
  30254. * Texture data comes from a raw cube data
  30255. */
  30256. CubeRaw = 8,
  30257. /**
  30258. * Texture data come from a prefiltered cube data file
  30259. */
  30260. CubePrefiltered = 9,
  30261. /**
  30262. * Texture content is raw 3D data
  30263. */
  30264. Raw3D = 10,
  30265. /**
  30266. * Texture content is a depth texture
  30267. */
  30268. Depth = 11,
  30269. /**
  30270. * Texture data comes from a raw cube data encoded with RGBD
  30271. */
  30272. CubeRawRGBD = 12
  30273. }
  30274. /**
  30275. * Class used to store data associated with WebGL texture data for the engine
  30276. * This class should not be used directly
  30277. */
  30278. export class InternalTexture {
  30279. /** @hidden */
  30280. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30281. /**
  30282. * Defines if the texture is ready
  30283. */
  30284. isReady: boolean;
  30285. /**
  30286. * Defines if the texture is a cube texture
  30287. */
  30288. isCube: boolean;
  30289. /**
  30290. * Defines if the texture contains 3D data
  30291. */
  30292. is3D: boolean;
  30293. /**
  30294. * Defines if the texture contains multiview data
  30295. */
  30296. isMultiview: boolean;
  30297. /**
  30298. * Gets the URL used to load this texture
  30299. */
  30300. url: string;
  30301. /**
  30302. * Gets the sampling mode of the texture
  30303. */
  30304. samplingMode: number;
  30305. /**
  30306. * Gets a boolean indicating if the texture needs mipmaps generation
  30307. */
  30308. generateMipMaps: boolean;
  30309. /**
  30310. * Gets the number of samples used by the texture (WebGL2+ only)
  30311. */
  30312. samples: number;
  30313. /**
  30314. * Gets the type of the texture (int, float...)
  30315. */
  30316. type: number;
  30317. /**
  30318. * Gets the format of the texture (RGB, RGBA...)
  30319. */
  30320. format: number;
  30321. /**
  30322. * Observable called when the texture is loaded
  30323. */
  30324. onLoadedObservable: Observable<InternalTexture>;
  30325. /**
  30326. * Gets the width of the texture
  30327. */
  30328. width: number;
  30329. /**
  30330. * Gets the height of the texture
  30331. */
  30332. height: number;
  30333. /**
  30334. * Gets the depth of the texture
  30335. */
  30336. depth: number;
  30337. /**
  30338. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30339. */
  30340. baseWidth: number;
  30341. /**
  30342. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30343. */
  30344. baseHeight: number;
  30345. /**
  30346. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30347. */
  30348. baseDepth: number;
  30349. /**
  30350. * Gets a boolean indicating if the texture is inverted on Y axis
  30351. */
  30352. invertY: boolean;
  30353. /** @hidden */
  30354. _invertVScale: boolean;
  30355. /** @hidden */
  30356. _associatedChannel: number;
  30357. /** @hidden */
  30358. _source: InternalTextureSource;
  30359. /** @hidden */
  30360. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30361. /** @hidden */
  30362. _bufferView: Nullable<ArrayBufferView>;
  30363. /** @hidden */
  30364. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30365. /** @hidden */
  30366. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30367. /** @hidden */
  30368. _size: number;
  30369. /** @hidden */
  30370. _extension: string;
  30371. /** @hidden */
  30372. _files: Nullable<string[]>;
  30373. /** @hidden */
  30374. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30375. /** @hidden */
  30376. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30377. /** @hidden */
  30378. _framebuffer: Nullable<WebGLFramebuffer>;
  30379. /** @hidden */
  30380. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30381. /** @hidden */
  30382. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30383. /** @hidden */
  30384. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30385. /** @hidden */
  30386. _attachments: Nullable<number[]>;
  30387. /** @hidden */
  30388. _cachedCoordinatesMode: Nullable<number>;
  30389. /** @hidden */
  30390. _cachedWrapU: Nullable<number>;
  30391. /** @hidden */
  30392. _cachedWrapV: Nullable<number>;
  30393. /** @hidden */
  30394. _cachedWrapR: Nullable<number>;
  30395. /** @hidden */
  30396. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30397. /** @hidden */
  30398. _isDisabled: boolean;
  30399. /** @hidden */
  30400. _compression: Nullable<string>;
  30401. /** @hidden */
  30402. _generateStencilBuffer: boolean;
  30403. /** @hidden */
  30404. _generateDepthBuffer: boolean;
  30405. /** @hidden */
  30406. _comparisonFunction: number;
  30407. /** @hidden */
  30408. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30409. /** @hidden */
  30410. _lodGenerationScale: number;
  30411. /** @hidden */
  30412. _lodGenerationOffset: number;
  30413. /** @hidden */
  30414. _colorTextureArray: Nullable<WebGLTexture>;
  30415. /** @hidden */
  30416. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30417. /** @hidden */
  30418. _lodTextureHigh: Nullable<BaseTexture>;
  30419. /** @hidden */
  30420. _lodTextureMid: Nullable<BaseTexture>;
  30421. /** @hidden */
  30422. _lodTextureLow: Nullable<BaseTexture>;
  30423. /** @hidden */
  30424. _isRGBD: boolean;
  30425. /** @hidden */
  30426. _linearSpecularLOD: boolean;
  30427. /** @hidden */
  30428. _irradianceTexture: Nullable<BaseTexture>;
  30429. /** @hidden */
  30430. _webGLTexture: Nullable<WebGLTexture>;
  30431. /** @hidden */
  30432. _references: number;
  30433. private _engine;
  30434. /**
  30435. * Gets the Engine the texture belongs to.
  30436. * @returns The babylon engine
  30437. */
  30438. getEngine(): ThinEngine;
  30439. /**
  30440. * Gets the data source type of the texture
  30441. */
  30442. readonly source: InternalTextureSource;
  30443. /**
  30444. * Creates a new InternalTexture
  30445. * @param engine defines the engine to use
  30446. * @param source defines the type of data that will be used
  30447. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30448. */
  30449. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30450. /**
  30451. * Increments the number of references (ie. the number of Texture that point to it)
  30452. */
  30453. incrementReferences(): void;
  30454. /**
  30455. * Change the size of the texture (not the size of the content)
  30456. * @param width defines the new width
  30457. * @param height defines the new height
  30458. * @param depth defines the new depth (1 by default)
  30459. */
  30460. updateSize(width: int, height: int, depth?: int): void;
  30461. /** @hidden */
  30462. _rebuild(): void;
  30463. /** @hidden */
  30464. _swapAndDie(target: InternalTexture): void;
  30465. /**
  30466. * Dispose the current allocated resources
  30467. */
  30468. dispose(): void;
  30469. }
  30470. }
  30471. declare module BABYLON {
  30472. /**
  30473. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30475. */
  30476. export class Analyser {
  30477. /**
  30478. * Gets or sets the smoothing
  30479. * @ignorenaming
  30480. */
  30481. SMOOTHING: number;
  30482. /**
  30483. * Gets or sets the FFT table size
  30484. * @ignorenaming
  30485. */
  30486. FFT_SIZE: number;
  30487. /**
  30488. * Gets or sets the bar graph amplitude
  30489. * @ignorenaming
  30490. */
  30491. BARGRAPHAMPLITUDE: number;
  30492. /**
  30493. * Gets or sets the position of the debug canvas
  30494. * @ignorenaming
  30495. */
  30496. DEBUGCANVASPOS: {
  30497. x: number;
  30498. y: number;
  30499. };
  30500. /**
  30501. * Gets or sets the debug canvas size
  30502. * @ignorenaming
  30503. */
  30504. DEBUGCANVASSIZE: {
  30505. width: number;
  30506. height: number;
  30507. };
  30508. private _byteFreqs;
  30509. private _byteTime;
  30510. private _floatFreqs;
  30511. private _webAudioAnalyser;
  30512. private _debugCanvas;
  30513. private _debugCanvasContext;
  30514. private _scene;
  30515. private _registerFunc;
  30516. private _audioEngine;
  30517. /**
  30518. * Creates a new analyser
  30519. * @param scene defines hosting scene
  30520. */
  30521. constructor(scene: Scene);
  30522. /**
  30523. * Get the number of data values you will have to play with for the visualization
  30524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30525. * @returns a number
  30526. */
  30527. getFrequencyBinCount(): number;
  30528. /**
  30529. * Gets the current frequency data as a byte array
  30530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30531. * @returns a Uint8Array
  30532. */
  30533. getByteFrequencyData(): Uint8Array;
  30534. /**
  30535. * Gets the current waveform as a byte array
  30536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30537. * @returns a Uint8Array
  30538. */
  30539. getByteTimeDomainData(): Uint8Array;
  30540. /**
  30541. * Gets the current frequency data as a float array
  30542. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30543. * @returns a Float32Array
  30544. */
  30545. getFloatFrequencyData(): Float32Array;
  30546. /**
  30547. * Renders the debug canvas
  30548. */
  30549. drawDebugCanvas(): void;
  30550. /**
  30551. * Stops rendering the debug canvas and removes it
  30552. */
  30553. stopDebugCanvas(): void;
  30554. /**
  30555. * Connects two audio nodes
  30556. * @param inputAudioNode defines first node to connect
  30557. * @param outputAudioNode defines second node to connect
  30558. */
  30559. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30560. /**
  30561. * Releases all associated resources
  30562. */
  30563. dispose(): void;
  30564. }
  30565. }
  30566. declare module BABYLON {
  30567. /**
  30568. * This represents an audio engine and it is responsible
  30569. * to play, synchronize and analyse sounds throughout the application.
  30570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30571. */
  30572. export interface IAudioEngine extends IDisposable {
  30573. /**
  30574. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30575. */
  30576. readonly canUseWebAudio: boolean;
  30577. /**
  30578. * Gets the current AudioContext if available.
  30579. */
  30580. readonly audioContext: Nullable<AudioContext>;
  30581. /**
  30582. * The master gain node defines the global audio volume of your audio engine.
  30583. */
  30584. readonly masterGain: GainNode;
  30585. /**
  30586. * Gets whether or not mp3 are supported by your browser.
  30587. */
  30588. readonly isMP3supported: boolean;
  30589. /**
  30590. * Gets whether or not ogg are supported by your browser.
  30591. */
  30592. readonly isOGGsupported: boolean;
  30593. /**
  30594. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30595. * @ignoreNaming
  30596. */
  30597. WarnedWebAudioUnsupported: boolean;
  30598. /**
  30599. * Defines if the audio engine relies on a custom unlocked button.
  30600. * In this case, the embedded button will not be displayed.
  30601. */
  30602. useCustomUnlockedButton: boolean;
  30603. /**
  30604. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30605. */
  30606. readonly unlocked: boolean;
  30607. /**
  30608. * Event raised when audio has been unlocked on the browser.
  30609. */
  30610. onAudioUnlockedObservable: Observable<AudioEngine>;
  30611. /**
  30612. * Event raised when audio has been locked on the browser.
  30613. */
  30614. onAudioLockedObservable: Observable<AudioEngine>;
  30615. /**
  30616. * Flags the audio engine in Locked state.
  30617. * This happens due to new browser policies preventing audio to autoplay.
  30618. */
  30619. lock(): void;
  30620. /**
  30621. * Unlocks the audio engine once a user action has been done on the dom.
  30622. * This is helpful to resume play once browser policies have been satisfied.
  30623. */
  30624. unlock(): void;
  30625. }
  30626. /**
  30627. * This represents the default audio engine used in babylon.
  30628. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30630. */
  30631. export class AudioEngine implements IAudioEngine {
  30632. private _audioContext;
  30633. private _audioContextInitialized;
  30634. private _muteButton;
  30635. private _hostElement;
  30636. /**
  30637. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30638. */
  30639. canUseWebAudio: boolean;
  30640. /**
  30641. * The master gain node defines the global audio volume of your audio engine.
  30642. */
  30643. masterGain: GainNode;
  30644. /**
  30645. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30646. * @ignoreNaming
  30647. */
  30648. WarnedWebAudioUnsupported: boolean;
  30649. /**
  30650. * Gets whether or not mp3 are supported by your browser.
  30651. */
  30652. isMP3supported: boolean;
  30653. /**
  30654. * Gets whether or not ogg are supported by your browser.
  30655. */
  30656. isOGGsupported: boolean;
  30657. /**
  30658. * Gets whether audio has been unlocked on the device.
  30659. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30660. * a user interaction has happened.
  30661. */
  30662. unlocked: boolean;
  30663. /**
  30664. * Defines if the audio engine relies on a custom unlocked button.
  30665. * In this case, the embedded button will not be displayed.
  30666. */
  30667. useCustomUnlockedButton: boolean;
  30668. /**
  30669. * Event raised when audio has been unlocked on the browser.
  30670. */
  30671. onAudioUnlockedObservable: Observable<AudioEngine>;
  30672. /**
  30673. * Event raised when audio has been locked on the browser.
  30674. */
  30675. onAudioLockedObservable: Observable<AudioEngine>;
  30676. /**
  30677. * Gets the current AudioContext if available.
  30678. */
  30679. readonly audioContext: Nullable<AudioContext>;
  30680. private _connectedAnalyser;
  30681. /**
  30682. * Instantiates a new audio engine.
  30683. *
  30684. * There should be only one per page as some browsers restrict the number
  30685. * of audio contexts you can create.
  30686. * @param hostElement defines the host element where to display the mute icon if necessary
  30687. */
  30688. constructor(hostElement?: Nullable<HTMLElement>);
  30689. /**
  30690. * Flags the audio engine in Locked state.
  30691. * This happens due to new browser policies preventing audio to autoplay.
  30692. */
  30693. lock(): void;
  30694. /**
  30695. * Unlocks the audio engine once a user action has been done on the dom.
  30696. * This is helpful to resume play once browser policies have been satisfied.
  30697. */
  30698. unlock(): void;
  30699. private _resumeAudioContext;
  30700. private _initializeAudioContext;
  30701. private _tryToRun;
  30702. private _triggerRunningState;
  30703. private _triggerSuspendedState;
  30704. private _displayMuteButton;
  30705. private _moveButtonToTopLeft;
  30706. private _onResize;
  30707. private _hideMuteButton;
  30708. /**
  30709. * Destroy and release the resources associated with the audio ccontext.
  30710. */
  30711. dispose(): void;
  30712. /**
  30713. * Gets the global volume sets on the master gain.
  30714. * @returns the global volume if set or -1 otherwise
  30715. */
  30716. getGlobalVolume(): number;
  30717. /**
  30718. * Sets the global volume of your experience (sets on the master gain).
  30719. * @param newVolume Defines the new global volume of the application
  30720. */
  30721. setGlobalVolume(newVolume: number): void;
  30722. /**
  30723. * Connect the audio engine to an audio analyser allowing some amazing
  30724. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30726. * @param analyser The analyser to connect to the engine
  30727. */
  30728. connectToAnalyser(analyser: Analyser): void;
  30729. }
  30730. }
  30731. declare module BABYLON {
  30732. /**
  30733. * Interface used to present a loading screen while loading a scene
  30734. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30735. */
  30736. export interface ILoadingScreen {
  30737. /**
  30738. * Function called to display the loading screen
  30739. */
  30740. displayLoadingUI: () => void;
  30741. /**
  30742. * Function called to hide the loading screen
  30743. */
  30744. hideLoadingUI: () => void;
  30745. /**
  30746. * Gets or sets the color to use for the background
  30747. */
  30748. loadingUIBackgroundColor: string;
  30749. /**
  30750. * Gets or sets the text to display while loading
  30751. */
  30752. loadingUIText: string;
  30753. }
  30754. /**
  30755. * Class used for the default loading screen
  30756. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30757. */
  30758. export class DefaultLoadingScreen implements ILoadingScreen {
  30759. private _renderingCanvas;
  30760. private _loadingText;
  30761. private _loadingDivBackgroundColor;
  30762. private _loadingDiv;
  30763. private _loadingTextDiv;
  30764. /** Gets or sets the logo url to use for the default loading screen */
  30765. static DefaultLogoUrl: string;
  30766. /** Gets or sets the spinner url to use for the default loading screen */
  30767. static DefaultSpinnerUrl: string;
  30768. /**
  30769. * Creates a new default loading screen
  30770. * @param _renderingCanvas defines the canvas used to render the scene
  30771. * @param _loadingText defines the default text to display
  30772. * @param _loadingDivBackgroundColor defines the default background color
  30773. */
  30774. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30775. /**
  30776. * Function called to display the loading screen
  30777. */
  30778. displayLoadingUI(): void;
  30779. /**
  30780. * Function called to hide the loading screen
  30781. */
  30782. hideLoadingUI(): void;
  30783. /**
  30784. * Gets or sets the text to display while loading
  30785. */
  30786. loadingUIText: string;
  30787. /**
  30788. * Gets or sets the color to use for the background
  30789. */
  30790. loadingUIBackgroundColor: string;
  30791. private _resizeLoadingUI;
  30792. }
  30793. }
  30794. declare module BABYLON {
  30795. /**
  30796. * Interface for any object that can request an animation frame
  30797. */
  30798. export interface ICustomAnimationFrameRequester {
  30799. /**
  30800. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30801. */
  30802. renderFunction?: Function;
  30803. /**
  30804. * Called to request the next frame to render to
  30805. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30806. */
  30807. requestAnimationFrame: Function;
  30808. /**
  30809. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30810. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30811. */
  30812. requestID?: number;
  30813. }
  30814. }
  30815. declare module BABYLON {
  30816. /**
  30817. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30818. */
  30819. export class PerformanceMonitor {
  30820. private _enabled;
  30821. private _rollingFrameTime;
  30822. private _lastFrameTimeMs;
  30823. /**
  30824. * constructor
  30825. * @param frameSampleSize The number of samples required to saturate the sliding window
  30826. */
  30827. constructor(frameSampleSize?: number);
  30828. /**
  30829. * Samples current frame
  30830. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30831. */
  30832. sampleFrame(timeMs?: number): void;
  30833. /**
  30834. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30835. */
  30836. readonly averageFrameTime: number;
  30837. /**
  30838. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30839. */
  30840. readonly averageFrameTimeVariance: number;
  30841. /**
  30842. * Returns the frame time of the most recent frame
  30843. */
  30844. readonly instantaneousFrameTime: number;
  30845. /**
  30846. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30847. */
  30848. readonly averageFPS: number;
  30849. /**
  30850. * Returns the average framerate in frames per second using the most recent frame time
  30851. */
  30852. readonly instantaneousFPS: number;
  30853. /**
  30854. * Returns true if enough samples have been taken to completely fill the sliding window
  30855. */
  30856. readonly isSaturated: boolean;
  30857. /**
  30858. * Enables contributions to the sliding window sample set
  30859. */
  30860. enable(): void;
  30861. /**
  30862. * Disables contributions to the sliding window sample set
  30863. * Samples will not be interpolated over the disabled period
  30864. */
  30865. disable(): void;
  30866. /**
  30867. * Returns true if sampling is enabled
  30868. */
  30869. readonly isEnabled: boolean;
  30870. /**
  30871. * Resets performance monitor
  30872. */
  30873. reset(): void;
  30874. }
  30875. /**
  30876. * RollingAverage
  30877. *
  30878. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30879. */
  30880. export class RollingAverage {
  30881. /**
  30882. * Current average
  30883. */
  30884. average: number;
  30885. /**
  30886. * Current variance
  30887. */
  30888. variance: number;
  30889. protected _samples: Array<number>;
  30890. protected _sampleCount: number;
  30891. protected _pos: number;
  30892. protected _m2: number;
  30893. /**
  30894. * constructor
  30895. * @param length The number of samples required to saturate the sliding window
  30896. */
  30897. constructor(length: number);
  30898. /**
  30899. * Adds a sample to the sample set
  30900. * @param v The sample value
  30901. */
  30902. add(v: number): void;
  30903. /**
  30904. * Returns previously added values or null if outside of history or outside the sliding window domain
  30905. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30906. * @return Value previously recorded with add() or null if outside of range
  30907. */
  30908. history(i: number): number;
  30909. /**
  30910. * Returns true if enough samples have been taken to completely fill the sliding window
  30911. * @return true if sample-set saturated
  30912. */
  30913. isSaturated(): boolean;
  30914. /**
  30915. * Resets the rolling average (equivalent to 0 samples taken so far)
  30916. */
  30917. reset(): void;
  30918. /**
  30919. * Wraps a value around the sample range boundaries
  30920. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30921. * @return Wrapped position in sample range
  30922. */
  30923. protected _wrapPosition(i: number): number;
  30924. }
  30925. }
  30926. declare module BABYLON {
  30927. /**
  30928. * This class is used to track a performance counter which is number based.
  30929. * The user has access to many properties which give statistics of different nature.
  30930. *
  30931. * The implementer can track two kinds of Performance Counter: time and count.
  30932. * 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.
  30933. * 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.
  30934. */
  30935. export class PerfCounter {
  30936. /**
  30937. * Gets or sets a global boolean to turn on and off all the counters
  30938. */
  30939. static Enabled: boolean;
  30940. /**
  30941. * Returns the smallest value ever
  30942. */
  30943. readonly min: number;
  30944. /**
  30945. * Returns the biggest value ever
  30946. */
  30947. readonly max: number;
  30948. /**
  30949. * Returns the average value since the performance counter is running
  30950. */
  30951. readonly average: number;
  30952. /**
  30953. * Returns the average value of the last second the counter was monitored
  30954. */
  30955. readonly lastSecAverage: number;
  30956. /**
  30957. * Returns the current value
  30958. */
  30959. readonly current: number;
  30960. /**
  30961. * Gets the accumulated total
  30962. */
  30963. readonly total: number;
  30964. /**
  30965. * Gets the total value count
  30966. */
  30967. readonly count: number;
  30968. /**
  30969. * Creates a new counter
  30970. */
  30971. constructor();
  30972. /**
  30973. * Call this method to start monitoring a new frame.
  30974. * 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.
  30975. */
  30976. fetchNewFrame(): void;
  30977. /**
  30978. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30979. * @param newCount the count value to add to the monitored count
  30980. * @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.
  30981. */
  30982. addCount(newCount: number, fetchResult: boolean): void;
  30983. /**
  30984. * Start monitoring this performance counter
  30985. */
  30986. beginMonitoring(): void;
  30987. /**
  30988. * Compute the time lapsed since the previous beginMonitoring() call.
  30989. * @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
  30990. */
  30991. endMonitoring(newFrame?: boolean): void;
  30992. private _fetchResult;
  30993. private _startMonitoringTime;
  30994. private _min;
  30995. private _max;
  30996. private _average;
  30997. private _current;
  30998. private _totalValueCount;
  30999. private _totalAccumulated;
  31000. private _lastSecAverage;
  31001. private _lastSecAccumulated;
  31002. private _lastSecTime;
  31003. private _lastSecValueCount;
  31004. }
  31005. }
  31006. declare module BABYLON {
  31007. /**
  31008. * Defines the interface used by display changed events
  31009. */
  31010. export interface IDisplayChangedEventArgs {
  31011. /** Gets the vrDisplay object (if any) */
  31012. vrDisplay: Nullable<any>;
  31013. /** Gets a boolean indicating if webVR is supported */
  31014. vrSupported: boolean;
  31015. }
  31016. /**
  31017. * Defines the interface used by objects containing a viewport (like a camera)
  31018. */
  31019. interface IViewportOwnerLike {
  31020. /**
  31021. * Gets or sets the viewport
  31022. */
  31023. viewport: IViewportLike;
  31024. }
  31025. /**
  31026. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31027. */
  31028. export class Engine extends ThinEngine {
  31029. /** Defines that alpha blending is disabled */
  31030. static readonly ALPHA_DISABLE: number;
  31031. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31032. static readonly ALPHA_ADD: number;
  31033. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31034. static readonly ALPHA_COMBINE: number;
  31035. /** Defines that alpha blending to DEST - SRC * DEST */
  31036. static readonly ALPHA_SUBTRACT: number;
  31037. /** Defines that alpha blending to SRC * DEST */
  31038. static readonly ALPHA_MULTIPLY: number;
  31039. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31040. static readonly ALPHA_MAXIMIZED: number;
  31041. /** Defines that alpha blending to SRC + DEST */
  31042. static readonly ALPHA_ONEONE: number;
  31043. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31044. static readonly ALPHA_PREMULTIPLIED: number;
  31045. /**
  31046. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31047. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31048. */
  31049. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31050. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31051. static readonly ALPHA_INTERPOLATE: number;
  31052. /**
  31053. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31054. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31055. */
  31056. static readonly ALPHA_SCREENMODE: number;
  31057. /** Defines that the ressource is not delayed*/
  31058. static readonly DELAYLOADSTATE_NONE: number;
  31059. /** Defines that the ressource was successfully delay loaded */
  31060. static readonly DELAYLOADSTATE_LOADED: number;
  31061. /** Defines that the ressource is currently delay loading */
  31062. static readonly DELAYLOADSTATE_LOADING: number;
  31063. /** Defines that the ressource is delayed and has not started loading */
  31064. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31065. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31066. static readonly NEVER: number;
  31067. /** 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 */
  31068. static readonly ALWAYS: number;
  31069. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31070. static readonly LESS: number;
  31071. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31072. static readonly EQUAL: number;
  31073. /** 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 */
  31074. static readonly LEQUAL: number;
  31075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31076. static readonly GREATER: number;
  31077. /** 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 */
  31078. static readonly GEQUAL: number;
  31079. /** 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 */
  31080. static readonly NOTEQUAL: number;
  31081. /** Passed to stencilOperation to specify that stencil value must be kept */
  31082. static readonly KEEP: number;
  31083. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31084. static readonly REPLACE: number;
  31085. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31086. static readonly INCR: number;
  31087. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31088. static readonly DECR: number;
  31089. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31090. static readonly INVERT: number;
  31091. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31092. static readonly INCR_WRAP: number;
  31093. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31094. static readonly DECR_WRAP: number;
  31095. /** Texture is not repeating outside of 0..1 UVs */
  31096. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31097. /** Texture is repeating outside of 0..1 UVs */
  31098. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31099. /** Texture is repeating and mirrored */
  31100. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31101. /** ALPHA */
  31102. static readonly TEXTUREFORMAT_ALPHA: number;
  31103. /** LUMINANCE */
  31104. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31105. /** LUMINANCE_ALPHA */
  31106. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31107. /** RGB */
  31108. static readonly TEXTUREFORMAT_RGB: number;
  31109. /** RGBA */
  31110. static readonly TEXTUREFORMAT_RGBA: number;
  31111. /** RED */
  31112. static readonly TEXTUREFORMAT_RED: number;
  31113. /** RED (2nd reference) */
  31114. static readonly TEXTUREFORMAT_R: number;
  31115. /** RG */
  31116. static readonly TEXTUREFORMAT_RG: number;
  31117. /** RED_INTEGER */
  31118. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31119. /** RED_INTEGER (2nd reference) */
  31120. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31121. /** RG_INTEGER */
  31122. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31123. /** RGB_INTEGER */
  31124. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31125. /** RGBA_INTEGER */
  31126. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31127. /** UNSIGNED_BYTE */
  31128. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31129. /** UNSIGNED_BYTE (2nd reference) */
  31130. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31131. /** FLOAT */
  31132. static readonly TEXTURETYPE_FLOAT: number;
  31133. /** HALF_FLOAT */
  31134. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31135. /** BYTE */
  31136. static readonly TEXTURETYPE_BYTE: number;
  31137. /** SHORT */
  31138. static readonly TEXTURETYPE_SHORT: number;
  31139. /** UNSIGNED_SHORT */
  31140. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31141. /** INT */
  31142. static readonly TEXTURETYPE_INT: number;
  31143. /** UNSIGNED_INT */
  31144. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31145. /** UNSIGNED_SHORT_4_4_4_4 */
  31146. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31147. /** UNSIGNED_SHORT_5_5_5_1 */
  31148. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31149. /** UNSIGNED_SHORT_5_6_5 */
  31150. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31151. /** UNSIGNED_INT_2_10_10_10_REV */
  31152. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31153. /** UNSIGNED_INT_24_8 */
  31154. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31155. /** UNSIGNED_INT_10F_11F_11F_REV */
  31156. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31157. /** UNSIGNED_INT_5_9_9_9_REV */
  31158. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31159. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31160. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31161. /** nearest is mag = nearest and min = nearest and mip = linear */
  31162. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31163. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31164. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31165. /** Trilinear is mag = linear and min = linear and mip = linear */
  31166. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31167. /** nearest is mag = nearest and min = nearest and mip = linear */
  31168. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31169. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31170. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31171. /** Trilinear is mag = linear and min = linear and mip = linear */
  31172. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31173. /** mag = nearest and min = nearest and mip = nearest */
  31174. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31175. /** mag = nearest and min = linear and mip = nearest */
  31176. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31177. /** mag = nearest and min = linear and mip = linear */
  31178. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31179. /** mag = nearest and min = linear and mip = none */
  31180. static readonly TEXTURE_NEAREST_LINEAR: number;
  31181. /** mag = nearest and min = nearest and mip = none */
  31182. static readonly TEXTURE_NEAREST_NEAREST: number;
  31183. /** mag = linear and min = nearest and mip = nearest */
  31184. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31185. /** mag = linear and min = nearest and mip = linear */
  31186. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31187. /** mag = linear and min = linear and mip = none */
  31188. static readonly TEXTURE_LINEAR_LINEAR: number;
  31189. /** mag = linear and min = nearest and mip = none */
  31190. static readonly TEXTURE_LINEAR_NEAREST: number;
  31191. /** Explicit coordinates mode */
  31192. static readonly TEXTURE_EXPLICIT_MODE: number;
  31193. /** Spherical coordinates mode */
  31194. static readonly TEXTURE_SPHERICAL_MODE: number;
  31195. /** Planar coordinates mode */
  31196. static readonly TEXTURE_PLANAR_MODE: number;
  31197. /** Cubic coordinates mode */
  31198. static readonly TEXTURE_CUBIC_MODE: number;
  31199. /** Projection coordinates mode */
  31200. static readonly TEXTURE_PROJECTION_MODE: number;
  31201. /** Skybox coordinates mode */
  31202. static readonly TEXTURE_SKYBOX_MODE: number;
  31203. /** Inverse Cubic coordinates mode */
  31204. static readonly TEXTURE_INVCUBIC_MODE: number;
  31205. /** Equirectangular coordinates mode */
  31206. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31207. /** Equirectangular Fixed coordinates mode */
  31208. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31209. /** Equirectangular Fixed Mirrored coordinates mode */
  31210. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31211. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31212. static readonly SCALEMODE_FLOOR: number;
  31213. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31214. static readonly SCALEMODE_NEAREST: number;
  31215. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31216. static readonly SCALEMODE_CEILING: number;
  31217. /**
  31218. * Returns the current npm package of the sdk
  31219. */
  31220. static readonly NpmPackage: string;
  31221. /**
  31222. * Returns the current version of the framework
  31223. */
  31224. static readonly Version: string;
  31225. /** Gets the list of created engines */
  31226. static readonly Instances: Engine[];
  31227. /**
  31228. * Gets the latest created engine
  31229. */
  31230. static readonly LastCreatedEngine: Nullable<Engine>;
  31231. /**
  31232. * Gets the latest created scene
  31233. */
  31234. static readonly LastCreatedScene: Nullable<Scene>;
  31235. /**
  31236. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31237. * @param flag defines which part of the materials must be marked as dirty
  31238. * @param predicate defines a predicate used to filter which materials should be affected
  31239. */
  31240. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31241. /**
  31242. * Method called to create the default loading screen.
  31243. * This can be overriden in your own app.
  31244. * @param canvas The rendering canvas element
  31245. * @returns The loading screen
  31246. */
  31247. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31248. /**
  31249. * Method called to create the default rescale post process on each engine.
  31250. */
  31251. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31252. /**
  31253. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31254. **/
  31255. enableOfflineSupport: boolean;
  31256. /**
  31257. * 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)
  31258. **/
  31259. disableManifestCheck: boolean;
  31260. /**
  31261. * Gets the list of created scenes
  31262. */
  31263. scenes: Scene[];
  31264. /**
  31265. * Event raised when a new scene is created
  31266. */
  31267. onNewSceneAddedObservable: Observable<Scene>;
  31268. /**
  31269. * Gets the list of created postprocesses
  31270. */
  31271. postProcesses: PostProcess[];
  31272. /**
  31273. * Gets a boolean indicating if the pointer is currently locked
  31274. */
  31275. isPointerLock: boolean;
  31276. /**
  31277. * Observable event triggered each time the rendering canvas is resized
  31278. */
  31279. onResizeObservable: Observable<Engine>;
  31280. /**
  31281. * Observable event triggered each time the canvas loses focus
  31282. */
  31283. onCanvasBlurObservable: Observable<Engine>;
  31284. /**
  31285. * Observable event triggered each time the canvas gains focus
  31286. */
  31287. onCanvasFocusObservable: Observable<Engine>;
  31288. /**
  31289. * Observable event triggered each time the canvas receives pointerout event
  31290. */
  31291. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31292. /**
  31293. * Observable raised when the engine begins a new frame
  31294. */
  31295. onBeginFrameObservable: Observable<Engine>;
  31296. /**
  31297. * If set, will be used to request the next animation frame for the render loop
  31298. */
  31299. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31300. /**
  31301. * Observable raised when the engine ends the current frame
  31302. */
  31303. onEndFrameObservable: Observable<Engine>;
  31304. /**
  31305. * Observable raised when the engine is about to compile a shader
  31306. */
  31307. onBeforeShaderCompilationObservable: Observable<Engine>;
  31308. /**
  31309. * Observable raised when the engine has jsut compiled a shader
  31310. */
  31311. onAfterShaderCompilationObservable: Observable<Engine>;
  31312. /**
  31313. * Gets the audio engine
  31314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31315. * @ignorenaming
  31316. */
  31317. static audioEngine: IAudioEngine;
  31318. /**
  31319. * Default AudioEngine factory responsible of creating the Audio Engine.
  31320. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31321. */
  31322. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31323. /**
  31324. * Default offline support factory responsible of creating a tool used to store data locally.
  31325. * By default, this will create a Database object if the workload has been embedded.
  31326. */
  31327. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31328. private _loadingScreen;
  31329. private _pointerLockRequested;
  31330. private _dummyFramebuffer;
  31331. private _rescalePostProcess;
  31332. /** @hidden */
  31333. protected _alphaMode: number;
  31334. /** @hidden */
  31335. protected _alphaEquation: number;
  31336. private _deterministicLockstep;
  31337. private _lockstepMaxSteps;
  31338. protected readonly _supportsHardwareTextureRescaling: boolean;
  31339. private _fps;
  31340. private _deltaTime;
  31341. /** @hidden */
  31342. _drawCalls: PerfCounter;
  31343. /**
  31344. * Turn this value on if you want to pause FPS computation when in background
  31345. */
  31346. disablePerformanceMonitorInBackground: boolean;
  31347. private _performanceMonitor;
  31348. /**
  31349. * Gets the performance monitor attached to this engine
  31350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31351. */
  31352. readonly performanceMonitor: PerformanceMonitor;
  31353. private _onFocus;
  31354. private _onBlur;
  31355. private _onCanvasPointerOut;
  31356. private _onCanvasBlur;
  31357. private _onCanvasFocus;
  31358. private _onFullscreenChange;
  31359. private _onPointerLockChange;
  31360. /**
  31361. * Creates a new engine
  31362. * @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
  31363. * @param antialias defines enable antialiasing (default: false)
  31364. * @param options defines further options to be sent to the getContext() function
  31365. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31366. */
  31367. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31368. /**
  31369. * Gets current aspect ratio
  31370. * @param viewportOwner defines the camera to use to get the aspect ratio
  31371. * @param useScreen defines if screen size must be used (or the current render target if any)
  31372. * @returns a number defining the aspect ratio
  31373. */
  31374. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31375. /**
  31376. * Gets current screen aspect ratio
  31377. * @returns a number defining the aspect ratio
  31378. */
  31379. getScreenAspectRatio(): number;
  31380. /**
  31381. * Gets host document
  31382. * @returns the host document object
  31383. */
  31384. getHostDocument(): Document;
  31385. /**
  31386. * Gets the client rect of the HTML canvas attached with the current webGL context
  31387. * @returns a client rectanglee
  31388. */
  31389. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31390. /**
  31391. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31393. * @returns true if engine is in deterministic lock step mode
  31394. */
  31395. isDeterministicLockStep(): boolean;
  31396. /**
  31397. * Gets the max steps when engine is running in deterministic lock step
  31398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31399. * @returns the max steps
  31400. */
  31401. getLockstepMaxSteps(): number;
  31402. /**
  31403. * Force the mipmap generation for the given render target texture
  31404. * @param texture defines the render target texture to use
  31405. */
  31406. generateMipMapsForCubemap(texture: InternalTexture): void;
  31407. /** States */
  31408. /**
  31409. * Set various states to the webGL context
  31410. * @param culling defines backface culling state
  31411. * @param zOffset defines the value to apply to zOffset (0 by default)
  31412. * @param force defines if states must be applied even if cache is up to date
  31413. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31414. */
  31415. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31416. /**
  31417. * Set the z offset to apply to current rendering
  31418. * @param value defines the offset to apply
  31419. */
  31420. setZOffset(value: number): void;
  31421. /**
  31422. * Gets the current value of the zOffset
  31423. * @returns the current zOffset state
  31424. */
  31425. getZOffset(): number;
  31426. /**
  31427. * Enable or disable depth buffering
  31428. * @param enable defines the state to set
  31429. */
  31430. setDepthBuffer(enable: boolean): void;
  31431. /**
  31432. * Gets a boolean indicating if depth writing is enabled
  31433. * @returns the current depth writing state
  31434. */
  31435. getDepthWrite(): boolean;
  31436. /**
  31437. * Enable or disable depth writing
  31438. * @param enable defines the state to set
  31439. */
  31440. setDepthWrite(enable: boolean): void;
  31441. /**
  31442. * Enable or disable color writing
  31443. * @param enable defines the state to set
  31444. */
  31445. setColorWrite(enable: boolean): void;
  31446. /**
  31447. * Gets a boolean indicating if color writing is enabled
  31448. * @returns the current color writing state
  31449. */
  31450. getColorWrite(): boolean;
  31451. /**
  31452. * Sets alpha constants used by some alpha blending modes
  31453. * @param r defines the red component
  31454. * @param g defines the green component
  31455. * @param b defines the blue component
  31456. * @param a defines the alpha component
  31457. */
  31458. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31459. /**
  31460. * Sets the current alpha mode
  31461. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31462. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31464. */
  31465. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31466. /**
  31467. * Gets the current alpha mode
  31468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31469. * @returns the current alpha mode
  31470. */
  31471. getAlphaMode(): number;
  31472. /**
  31473. * Sets the current alpha equation
  31474. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31475. */
  31476. setAlphaEquation(equation: number): void;
  31477. /**
  31478. * Gets the current alpha equation.
  31479. * @returns the current alpha equation
  31480. */
  31481. getAlphaEquation(): number;
  31482. /**
  31483. * Gets a boolean indicating if stencil buffer is enabled
  31484. * @returns the current stencil buffer state
  31485. */
  31486. getStencilBuffer(): boolean;
  31487. /**
  31488. * Enable or disable the stencil buffer
  31489. * @param enable defines if the stencil buffer must be enabled or disabled
  31490. */
  31491. setStencilBuffer(enable: boolean): void;
  31492. /**
  31493. * Gets the current stencil mask
  31494. * @returns a number defining the new stencil mask to use
  31495. */
  31496. getStencilMask(): number;
  31497. /**
  31498. * Sets the current stencil mask
  31499. * @param mask defines the new stencil mask to use
  31500. */
  31501. setStencilMask(mask: number): void;
  31502. /**
  31503. * Gets the current stencil function
  31504. * @returns a number defining the stencil function to use
  31505. */
  31506. getStencilFunction(): number;
  31507. /**
  31508. * Gets the current stencil reference value
  31509. * @returns a number defining the stencil reference value to use
  31510. */
  31511. getStencilFunctionReference(): number;
  31512. /**
  31513. * Gets the current stencil mask
  31514. * @returns a number defining the stencil mask to use
  31515. */
  31516. getStencilFunctionMask(): number;
  31517. /**
  31518. * Sets the current stencil function
  31519. * @param stencilFunc defines the new stencil function to use
  31520. */
  31521. setStencilFunction(stencilFunc: number): void;
  31522. /**
  31523. * Sets the current stencil reference
  31524. * @param reference defines the new stencil reference to use
  31525. */
  31526. setStencilFunctionReference(reference: number): void;
  31527. /**
  31528. * Sets the current stencil mask
  31529. * @param mask defines the new stencil mask to use
  31530. */
  31531. setStencilFunctionMask(mask: number): void;
  31532. /**
  31533. * Gets the current stencil operation when stencil fails
  31534. * @returns a number defining stencil operation to use when stencil fails
  31535. */
  31536. getStencilOperationFail(): number;
  31537. /**
  31538. * Gets the current stencil operation when depth fails
  31539. * @returns a number defining stencil operation to use when depth fails
  31540. */
  31541. getStencilOperationDepthFail(): number;
  31542. /**
  31543. * Gets the current stencil operation when stencil passes
  31544. * @returns a number defining stencil operation to use when stencil passes
  31545. */
  31546. getStencilOperationPass(): number;
  31547. /**
  31548. * Sets the stencil operation to use when stencil fails
  31549. * @param operation defines the stencil operation to use when stencil fails
  31550. */
  31551. setStencilOperationFail(operation: number): void;
  31552. /**
  31553. * Sets the stencil operation to use when depth fails
  31554. * @param operation defines the stencil operation to use when depth fails
  31555. */
  31556. setStencilOperationDepthFail(operation: number): void;
  31557. /**
  31558. * Sets the stencil operation to use when stencil passes
  31559. * @param operation defines the stencil operation to use when stencil passes
  31560. */
  31561. setStencilOperationPass(operation: number): void;
  31562. /**
  31563. * Sets a boolean indicating if the dithering state is enabled or disabled
  31564. * @param value defines the dithering state
  31565. */
  31566. setDitheringState(value: boolean): void;
  31567. /**
  31568. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31569. * @param value defines the rasterizer state
  31570. */
  31571. setRasterizerState(value: boolean): void;
  31572. /**
  31573. * Gets the current depth function
  31574. * @returns a number defining the depth function
  31575. */
  31576. getDepthFunction(): Nullable<number>;
  31577. /**
  31578. * Sets the current depth function
  31579. * @param depthFunc defines the function to use
  31580. */
  31581. setDepthFunction(depthFunc: number): void;
  31582. /**
  31583. * Sets the current depth function to GREATER
  31584. */
  31585. setDepthFunctionToGreater(): void;
  31586. /**
  31587. * Sets the current depth function to GEQUAL
  31588. */
  31589. setDepthFunctionToGreaterOrEqual(): void;
  31590. /**
  31591. * Sets the current depth function to LESS
  31592. */
  31593. setDepthFunctionToLess(): void;
  31594. /**
  31595. * Sets the current depth function to LEQUAL
  31596. */
  31597. setDepthFunctionToLessOrEqual(): void;
  31598. private _cachedStencilBuffer;
  31599. private _cachedStencilFunction;
  31600. private _cachedStencilMask;
  31601. private _cachedStencilOperationPass;
  31602. private _cachedStencilOperationFail;
  31603. private _cachedStencilOperationDepthFail;
  31604. private _cachedStencilReference;
  31605. /**
  31606. * Caches the the state of the stencil buffer
  31607. */
  31608. cacheStencilState(): void;
  31609. /**
  31610. * Restores the state of the stencil buffer
  31611. */
  31612. restoreStencilState(): void;
  31613. /**
  31614. * Directly set the WebGL Viewport
  31615. * @param x defines the x coordinate of the viewport (in screen space)
  31616. * @param y defines the y coordinate of the viewport (in screen space)
  31617. * @param width defines the width of the viewport (in screen space)
  31618. * @param height defines the height of the viewport (in screen space)
  31619. * @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
  31620. */
  31621. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31622. /**
  31623. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31624. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31625. * @param y defines the y-coordinate of the corner of the clear rectangle
  31626. * @param width defines the width of the clear rectangle
  31627. * @param height defines the height of the clear rectangle
  31628. * @param clearColor defines the clear color
  31629. */
  31630. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31631. /**
  31632. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31633. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31634. * @param y defines the y-coordinate of the corner of the clear rectangle
  31635. * @param width defines the width of the clear rectangle
  31636. * @param height defines the height of the clear rectangle
  31637. */
  31638. enableScissor(x: number, y: number, width: number, height: number): void;
  31639. /**
  31640. * Disable previously set scissor test rectangle
  31641. */
  31642. disableScissor(): void;
  31643. protected _reportDrawCall(): void;
  31644. /**
  31645. * Initializes a webVR display and starts listening to display change events
  31646. * The onVRDisplayChangedObservable will be notified upon these changes
  31647. * @returns The onVRDisplayChangedObservable
  31648. */
  31649. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31650. /** @hidden */
  31651. _prepareVRComponent(): void;
  31652. /** @hidden */
  31653. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31654. /** @hidden */
  31655. _submitVRFrame(): void;
  31656. /**
  31657. * Call this function to leave webVR mode
  31658. * Will do nothing if webVR is not supported or if there is no webVR device
  31659. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31660. */
  31661. disableVR(): void;
  31662. /**
  31663. * Gets a boolean indicating that the system is in VR mode and is presenting
  31664. * @returns true if VR mode is engaged
  31665. */
  31666. isVRPresenting(): boolean;
  31667. /** @hidden */
  31668. _requestVRFrame(): void;
  31669. /** @hidden */
  31670. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31671. /**
  31672. * Gets the source code of the vertex shader associated with a specific webGL program
  31673. * @param program defines the program to use
  31674. * @returns a string containing the source code of the vertex shader associated with the program
  31675. */
  31676. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31677. /**
  31678. * Gets the source code of the fragment shader associated with a specific webGL program
  31679. * @param program defines the program to use
  31680. * @returns a string containing the source code of the fragment shader associated with the program
  31681. */
  31682. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31683. /**
  31684. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31685. * @param x defines the x coordinate of the rectangle where pixels must be read
  31686. * @param y defines the y coordinate of the rectangle where pixels must be read
  31687. * @param width defines the width of the rectangle where pixels must be read
  31688. * @param height defines the height of the rectangle where pixels must be read
  31689. * @returns a Uint8Array containing RGBA colors
  31690. */
  31691. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31692. /**
  31693. * Sets a depth stencil texture from a render target to the according uniform.
  31694. * @param channel The texture channel
  31695. * @param uniform The uniform to set
  31696. * @param texture The render target texture containing the depth stencil texture to apply
  31697. */
  31698. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31699. /**
  31700. * Sets a texture to the webGL context from a postprocess
  31701. * @param channel defines the channel to use
  31702. * @param postProcess defines the source postprocess
  31703. */
  31704. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31705. /**
  31706. * Binds the output of the passed in post process to the texture channel specified
  31707. * @param channel The channel the texture should be bound to
  31708. * @param postProcess The post process which's output should be bound
  31709. */
  31710. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31711. /** @hidden */
  31712. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31713. protected _rebuildBuffers(): void;
  31714. _renderLoop(): void;
  31715. /**
  31716. * Toggle full screen mode
  31717. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31718. */
  31719. switchFullscreen(requestPointerLock: boolean): void;
  31720. /**
  31721. * Enters full screen mode
  31722. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31723. */
  31724. enterFullscreen(requestPointerLock: boolean): void;
  31725. /**
  31726. * Exits full screen mode
  31727. */
  31728. exitFullscreen(): void;
  31729. /**
  31730. * Enters Pointerlock mode
  31731. */
  31732. enterPointerlock(): void;
  31733. /**
  31734. * Exits Pointerlock mode
  31735. */
  31736. exitPointerlock(): void;
  31737. /**
  31738. * Begin a new frame
  31739. */
  31740. beginFrame(): void;
  31741. /**
  31742. * Enf the current frame
  31743. */
  31744. endFrame(): void;
  31745. resize(): void;
  31746. /**
  31747. * Set the compressed texture format to use, based on the formats you have, and the formats
  31748. * supported by the hardware / browser.
  31749. *
  31750. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31751. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31752. * to API arguments needed to compressed textures. This puts the burden on the container
  31753. * generator to house the arcane code for determining these for current & future formats.
  31754. *
  31755. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31756. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31757. *
  31758. * Note: The result of this call is not taken into account when a texture is base64.
  31759. *
  31760. * @param formatsAvailable defines the list of those format families you have created
  31761. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31762. *
  31763. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31764. * @returns The extension selected.
  31765. */
  31766. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31767. /**
  31768. * Force a specific size of the canvas
  31769. * @param width defines the new canvas' width
  31770. * @param height defines the new canvas' height
  31771. */
  31772. setSize(width: number, height: number): void;
  31773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31775. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31776. _releaseTexture(texture: InternalTexture): void;
  31777. /**
  31778. * @hidden
  31779. * Rescales a texture
  31780. * @param source input texutre
  31781. * @param destination destination texture
  31782. * @param scene scene to use to render the resize
  31783. * @param internalFormat format to use when resizing
  31784. * @param onComplete callback to be called when resize has completed
  31785. */
  31786. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31787. /**
  31788. * Gets the current framerate
  31789. * @returns a number representing the framerate
  31790. */
  31791. getFps(): number;
  31792. /**
  31793. * Gets the time spent between current and previous frame
  31794. * @returns a number representing the delta time in ms
  31795. */
  31796. getDeltaTime(): number;
  31797. private _measureFps;
  31798. /**
  31799. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31800. * @param renderTarget The render target to set the frame buffer for
  31801. */
  31802. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31803. /**
  31804. * Update a dynamic index buffer
  31805. * @param indexBuffer defines the target index buffer
  31806. * @param indices defines the data to update
  31807. * @param offset defines the offset in the target index buffer where update should start
  31808. */
  31809. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31810. /**
  31811. * Updates the sample count of a render target texture
  31812. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31813. * @param texture defines the texture to update
  31814. * @param samples defines the sample count to set
  31815. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31816. */
  31817. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31818. /** @hidden */
  31819. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31820. dispose(): void;
  31821. private _disableTouchAction;
  31822. /**
  31823. * Display the loading screen
  31824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31825. */
  31826. displayLoadingUI(): void;
  31827. /**
  31828. * Hide the loading screen
  31829. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31830. */
  31831. hideLoadingUI(): void;
  31832. /**
  31833. * Gets the current loading screen object
  31834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31835. */
  31836. /**
  31837. * Sets the current loading screen object
  31838. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31839. */
  31840. loadingScreen: ILoadingScreen;
  31841. /**
  31842. * Sets the current loading screen text
  31843. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31844. */
  31845. loadingUIText: string;
  31846. /**
  31847. * Sets the current loading screen background color
  31848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31849. */
  31850. loadingUIBackgroundColor: string;
  31851. /** Pointerlock and fullscreen */
  31852. /**
  31853. * Ask the browser to promote the current element to pointerlock mode
  31854. * @param element defines the DOM element to promote
  31855. */
  31856. static _RequestPointerlock(element: HTMLElement): void;
  31857. /**
  31858. * Asks the browser to exit pointerlock mode
  31859. */
  31860. static _ExitPointerlock(): void;
  31861. /**
  31862. * Ask the browser to promote the current element to fullscreen rendering mode
  31863. * @param element defines the DOM element to promote
  31864. */
  31865. static _RequestFullscreen(element: HTMLElement): void;
  31866. /**
  31867. * Asks the browser to exit fullscreen mode
  31868. */
  31869. static _ExitFullscreen(): void;
  31870. }
  31871. }
  31872. declare module BABYLON {
  31873. /**
  31874. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31875. * during the life time of the application.
  31876. */
  31877. export class EngineStore {
  31878. /** Gets the list of created engines */
  31879. static Instances: Engine[];
  31880. /** @hidden */
  31881. static _LastCreatedScene: Nullable<Scene>;
  31882. /**
  31883. * Gets the latest created engine
  31884. */
  31885. static readonly LastCreatedEngine: Nullable<Engine>;
  31886. /**
  31887. * Gets the latest created scene
  31888. */
  31889. static readonly LastCreatedScene: Nullable<Scene>;
  31890. /**
  31891. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31892. * @ignorenaming
  31893. */
  31894. static UseFallbackTexture: boolean;
  31895. /**
  31896. * Texture content used if a texture cannot loaded
  31897. * @ignorenaming
  31898. */
  31899. static FallbackTexture: string;
  31900. }
  31901. }
  31902. declare module BABYLON {
  31903. /**
  31904. * Helper class that provides a small promise polyfill
  31905. */
  31906. export class PromisePolyfill {
  31907. /**
  31908. * Static function used to check if the polyfill is required
  31909. * If this is the case then the function will inject the polyfill to window.Promise
  31910. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31911. */
  31912. static Apply(force?: boolean): void;
  31913. }
  31914. }
  31915. declare module BABYLON {
  31916. /**
  31917. * Interface for screenshot methods with describe argument called `size` as object with options
  31918. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31919. */
  31920. export interface IScreenshotSize {
  31921. /**
  31922. * number in pixels for canvas height
  31923. */
  31924. height?: number;
  31925. /**
  31926. * multiplier allowing render at a higher or lower resolution
  31927. * If value is defined then height and width will be ignored and taken from camera
  31928. */
  31929. precision?: number;
  31930. /**
  31931. * number in pixels for canvas width
  31932. */
  31933. width?: number;
  31934. }
  31935. }
  31936. declare module BABYLON {
  31937. interface IColor4Like {
  31938. r: float;
  31939. g: float;
  31940. b: float;
  31941. a: float;
  31942. }
  31943. /**
  31944. * Class containing a set of static utilities functions
  31945. */
  31946. export class Tools {
  31947. /**
  31948. * Gets or sets the base URL to use to load assets
  31949. */
  31950. static BaseUrl: string;
  31951. /**
  31952. * Enable/Disable Custom HTTP Request Headers globally.
  31953. * default = false
  31954. * @see CustomRequestHeaders
  31955. */
  31956. static UseCustomRequestHeaders: boolean;
  31957. /**
  31958. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31959. * i.e. when loading files, where the server/service expects an Authorization header
  31960. */
  31961. static CustomRequestHeaders: {
  31962. [key: string]: string;
  31963. };
  31964. /**
  31965. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31966. */
  31967. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31968. /**
  31969. * Default behaviour for cors in the application.
  31970. * It can be a string if the expected behavior is identical in the entire app.
  31971. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31972. */
  31973. static CorsBehavior: string | ((url: string | string[]) => string);
  31974. /**
  31975. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31976. * @ignorenaming
  31977. */
  31978. static UseFallbackTexture: boolean;
  31979. /**
  31980. * Use this object to register external classes like custom textures or material
  31981. * to allow the laoders to instantiate them
  31982. */
  31983. static RegisteredExternalClasses: {
  31984. [key: string]: Object;
  31985. };
  31986. /**
  31987. * Texture content used if a texture cannot loaded
  31988. * @ignorenaming
  31989. */
  31990. static fallbackTexture: string;
  31991. /**
  31992. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31993. * @param u defines the coordinate on X axis
  31994. * @param v defines the coordinate on Y axis
  31995. * @param width defines the width of the source data
  31996. * @param height defines the height of the source data
  31997. * @param pixels defines the source byte array
  31998. * @param color defines the output color
  31999. */
  32000. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32001. /**
  32002. * Interpolates between a and b via alpha
  32003. * @param a The lower value (returned when alpha = 0)
  32004. * @param b The upper value (returned when alpha = 1)
  32005. * @param alpha The interpolation-factor
  32006. * @return The mixed value
  32007. */
  32008. static Mix(a: number, b: number, alpha: number): number;
  32009. /**
  32010. * Tries to instantiate a new object from a given class name
  32011. * @param className defines the class name to instantiate
  32012. * @returns the new object or null if the system was not able to do the instantiation
  32013. */
  32014. static Instantiate(className: string): any;
  32015. /**
  32016. * Provides a slice function that will work even on IE
  32017. * @param data defines the array to slice
  32018. * @param start defines the start of the data (optional)
  32019. * @param end defines the end of the data (optional)
  32020. * @returns the new sliced array
  32021. */
  32022. static Slice<T>(data: T, start?: number, end?: number): T;
  32023. /**
  32024. * Polyfill for setImmediate
  32025. * @param action defines the action to execute after the current execution block
  32026. */
  32027. static SetImmediate(action: () => void): void;
  32028. /**
  32029. * Function indicating if a number is an exponent of 2
  32030. * @param value defines the value to test
  32031. * @returns true if the value is an exponent of 2
  32032. */
  32033. static IsExponentOfTwo(value: number): boolean;
  32034. private static _tmpFloatArray;
  32035. /**
  32036. * Returns the nearest 32-bit single precision float representation of a Number
  32037. * @param value A Number. If the parameter is of a different type, it will get converted
  32038. * to a number or to NaN if it cannot be converted
  32039. * @returns number
  32040. */
  32041. static FloatRound(value: number): number;
  32042. /**
  32043. * Extracts the filename from a path
  32044. * @param path defines the path to use
  32045. * @returns the filename
  32046. */
  32047. static GetFilename(path: string): string;
  32048. /**
  32049. * Extracts the "folder" part of a path (everything before the filename).
  32050. * @param uri The URI to extract the info from
  32051. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32052. * @returns The "folder" part of the path
  32053. */
  32054. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32055. /**
  32056. * Extracts text content from a DOM element hierarchy
  32057. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32058. */
  32059. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32060. /**
  32061. * Convert an angle in radians to degrees
  32062. * @param angle defines the angle to convert
  32063. * @returns the angle in degrees
  32064. */
  32065. static ToDegrees(angle: number): number;
  32066. /**
  32067. * Convert an angle in degrees to radians
  32068. * @param angle defines the angle to convert
  32069. * @returns the angle in radians
  32070. */
  32071. static ToRadians(angle: number): number;
  32072. /**
  32073. * Encode a buffer to a base64 string
  32074. * @param buffer defines the buffer to encode
  32075. * @returns the encoded string
  32076. */
  32077. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32078. /**
  32079. * Returns an array if obj is not an array
  32080. * @param obj defines the object to evaluate as an array
  32081. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32082. * @returns either obj directly if obj is an array or a new array containing obj
  32083. */
  32084. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32085. /**
  32086. * Gets the pointer prefix to use
  32087. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32088. */
  32089. static GetPointerPrefix(): string;
  32090. /**
  32091. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32092. * @param url define the url we are trying
  32093. * @param element define the dom element where to configure the cors policy
  32094. */
  32095. static SetCorsBehavior(url: string | string[], element: {
  32096. crossOrigin: string | null;
  32097. }): void;
  32098. /**
  32099. * Removes unwanted characters from an url
  32100. * @param url defines the url to clean
  32101. * @returns the cleaned url
  32102. */
  32103. static CleanUrl(url: string): string;
  32104. /**
  32105. * Gets or sets a function used to pre-process url before using them to load assets
  32106. */
  32107. static PreprocessUrl: (url: string) => string;
  32108. /**
  32109. * Loads an image as an HTMLImageElement.
  32110. * @param input url string, ArrayBuffer, or Blob to load
  32111. * @param onLoad callback called when the image successfully loads
  32112. * @param onError callback called when the image fails to load
  32113. * @param offlineProvider offline provider for caching
  32114. * @param mimeType optional mime type
  32115. * @returns the HTMLImageElement of the loaded image
  32116. */
  32117. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32118. /**
  32119. * Loads a file
  32120. * @param url url string, ArrayBuffer, or Blob to load
  32121. * @param onSuccess callback called when the file successfully loads
  32122. * @param onProgress callback called while file is loading (if the server supports this mode)
  32123. * @param offlineProvider defines the offline provider for caching
  32124. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32125. * @param onError callback called when the file fails to load
  32126. * @returns a file request object
  32127. */
  32128. 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;
  32129. /**
  32130. * Loads a file from a url
  32131. * @param url the file url to load
  32132. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32133. */
  32134. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32135. /**
  32136. * Load a script (identified by an url). When the url returns, the
  32137. * content of this file is added into a new script element, attached to the DOM (body element)
  32138. * @param scriptUrl defines the url of the script to laod
  32139. * @param onSuccess defines the callback called when the script is loaded
  32140. * @param onError defines the callback to call if an error occurs
  32141. * @param scriptId defines the id of the script element
  32142. */
  32143. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32144. /**
  32145. * Load an asynchronous script (identified by an url). When the url returns, the
  32146. * content of this file is added into a new script element, attached to the DOM (body element)
  32147. * @param scriptUrl defines the url of the script to laod
  32148. * @param scriptId defines the id of the script element
  32149. * @returns a promise request object
  32150. */
  32151. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32152. /**
  32153. * Loads a file from a blob
  32154. * @param fileToLoad defines the blob to use
  32155. * @param callback defines the callback to call when data is loaded
  32156. * @param progressCallback defines the callback to call during loading process
  32157. * @returns a file request object
  32158. */
  32159. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32160. /**
  32161. * Loads a file
  32162. * @param fileToLoad defines the file to load
  32163. * @param callback defines the callback to call when data is loaded
  32164. * @param progressCallBack defines the callback to call during loading process
  32165. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32166. * @returns a file request object
  32167. */
  32168. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32169. /**
  32170. * Creates a data url from a given string content
  32171. * @param content defines the content to convert
  32172. * @returns the new data url link
  32173. */
  32174. static FileAsURL(content: string): string;
  32175. /**
  32176. * Format the given number to a specific decimal format
  32177. * @param value defines the number to format
  32178. * @param decimals defines the number of decimals to use
  32179. * @returns the formatted string
  32180. */
  32181. static Format(value: number, decimals?: number): string;
  32182. /**
  32183. * Tries to copy an object by duplicating every property
  32184. * @param source defines the source object
  32185. * @param destination defines the target object
  32186. * @param doNotCopyList defines a list of properties to avoid
  32187. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32188. */
  32189. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32190. /**
  32191. * Gets a boolean indicating if the given object has no own property
  32192. * @param obj defines the object to test
  32193. * @returns true if object has no own property
  32194. */
  32195. static IsEmpty(obj: any): boolean;
  32196. /**
  32197. * Function used to register events at window level
  32198. * @param windowElement defines the Window object to use
  32199. * @param events defines the events to register
  32200. */
  32201. static RegisterTopRootEvents(windowElement: Window, events: {
  32202. name: string;
  32203. handler: Nullable<(e: FocusEvent) => any>;
  32204. }[]): void;
  32205. /**
  32206. * Function used to unregister events from window level
  32207. * @param windowElement defines the Window object to use
  32208. * @param events defines the events to unregister
  32209. */
  32210. static UnregisterTopRootEvents(windowElement: Window, events: {
  32211. name: string;
  32212. handler: Nullable<(e: FocusEvent) => any>;
  32213. }[]): void;
  32214. /**
  32215. * @ignore
  32216. */
  32217. static _ScreenshotCanvas: HTMLCanvasElement;
  32218. /**
  32219. * Dumps the current bound framebuffer
  32220. * @param width defines the rendering width
  32221. * @param height defines the rendering height
  32222. * @param engine defines the hosting engine
  32223. * @param successCallback defines the callback triggered once the data are available
  32224. * @param mimeType defines the mime type of the result
  32225. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32226. */
  32227. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32228. /**
  32229. * Converts the canvas data to blob.
  32230. * This acts as a polyfill for browsers not supporting the to blob function.
  32231. * @param canvas Defines the canvas to extract the data from
  32232. * @param successCallback Defines the callback triggered once the data are available
  32233. * @param mimeType Defines the mime type of the result
  32234. */
  32235. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32236. /**
  32237. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32238. * @param successCallback defines the callback triggered once the data are available
  32239. * @param mimeType defines the mime type of the result
  32240. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32241. */
  32242. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32243. /**
  32244. * Downloads a blob in the browser
  32245. * @param blob defines the blob to download
  32246. * @param fileName defines the name of the downloaded file
  32247. */
  32248. static Download(blob: Blob, fileName: string): void;
  32249. /**
  32250. * Captures a screenshot of the current rendering
  32251. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32252. * @param engine defines the rendering engine
  32253. * @param camera defines the source camera
  32254. * @param size This parameter can be set to a single number or to an object with the
  32255. * following (optional) properties: precision, width, height. If a single number is passed,
  32256. * it will be used for both width and height. If an object is passed, the screenshot size
  32257. * will be derived from the parameters. The precision property is a multiplier allowing
  32258. * rendering at a higher or lower resolution
  32259. * @param successCallback defines the callback receives a single parameter which contains the
  32260. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32261. * src parameter of an <img> to display it
  32262. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32263. * Check your browser for supported MIME types
  32264. */
  32265. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32266. /**
  32267. * Captures a screenshot of the current rendering
  32268. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32269. * @param engine defines the rendering engine
  32270. * @param camera defines the source camera
  32271. * @param size This parameter can be set to a single number or to an object with the
  32272. * following (optional) properties: precision, width, height. If a single number is passed,
  32273. * it will be used for both width and height. If an object is passed, the screenshot size
  32274. * will be derived from the parameters. The precision property is a multiplier allowing
  32275. * rendering at a higher or lower resolution
  32276. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32277. * Check your browser for supported MIME types
  32278. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32279. * to the src parameter of an <img> to display it
  32280. */
  32281. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32282. /**
  32283. * Generates an image screenshot from the specified camera.
  32284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32285. * @param engine The engine to use for rendering
  32286. * @param camera The camera to use for rendering
  32287. * @param size This parameter can be set to a single number or to an object with the
  32288. * following (optional) properties: precision, width, height. If a single number is passed,
  32289. * it will be used for both width and height. If an object is passed, the screenshot size
  32290. * will be derived from the parameters. The precision property is a multiplier allowing
  32291. * rendering at a higher or lower resolution
  32292. * @param successCallback The callback receives a single parameter which contains the
  32293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32294. * src parameter of an <img> to display it
  32295. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32296. * Check your browser for supported MIME types
  32297. * @param samples Texture samples (default: 1)
  32298. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32299. * @param fileName A name for for the downloaded file.
  32300. */
  32301. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32302. /**
  32303. * Generates an image screenshot from the specified camera.
  32304. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32305. * @param engine The engine to use for rendering
  32306. * @param camera The camera to use for rendering
  32307. * @param size This parameter can be set to a single number or to an object with the
  32308. * following (optional) properties: precision, width, height. If a single number is passed,
  32309. * it will be used for both width and height. If an object is passed, the screenshot size
  32310. * will be derived from the parameters. The precision property is a multiplier allowing
  32311. * rendering at a higher or lower resolution
  32312. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32313. * Check your browser for supported MIME types
  32314. * @param samples Texture samples (default: 1)
  32315. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32316. * @param fileName A name for for the downloaded file.
  32317. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32318. * to the src parameter of an <img> to display it
  32319. */
  32320. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32321. /**
  32322. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32323. * Be aware Math.random() could cause collisions, but:
  32324. * "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"
  32325. * @returns a pseudo random id
  32326. */
  32327. static RandomId(): string;
  32328. /**
  32329. * Test if the given uri is a base64 string
  32330. * @param uri The uri to test
  32331. * @return True if the uri is a base64 string or false otherwise
  32332. */
  32333. static IsBase64(uri: string): boolean;
  32334. /**
  32335. * Decode the given base64 uri.
  32336. * @param uri The uri to decode
  32337. * @return The decoded base64 data.
  32338. */
  32339. static DecodeBase64(uri: string): ArrayBuffer;
  32340. /**
  32341. * Gets the absolute url.
  32342. * @param url the input url
  32343. * @return the absolute url
  32344. */
  32345. static GetAbsoluteUrl(url: string): string;
  32346. /**
  32347. * No log
  32348. */
  32349. static readonly NoneLogLevel: number;
  32350. /**
  32351. * Only message logs
  32352. */
  32353. static readonly MessageLogLevel: number;
  32354. /**
  32355. * Only warning logs
  32356. */
  32357. static readonly WarningLogLevel: number;
  32358. /**
  32359. * Only error logs
  32360. */
  32361. static readonly ErrorLogLevel: number;
  32362. /**
  32363. * All logs
  32364. */
  32365. static readonly AllLogLevel: number;
  32366. /**
  32367. * Gets a value indicating the number of loading errors
  32368. * @ignorenaming
  32369. */
  32370. static readonly errorsCount: number;
  32371. /**
  32372. * Callback called when a new log is added
  32373. */
  32374. static OnNewCacheEntry: (entry: string) => void;
  32375. /**
  32376. * Log a message to the console
  32377. * @param message defines the message to log
  32378. */
  32379. static Log(message: string): void;
  32380. /**
  32381. * Write a warning message to the console
  32382. * @param message defines the message to log
  32383. */
  32384. static Warn(message: string): void;
  32385. /**
  32386. * Write an error message to the console
  32387. * @param message defines the message to log
  32388. */
  32389. static Error(message: string): void;
  32390. /**
  32391. * Gets current log cache (list of logs)
  32392. */
  32393. static readonly LogCache: string;
  32394. /**
  32395. * Clears the log cache
  32396. */
  32397. static ClearLogCache(): void;
  32398. /**
  32399. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32400. */
  32401. static LogLevels: number;
  32402. /**
  32403. * Checks if the window object exists
  32404. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32405. */
  32406. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32407. /**
  32408. * No performance log
  32409. */
  32410. static readonly PerformanceNoneLogLevel: number;
  32411. /**
  32412. * Use user marks to log performance
  32413. */
  32414. static readonly PerformanceUserMarkLogLevel: number;
  32415. /**
  32416. * Log performance to the console
  32417. */
  32418. static readonly PerformanceConsoleLogLevel: number;
  32419. private static _performance;
  32420. /**
  32421. * Sets the current performance log level
  32422. */
  32423. static PerformanceLogLevel: number;
  32424. private static _StartPerformanceCounterDisabled;
  32425. private static _EndPerformanceCounterDisabled;
  32426. private static _StartUserMark;
  32427. private static _EndUserMark;
  32428. private static _StartPerformanceConsole;
  32429. private static _EndPerformanceConsole;
  32430. /**
  32431. * Starts a performance counter
  32432. */
  32433. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32434. /**
  32435. * Ends a specific performance coutner
  32436. */
  32437. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32438. /**
  32439. * Gets either window.performance.now() if supported or Date.now() else
  32440. */
  32441. static readonly Now: number;
  32442. /**
  32443. * This method will return the name of the class used to create the instance of the given object.
  32444. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32445. * @param object the object to get the class name from
  32446. * @param isType defines if the object is actually a type
  32447. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32448. */
  32449. static GetClassName(object: any, isType?: boolean): string;
  32450. /**
  32451. * Gets the first element of an array satisfying a given predicate
  32452. * @param array defines the array to browse
  32453. * @param predicate defines the predicate to use
  32454. * @returns null if not found or the element
  32455. */
  32456. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32457. /**
  32458. * This method will return the name of the full name of the class, including its owning module (if any).
  32459. * 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).
  32460. * @param object the object to get the class name from
  32461. * @param isType defines if the object is actually a type
  32462. * @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.
  32463. * @ignorenaming
  32464. */
  32465. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32466. /**
  32467. * Returns a promise that resolves after the given amount of time.
  32468. * @param delay Number of milliseconds to delay
  32469. * @returns Promise that resolves after the given amount of time
  32470. */
  32471. static DelayAsync(delay: number): Promise<void>;
  32472. }
  32473. /**
  32474. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32475. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32476. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32477. * @param name The name of the class, case should be preserved
  32478. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32479. */
  32480. export function className(name: string, module?: string): (target: Object) => void;
  32481. /**
  32482. * An implementation of a loop for asynchronous functions.
  32483. */
  32484. export class AsyncLoop {
  32485. /**
  32486. * Defines the number of iterations for the loop
  32487. */
  32488. iterations: number;
  32489. /**
  32490. * Defines the current index of the loop.
  32491. */
  32492. index: number;
  32493. private _done;
  32494. private _fn;
  32495. private _successCallback;
  32496. /**
  32497. * Constructor.
  32498. * @param iterations the number of iterations.
  32499. * @param func the function to run each iteration
  32500. * @param successCallback the callback that will be called upon succesful execution
  32501. * @param offset starting offset.
  32502. */
  32503. constructor(
  32504. /**
  32505. * Defines the number of iterations for the loop
  32506. */
  32507. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32508. /**
  32509. * Execute the next iteration. Must be called after the last iteration was finished.
  32510. */
  32511. executeNext(): void;
  32512. /**
  32513. * Break the loop and run the success callback.
  32514. */
  32515. breakLoop(): void;
  32516. /**
  32517. * Create and run an async loop.
  32518. * @param iterations the number of iterations.
  32519. * @param fn the function to run each iteration
  32520. * @param successCallback the callback that will be called upon succesful execution
  32521. * @param offset starting offset.
  32522. * @returns the created async loop object
  32523. */
  32524. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32525. /**
  32526. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32527. * @param iterations total number of iterations
  32528. * @param syncedIterations number of synchronous iterations in each async iteration.
  32529. * @param fn the function to call each iteration.
  32530. * @param callback a success call back that will be called when iterating stops.
  32531. * @param breakFunction a break condition (optional)
  32532. * @param timeout timeout settings for the setTimeout function. default - 0.
  32533. * @returns the created async loop object
  32534. */
  32535. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32536. }
  32537. }
  32538. declare module BABYLON {
  32539. /**
  32540. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32541. * The underlying implementation relies on an associative array to ensure the best performances.
  32542. * The value can be anything including 'null' but except 'undefined'
  32543. */
  32544. export class StringDictionary<T> {
  32545. /**
  32546. * This will clear this dictionary and copy the content from the 'source' one.
  32547. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32548. * @param source the dictionary to take the content from and copy to this dictionary
  32549. */
  32550. copyFrom(source: StringDictionary<T>): void;
  32551. /**
  32552. * Get a value based from its key
  32553. * @param key the given key to get the matching value from
  32554. * @return the value if found, otherwise undefined is returned
  32555. */
  32556. get(key: string): T | undefined;
  32557. /**
  32558. * Get a value from its key or add it if it doesn't exist.
  32559. * This method will ensure you that a given key/data will be present in the dictionary.
  32560. * @param key the given key to get the matching value from
  32561. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32562. * The factory will only be invoked if there's no data for the given key.
  32563. * @return the value corresponding to the key.
  32564. */
  32565. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32566. /**
  32567. * Get a value from its key if present in the dictionary otherwise add it
  32568. * @param key the key to get the value from
  32569. * @param val if there's no such key/value pair in the dictionary add it with this value
  32570. * @return the value corresponding to the key
  32571. */
  32572. getOrAdd(key: string, val: T): T;
  32573. /**
  32574. * Check if there's a given key in the dictionary
  32575. * @param key the key to check for
  32576. * @return true if the key is present, false otherwise
  32577. */
  32578. contains(key: string): boolean;
  32579. /**
  32580. * Add a new key and its corresponding value
  32581. * @param key the key to add
  32582. * @param value the value corresponding to the key
  32583. * @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
  32584. */
  32585. add(key: string, value: T): boolean;
  32586. /**
  32587. * Update a specific value associated to a key
  32588. * @param key defines the key to use
  32589. * @param value defines the value to store
  32590. * @returns true if the value was updated (or false if the key was not found)
  32591. */
  32592. set(key: string, value: T): boolean;
  32593. /**
  32594. * Get the element of the given key and remove it from the dictionary
  32595. * @param key defines the key to search
  32596. * @returns the value associated with the key or null if not found
  32597. */
  32598. getAndRemove(key: string): Nullable<T>;
  32599. /**
  32600. * Remove a key/value from the dictionary.
  32601. * @param key the key to remove
  32602. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32603. */
  32604. remove(key: string): boolean;
  32605. /**
  32606. * Clear the whole content of the dictionary
  32607. */
  32608. clear(): void;
  32609. /**
  32610. * Gets the current count
  32611. */
  32612. readonly count: number;
  32613. /**
  32614. * Execute a callback on each key/val of the dictionary.
  32615. * Note that you can remove any element in this dictionary in the callback implementation
  32616. * @param callback the callback to execute on a given key/value pair
  32617. */
  32618. forEach(callback: (key: string, val: T) => void): void;
  32619. /**
  32620. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32621. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32622. * Note that you can remove any element in this dictionary in the callback implementation
  32623. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32624. * @returns the first item
  32625. */
  32626. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32627. private _count;
  32628. private _data;
  32629. }
  32630. }
  32631. declare module BABYLON {
  32632. /** @hidden */
  32633. export interface ICollisionCoordinator {
  32634. createCollider(): Collider;
  32635. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32636. init(scene: Scene): void;
  32637. }
  32638. /** @hidden */
  32639. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32640. private _scene;
  32641. private _scaledPosition;
  32642. private _scaledVelocity;
  32643. private _finalPosition;
  32644. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32645. createCollider(): Collider;
  32646. init(scene: Scene): void;
  32647. private _collideWithWorld;
  32648. }
  32649. }
  32650. declare module BABYLON {
  32651. /**
  32652. * Class used to manage all inputs for the scene.
  32653. */
  32654. export class InputManager {
  32655. /** The distance in pixel that you have to move to prevent some events */
  32656. static DragMovementThreshold: number;
  32657. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32658. static LongPressDelay: number;
  32659. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32660. static DoubleClickDelay: number;
  32661. /** If you need to check double click without raising a single click at first click, enable this flag */
  32662. static ExclusiveDoubleClickMode: boolean;
  32663. private _wheelEventName;
  32664. private _onPointerMove;
  32665. private _onPointerDown;
  32666. private _onPointerUp;
  32667. private _initClickEvent;
  32668. private _initActionManager;
  32669. private _delayedSimpleClick;
  32670. private _delayedSimpleClickTimeout;
  32671. private _previousDelayedSimpleClickTimeout;
  32672. private _meshPickProceed;
  32673. private _previousButtonPressed;
  32674. private _currentPickResult;
  32675. private _previousPickResult;
  32676. private _totalPointersPressed;
  32677. private _doubleClickOccured;
  32678. private _pointerOverMesh;
  32679. private _pickedDownMesh;
  32680. private _pickedUpMesh;
  32681. private _pointerX;
  32682. private _pointerY;
  32683. private _unTranslatedPointerX;
  32684. private _unTranslatedPointerY;
  32685. private _startingPointerPosition;
  32686. private _previousStartingPointerPosition;
  32687. private _startingPointerTime;
  32688. private _previousStartingPointerTime;
  32689. private _pointerCaptures;
  32690. private _onKeyDown;
  32691. private _onKeyUp;
  32692. private _onCanvasFocusObserver;
  32693. private _onCanvasBlurObserver;
  32694. private _scene;
  32695. /**
  32696. * Creates a new InputManager
  32697. * @param scene defines the hosting scene
  32698. */
  32699. constructor(scene: Scene);
  32700. /**
  32701. * Gets the mesh that is currently under the pointer
  32702. */
  32703. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32704. /**
  32705. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32706. */
  32707. readonly unTranslatedPointer: Vector2;
  32708. /**
  32709. * Gets or sets the current on-screen X position of the pointer
  32710. */
  32711. pointerX: number;
  32712. /**
  32713. * Gets or sets the current on-screen Y position of the pointer
  32714. */
  32715. pointerY: number;
  32716. private _updatePointerPosition;
  32717. private _processPointerMove;
  32718. private _setRayOnPointerInfo;
  32719. private _checkPrePointerObservable;
  32720. /**
  32721. * Use this method to simulate a pointer move on a mesh
  32722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32725. */
  32726. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32727. /**
  32728. * Use this method to simulate a pointer down on a mesh
  32729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32732. */
  32733. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32734. private _processPointerDown;
  32735. /** @hidden */
  32736. _isPointerSwiping(): boolean;
  32737. /**
  32738. * Use this method to simulate a pointer up on a mesh
  32739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32742. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32743. */
  32744. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32745. private _processPointerUp;
  32746. /**
  32747. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32748. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32749. * @returns true if the pointer was captured
  32750. */
  32751. isPointerCaptured(pointerId?: number): boolean;
  32752. /**
  32753. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32754. * @param attachUp defines if you want to attach events to pointerup
  32755. * @param attachDown defines if you want to attach events to pointerdown
  32756. * @param attachMove defines if you want to attach events to pointermove
  32757. */
  32758. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32759. /**
  32760. * Detaches all event handlers
  32761. */
  32762. detachControl(): void;
  32763. /**
  32764. * Force the value of meshUnderPointer
  32765. * @param mesh defines the mesh to use
  32766. */
  32767. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32768. /**
  32769. * Gets the mesh under the pointer
  32770. * @returns a Mesh or null if no mesh is under the pointer
  32771. */
  32772. getPointerOverMesh(): Nullable<AbstractMesh>;
  32773. }
  32774. }
  32775. declare module BABYLON {
  32776. /**
  32777. * Helper class used to generate session unique ID
  32778. */
  32779. export class UniqueIdGenerator {
  32780. private static _UniqueIdCounter;
  32781. /**
  32782. * Gets an unique (relatively to the current scene) Id
  32783. */
  32784. static readonly UniqueId: number;
  32785. }
  32786. }
  32787. declare module BABYLON {
  32788. /**
  32789. * This class defines the direct association between an animation and a target
  32790. */
  32791. export class TargetedAnimation {
  32792. /**
  32793. * Animation to perform
  32794. */
  32795. animation: Animation;
  32796. /**
  32797. * Target to animate
  32798. */
  32799. target: any;
  32800. /**
  32801. * Serialize the object
  32802. * @returns the JSON object representing the current entity
  32803. */
  32804. serialize(): any;
  32805. }
  32806. /**
  32807. * Use this class to create coordinated animations on multiple targets
  32808. */
  32809. export class AnimationGroup implements IDisposable {
  32810. /** The name of the animation group */
  32811. name: string;
  32812. private _scene;
  32813. private _targetedAnimations;
  32814. private _animatables;
  32815. private _from;
  32816. private _to;
  32817. private _isStarted;
  32818. private _isPaused;
  32819. private _speedRatio;
  32820. private _loopAnimation;
  32821. /**
  32822. * Gets or sets the unique id of the node
  32823. */
  32824. uniqueId: number;
  32825. /**
  32826. * This observable will notify when one animation have ended
  32827. */
  32828. onAnimationEndObservable: Observable<TargetedAnimation>;
  32829. /**
  32830. * Observer raised when one animation loops
  32831. */
  32832. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32833. /**
  32834. * This observable will notify when all animations have ended.
  32835. */
  32836. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32837. /**
  32838. * This observable will notify when all animations have paused.
  32839. */
  32840. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32841. /**
  32842. * This observable will notify when all animations are playing.
  32843. */
  32844. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32845. /**
  32846. * Gets the first frame
  32847. */
  32848. readonly from: number;
  32849. /**
  32850. * Gets the last frame
  32851. */
  32852. readonly to: number;
  32853. /**
  32854. * Define if the animations are started
  32855. */
  32856. readonly isStarted: boolean;
  32857. /**
  32858. * Gets a value indicating that the current group is playing
  32859. */
  32860. readonly isPlaying: boolean;
  32861. /**
  32862. * Gets or sets the speed ratio to use for all animations
  32863. */
  32864. /**
  32865. * Gets or sets the speed ratio to use for all animations
  32866. */
  32867. speedRatio: number;
  32868. /**
  32869. * Gets or sets if all animations should loop or not
  32870. */
  32871. loopAnimation: boolean;
  32872. /**
  32873. * Gets the targeted animations for this animation group
  32874. */
  32875. readonly targetedAnimations: Array<TargetedAnimation>;
  32876. /**
  32877. * returning the list of animatables controlled by this animation group.
  32878. */
  32879. readonly animatables: Array<Animatable>;
  32880. /**
  32881. * Instantiates a new Animation Group.
  32882. * This helps managing several animations at once.
  32883. * @see http://doc.babylonjs.com/how_to/group
  32884. * @param name Defines the name of the group
  32885. * @param scene Defines the scene the group belongs to
  32886. */
  32887. constructor(
  32888. /** The name of the animation group */
  32889. name: string, scene?: Nullable<Scene>);
  32890. /**
  32891. * Add an animation (with its target) in the group
  32892. * @param animation defines the animation we want to add
  32893. * @param target defines the target of the animation
  32894. * @returns the TargetedAnimation object
  32895. */
  32896. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32897. /**
  32898. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32899. * It can add constant keys at begin or end
  32900. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32901. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32902. * @returns the animation group
  32903. */
  32904. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32905. /**
  32906. * Start all animations on given targets
  32907. * @param loop defines if animations must loop
  32908. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32909. * @param from defines the from key (optional)
  32910. * @param to defines the to key (optional)
  32911. * @returns the current animation group
  32912. */
  32913. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32914. /**
  32915. * Pause all animations
  32916. * @returns the animation group
  32917. */
  32918. pause(): AnimationGroup;
  32919. /**
  32920. * Play all animations to initial state
  32921. * This function will start() the animations if they were not started or will restart() them if they were paused
  32922. * @param loop defines if animations must loop
  32923. * @returns the animation group
  32924. */
  32925. play(loop?: boolean): AnimationGroup;
  32926. /**
  32927. * Reset all animations to initial state
  32928. * @returns the animation group
  32929. */
  32930. reset(): AnimationGroup;
  32931. /**
  32932. * Restart animations from key 0
  32933. * @returns the animation group
  32934. */
  32935. restart(): AnimationGroup;
  32936. /**
  32937. * Stop all animations
  32938. * @returns the animation group
  32939. */
  32940. stop(): AnimationGroup;
  32941. /**
  32942. * Set animation weight for all animatables
  32943. * @param weight defines the weight to use
  32944. * @return the animationGroup
  32945. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32946. */
  32947. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32948. /**
  32949. * Synchronize and normalize all animatables with a source animatable
  32950. * @param root defines the root animatable to synchronize with
  32951. * @return the animationGroup
  32952. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32953. */
  32954. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32955. /**
  32956. * Goes to a specific frame in this animation group
  32957. * @param frame the frame number to go to
  32958. * @return the animationGroup
  32959. */
  32960. goToFrame(frame: number): AnimationGroup;
  32961. /**
  32962. * Dispose all associated resources
  32963. */
  32964. dispose(): void;
  32965. private _checkAnimationGroupEnded;
  32966. /**
  32967. * Clone the current animation group and returns a copy
  32968. * @param newName defines the name of the new group
  32969. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32970. * @returns the new aniamtion group
  32971. */
  32972. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32973. /**
  32974. * Serializes the animationGroup to an object
  32975. * @returns Serialized object
  32976. */
  32977. serialize(): any;
  32978. /**
  32979. * Returns a new AnimationGroup object parsed from the source provided.
  32980. * @param parsedAnimationGroup defines the source
  32981. * @param scene defines the scene that will receive the animationGroup
  32982. * @returns a new AnimationGroup
  32983. */
  32984. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32985. /**
  32986. * Returns the string "AnimationGroup"
  32987. * @returns "AnimationGroup"
  32988. */
  32989. getClassName(): string;
  32990. /**
  32991. * Creates a detailled string about the object
  32992. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32993. * @returns a string representing the object
  32994. */
  32995. toString(fullDetails?: boolean): string;
  32996. }
  32997. }
  32998. declare module BABYLON {
  32999. /**
  33000. * Define an interface for all classes that will hold resources
  33001. */
  33002. export interface IDisposable {
  33003. /**
  33004. * Releases all held resources
  33005. */
  33006. dispose(): void;
  33007. }
  33008. /** Interface defining initialization parameters for Scene class */
  33009. export interface SceneOptions {
  33010. /**
  33011. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33012. * It will improve performance when the number of geometries becomes important.
  33013. */
  33014. useGeometryUniqueIdsMap?: boolean;
  33015. /**
  33016. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33017. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33018. */
  33019. useMaterialMeshMap?: boolean;
  33020. /**
  33021. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33022. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33023. */
  33024. useClonedMeshhMap?: boolean;
  33025. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33026. virtual?: boolean;
  33027. }
  33028. /**
  33029. * Represents a scene to be rendered by the engine.
  33030. * @see http://doc.babylonjs.com/features/scene
  33031. */
  33032. export class Scene extends AbstractScene implements IAnimatable {
  33033. /** The fog is deactivated */
  33034. static readonly FOGMODE_NONE: number;
  33035. /** The fog density is following an exponential function */
  33036. static readonly FOGMODE_EXP: number;
  33037. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33038. static readonly FOGMODE_EXP2: number;
  33039. /** The fog density is following a linear function. */
  33040. static readonly FOGMODE_LINEAR: number;
  33041. /**
  33042. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33044. */
  33045. static MinDeltaTime: number;
  33046. /**
  33047. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33049. */
  33050. static MaxDeltaTime: number;
  33051. /**
  33052. * Factory used to create the default material.
  33053. * @param name The name of the material to create
  33054. * @param scene The scene to create the material for
  33055. * @returns The default material
  33056. */
  33057. static DefaultMaterialFactory(scene: Scene): Material;
  33058. /**
  33059. * Factory used to create the a collision coordinator.
  33060. * @returns The collision coordinator
  33061. */
  33062. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33063. /** @hidden */
  33064. _inputManager: InputManager;
  33065. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33066. cameraToUseForPointers: Nullable<Camera>;
  33067. /** @hidden */
  33068. readonly _isScene: boolean;
  33069. /**
  33070. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33071. */
  33072. autoClear: boolean;
  33073. /**
  33074. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33075. */
  33076. autoClearDepthAndStencil: boolean;
  33077. /**
  33078. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33079. */
  33080. clearColor: Color4;
  33081. /**
  33082. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33083. */
  33084. ambientColor: Color3;
  33085. /**
  33086. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33087. * It should only be one of the following (if not the default embedded one):
  33088. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33089. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33090. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33091. * The material properties need to be setup according to the type of texture in use.
  33092. */
  33093. environmentBRDFTexture: BaseTexture;
  33094. /** @hidden */
  33095. protected _environmentTexture: Nullable<BaseTexture>;
  33096. /**
  33097. * Texture used in all pbr material as the reflection texture.
  33098. * As in the majority of the scene they are the same (exception for multi room and so on),
  33099. * this is easier to reference from here than from all the materials.
  33100. */
  33101. /**
  33102. * Texture used in all pbr material as the reflection texture.
  33103. * As in the majority of the scene they are the same (exception for multi room and so on),
  33104. * this is easier to set here than in all the materials.
  33105. */
  33106. environmentTexture: Nullable<BaseTexture>;
  33107. /** @hidden */
  33108. protected _environmentIntensity: number;
  33109. /**
  33110. * Intensity of the environment in all pbr material.
  33111. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33112. * As in the majority of the scene they are the same (exception for multi room and so on),
  33113. * this is easier to reference from here than from all the materials.
  33114. */
  33115. /**
  33116. * Intensity of the environment in all pbr material.
  33117. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33118. * As in the majority of the scene they are the same (exception for multi room and so on),
  33119. * this is easier to set here than in all the materials.
  33120. */
  33121. environmentIntensity: number;
  33122. /** @hidden */
  33123. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33124. /**
  33125. * Default image processing configuration used either in the rendering
  33126. * Forward main pass or through the imageProcessingPostProcess if present.
  33127. * As in the majority of the scene they are the same (exception for multi camera),
  33128. * this is easier to reference from here than from all the materials and post process.
  33129. *
  33130. * No setter as we it is a shared configuration, you can set the values instead.
  33131. */
  33132. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33133. private _forceWireframe;
  33134. /**
  33135. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33136. */
  33137. forceWireframe: boolean;
  33138. private _forcePointsCloud;
  33139. /**
  33140. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33141. */
  33142. forcePointsCloud: boolean;
  33143. /**
  33144. * Gets or sets the active clipplane 1
  33145. */
  33146. clipPlane: Nullable<Plane>;
  33147. /**
  33148. * Gets or sets the active clipplane 2
  33149. */
  33150. clipPlane2: Nullable<Plane>;
  33151. /**
  33152. * Gets or sets the active clipplane 3
  33153. */
  33154. clipPlane3: Nullable<Plane>;
  33155. /**
  33156. * Gets or sets the active clipplane 4
  33157. */
  33158. clipPlane4: Nullable<Plane>;
  33159. /**
  33160. * Gets or sets a boolean indicating if animations are enabled
  33161. */
  33162. animationsEnabled: boolean;
  33163. private _animationPropertiesOverride;
  33164. /**
  33165. * Gets or sets the animation properties override
  33166. */
  33167. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33168. /**
  33169. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33170. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33171. */
  33172. useConstantAnimationDeltaTime: boolean;
  33173. /**
  33174. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33175. * Please note that it requires to run a ray cast through the scene on every frame
  33176. */
  33177. constantlyUpdateMeshUnderPointer: boolean;
  33178. /**
  33179. * Defines the HTML cursor to use when hovering over interactive elements
  33180. */
  33181. hoverCursor: string;
  33182. /**
  33183. * Defines the HTML default cursor to use (empty by default)
  33184. */
  33185. defaultCursor: string;
  33186. /**
  33187. * Defines wether cursors are handled by the scene.
  33188. */
  33189. doNotHandleCursors: boolean;
  33190. /**
  33191. * This is used to call preventDefault() on pointer down
  33192. * in order to block unwanted artifacts like system double clicks
  33193. */
  33194. preventDefaultOnPointerDown: boolean;
  33195. /**
  33196. * This is used to call preventDefault() on pointer up
  33197. * in order to block unwanted artifacts like system double clicks
  33198. */
  33199. preventDefaultOnPointerUp: boolean;
  33200. /**
  33201. * Gets or sets user defined metadata
  33202. */
  33203. metadata: any;
  33204. /**
  33205. * For internal use only. Please do not use.
  33206. */
  33207. reservedDataStore: any;
  33208. /**
  33209. * Gets the name of the plugin used to load this scene (null by default)
  33210. */
  33211. loadingPluginName: string;
  33212. /**
  33213. * Use this array to add regular expressions used to disable offline support for specific urls
  33214. */
  33215. disableOfflineSupportExceptionRules: RegExp[];
  33216. /**
  33217. * An event triggered when the scene is disposed.
  33218. */
  33219. onDisposeObservable: Observable<Scene>;
  33220. private _onDisposeObserver;
  33221. /** Sets a function to be executed when this scene is disposed. */
  33222. onDispose: () => void;
  33223. /**
  33224. * An event triggered before rendering the scene (right after animations and physics)
  33225. */
  33226. onBeforeRenderObservable: Observable<Scene>;
  33227. private _onBeforeRenderObserver;
  33228. /** Sets a function to be executed before rendering this scene */
  33229. beforeRender: Nullable<() => void>;
  33230. /**
  33231. * An event triggered after rendering the scene
  33232. */
  33233. onAfterRenderObservable: Observable<Scene>;
  33234. /**
  33235. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33236. */
  33237. onAfterRenderCameraObservable: Observable<Camera>;
  33238. private _onAfterRenderObserver;
  33239. /** Sets a function to be executed after rendering this scene */
  33240. afterRender: Nullable<() => void>;
  33241. /**
  33242. * An event triggered before animating the scene
  33243. */
  33244. onBeforeAnimationsObservable: Observable<Scene>;
  33245. /**
  33246. * An event triggered after animations processing
  33247. */
  33248. onAfterAnimationsObservable: Observable<Scene>;
  33249. /**
  33250. * An event triggered before draw calls are ready to be sent
  33251. */
  33252. onBeforeDrawPhaseObservable: Observable<Scene>;
  33253. /**
  33254. * An event triggered after draw calls have been sent
  33255. */
  33256. onAfterDrawPhaseObservable: Observable<Scene>;
  33257. /**
  33258. * An event triggered when the scene is ready
  33259. */
  33260. onReadyObservable: Observable<Scene>;
  33261. /**
  33262. * An event triggered before rendering a camera
  33263. */
  33264. onBeforeCameraRenderObservable: Observable<Camera>;
  33265. private _onBeforeCameraRenderObserver;
  33266. /** Sets a function to be executed before rendering a camera*/
  33267. beforeCameraRender: () => void;
  33268. /**
  33269. * An event triggered after rendering a camera
  33270. */
  33271. onAfterCameraRenderObservable: Observable<Camera>;
  33272. private _onAfterCameraRenderObserver;
  33273. /** Sets a function to be executed after rendering a camera*/
  33274. afterCameraRender: () => void;
  33275. /**
  33276. * An event triggered when active meshes evaluation is about to start
  33277. */
  33278. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33279. /**
  33280. * An event triggered when active meshes evaluation is done
  33281. */
  33282. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33283. /**
  33284. * An event triggered when particles rendering is about to start
  33285. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33286. */
  33287. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33288. /**
  33289. * An event triggered when particles rendering is done
  33290. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33291. */
  33292. onAfterParticlesRenderingObservable: Observable<Scene>;
  33293. /**
  33294. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33295. */
  33296. onDataLoadedObservable: Observable<Scene>;
  33297. /**
  33298. * An event triggered when a camera is created
  33299. */
  33300. onNewCameraAddedObservable: Observable<Camera>;
  33301. /**
  33302. * An event triggered when a camera is removed
  33303. */
  33304. onCameraRemovedObservable: Observable<Camera>;
  33305. /**
  33306. * An event triggered when a light is created
  33307. */
  33308. onNewLightAddedObservable: Observable<Light>;
  33309. /**
  33310. * An event triggered when a light is removed
  33311. */
  33312. onLightRemovedObservable: Observable<Light>;
  33313. /**
  33314. * An event triggered when a geometry is created
  33315. */
  33316. onNewGeometryAddedObservable: Observable<Geometry>;
  33317. /**
  33318. * An event triggered when a geometry is removed
  33319. */
  33320. onGeometryRemovedObservable: Observable<Geometry>;
  33321. /**
  33322. * An event triggered when a transform node is created
  33323. */
  33324. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33325. /**
  33326. * An event triggered when a transform node is removed
  33327. */
  33328. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33329. /**
  33330. * An event triggered when a mesh is created
  33331. */
  33332. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33333. /**
  33334. * An event triggered when a mesh is removed
  33335. */
  33336. onMeshRemovedObservable: Observable<AbstractMesh>;
  33337. /**
  33338. * An event triggered when a skeleton is created
  33339. */
  33340. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33341. /**
  33342. * An event triggered when a skeleton is removed
  33343. */
  33344. onSkeletonRemovedObservable: Observable<Skeleton>;
  33345. /**
  33346. * An event triggered when a material is created
  33347. */
  33348. onNewMaterialAddedObservable: Observable<Material>;
  33349. /**
  33350. * An event triggered when a material is removed
  33351. */
  33352. onMaterialRemovedObservable: Observable<Material>;
  33353. /**
  33354. * An event triggered when a texture is created
  33355. */
  33356. onNewTextureAddedObservable: Observable<BaseTexture>;
  33357. /**
  33358. * An event triggered when a texture is removed
  33359. */
  33360. onTextureRemovedObservable: Observable<BaseTexture>;
  33361. /**
  33362. * An event triggered when render targets are about to be rendered
  33363. * Can happen multiple times per frame.
  33364. */
  33365. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33366. /**
  33367. * An event triggered when render targets were rendered.
  33368. * Can happen multiple times per frame.
  33369. */
  33370. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33371. /**
  33372. * An event triggered before calculating deterministic simulation step
  33373. */
  33374. onBeforeStepObservable: Observable<Scene>;
  33375. /**
  33376. * An event triggered after calculating deterministic simulation step
  33377. */
  33378. onAfterStepObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered when the activeCamera property is updated
  33381. */
  33382. onActiveCameraChanged: Observable<Scene>;
  33383. /**
  33384. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33385. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33386. * 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)
  33387. */
  33388. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33389. /**
  33390. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33391. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33392. * 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)
  33393. */
  33394. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33395. /**
  33396. * This Observable will when a mesh has been imported into the scene.
  33397. */
  33398. onMeshImportedObservable: Observable<AbstractMesh>;
  33399. /**
  33400. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33401. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33402. */
  33403. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33404. /** @hidden */
  33405. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33406. /**
  33407. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33408. */
  33409. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33410. /**
  33411. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33412. */
  33413. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33414. /**
  33415. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33416. */
  33417. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33418. /** Callback called when a pointer move is detected */
  33419. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33420. /** Callback called when a pointer down is detected */
  33421. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33422. /** Callback called when a pointer up is detected */
  33423. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33424. /** Callback called when a pointer pick is detected */
  33425. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33426. /**
  33427. * 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).
  33428. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33429. */
  33430. onPrePointerObservable: Observable<PointerInfoPre>;
  33431. /**
  33432. * Observable event triggered each time an input event is received from the rendering canvas
  33433. */
  33434. onPointerObservable: Observable<PointerInfo>;
  33435. /**
  33436. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33437. */
  33438. readonly unTranslatedPointer: Vector2;
  33439. /**
  33440. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33441. */
  33442. static DragMovementThreshold: number;
  33443. /**
  33444. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33445. */
  33446. static LongPressDelay: number;
  33447. /**
  33448. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33449. */
  33450. static DoubleClickDelay: number;
  33451. /** If you need to check double click without raising a single click at first click, enable this flag */
  33452. static ExclusiveDoubleClickMode: boolean;
  33453. /** @hidden */
  33454. _mirroredCameraPosition: Nullable<Vector3>;
  33455. /**
  33456. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33457. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33458. */
  33459. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33460. /**
  33461. * Observable event triggered each time an keyboard event is received from the hosting window
  33462. */
  33463. onKeyboardObservable: Observable<KeyboardInfo>;
  33464. private _useRightHandedSystem;
  33465. /**
  33466. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33467. */
  33468. useRightHandedSystem: boolean;
  33469. private _timeAccumulator;
  33470. private _currentStepId;
  33471. private _currentInternalStep;
  33472. /**
  33473. * Sets the step Id used by deterministic lock step
  33474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33475. * @param newStepId defines the step Id
  33476. */
  33477. setStepId(newStepId: number): void;
  33478. /**
  33479. * Gets the step Id used by deterministic lock step
  33480. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33481. * @returns the step Id
  33482. */
  33483. getStepId(): number;
  33484. /**
  33485. * Gets the internal step used by deterministic lock step
  33486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33487. * @returns the internal step
  33488. */
  33489. getInternalStep(): number;
  33490. private _fogEnabled;
  33491. /**
  33492. * Gets or sets a boolean indicating if fog is enabled on this scene
  33493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33494. * (Default is true)
  33495. */
  33496. fogEnabled: boolean;
  33497. private _fogMode;
  33498. /**
  33499. * Gets or sets the fog mode to use
  33500. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33501. * | mode | value |
  33502. * | --- | --- |
  33503. * | FOGMODE_NONE | 0 |
  33504. * | FOGMODE_EXP | 1 |
  33505. * | FOGMODE_EXP2 | 2 |
  33506. * | FOGMODE_LINEAR | 3 |
  33507. */
  33508. fogMode: number;
  33509. /**
  33510. * Gets or sets the fog color to use
  33511. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33512. * (Default is Color3(0.2, 0.2, 0.3))
  33513. */
  33514. fogColor: Color3;
  33515. /**
  33516. * Gets or sets the fog density to use
  33517. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33518. * (Default is 0.1)
  33519. */
  33520. fogDensity: number;
  33521. /**
  33522. * Gets or sets the fog start distance to use
  33523. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33524. * (Default is 0)
  33525. */
  33526. fogStart: number;
  33527. /**
  33528. * Gets or sets the fog end distance to use
  33529. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33530. * (Default is 1000)
  33531. */
  33532. fogEnd: number;
  33533. private _shadowsEnabled;
  33534. /**
  33535. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33536. */
  33537. shadowsEnabled: boolean;
  33538. private _lightsEnabled;
  33539. /**
  33540. * Gets or sets a boolean indicating if lights are enabled on this scene
  33541. */
  33542. lightsEnabled: boolean;
  33543. /** All of the active cameras added to this scene. */
  33544. activeCameras: Camera[];
  33545. /** @hidden */
  33546. _activeCamera: Nullable<Camera>;
  33547. /** Gets or sets the current active camera */
  33548. activeCamera: Nullable<Camera>;
  33549. private _defaultMaterial;
  33550. /** The default material used on meshes when no material is affected */
  33551. /** The default material used on meshes when no material is affected */
  33552. defaultMaterial: Material;
  33553. private _texturesEnabled;
  33554. /**
  33555. * Gets or sets a boolean indicating if textures are enabled on this scene
  33556. */
  33557. texturesEnabled: boolean;
  33558. /**
  33559. * Gets or sets a boolean indicating if particles are enabled on this scene
  33560. */
  33561. particlesEnabled: boolean;
  33562. /**
  33563. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33564. */
  33565. spritesEnabled: boolean;
  33566. private _skeletonsEnabled;
  33567. /**
  33568. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33569. */
  33570. skeletonsEnabled: boolean;
  33571. /**
  33572. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33573. */
  33574. lensFlaresEnabled: boolean;
  33575. /**
  33576. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33578. */
  33579. collisionsEnabled: boolean;
  33580. private _collisionCoordinator;
  33581. /** @hidden */
  33582. readonly collisionCoordinator: ICollisionCoordinator;
  33583. /**
  33584. * Defines the gravity applied to this scene (used only for collisions)
  33585. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33586. */
  33587. gravity: Vector3;
  33588. /**
  33589. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33590. */
  33591. postProcessesEnabled: boolean;
  33592. /**
  33593. * The list of postprocesses added to the scene
  33594. */
  33595. postProcesses: PostProcess[];
  33596. /**
  33597. * Gets the current postprocess manager
  33598. */
  33599. postProcessManager: PostProcessManager;
  33600. /**
  33601. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33602. */
  33603. renderTargetsEnabled: boolean;
  33604. /**
  33605. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33606. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33607. */
  33608. dumpNextRenderTargets: boolean;
  33609. /**
  33610. * The list of user defined render targets added to the scene
  33611. */
  33612. customRenderTargets: RenderTargetTexture[];
  33613. /**
  33614. * Defines if texture loading must be delayed
  33615. * If true, textures will only be loaded when they need to be rendered
  33616. */
  33617. useDelayedTextureLoading: boolean;
  33618. /**
  33619. * Gets the list of meshes imported to the scene through SceneLoader
  33620. */
  33621. importedMeshesFiles: String[];
  33622. /**
  33623. * Gets or sets a boolean indicating if probes are enabled on this scene
  33624. */
  33625. probesEnabled: boolean;
  33626. /**
  33627. * Gets or sets the current offline provider to use to store scene data
  33628. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33629. */
  33630. offlineProvider: IOfflineProvider;
  33631. /**
  33632. * Gets or sets the action manager associated with the scene
  33633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33634. */
  33635. actionManager: AbstractActionManager;
  33636. private _meshesForIntersections;
  33637. /**
  33638. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33639. */
  33640. proceduralTexturesEnabled: boolean;
  33641. private _engine;
  33642. private _totalVertices;
  33643. /** @hidden */
  33644. _activeIndices: PerfCounter;
  33645. /** @hidden */
  33646. _activeParticles: PerfCounter;
  33647. /** @hidden */
  33648. _activeBones: PerfCounter;
  33649. private _animationRatio;
  33650. /** @hidden */
  33651. _animationTimeLast: number;
  33652. /** @hidden */
  33653. _animationTime: number;
  33654. /**
  33655. * Gets or sets a general scale for animation speed
  33656. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33657. */
  33658. animationTimeScale: number;
  33659. /** @hidden */
  33660. _cachedMaterial: Nullable<Material>;
  33661. /** @hidden */
  33662. _cachedEffect: Nullable<Effect>;
  33663. /** @hidden */
  33664. _cachedVisibility: Nullable<number>;
  33665. private _renderId;
  33666. private _frameId;
  33667. private _executeWhenReadyTimeoutId;
  33668. private _intermediateRendering;
  33669. private _viewUpdateFlag;
  33670. private _projectionUpdateFlag;
  33671. /** @hidden */
  33672. _toBeDisposed: Nullable<IDisposable>[];
  33673. private _activeRequests;
  33674. /** @hidden */
  33675. _pendingData: any[];
  33676. private _isDisposed;
  33677. /**
  33678. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33679. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33680. */
  33681. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33682. private _activeMeshes;
  33683. private _processedMaterials;
  33684. private _renderTargets;
  33685. /** @hidden */
  33686. _activeParticleSystems: SmartArray<IParticleSystem>;
  33687. private _activeSkeletons;
  33688. private _softwareSkinnedMeshes;
  33689. private _renderingManager;
  33690. /** @hidden */
  33691. _activeAnimatables: Animatable[];
  33692. private _transformMatrix;
  33693. private _sceneUbo;
  33694. /** @hidden */
  33695. _viewMatrix: Matrix;
  33696. private _projectionMatrix;
  33697. /** @hidden */
  33698. _forcedViewPosition: Nullable<Vector3>;
  33699. /** @hidden */
  33700. _frustumPlanes: Plane[];
  33701. /**
  33702. * Gets the list of frustum planes (built from the active camera)
  33703. */
  33704. readonly frustumPlanes: Plane[];
  33705. /**
  33706. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33707. * This is useful if there are more lights that the maximum simulteanous authorized
  33708. */
  33709. requireLightSorting: boolean;
  33710. /** @hidden */
  33711. readonly useMaterialMeshMap: boolean;
  33712. /** @hidden */
  33713. readonly useClonedMeshhMap: boolean;
  33714. private _externalData;
  33715. private _uid;
  33716. /**
  33717. * @hidden
  33718. * Backing store of defined scene components.
  33719. */
  33720. _components: ISceneComponent[];
  33721. /**
  33722. * @hidden
  33723. * Backing store of defined scene components.
  33724. */
  33725. _serializableComponents: ISceneSerializableComponent[];
  33726. /**
  33727. * List of components to register on the next registration step.
  33728. */
  33729. private _transientComponents;
  33730. /**
  33731. * Registers the transient components if needed.
  33732. */
  33733. private _registerTransientComponents;
  33734. /**
  33735. * @hidden
  33736. * Add a component to the scene.
  33737. * Note that the ccomponent could be registered on th next frame if this is called after
  33738. * the register component stage.
  33739. * @param component Defines the component to add to the scene
  33740. */
  33741. _addComponent(component: ISceneComponent): void;
  33742. /**
  33743. * @hidden
  33744. * Gets a component from the scene.
  33745. * @param name defines the name of the component to retrieve
  33746. * @returns the component or null if not present
  33747. */
  33748. _getComponent(name: string): Nullable<ISceneComponent>;
  33749. /**
  33750. * @hidden
  33751. * Defines the actions happening before camera updates.
  33752. */
  33753. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33754. /**
  33755. * @hidden
  33756. * Defines the actions happening before clear the canvas.
  33757. */
  33758. _beforeClearStage: Stage<SimpleStageAction>;
  33759. /**
  33760. * @hidden
  33761. * Defines the actions when collecting render targets for the frame.
  33762. */
  33763. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33764. /**
  33765. * @hidden
  33766. * Defines the actions happening for one camera in the frame.
  33767. */
  33768. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33769. /**
  33770. * @hidden
  33771. * Defines the actions happening during the per mesh ready checks.
  33772. */
  33773. _isReadyForMeshStage: Stage<MeshStageAction>;
  33774. /**
  33775. * @hidden
  33776. * Defines the actions happening before evaluate active mesh checks.
  33777. */
  33778. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33779. /**
  33780. * @hidden
  33781. * Defines the actions happening during the evaluate sub mesh checks.
  33782. */
  33783. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33784. /**
  33785. * @hidden
  33786. * Defines the actions happening during the active mesh stage.
  33787. */
  33788. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33789. /**
  33790. * @hidden
  33791. * Defines the actions happening during the per camera render target step.
  33792. */
  33793. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33794. /**
  33795. * @hidden
  33796. * Defines the actions happening just before the active camera is drawing.
  33797. */
  33798. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33799. /**
  33800. * @hidden
  33801. * Defines the actions happening just before a render target is drawing.
  33802. */
  33803. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33804. /**
  33805. * @hidden
  33806. * Defines the actions happening just before a rendering group is drawing.
  33807. */
  33808. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33809. /**
  33810. * @hidden
  33811. * Defines the actions happening just before a mesh is drawing.
  33812. */
  33813. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33814. /**
  33815. * @hidden
  33816. * Defines the actions happening just after a mesh has been drawn.
  33817. */
  33818. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33819. /**
  33820. * @hidden
  33821. * Defines the actions happening just after a rendering group has been drawn.
  33822. */
  33823. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33824. /**
  33825. * @hidden
  33826. * Defines the actions happening just after the active camera has been drawn.
  33827. */
  33828. _afterCameraDrawStage: Stage<CameraStageAction>;
  33829. /**
  33830. * @hidden
  33831. * Defines the actions happening just after a render target has been drawn.
  33832. */
  33833. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33834. /**
  33835. * @hidden
  33836. * Defines the actions happening just after rendering all cameras and computing intersections.
  33837. */
  33838. _afterRenderStage: Stage<SimpleStageAction>;
  33839. /**
  33840. * @hidden
  33841. * Defines the actions happening when a pointer move event happens.
  33842. */
  33843. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33844. /**
  33845. * @hidden
  33846. * Defines the actions happening when a pointer down event happens.
  33847. */
  33848. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33849. /**
  33850. * @hidden
  33851. * Defines the actions happening when a pointer up event happens.
  33852. */
  33853. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33854. /**
  33855. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33856. */
  33857. private geometriesByUniqueId;
  33858. /**
  33859. * Creates a new Scene
  33860. * @param engine defines the engine to use to render this scene
  33861. * @param options defines the scene options
  33862. */
  33863. constructor(engine: Engine, options?: SceneOptions);
  33864. /**
  33865. * Gets a string idenfifying the name of the class
  33866. * @returns "Scene" string
  33867. */
  33868. getClassName(): string;
  33869. private _defaultMeshCandidates;
  33870. /**
  33871. * @hidden
  33872. */
  33873. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33874. private _defaultSubMeshCandidates;
  33875. /**
  33876. * @hidden
  33877. */
  33878. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33879. /**
  33880. * Sets the default candidate providers for the scene.
  33881. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33882. * and getCollidingSubMeshCandidates to their default function
  33883. */
  33884. setDefaultCandidateProviders(): void;
  33885. /**
  33886. * Gets the mesh that is currently under the pointer
  33887. */
  33888. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33889. /**
  33890. * Gets or sets the current on-screen X position of the pointer
  33891. */
  33892. pointerX: number;
  33893. /**
  33894. * Gets or sets the current on-screen Y position of the pointer
  33895. */
  33896. pointerY: number;
  33897. /**
  33898. * Gets the cached material (ie. the latest rendered one)
  33899. * @returns the cached material
  33900. */
  33901. getCachedMaterial(): Nullable<Material>;
  33902. /**
  33903. * Gets the cached effect (ie. the latest rendered one)
  33904. * @returns the cached effect
  33905. */
  33906. getCachedEffect(): Nullable<Effect>;
  33907. /**
  33908. * Gets the cached visibility state (ie. the latest rendered one)
  33909. * @returns the cached visibility state
  33910. */
  33911. getCachedVisibility(): Nullable<number>;
  33912. /**
  33913. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33914. * @param material defines the current material
  33915. * @param effect defines the current effect
  33916. * @param visibility defines the current visibility state
  33917. * @returns true if one parameter is not cached
  33918. */
  33919. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33920. /**
  33921. * Gets the engine associated with the scene
  33922. * @returns an Engine
  33923. */
  33924. getEngine(): Engine;
  33925. /**
  33926. * Gets the total number of vertices rendered per frame
  33927. * @returns the total number of vertices rendered per frame
  33928. */
  33929. getTotalVertices(): number;
  33930. /**
  33931. * Gets the performance counter for total vertices
  33932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33933. */
  33934. readonly totalVerticesPerfCounter: PerfCounter;
  33935. /**
  33936. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33937. * @returns the total number of active indices rendered per frame
  33938. */
  33939. getActiveIndices(): number;
  33940. /**
  33941. * Gets the performance counter for active indices
  33942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33943. */
  33944. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33945. /**
  33946. * Gets the total number of active particles rendered per frame
  33947. * @returns the total number of active particles rendered per frame
  33948. */
  33949. getActiveParticles(): number;
  33950. /**
  33951. * Gets the performance counter for active particles
  33952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33953. */
  33954. readonly activeParticlesPerfCounter: PerfCounter;
  33955. /**
  33956. * Gets the total number of active bones rendered per frame
  33957. * @returns the total number of active bones rendered per frame
  33958. */
  33959. getActiveBones(): number;
  33960. /**
  33961. * Gets the performance counter for active bones
  33962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33963. */
  33964. readonly activeBonesPerfCounter: PerfCounter;
  33965. /**
  33966. * Gets the array of active meshes
  33967. * @returns an array of AbstractMesh
  33968. */
  33969. getActiveMeshes(): SmartArray<AbstractMesh>;
  33970. /**
  33971. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33972. * @returns a number
  33973. */
  33974. getAnimationRatio(): number;
  33975. /**
  33976. * Gets an unique Id for the current render phase
  33977. * @returns a number
  33978. */
  33979. getRenderId(): number;
  33980. /**
  33981. * Gets an unique Id for the current frame
  33982. * @returns a number
  33983. */
  33984. getFrameId(): number;
  33985. /** Call this function if you want to manually increment the render Id*/
  33986. incrementRenderId(): void;
  33987. private _createUbo;
  33988. /**
  33989. * Use this method to simulate a pointer move on a mesh
  33990. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33991. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33992. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33993. * @returns the current scene
  33994. */
  33995. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33996. /**
  33997. * Use this method to simulate a pointer down on a mesh
  33998. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33999. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34000. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34001. * @returns the current scene
  34002. */
  34003. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34004. /**
  34005. * Use this method to simulate a pointer up on a mesh
  34006. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34007. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34008. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34009. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34010. * @returns the current scene
  34011. */
  34012. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34013. /**
  34014. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34015. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34016. * @returns true if the pointer was captured
  34017. */
  34018. isPointerCaptured(pointerId?: number): boolean;
  34019. /**
  34020. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34021. * @param attachUp defines if you want to attach events to pointerup
  34022. * @param attachDown defines if you want to attach events to pointerdown
  34023. * @param attachMove defines if you want to attach events to pointermove
  34024. */
  34025. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34026. /** Detaches all event handlers*/
  34027. detachControl(): void;
  34028. /**
  34029. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34030. * Delay loaded resources are not taking in account
  34031. * @return true if all required resources are ready
  34032. */
  34033. isReady(): boolean;
  34034. /** Resets all cached information relative to material (including effect and visibility) */
  34035. resetCachedMaterial(): void;
  34036. /**
  34037. * Registers a function to be called before every frame render
  34038. * @param func defines the function to register
  34039. */
  34040. registerBeforeRender(func: () => void): void;
  34041. /**
  34042. * Unregisters a function called before every frame render
  34043. * @param func defines the function to unregister
  34044. */
  34045. unregisterBeforeRender(func: () => void): void;
  34046. /**
  34047. * Registers a function to be called after every frame render
  34048. * @param func defines the function to register
  34049. */
  34050. registerAfterRender(func: () => void): void;
  34051. /**
  34052. * Unregisters a function called after every frame render
  34053. * @param func defines the function to unregister
  34054. */
  34055. unregisterAfterRender(func: () => void): void;
  34056. private _executeOnceBeforeRender;
  34057. /**
  34058. * The provided function will run before render once and will be disposed afterwards.
  34059. * A timeout delay can be provided so that the function will be executed in N ms.
  34060. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34061. * @param func The function to be executed.
  34062. * @param timeout optional delay in ms
  34063. */
  34064. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34065. /** @hidden */
  34066. _addPendingData(data: any): void;
  34067. /** @hidden */
  34068. _removePendingData(data: any): void;
  34069. /**
  34070. * Returns the number of items waiting to be loaded
  34071. * @returns the number of items waiting to be loaded
  34072. */
  34073. getWaitingItemsCount(): number;
  34074. /**
  34075. * Returns a boolean indicating if the scene is still loading data
  34076. */
  34077. readonly isLoading: boolean;
  34078. /**
  34079. * Registers a function to be executed when the scene is ready
  34080. * @param {Function} func - the function to be executed
  34081. */
  34082. executeWhenReady(func: () => void): void;
  34083. /**
  34084. * Returns a promise that resolves when the scene is ready
  34085. * @returns A promise that resolves when the scene is ready
  34086. */
  34087. whenReadyAsync(): Promise<void>;
  34088. /** @hidden */
  34089. _checkIsReady(): void;
  34090. /**
  34091. * Gets all animatable attached to the scene
  34092. */
  34093. readonly animatables: Animatable[];
  34094. /**
  34095. * Resets the last animation time frame.
  34096. * Useful to override when animations start running when loading a scene for the first time.
  34097. */
  34098. resetLastAnimationTimeFrame(): void;
  34099. /**
  34100. * Gets the current view matrix
  34101. * @returns a Matrix
  34102. */
  34103. getViewMatrix(): Matrix;
  34104. /**
  34105. * Gets the current projection matrix
  34106. * @returns a Matrix
  34107. */
  34108. getProjectionMatrix(): Matrix;
  34109. /**
  34110. * Gets the current transform matrix
  34111. * @returns a Matrix made of View * Projection
  34112. */
  34113. getTransformMatrix(): Matrix;
  34114. /**
  34115. * Sets the current transform matrix
  34116. * @param viewL defines the View matrix to use
  34117. * @param projectionL defines the Projection matrix to use
  34118. * @param viewR defines the right View matrix to use (if provided)
  34119. * @param projectionR defines the right Projection matrix to use (if provided)
  34120. */
  34121. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34122. /**
  34123. * Gets the uniform buffer used to store scene data
  34124. * @returns a UniformBuffer
  34125. */
  34126. getSceneUniformBuffer(): UniformBuffer;
  34127. /**
  34128. * Gets an unique (relatively to the current scene) Id
  34129. * @returns an unique number for the scene
  34130. */
  34131. getUniqueId(): number;
  34132. /**
  34133. * Add a mesh to the list of scene's meshes
  34134. * @param newMesh defines the mesh to add
  34135. * @param recursive if all child meshes should also be added to the scene
  34136. */
  34137. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34138. /**
  34139. * Remove a mesh for the list of scene's meshes
  34140. * @param toRemove defines the mesh to remove
  34141. * @param recursive if all child meshes should also be removed from the scene
  34142. * @returns the index where the mesh was in the mesh list
  34143. */
  34144. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34145. /**
  34146. * Add a transform node to the list of scene's transform nodes
  34147. * @param newTransformNode defines the transform node to add
  34148. */
  34149. addTransformNode(newTransformNode: TransformNode): void;
  34150. /**
  34151. * Remove a transform node for the list of scene's transform nodes
  34152. * @param toRemove defines the transform node to remove
  34153. * @returns the index where the transform node was in the transform node list
  34154. */
  34155. removeTransformNode(toRemove: TransformNode): number;
  34156. /**
  34157. * Remove a skeleton for the list of scene's skeletons
  34158. * @param toRemove defines the skeleton to remove
  34159. * @returns the index where the skeleton was in the skeleton list
  34160. */
  34161. removeSkeleton(toRemove: Skeleton): number;
  34162. /**
  34163. * Remove a morph target for the list of scene's morph targets
  34164. * @param toRemove defines the morph target to remove
  34165. * @returns the index where the morph target was in the morph target list
  34166. */
  34167. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34168. /**
  34169. * Remove a light for the list of scene's lights
  34170. * @param toRemove defines the light to remove
  34171. * @returns the index where the light was in the light list
  34172. */
  34173. removeLight(toRemove: Light): number;
  34174. /**
  34175. * Remove a camera for the list of scene's cameras
  34176. * @param toRemove defines the camera to remove
  34177. * @returns the index where the camera was in the camera list
  34178. */
  34179. removeCamera(toRemove: Camera): number;
  34180. /**
  34181. * Remove a particle system for the list of scene's particle systems
  34182. * @param toRemove defines the particle system to remove
  34183. * @returns the index where the particle system was in the particle system list
  34184. */
  34185. removeParticleSystem(toRemove: IParticleSystem): number;
  34186. /**
  34187. * Remove a animation for the list of scene's animations
  34188. * @param toRemove defines the animation to remove
  34189. * @returns the index where the animation was in the animation list
  34190. */
  34191. removeAnimation(toRemove: Animation): number;
  34192. /**
  34193. * Will stop the animation of the given target
  34194. * @param target - the target
  34195. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34196. * @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)
  34197. */
  34198. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34199. /**
  34200. * Removes the given animation group from this scene.
  34201. * @param toRemove The animation group to remove
  34202. * @returns The index of the removed animation group
  34203. */
  34204. removeAnimationGroup(toRemove: AnimationGroup): number;
  34205. /**
  34206. * Removes the given multi-material from this scene.
  34207. * @param toRemove The multi-material to remove
  34208. * @returns The index of the removed multi-material
  34209. */
  34210. removeMultiMaterial(toRemove: MultiMaterial): number;
  34211. /**
  34212. * Removes the given material from this scene.
  34213. * @param toRemove The material to remove
  34214. * @returns The index of the removed material
  34215. */
  34216. removeMaterial(toRemove: Material): number;
  34217. /**
  34218. * Removes the given action manager from this scene.
  34219. * @param toRemove The action manager to remove
  34220. * @returns The index of the removed action manager
  34221. */
  34222. removeActionManager(toRemove: AbstractActionManager): number;
  34223. /**
  34224. * Removes the given texture from this scene.
  34225. * @param toRemove The texture to remove
  34226. * @returns The index of the removed texture
  34227. */
  34228. removeTexture(toRemove: BaseTexture): number;
  34229. /**
  34230. * Adds the given light to this scene
  34231. * @param newLight The light to add
  34232. */
  34233. addLight(newLight: Light): void;
  34234. /**
  34235. * Sorts the list list based on light priorities
  34236. */
  34237. sortLightsByPriority(): void;
  34238. /**
  34239. * Adds the given camera to this scene
  34240. * @param newCamera The camera to add
  34241. */
  34242. addCamera(newCamera: Camera): void;
  34243. /**
  34244. * Adds the given skeleton to this scene
  34245. * @param newSkeleton The skeleton to add
  34246. */
  34247. addSkeleton(newSkeleton: Skeleton): void;
  34248. /**
  34249. * Adds the given particle system to this scene
  34250. * @param newParticleSystem The particle system to add
  34251. */
  34252. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34253. /**
  34254. * Adds the given animation to this scene
  34255. * @param newAnimation The animation to add
  34256. */
  34257. addAnimation(newAnimation: Animation): void;
  34258. /**
  34259. * Adds the given animation group to this scene.
  34260. * @param newAnimationGroup The animation group to add
  34261. */
  34262. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34263. /**
  34264. * Adds the given multi-material to this scene
  34265. * @param newMultiMaterial The multi-material to add
  34266. */
  34267. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34268. /**
  34269. * Adds the given material to this scene
  34270. * @param newMaterial The material to add
  34271. */
  34272. addMaterial(newMaterial: Material): void;
  34273. /**
  34274. * Adds the given morph target to this scene
  34275. * @param newMorphTargetManager The morph target to add
  34276. */
  34277. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34278. /**
  34279. * Adds the given geometry to this scene
  34280. * @param newGeometry The geometry to add
  34281. */
  34282. addGeometry(newGeometry: Geometry): void;
  34283. /**
  34284. * Adds the given action manager to this scene
  34285. * @param newActionManager The action manager to add
  34286. */
  34287. addActionManager(newActionManager: AbstractActionManager): void;
  34288. /**
  34289. * Adds the given texture to this scene.
  34290. * @param newTexture The texture to add
  34291. */
  34292. addTexture(newTexture: BaseTexture): void;
  34293. /**
  34294. * Switch active camera
  34295. * @param newCamera defines the new active camera
  34296. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34297. */
  34298. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34299. /**
  34300. * sets the active camera of the scene using its ID
  34301. * @param id defines the camera's ID
  34302. * @return the new active camera or null if none found.
  34303. */
  34304. setActiveCameraByID(id: string): Nullable<Camera>;
  34305. /**
  34306. * sets the active camera of the scene using its name
  34307. * @param name defines the camera's name
  34308. * @returns the new active camera or null if none found.
  34309. */
  34310. setActiveCameraByName(name: string): Nullable<Camera>;
  34311. /**
  34312. * get an animation group using its name
  34313. * @param name defines the material's name
  34314. * @return the animation group or null if none found.
  34315. */
  34316. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34317. /**
  34318. * Get a material using its unique id
  34319. * @param uniqueId defines the material's unique id
  34320. * @return the material or null if none found.
  34321. */
  34322. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34323. /**
  34324. * get a material using its id
  34325. * @param id defines the material's ID
  34326. * @return the material or null if none found.
  34327. */
  34328. getMaterialByID(id: string): Nullable<Material>;
  34329. /**
  34330. * Gets a the last added material using a given id
  34331. * @param id defines the material's ID
  34332. * @return the last material with the given id or null if none found.
  34333. */
  34334. getLastMaterialByID(id: string): Nullable<Material>;
  34335. /**
  34336. * Gets a material using its name
  34337. * @param name defines the material's name
  34338. * @return the material or null if none found.
  34339. */
  34340. getMaterialByName(name: string): Nullable<Material>;
  34341. /**
  34342. * Get a texture using its unique id
  34343. * @param uniqueId defines the texture's unique id
  34344. * @return the texture or null if none found.
  34345. */
  34346. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34347. /**
  34348. * Gets a camera using its id
  34349. * @param id defines the id to look for
  34350. * @returns the camera or null if not found
  34351. */
  34352. getCameraByID(id: string): Nullable<Camera>;
  34353. /**
  34354. * Gets a camera using its unique id
  34355. * @param uniqueId defines the unique id to look for
  34356. * @returns the camera or null if not found
  34357. */
  34358. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34359. /**
  34360. * Gets a camera using its name
  34361. * @param name defines the camera's name
  34362. * @return the camera or null if none found.
  34363. */
  34364. getCameraByName(name: string): Nullable<Camera>;
  34365. /**
  34366. * Gets a bone using its id
  34367. * @param id defines the bone's id
  34368. * @return the bone or null if not found
  34369. */
  34370. getBoneByID(id: string): Nullable<Bone>;
  34371. /**
  34372. * Gets a bone using its id
  34373. * @param name defines the bone's name
  34374. * @return the bone or null if not found
  34375. */
  34376. getBoneByName(name: string): Nullable<Bone>;
  34377. /**
  34378. * Gets a light node using its name
  34379. * @param name defines the the light's name
  34380. * @return the light or null if none found.
  34381. */
  34382. getLightByName(name: string): Nullable<Light>;
  34383. /**
  34384. * Gets a light node using its id
  34385. * @param id defines the light's id
  34386. * @return the light or null if none found.
  34387. */
  34388. getLightByID(id: string): Nullable<Light>;
  34389. /**
  34390. * Gets a light node using its scene-generated unique ID
  34391. * @param uniqueId defines the light's unique id
  34392. * @return the light or null if none found.
  34393. */
  34394. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34395. /**
  34396. * Gets a particle system by id
  34397. * @param id defines the particle system id
  34398. * @return the corresponding system or null if none found
  34399. */
  34400. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34401. /**
  34402. * Gets a geometry using its ID
  34403. * @param id defines the geometry's id
  34404. * @return the geometry or null if none found.
  34405. */
  34406. getGeometryByID(id: string): Nullable<Geometry>;
  34407. private _getGeometryByUniqueID;
  34408. /**
  34409. * Add a new geometry to this scene
  34410. * @param geometry defines the geometry to be added to the scene.
  34411. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34412. * @return a boolean defining if the geometry was added or not
  34413. */
  34414. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34415. /**
  34416. * Removes an existing geometry
  34417. * @param geometry defines the geometry to be removed from the scene
  34418. * @return a boolean defining if the geometry was removed or not
  34419. */
  34420. removeGeometry(geometry: Geometry): boolean;
  34421. /**
  34422. * Gets the list of geometries attached to the scene
  34423. * @returns an array of Geometry
  34424. */
  34425. getGeometries(): Geometry[];
  34426. /**
  34427. * Gets the first added mesh found of a given ID
  34428. * @param id defines the id to search for
  34429. * @return the mesh found or null if not found at all
  34430. */
  34431. getMeshByID(id: string): Nullable<AbstractMesh>;
  34432. /**
  34433. * Gets a list of meshes using their id
  34434. * @param id defines the id to search for
  34435. * @returns a list of meshes
  34436. */
  34437. getMeshesByID(id: string): Array<AbstractMesh>;
  34438. /**
  34439. * Gets the first added transform node found of a given ID
  34440. * @param id defines the id to search for
  34441. * @return the found transform node or null if not found at all.
  34442. */
  34443. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34444. /**
  34445. * Gets a transform node with its auto-generated unique id
  34446. * @param uniqueId efines the unique id to search for
  34447. * @return the found transform node or null if not found at all.
  34448. */
  34449. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34450. /**
  34451. * Gets a list of transform nodes using their id
  34452. * @param id defines the id to search for
  34453. * @returns a list of transform nodes
  34454. */
  34455. getTransformNodesByID(id: string): Array<TransformNode>;
  34456. /**
  34457. * Gets a mesh with its auto-generated unique id
  34458. * @param uniqueId defines the unique id to search for
  34459. * @return the found mesh or null if not found at all.
  34460. */
  34461. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34462. /**
  34463. * Gets a the last added mesh using a given id
  34464. * @param id defines the id to search for
  34465. * @return the found mesh or null if not found at all.
  34466. */
  34467. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34468. /**
  34469. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34470. * @param id defines the id to search for
  34471. * @return the found node or null if not found at all
  34472. */
  34473. getLastEntryByID(id: string): Nullable<Node>;
  34474. /**
  34475. * Gets a node (Mesh, Camera, Light) using a given id
  34476. * @param id defines the id to search for
  34477. * @return the found node or null if not found at all
  34478. */
  34479. getNodeByID(id: string): Nullable<Node>;
  34480. /**
  34481. * Gets a node (Mesh, Camera, Light) using a given name
  34482. * @param name defines the name to search for
  34483. * @return the found node or null if not found at all.
  34484. */
  34485. getNodeByName(name: string): Nullable<Node>;
  34486. /**
  34487. * Gets a mesh using a given name
  34488. * @param name defines the name to search for
  34489. * @return the found mesh or null if not found at all.
  34490. */
  34491. getMeshByName(name: string): Nullable<AbstractMesh>;
  34492. /**
  34493. * Gets a transform node using a given name
  34494. * @param name defines the name to search for
  34495. * @return the found transform node or null if not found at all.
  34496. */
  34497. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34498. /**
  34499. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34500. * @param id defines the id to search for
  34501. * @return the found skeleton or null if not found at all.
  34502. */
  34503. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34504. /**
  34505. * Gets a skeleton using a given auto generated unique id
  34506. * @param uniqueId defines the unique id to search for
  34507. * @return the found skeleton or null if not found at all.
  34508. */
  34509. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34510. /**
  34511. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34512. * @param id defines the id to search for
  34513. * @return the found skeleton or null if not found at all.
  34514. */
  34515. getSkeletonById(id: string): Nullable<Skeleton>;
  34516. /**
  34517. * Gets a skeleton using a given name
  34518. * @param name defines the name to search for
  34519. * @return the found skeleton or null if not found at all.
  34520. */
  34521. getSkeletonByName(name: string): Nullable<Skeleton>;
  34522. /**
  34523. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34524. * @param id defines the id to search for
  34525. * @return the found morph target manager or null if not found at all.
  34526. */
  34527. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34528. /**
  34529. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34530. * @param id defines the id to search for
  34531. * @return the found morph target or null if not found at all.
  34532. */
  34533. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34534. /**
  34535. * Gets a boolean indicating if the given mesh is active
  34536. * @param mesh defines the mesh to look for
  34537. * @returns true if the mesh is in the active list
  34538. */
  34539. isActiveMesh(mesh: AbstractMesh): boolean;
  34540. /**
  34541. * Return a unique id as a string which can serve as an identifier for the scene
  34542. */
  34543. readonly uid: string;
  34544. /**
  34545. * Add an externaly attached data from its key.
  34546. * This method call will fail and return false, if such key already exists.
  34547. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34548. * @param key the unique key that identifies the data
  34549. * @param data the data object to associate to the key for this Engine instance
  34550. * @return true if no such key were already present and the data was added successfully, false otherwise
  34551. */
  34552. addExternalData<T>(key: string, data: T): boolean;
  34553. /**
  34554. * Get an externaly attached data from its key
  34555. * @param key the unique key that identifies the data
  34556. * @return the associated data, if present (can be null), or undefined if not present
  34557. */
  34558. getExternalData<T>(key: string): Nullable<T>;
  34559. /**
  34560. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34561. * @param key the unique key that identifies the data
  34562. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34563. * @return the associated data, can be null if the factory returned null.
  34564. */
  34565. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34566. /**
  34567. * Remove an externaly attached data from the Engine instance
  34568. * @param key the unique key that identifies the data
  34569. * @return true if the data was successfully removed, false if it doesn't exist
  34570. */
  34571. removeExternalData(key: string): boolean;
  34572. private _evaluateSubMesh;
  34573. /**
  34574. * Clear the processed materials smart array preventing retention point in material dispose.
  34575. */
  34576. freeProcessedMaterials(): void;
  34577. private _preventFreeActiveMeshesAndRenderingGroups;
  34578. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34579. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34580. * when disposing several meshes in a row or a hierarchy of meshes.
  34581. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34582. */
  34583. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34584. /**
  34585. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34586. */
  34587. freeActiveMeshes(): void;
  34588. /**
  34589. * Clear the info related to rendering groups preventing retention points during dispose.
  34590. */
  34591. freeRenderingGroups(): void;
  34592. /** @hidden */
  34593. _isInIntermediateRendering(): boolean;
  34594. /**
  34595. * Lambda returning the list of potentially active meshes.
  34596. */
  34597. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34598. /**
  34599. * Lambda returning the list of potentially active sub meshes.
  34600. */
  34601. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34602. /**
  34603. * Lambda returning the list of potentially intersecting sub meshes.
  34604. */
  34605. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34606. /**
  34607. * Lambda returning the list of potentially colliding sub meshes.
  34608. */
  34609. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34610. private _activeMeshesFrozen;
  34611. /**
  34612. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34613. * @returns the current scene
  34614. */
  34615. freezeActiveMeshes(): Scene;
  34616. /**
  34617. * Use this function to restart evaluating active meshes on every frame
  34618. * @returns the current scene
  34619. */
  34620. unfreezeActiveMeshes(): Scene;
  34621. private _evaluateActiveMeshes;
  34622. private _activeMesh;
  34623. /**
  34624. * Update the transform matrix to update from the current active camera
  34625. * @param force defines a boolean used to force the update even if cache is up to date
  34626. */
  34627. updateTransformMatrix(force?: boolean): void;
  34628. private _bindFrameBuffer;
  34629. /** @hidden */
  34630. _allowPostProcessClearColor: boolean;
  34631. /** @hidden */
  34632. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34633. private _processSubCameras;
  34634. private _checkIntersections;
  34635. /** @hidden */
  34636. _advancePhysicsEngineStep(step: number): void;
  34637. /**
  34638. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34639. */
  34640. getDeterministicFrameTime: () => number;
  34641. /** @hidden */
  34642. _animate(): void;
  34643. /** Execute all animations (for a frame) */
  34644. animate(): void;
  34645. /**
  34646. * Render the scene
  34647. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34648. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34649. */
  34650. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34651. /**
  34652. * Freeze all materials
  34653. * A frozen material will not be updatable but should be faster to render
  34654. */
  34655. freezeMaterials(): void;
  34656. /**
  34657. * Unfreeze all materials
  34658. * A frozen material will not be updatable but should be faster to render
  34659. */
  34660. unfreezeMaterials(): void;
  34661. /**
  34662. * Releases all held ressources
  34663. */
  34664. dispose(): void;
  34665. /**
  34666. * Gets if the scene is already disposed
  34667. */
  34668. readonly isDisposed: boolean;
  34669. /**
  34670. * Call this function to reduce memory footprint of the scene.
  34671. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34672. */
  34673. clearCachedVertexData(): void;
  34674. /**
  34675. * This function will remove the local cached buffer data from texture.
  34676. * It will save memory but will prevent the texture from being rebuilt
  34677. */
  34678. cleanCachedTextureBuffer(): void;
  34679. /**
  34680. * Get the world extend vectors with an optional filter
  34681. *
  34682. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34683. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34684. */
  34685. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34686. min: Vector3;
  34687. max: Vector3;
  34688. };
  34689. /**
  34690. * Creates a ray that can be used to pick in the scene
  34691. * @param x defines the x coordinate of the origin (on-screen)
  34692. * @param y defines the y coordinate of the origin (on-screen)
  34693. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34694. * @param camera defines the camera to use for the picking
  34695. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34696. * @returns a Ray
  34697. */
  34698. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34699. /**
  34700. * Creates a ray that can be used to pick in the scene
  34701. * @param x defines the x coordinate of the origin (on-screen)
  34702. * @param y defines the y coordinate of the origin (on-screen)
  34703. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34704. * @param result defines the ray where to store the picking ray
  34705. * @param camera defines the camera to use for the picking
  34706. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34707. * @returns the current scene
  34708. */
  34709. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34710. /**
  34711. * Creates a ray that can be used to pick in the scene
  34712. * @param x defines the x coordinate of the origin (on-screen)
  34713. * @param y defines the y coordinate of the origin (on-screen)
  34714. * @param camera defines the camera to use for the picking
  34715. * @returns a Ray
  34716. */
  34717. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34718. /**
  34719. * Creates a ray that can be used to pick in the scene
  34720. * @param x defines the x coordinate of the origin (on-screen)
  34721. * @param y defines the y coordinate of the origin (on-screen)
  34722. * @param result defines the ray where to store the picking ray
  34723. * @param camera defines the camera to use for the picking
  34724. * @returns the current scene
  34725. */
  34726. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34727. /** Launch a ray to try to pick a mesh in the scene
  34728. * @param x position on screen
  34729. * @param y position on screen
  34730. * @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
  34731. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34732. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34734. * @returns a PickingInfo
  34735. */
  34736. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34737. /** Use the given ray to pick a mesh in the scene
  34738. * @param ray The ray to use to pick meshes
  34739. * @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
  34740. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34742. * @returns a PickingInfo
  34743. */
  34744. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34745. /**
  34746. * Launch a ray to try to pick a mesh in the scene
  34747. * @param x X position on screen
  34748. * @param y Y position on screen
  34749. * @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
  34750. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34752. * @returns an array of PickingInfo
  34753. */
  34754. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34755. /**
  34756. * Launch a ray to try to pick a mesh in the scene
  34757. * @param ray Ray to use
  34758. * @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
  34759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34760. * @returns an array of PickingInfo
  34761. */
  34762. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34763. /**
  34764. * Force the value of meshUnderPointer
  34765. * @param mesh defines the mesh to use
  34766. */
  34767. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34768. /**
  34769. * Gets the mesh under the pointer
  34770. * @returns a Mesh or null if no mesh is under the pointer
  34771. */
  34772. getPointerOverMesh(): Nullable<AbstractMesh>;
  34773. /** @hidden */
  34774. _rebuildGeometries(): void;
  34775. /** @hidden */
  34776. _rebuildTextures(): void;
  34777. private _getByTags;
  34778. /**
  34779. * Get a list of meshes by tags
  34780. * @param tagsQuery defines the tags query to use
  34781. * @param forEach defines a predicate used to filter results
  34782. * @returns an array of Mesh
  34783. */
  34784. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34785. /**
  34786. * Get a list of cameras by tags
  34787. * @param tagsQuery defines the tags query to use
  34788. * @param forEach defines a predicate used to filter results
  34789. * @returns an array of Camera
  34790. */
  34791. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34792. /**
  34793. * Get a list of lights by tags
  34794. * @param tagsQuery defines the tags query to use
  34795. * @param forEach defines a predicate used to filter results
  34796. * @returns an array of Light
  34797. */
  34798. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34799. /**
  34800. * Get a list of materials by tags
  34801. * @param tagsQuery defines the tags query to use
  34802. * @param forEach defines a predicate used to filter results
  34803. * @returns an array of Material
  34804. */
  34805. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34806. /**
  34807. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34808. * This allowed control for front to back rendering or reversly depending of the special needs.
  34809. *
  34810. * @param renderingGroupId The rendering group id corresponding to its index
  34811. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34812. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34813. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34814. */
  34815. 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;
  34816. /**
  34817. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34818. *
  34819. * @param renderingGroupId The rendering group id corresponding to its index
  34820. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34821. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34822. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34823. */
  34824. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34825. /**
  34826. * Gets the current auto clear configuration for one rendering group of the rendering
  34827. * manager.
  34828. * @param index the rendering group index to get the information for
  34829. * @returns The auto clear setup for the requested rendering group
  34830. */
  34831. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34832. private _blockMaterialDirtyMechanism;
  34833. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34834. blockMaterialDirtyMechanism: boolean;
  34835. /**
  34836. * Will flag all materials as dirty to trigger new shader compilation
  34837. * @param flag defines the flag used to specify which material part must be marked as dirty
  34838. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34839. */
  34840. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34841. /** @hidden */
  34842. _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;
  34843. /** @hidden */
  34844. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34845. }
  34846. }
  34847. declare module BABYLON {
  34848. /**
  34849. * Set of assets to keep when moving a scene into an asset container.
  34850. */
  34851. export class KeepAssets extends AbstractScene {
  34852. }
  34853. /**
  34854. * Container with a set of assets that can be added or removed from a scene.
  34855. */
  34856. export class AssetContainer extends AbstractScene {
  34857. /**
  34858. * The scene the AssetContainer belongs to.
  34859. */
  34860. scene: Scene;
  34861. /**
  34862. * Instantiates an AssetContainer.
  34863. * @param scene The scene the AssetContainer belongs to.
  34864. */
  34865. constructor(scene: Scene);
  34866. /**
  34867. * Adds all the assets from the container to the scene.
  34868. */
  34869. addAllToScene(): void;
  34870. /**
  34871. * Removes all the assets in the container from the scene
  34872. */
  34873. removeAllFromScene(): void;
  34874. /**
  34875. * Disposes all the assets in the container
  34876. */
  34877. dispose(): void;
  34878. private _moveAssets;
  34879. /**
  34880. * Removes all the assets contained in the scene and adds them to the container.
  34881. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34882. */
  34883. moveAllFromScene(keepAssets?: KeepAssets): void;
  34884. /**
  34885. * 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.
  34886. * @returns the root mesh
  34887. */
  34888. createRootMesh(): Mesh;
  34889. }
  34890. }
  34891. declare module BABYLON {
  34892. /**
  34893. * Defines how the parser contract is defined.
  34894. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34895. */
  34896. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34897. /**
  34898. * Defines how the individual parser contract is defined.
  34899. * These parser can parse an individual asset
  34900. */
  34901. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34902. /**
  34903. * Base class of the scene acting as a container for the different elements composing a scene.
  34904. * This class is dynamically extended by the different components of the scene increasing
  34905. * flexibility and reducing coupling
  34906. */
  34907. export abstract class AbstractScene {
  34908. /**
  34909. * Stores the list of available parsers in the application.
  34910. */
  34911. private static _BabylonFileParsers;
  34912. /**
  34913. * Stores the list of available individual parsers in the application.
  34914. */
  34915. private static _IndividualBabylonFileParsers;
  34916. /**
  34917. * Adds a parser in the list of available ones
  34918. * @param name Defines the name of the parser
  34919. * @param parser Defines the parser to add
  34920. */
  34921. static AddParser(name: string, parser: BabylonFileParser): void;
  34922. /**
  34923. * Gets a general parser from the list of avaialble ones
  34924. * @param name Defines the name of the parser
  34925. * @returns the requested parser or null
  34926. */
  34927. static GetParser(name: string): Nullable<BabylonFileParser>;
  34928. /**
  34929. * Adds n individual parser in the list of available ones
  34930. * @param name Defines the name of the parser
  34931. * @param parser Defines the parser to add
  34932. */
  34933. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34934. /**
  34935. * Gets an individual parser from the list of avaialble ones
  34936. * @param name Defines the name of the parser
  34937. * @returns the requested parser or null
  34938. */
  34939. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34940. /**
  34941. * Parser json data and populate both a scene and its associated container object
  34942. * @param jsonData Defines the data to parse
  34943. * @param scene Defines the scene to parse the data for
  34944. * @param container Defines the container attached to the parsing sequence
  34945. * @param rootUrl Defines the root url of the data
  34946. */
  34947. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34948. /**
  34949. * Gets the list of root nodes (ie. nodes with no parent)
  34950. */
  34951. rootNodes: Node[];
  34952. /** All of the cameras added to this scene
  34953. * @see http://doc.babylonjs.com/babylon101/cameras
  34954. */
  34955. cameras: Camera[];
  34956. /**
  34957. * All of the lights added to this scene
  34958. * @see http://doc.babylonjs.com/babylon101/lights
  34959. */
  34960. lights: Light[];
  34961. /**
  34962. * All of the (abstract) meshes added to this scene
  34963. */
  34964. meshes: AbstractMesh[];
  34965. /**
  34966. * The list of skeletons added to the scene
  34967. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34968. */
  34969. skeletons: Skeleton[];
  34970. /**
  34971. * All of the particle systems added to this scene
  34972. * @see http://doc.babylonjs.com/babylon101/particles
  34973. */
  34974. particleSystems: IParticleSystem[];
  34975. /**
  34976. * Gets a list of Animations associated with the scene
  34977. */
  34978. animations: Animation[];
  34979. /**
  34980. * All of the animation groups added to this scene
  34981. * @see http://doc.babylonjs.com/how_to/group
  34982. */
  34983. animationGroups: AnimationGroup[];
  34984. /**
  34985. * All of the multi-materials added to this scene
  34986. * @see http://doc.babylonjs.com/how_to/multi_materials
  34987. */
  34988. multiMaterials: MultiMaterial[];
  34989. /**
  34990. * All of the materials added to this scene
  34991. * In the context of a Scene, it is not supposed to be modified manually.
  34992. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34993. * Note also that the order of the Material wihin the array is not significant and might change.
  34994. * @see http://doc.babylonjs.com/babylon101/materials
  34995. */
  34996. materials: Material[];
  34997. /**
  34998. * The list of morph target managers added to the scene
  34999. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35000. */
  35001. morphTargetManagers: MorphTargetManager[];
  35002. /**
  35003. * The list of geometries used in the scene.
  35004. */
  35005. geometries: Geometry[];
  35006. /**
  35007. * All of the tranform nodes added to this scene
  35008. * In the context of a Scene, it is not supposed to be modified manually.
  35009. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35010. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35011. * @see http://doc.babylonjs.com/how_to/transformnode
  35012. */
  35013. transformNodes: TransformNode[];
  35014. /**
  35015. * ActionManagers available on the scene.
  35016. */
  35017. actionManagers: AbstractActionManager[];
  35018. /**
  35019. * Textures to keep.
  35020. */
  35021. textures: BaseTexture[];
  35022. /**
  35023. * Environment texture for the scene
  35024. */
  35025. environmentTexture: Nullable<BaseTexture>;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Interface used to define options for Sound class
  35031. */
  35032. export interface ISoundOptions {
  35033. /**
  35034. * Does the sound autoplay once loaded.
  35035. */
  35036. autoplay?: boolean;
  35037. /**
  35038. * Does the sound loop after it finishes playing once.
  35039. */
  35040. loop?: boolean;
  35041. /**
  35042. * Sound's volume
  35043. */
  35044. volume?: number;
  35045. /**
  35046. * Is it a spatial sound?
  35047. */
  35048. spatialSound?: boolean;
  35049. /**
  35050. * Maximum distance to hear that sound
  35051. */
  35052. maxDistance?: number;
  35053. /**
  35054. * Uses user defined attenuation function
  35055. */
  35056. useCustomAttenuation?: boolean;
  35057. /**
  35058. * Define the roll off factor of spatial sounds.
  35059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35060. */
  35061. rolloffFactor?: number;
  35062. /**
  35063. * Define the reference distance the sound should be heard perfectly.
  35064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35065. */
  35066. refDistance?: number;
  35067. /**
  35068. * Define the distance attenuation model the sound will follow.
  35069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35070. */
  35071. distanceModel?: string;
  35072. /**
  35073. * Defines the playback speed (1 by default)
  35074. */
  35075. playbackRate?: number;
  35076. /**
  35077. * Defines if the sound is from a streaming source
  35078. */
  35079. streaming?: boolean;
  35080. /**
  35081. * Defines an optional length (in seconds) inside the sound file
  35082. */
  35083. length?: number;
  35084. /**
  35085. * Defines an optional offset (in seconds) inside the sound file
  35086. */
  35087. offset?: number;
  35088. /**
  35089. * If true, URLs will not be required to state the audio file codec to use.
  35090. */
  35091. skipCodecCheck?: boolean;
  35092. }
  35093. /**
  35094. * Defines a sound that can be played in the application.
  35095. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35097. */
  35098. export class Sound {
  35099. /**
  35100. * The name of the sound in the scene.
  35101. */
  35102. name: string;
  35103. /**
  35104. * Does the sound autoplay once loaded.
  35105. */
  35106. autoplay: boolean;
  35107. /**
  35108. * Does the sound loop after it finishes playing once.
  35109. */
  35110. loop: boolean;
  35111. /**
  35112. * Does the sound use a custom attenuation curve to simulate the falloff
  35113. * happening when the source gets further away from the camera.
  35114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35115. */
  35116. useCustomAttenuation: boolean;
  35117. /**
  35118. * The sound track id this sound belongs to.
  35119. */
  35120. soundTrackId: number;
  35121. /**
  35122. * Is this sound currently played.
  35123. */
  35124. isPlaying: boolean;
  35125. /**
  35126. * Is this sound currently paused.
  35127. */
  35128. isPaused: boolean;
  35129. /**
  35130. * Does this sound enables spatial sound.
  35131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35132. */
  35133. spatialSound: boolean;
  35134. /**
  35135. * Define the reference distance the sound should be heard perfectly.
  35136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35137. */
  35138. refDistance: number;
  35139. /**
  35140. * Define the roll off factor of spatial sounds.
  35141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35142. */
  35143. rolloffFactor: number;
  35144. /**
  35145. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35147. */
  35148. maxDistance: number;
  35149. /**
  35150. * Define the distance attenuation model the sound will follow.
  35151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35152. */
  35153. distanceModel: string;
  35154. /**
  35155. * @hidden
  35156. * Back Compat
  35157. **/
  35158. onended: () => any;
  35159. /**
  35160. * Observable event when the current playing sound finishes.
  35161. */
  35162. onEndedObservable: Observable<Sound>;
  35163. private _panningModel;
  35164. private _playbackRate;
  35165. private _streaming;
  35166. private _startTime;
  35167. private _startOffset;
  35168. private _position;
  35169. /** @hidden */
  35170. _positionInEmitterSpace: boolean;
  35171. private _localDirection;
  35172. private _volume;
  35173. private _isReadyToPlay;
  35174. private _isDirectional;
  35175. private _readyToPlayCallback;
  35176. private _audioBuffer;
  35177. private _soundSource;
  35178. private _streamingSource;
  35179. private _soundPanner;
  35180. private _soundGain;
  35181. private _inputAudioNode;
  35182. private _outputAudioNode;
  35183. private _coneInnerAngle;
  35184. private _coneOuterAngle;
  35185. private _coneOuterGain;
  35186. private _scene;
  35187. private _connectedTransformNode;
  35188. private _customAttenuationFunction;
  35189. private _registerFunc;
  35190. private _isOutputConnected;
  35191. private _htmlAudioElement;
  35192. private _urlType;
  35193. private _length?;
  35194. private _offset?;
  35195. /** @hidden */
  35196. static _SceneComponentInitialization: (scene: Scene) => void;
  35197. /**
  35198. * Create a sound and attach it to a scene
  35199. * @param name Name of your sound
  35200. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35201. * @param scene defines the scene the sound belongs to
  35202. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35203. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35204. */
  35205. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35206. /**
  35207. * Release the sound and its associated resources
  35208. */
  35209. dispose(): void;
  35210. /**
  35211. * Gets if the sounds is ready to be played or not.
  35212. * @returns true if ready, otherwise false
  35213. */
  35214. isReady(): boolean;
  35215. private _soundLoaded;
  35216. /**
  35217. * Sets the data of the sound from an audiobuffer
  35218. * @param audioBuffer The audioBuffer containing the data
  35219. */
  35220. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35221. /**
  35222. * Updates the current sounds options such as maxdistance, loop...
  35223. * @param options A JSON object containing values named as the object properties
  35224. */
  35225. updateOptions(options: ISoundOptions): void;
  35226. private _createSpatialParameters;
  35227. private _updateSpatialParameters;
  35228. /**
  35229. * Switch the panning model to HRTF:
  35230. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35232. */
  35233. switchPanningModelToHRTF(): void;
  35234. /**
  35235. * Switch the panning model to Equal Power:
  35236. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35238. */
  35239. switchPanningModelToEqualPower(): void;
  35240. private _switchPanningModel;
  35241. /**
  35242. * Connect this sound to a sound track audio node like gain...
  35243. * @param soundTrackAudioNode the sound track audio node to connect to
  35244. */
  35245. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35246. /**
  35247. * Transform this sound into a directional source
  35248. * @param coneInnerAngle Size of the inner cone in degree
  35249. * @param coneOuterAngle Size of the outer cone in degree
  35250. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35251. */
  35252. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35253. /**
  35254. * Gets or sets the inner angle for the directional cone.
  35255. */
  35256. /**
  35257. * Gets or sets the inner angle for the directional cone.
  35258. */
  35259. directionalConeInnerAngle: number;
  35260. /**
  35261. * Gets or sets the outer angle for the directional cone.
  35262. */
  35263. /**
  35264. * Gets or sets the outer angle for the directional cone.
  35265. */
  35266. directionalConeOuterAngle: number;
  35267. /**
  35268. * Sets the position of the emitter if spatial sound is enabled
  35269. * @param newPosition Defines the new posisiton
  35270. */
  35271. setPosition(newPosition: Vector3): void;
  35272. /**
  35273. * Sets the local direction of the emitter if spatial sound is enabled
  35274. * @param newLocalDirection Defines the new local direction
  35275. */
  35276. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35277. private _updateDirection;
  35278. /** @hidden */
  35279. updateDistanceFromListener(): void;
  35280. /**
  35281. * Sets a new custom attenuation function for the sound.
  35282. * @param callback Defines the function used for the attenuation
  35283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35284. */
  35285. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35286. /**
  35287. * Play the sound
  35288. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35289. * @param offset (optional) Start the sound at a specific time in seconds
  35290. * @param length (optional) Sound duration (in seconds)
  35291. */
  35292. play(time?: number, offset?: number, length?: number): void;
  35293. private _onended;
  35294. /**
  35295. * Stop the sound
  35296. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35297. */
  35298. stop(time?: number): void;
  35299. /**
  35300. * Put the sound in pause
  35301. */
  35302. pause(): void;
  35303. /**
  35304. * Sets a dedicated volume for this sounds
  35305. * @param newVolume Define the new volume of the sound
  35306. * @param time Define time for gradual change to new volume
  35307. */
  35308. setVolume(newVolume: number, time?: number): void;
  35309. /**
  35310. * Set the sound play back rate
  35311. * @param newPlaybackRate Define the playback rate the sound should be played at
  35312. */
  35313. setPlaybackRate(newPlaybackRate: number): void;
  35314. /**
  35315. * Gets the volume of the sound.
  35316. * @returns the volume of the sound
  35317. */
  35318. getVolume(): number;
  35319. /**
  35320. * Attach the sound to a dedicated mesh
  35321. * @param transformNode The transform node to connect the sound with
  35322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35323. */
  35324. attachToMesh(transformNode: TransformNode): void;
  35325. /**
  35326. * Detach the sound from the previously attached mesh
  35327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35328. */
  35329. detachFromMesh(): void;
  35330. private _onRegisterAfterWorldMatrixUpdate;
  35331. /**
  35332. * Clone the current sound in the scene.
  35333. * @returns the new sound clone
  35334. */
  35335. clone(): Nullable<Sound>;
  35336. /**
  35337. * Gets the current underlying audio buffer containing the data
  35338. * @returns the audio buffer
  35339. */
  35340. getAudioBuffer(): Nullable<AudioBuffer>;
  35341. /**
  35342. * Serializes the Sound in a JSON representation
  35343. * @returns the JSON representation of the sound
  35344. */
  35345. serialize(): any;
  35346. /**
  35347. * Parse a JSON representation of a sound to innstantiate in a given scene
  35348. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35349. * @param scene Define the scene the new parsed sound should be created in
  35350. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35351. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35352. * @returns the newly parsed sound
  35353. */
  35354. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35355. }
  35356. }
  35357. declare module BABYLON {
  35358. /**
  35359. * This defines an action helpful to play a defined sound on a triggered action.
  35360. */
  35361. export class PlaySoundAction extends Action {
  35362. private _sound;
  35363. /**
  35364. * Instantiate the action
  35365. * @param triggerOptions defines the trigger options
  35366. * @param sound defines the sound to play
  35367. * @param condition defines the trigger related conditions
  35368. */
  35369. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35370. /** @hidden */
  35371. _prepare(): void;
  35372. /**
  35373. * Execute the action and play the sound.
  35374. */
  35375. execute(): void;
  35376. /**
  35377. * Serializes the actions and its related information.
  35378. * @param parent defines the object to serialize in
  35379. * @returns the serialized object
  35380. */
  35381. serialize(parent: any): any;
  35382. }
  35383. /**
  35384. * This defines an action helpful to stop a defined sound on a triggered action.
  35385. */
  35386. export class StopSoundAction extends Action {
  35387. private _sound;
  35388. /**
  35389. * Instantiate the action
  35390. * @param triggerOptions defines the trigger options
  35391. * @param sound defines the sound to stop
  35392. * @param condition defines the trigger related conditions
  35393. */
  35394. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35395. /** @hidden */
  35396. _prepare(): void;
  35397. /**
  35398. * Execute the action and stop the sound.
  35399. */
  35400. execute(): void;
  35401. /**
  35402. * Serializes the actions and its related information.
  35403. * @param parent defines the object to serialize in
  35404. * @returns the serialized object
  35405. */
  35406. serialize(parent: any): any;
  35407. }
  35408. }
  35409. declare module BABYLON {
  35410. /**
  35411. * This defines an action responsible to change the value of a property
  35412. * by interpolating between its current value and the newly set one once triggered.
  35413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35414. */
  35415. export class InterpolateValueAction extends Action {
  35416. /**
  35417. * Defines the path of the property where the value should be interpolated
  35418. */
  35419. propertyPath: string;
  35420. /**
  35421. * Defines the target value at the end of the interpolation.
  35422. */
  35423. value: any;
  35424. /**
  35425. * Defines the time it will take for the property to interpolate to the value.
  35426. */
  35427. duration: number;
  35428. /**
  35429. * Defines if the other scene animations should be stopped when the action has been triggered
  35430. */
  35431. stopOtherAnimations?: boolean;
  35432. /**
  35433. * Defines a callback raised once the interpolation animation has been done.
  35434. */
  35435. onInterpolationDone?: () => void;
  35436. /**
  35437. * Observable triggered once the interpolation animation has been done.
  35438. */
  35439. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35440. private _target;
  35441. private _effectiveTarget;
  35442. private _property;
  35443. /**
  35444. * Instantiate the action
  35445. * @param triggerOptions defines the trigger options
  35446. * @param target defines the object containing the value to interpolate
  35447. * @param propertyPath defines the path to the property in the target object
  35448. * @param value defines the target value at the end of the interpolation
  35449. * @param duration deines the time it will take for the property to interpolate to the value.
  35450. * @param condition defines the trigger related conditions
  35451. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35452. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35453. */
  35454. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35455. /** @hidden */
  35456. _prepare(): void;
  35457. /**
  35458. * Execute the action starts the value interpolation.
  35459. */
  35460. execute(): void;
  35461. /**
  35462. * Serializes the actions and its related information.
  35463. * @param parent defines the object to serialize in
  35464. * @returns the serialized object
  35465. */
  35466. serialize(parent: any): any;
  35467. }
  35468. }
  35469. declare module BABYLON {
  35470. /**
  35471. * Options allowed during the creation of a sound track.
  35472. */
  35473. export interface ISoundTrackOptions {
  35474. /**
  35475. * The volume the sound track should take during creation
  35476. */
  35477. volume?: number;
  35478. /**
  35479. * Define if the sound track is the main sound track of the scene
  35480. */
  35481. mainTrack?: boolean;
  35482. }
  35483. /**
  35484. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35485. * It will be also used in a future release to apply effects on a specific track.
  35486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35487. */
  35488. export class SoundTrack {
  35489. /**
  35490. * The unique identifier of the sound track in the scene.
  35491. */
  35492. id: number;
  35493. /**
  35494. * The list of sounds included in the sound track.
  35495. */
  35496. soundCollection: Array<Sound>;
  35497. private _outputAudioNode;
  35498. private _scene;
  35499. private _isMainTrack;
  35500. private _connectedAnalyser;
  35501. private _options;
  35502. private _isInitialized;
  35503. /**
  35504. * Creates a new sound track.
  35505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35506. * @param scene Define the scene the sound track belongs to
  35507. * @param options
  35508. */
  35509. constructor(scene: Scene, options?: ISoundTrackOptions);
  35510. private _initializeSoundTrackAudioGraph;
  35511. /**
  35512. * Release the sound track and its associated resources
  35513. */
  35514. dispose(): void;
  35515. /**
  35516. * Adds a sound to this sound track
  35517. * @param sound define the cound to add
  35518. * @ignoreNaming
  35519. */
  35520. AddSound(sound: Sound): void;
  35521. /**
  35522. * Removes a sound to this sound track
  35523. * @param sound define the cound to remove
  35524. * @ignoreNaming
  35525. */
  35526. RemoveSound(sound: Sound): void;
  35527. /**
  35528. * Set a global volume for the full sound track.
  35529. * @param newVolume Define the new volume of the sound track
  35530. */
  35531. setVolume(newVolume: number): void;
  35532. /**
  35533. * Switch the panning model to HRTF:
  35534. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35536. */
  35537. switchPanningModelToHRTF(): void;
  35538. /**
  35539. * Switch the panning model to Equal Power:
  35540. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35542. */
  35543. switchPanningModelToEqualPower(): void;
  35544. /**
  35545. * Connect the sound track to an audio analyser allowing some amazing
  35546. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35548. * @param analyser The analyser to connect to the engine
  35549. */
  35550. connectToAnalyser(analyser: Analyser): void;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. interface AbstractScene {
  35555. /**
  35556. * The list of sounds used in the scene.
  35557. */
  35558. sounds: Nullable<Array<Sound>>;
  35559. }
  35560. interface Scene {
  35561. /**
  35562. * @hidden
  35563. * Backing field
  35564. */
  35565. _mainSoundTrack: SoundTrack;
  35566. /**
  35567. * The main sound track played by the scene.
  35568. * It cotains your primary collection of sounds.
  35569. */
  35570. mainSoundTrack: SoundTrack;
  35571. /**
  35572. * The list of sound tracks added to the scene
  35573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35574. */
  35575. soundTracks: Nullable<Array<SoundTrack>>;
  35576. /**
  35577. * Gets a sound using a given name
  35578. * @param name defines the name to search for
  35579. * @return the found sound or null if not found at all.
  35580. */
  35581. getSoundByName(name: string): Nullable<Sound>;
  35582. /**
  35583. * Gets or sets if audio support is enabled
  35584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35585. */
  35586. audioEnabled: boolean;
  35587. /**
  35588. * Gets or sets if audio will be output to headphones
  35589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35590. */
  35591. headphone: boolean;
  35592. /**
  35593. * Gets or sets custom audio listener position provider
  35594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35595. */
  35596. audioListenerPositionProvider: Nullable<() => Vector3>;
  35597. }
  35598. /**
  35599. * Defines the sound scene component responsible to manage any sounds
  35600. * in a given scene.
  35601. */
  35602. export class AudioSceneComponent implements ISceneSerializableComponent {
  35603. /**
  35604. * The component name helpfull to identify the component in the list of scene components.
  35605. */
  35606. readonly name: string;
  35607. /**
  35608. * The scene the component belongs to.
  35609. */
  35610. scene: Scene;
  35611. private _audioEnabled;
  35612. /**
  35613. * Gets whether audio is enabled or not.
  35614. * Please use related enable/disable method to switch state.
  35615. */
  35616. readonly audioEnabled: boolean;
  35617. private _headphone;
  35618. /**
  35619. * Gets whether audio is outputing to headphone or not.
  35620. * Please use the according Switch methods to change output.
  35621. */
  35622. readonly headphone: boolean;
  35623. private _audioListenerPositionProvider;
  35624. /**
  35625. * Gets the current audio listener position provider
  35626. */
  35627. /**
  35628. * Sets a custom listener position for all sounds in the scene
  35629. * By default, this is the position of the first active camera
  35630. */
  35631. audioListenerPositionProvider: Nullable<() => Vector3>;
  35632. /**
  35633. * Creates a new instance of the component for the given scene
  35634. * @param scene Defines the scene to register the component in
  35635. */
  35636. constructor(scene: Scene);
  35637. /**
  35638. * Registers the component in a given scene
  35639. */
  35640. register(): void;
  35641. /**
  35642. * Rebuilds the elements related to this component in case of
  35643. * context lost for instance.
  35644. */
  35645. rebuild(): void;
  35646. /**
  35647. * Serializes the component data to the specified json object
  35648. * @param serializationObject The object to serialize to
  35649. */
  35650. serialize(serializationObject: any): void;
  35651. /**
  35652. * Adds all the elements from the container to the scene
  35653. * @param container the container holding the elements
  35654. */
  35655. addFromContainer(container: AbstractScene): void;
  35656. /**
  35657. * Removes all the elements in the container from the scene
  35658. * @param container contains the elements to remove
  35659. * @param dispose if the removed element should be disposed (default: false)
  35660. */
  35661. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35662. /**
  35663. * Disposes the component and the associated ressources.
  35664. */
  35665. dispose(): void;
  35666. /**
  35667. * Disables audio in the associated scene.
  35668. */
  35669. disableAudio(): void;
  35670. /**
  35671. * Enables audio in the associated scene.
  35672. */
  35673. enableAudio(): void;
  35674. /**
  35675. * Switch audio to headphone output.
  35676. */
  35677. switchAudioModeForHeadphones(): void;
  35678. /**
  35679. * Switch audio to normal speakers.
  35680. */
  35681. switchAudioModeForNormalSpeakers(): void;
  35682. private _afterRender;
  35683. }
  35684. }
  35685. declare module BABYLON {
  35686. /**
  35687. * Wraps one or more Sound objects and selects one with random weight for playback.
  35688. */
  35689. export class WeightedSound {
  35690. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35691. loop: boolean;
  35692. private _coneInnerAngle;
  35693. private _coneOuterAngle;
  35694. private _volume;
  35695. /** A Sound is currently playing. */
  35696. isPlaying: boolean;
  35697. /** A Sound is currently paused. */
  35698. isPaused: boolean;
  35699. private _sounds;
  35700. private _weights;
  35701. private _currentIndex?;
  35702. /**
  35703. * Creates a new WeightedSound from the list of sounds given.
  35704. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35705. * @param sounds Array of Sounds that will be selected from.
  35706. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35707. */
  35708. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35709. /**
  35710. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35711. */
  35712. /**
  35713. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35714. */
  35715. directionalConeInnerAngle: number;
  35716. /**
  35717. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35718. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35719. */
  35720. /**
  35721. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35722. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35723. */
  35724. directionalConeOuterAngle: number;
  35725. /**
  35726. * Playback volume.
  35727. */
  35728. /**
  35729. * Playback volume.
  35730. */
  35731. volume: number;
  35732. private _onended;
  35733. /**
  35734. * Suspend playback
  35735. */
  35736. pause(): void;
  35737. /**
  35738. * Stop playback
  35739. */
  35740. stop(): void;
  35741. /**
  35742. * Start playback.
  35743. * @param startOffset Position the clip head at a specific time in seconds.
  35744. */
  35745. play(startOffset?: number): void;
  35746. }
  35747. }
  35748. declare module BABYLON {
  35749. /**
  35750. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35752. */
  35753. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35754. /**
  35755. * Gets the name of the behavior.
  35756. */
  35757. readonly name: string;
  35758. /**
  35759. * The easing function used by animations
  35760. */
  35761. static EasingFunction: BackEase;
  35762. /**
  35763. * The easing mode used by animations
  35764. */
  35765. static EasingMode: number;
  35766. /**
  35767. * The duration of the animation, in milliseconds
  35768. */
  35769. transitionDuration: number;
  35770. /**
  35771. * Length of the distance animated by the transition when lower radius is reached
  35772. */
  35773. lowerRadiusTransitionRange: number;
  35774. /**
  35775. * Length of the distance animated by the transition when upper radius is reached
  35776. */
  35777. upperRadiusTransitionRange: number;
  35778. private _autoTransitionRange;
  35779. /**
  35780. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35781. */
  35782. /**
  35783. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35784. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35785. */
  35786. autoTransitionRange: boolean;
  35787. private _attachedCamera;
  35788. private _onAfterCheckInputsObserver;
  35789. private _onMeshTargetChangedObserver;
  35790. /**
  35791. * Initializes the behavior.
  35792. */
  35793. init(): void;
  35794. /**
  35795. * Attaches the behavior to its arc rotate camera.
  35796. * @param camera Defines the camera to attach the behavior to
  35797. */
  35798. attach(camera: ArcRotateCamera): void;
  35799. /**
  35800. * Detaches the behavior from its current arc rotate camera.
  35801. */
  35802. detach(): void;
  35803. private _radiusIsAnimating;
  35804. private _radiusBounceTransition;
  35805. private _animatables;
  35806. private _cachedWheelPrecision;
  35807. /**
  35808. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35809. * @param radiusLimit The limit to check against.
  35810. * @return Bool to indicate if at limit.
  35811. */
  35812. private _isRadiusAtLimit;
  35813. /**
  35814. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35815. * @param radiusDelta The delta by which to animate to. Can be negative.
  35816. */
  35817. private _applyBoundRadiusAnimation;
  35818. /**
  35819. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35820. */
  35821. protected _clearAnimationLocks(): void;
  35822. /**
  35823. * Stops and removes all animations that have been applied to the camera
  35824. */
  35825. stopAllAnimations(): void;
  35826. }
  35827. }
  35828. declare module BABYLON {
  35829. /**
  35830. * 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.
  35831. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35832. */
  35833. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35834. /**
  35835. * Gets the name of the behavior.
  35836. */
  35837. readonly name: string;
  35838. private _mode;
  35839. private _radiusScale;
  35840. private _positionScale;
  35841. private _defaultElevation;
  35842. private _elevationReturnTime;
  35843. private _elevationReturnWaitTime;
  35844. private _zoomStopsAnimation;
  35845. private _framingTime;
  35846. /**
  35847. * The easing function used by animations
  35848. */
  35849. static EasingFunction: ExponentialEase;
  35850. /**
  35851. * The easing mode used by animations
  35852. */
  35853. static EasingMode: number;
  35854. /**
  35855. * Sets the current mode used by the behavior
  35856. */
  35857. /**
  35858. * Gets current mode used by the behavior.
  35859. */
  35860. mode: number;
  35861. /**
  35862. * Sets the scale applied to the radius (1 by default)
  35863. */
  35864. /**
  35865. * Gets the scale applied to the radius
  35866. */
  35867. radiusScale: number;
  35868. /**
  35869. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35870. */
  35871. /**
  35872. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35873. */
  35874. positionScale: number;
  35875. /**
  35876. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35877. * behaviour is triggered, in radians.
  35878. */
  35879. /**
  35880. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35881. * behaviour is triggered, in radians.
  35882. */
  35883. defaultElevation: number;
  35884. /**
  35885. * Sets the time (in milliseconds) taken to return to the default beta position.
  35886. * Negative value indicates camera should not return to default.
  35887. */
  35888. /**
  35889. * Gets the time (in milliseconds) taken to return to the default beta position.
  35890. * Negative value indicates camera should not return to default.
  35891. */
  35892. elevationReturnTime: number;
  35893. /**
  35894. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35895. */
  35896. /**
  35897. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35898. */
  35899. elevationReturnWaitTime: number;
  35900. /**
  35901. * Sets the flag that indicates if user zooming should stop animation.
  35902. */
  35903. /**
  35904. * Gets the flag that indicates if user zooming should stop animation.
  35905. */
  35906. zoomStopsAnimation: boolean;
  35907. /**
  35908. * Sets the transition time when framing the mesh, in milliseconds
  35909. */
  35910. /**
  35911. * Gets the transition time when framing the mesh, in milliseconds
  35912. */
  35913. framingTime: number;
  35914. /**
  35915. * Define if the behavior should automatically change the configured
  35916. * camera limits and sensibilities.
  35917. */
  35918. autoCorrectCameraLimitsAndSensibility: boolean;
  35919. private _onPrePointerObservableObserver;
  35920. private _onAfterCheckInputsObserver;
  35921. private _onMeshTargetChangedObserver;
  35922. private _attachedCamera;
  35923. private _isPointerDown;
  35924. private _lastInteractionTime;
  35925. /**
  35926. * Initializes the behavior.
  35927. */
  35928. init(): void;
  35929. /**
  35930. * Attaches the behavior to its arc rotate camera.
  35931. * @param camera Defines the camera to attach the behavior to
  35932. */
  35933. attach(camera: ArcRotateCamera): void;
  35934. /**
  35935. * Detaches the behavior from its current arc rotate camera.
  35936. */
  35937. detach(): void;
  35938. private _animatables;
  35939. private _betaIsAnimating;
  35940. private _betaTransition;
  35941. private _radiusTransition;
  35942. private _vectorTransition;
  35943. /**
  35944. * Targets the given mesh and updates zoom level accordingly.
  35945. * @param mesh The mesh to target.
  35946. * @param radius Optional. If a cached radius position already exists, overrides default.
  35947. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35948. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35949. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35950. */
  35951. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35952. /**
  35953. * Targets the given mesh with its children and updates zoom level accordingly.
  35954. * @param mesh The mesh to target.
  35955. * @param radius Optional. If a cached radius position already exists, overrides default.
  35956. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35957. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35958. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35959. */
  35960. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35961. /**
  35962. * Targets the given meshes with their children and updates zoom level accordingly.
  35963. * @param meshes The mesh to target.
  35964. * @param radius Optional. If a cached radius position already exists, overrides default.
  35965. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35968. */
  35969. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35970. /**
  35971. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35972. * @param minimumWorld Determines the smaller position of the bounding box extend
  35973. * @param maximumWorld Determines the bigger position of the bounding box extend
  35974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35976. */
  35977. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35978. /**
  35979. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35980. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35981. * frustum width.
  35982. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35983. * to fully enclose the mesh in the viewing frustum.
  35984. */
  35985. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35986. /**
  35987. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35988. * is automatically returned to its default position (expected to be above ground plane).
  35989. */
  35990. private _maintainCameraAboveGround;
  35991. /**
  35992. * Returns the frustum slope based on the canvas ratio and camera FOV
  35993. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35994. */
  35995. private _getFrustumSlope;
  35996. /**
  35997. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35998. */
  35999. private _clearAnimationLocks;
  36000. /**
  36001. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36002. */
  36003. private _applyUserInteraction;
  36004. /**
  36005. * Stops and removes all animations that have been applied to the camera
  36006. */
  36007. stopAllAnimations(): void;
  36008. /**
  36009. * Gets a value indicating if the user is moving the camera
  36010. */
  36011. readonly isUserIsMoving: boolean;
  36012. /**
  36013. * The camera can move all the way towards the mesh.
  36014. */
  36015. static IgnoreBoundsSizeMode: number;
  36016. /**
  36017. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36018. */
  36019. static FitFrustumSidesMode: number;
  36020. }
  36021. }
  36022. declare module BABYLON {
  36023. /**
  36024. * Base class for Camera Pointer Inputs.
  36025. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36026. * for example usage.
  36027. */
  36028. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36029. /**
  36030. * Defines the camera the input is attached to.
  36031. */
  36032. abstract camera: Camera;
  36033. /**
  36034. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36035. */
  36036. protected _altKey: boolean;
  36037. protected _ctrlKey: boolean;
  36038. protected _metaKey: boolean;
  36039. protected _shiftKey: boolean;
  36040. /**
  36041. * Which mouse buttons were pressed at time of last mouse event.
  36042. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36043. */
  36044. protected _buttonsPressed: number;
  36045. /**
  36046. * Defines the buttons associated with the input to handle camera move.
  36047. */
  36048. buttons: number[];
  36049. /**
  36050. * Attach the input controls to a specific dom element to get the input from.
  36051. * @param element Defines the element the controls should be listened from
  36052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36053. */
  36054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36055. /**
  36056. * Detach the current controls from the specified dom element.
  36057. * @param element Defines the element to stop listening the inputs from
  36058. */
  36059. detachControl(element: Nullable<HTMLElement>): void;
  36060. /**
  36061. * Gets the class name of the current input.
  36062. * @returns the class name
  36063. */
  36064. getClassName(): string;
  36065. /**
  36066. * Get the friendly name associated with the input class.
  36067. * @returns the input friendly name
  36068. */
  36069. getSimpleName(): string;
  36070. /**
  36071. * Called on pointer POINTERDOUBLETAP event.
  36072. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36073. */
  36074. protected onDoubleTap(type: string): void;
  36075. /**
  36076. * Called on pointer POINTERMOVE event if only a single touch is active.
  36077. * Override this method to provide functionality.
  36078. */
  36079. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36080. /**
  36081. * Called on pointer POINTERMOVE event if multiple touches are active.
  36082. * Override this method to provide functionality.
  36083. */
  36084. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36085. /**
  36086. * Called on JS contextmenu event.
  36087. * Override this method to provide functionality.
  36088. */
  36089. protected onContextMenu(evt: PointerEvent): void;
  36090. /**
  36091. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36092. * press.
  36093. * Override this method to provide functionality.
  36094. */
  36095. protected onButtonDown(evt: PointerEvent): void;
  36096. /**
  36097. * Called each time a new POINTERUP event occurs. Ie, for each button
  36098. * release.
  36099. * Override this method to provide functionality.
  36100. */
  36101. protected onButtonUp(evt: PointerEvent): void;
  36102. /**
  36103. * Called when window becomes inactive.
  36104. * Override this method to provide functionality.
  36105. */
  36106. protected onLostFocus(): void;
  36107. private _pointerInput;
  36108. private _observer;
  36109. private _onLostFocus;
  36110. private pointA;
  36111. private pointB;
  36112. }
  36113. }
  36114. declare module BABYLON {
  36115. /**
  36116. * Manage the pointers inputs to control an arc rotate camera.
  36117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36118. */
  36119. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36120. /**
  36121. * Defines the camera the input is attached to.
  36122. */
  36123. camera: ArcRotateCamera;
  36124. /**
  36125. * Gets the class name of the current input.
  36126. * @returns the class name
  36127. */
  36128. getClassName(): string;
  36129. /**
  36130. * Defines the buttons associated with the input to handle camera move.
  36131. */
  36132. buttons: number[];
  36133. /**
  36134. * Defines the pointer angular sensibility along the X axis or how fast is
  36135. * the camera rotating.
  36136. */
  36137. angularSensibilityX: number;
  36138. /**
  36139. * Defines the pointer angular sensibility along the Y axis or how fast is
  36140. * the camera rotating.
  36141. */
  36142. angularSensibilityY: number;
  36143. /**
  36144. * Defines the pointer pinch precision or how fast is the camera zooming.
  36145. */
  36146. pinchPrecision: number;
  36147. /**
  36148. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36149. * from 0.
  36150. * It defines the percentage of current camera.radius to use as delta when
  36151. * pinch zoom is used.
  36152. */
  36153. pinchDeltaPercentage: number;
  36154. /**
  36155. * Defines the pointer panning sensibility or how fast is the camera moving.
  36156. */
  36157. panningSensibility: number;
  36158. /**
  36159. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36160. */
  36161. multiTouchPanning: boolean;
  36162. /**
  36163. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36164. * zoom (pinch) through multitouch.
  36165. */
  36166. multiTouchPanAndZoom: boolean;
  36167. /**
  36168. * Revers pinch action direction.
  36169. */
  36170. pinchInwards: boolean;
  36171. private _isPanClick;
  36172. private _twoFingerActivityCount;
  36173. private _isPinching;
  36174. /**
  36175. * Called on pointer POINTERMOVE event if only a single touch is active.
  36176. */
  36177. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36178. /**
  36179. * Called on pointer POINTERDOUBLETAP event.
  36180. */
  36181. protected onDoubleTap(type: string): void;
  36182. /**
  36183. * Called on pointer POINTERMOVE event if multiple touches are active.
  36184. */
  36185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36186. /**
  36187. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36188. * press.
  36189. */
  36190. protected onButtonDown(evt: PointerEvent): void;
  36191. /**
  36192. * Called each time a new POINTERUP event occurs. Ie, for each button
  36193. * release.
  36194. */
  36195. protected onButtonUp(evt: PointerEvent): void;
  36196. /**
  36197. * Called when window becomes inactive.
  36198. */
  36199. protected onLostFocus(): void;
  36200. }
  36201. }
  36202. declare module BABYLON {
  36203. /**
  36204. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36206. */
  36207. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36208. /**
  36209. * Defines the camera the input is attached to.
  36210. */
  36211. camera: ArcRotateCamera;
  36212. /**
  36213. * Defines the list of key codes associated with the up action (increase alpha)
  36214. */
  36215. keysUp: number[];
  36216. /**
  36217. * Defines the list of key codes associated with the down action (decrease alpha)
  36218. */
  36219. keysDown: number[];
  36220. /**
  36221. * Defines the list of key codes associated with the left action (increase beta)
  36222. */
  36223. keysLeft: number[];
  36224. /**
  36225. * Defines the list of key codes associated with the right action (decrease beta)
  36226. */
  36227. keysRight: number[];
  36228. /**
  36229. * Defines the list of key codes associated with the reset action.
  36230. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36231. */
  36232. keysReset: number[];
  36233. /**
  36234. * Defines the panning sensibility of the inputs.
  36235. * (How fast is the camera paning)
  36236. */
  36237. panningSensibility: number;
  36238. /**
  36239. * Defines the zooming sensibility of the inputs.
  36240. * (How fast is the camera zooming)
  36241. */
  36242. zoomingSensibility: number;
  36243. /**
  36244. * Defines wether maintaining the alt key down switch the movement mode from
  36245. * orientation to zoom.
  36246. */
  36247. useAltToZoom: boolean;
  36248. /**
  36249. * Rotation speed of the camera
  36250. */
  36251. angularSpeed: number;
  36252. private _keys;
  36253. private _ctrlPressed;
  36254. private _altPressed;
  36255. private _onCanvasBlurObserver;
  36256. private _onKeyboardObserver;
  36257. private _engine;
  36258. private _scene;
  36259. /**
  36260. * Attach the input controls to a specific dom element to get the input from.
  36261. * @param element Defines the element the controls should be listened from
  36262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36263. */
  36264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36265. /**
  36266. * Detach the current controls from the specified dom element.
  36267. * @param element Defines the element to stop listening the inputs from
  36268. */
  36269. detachControl(element: Nullable<HTMLElement>): void;
  36270. /**
  36271. * Update the current camera state depending on the inputs that have been used this frame.
  36272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36273. */
  36274. checkInputs(): void;
  36275. /**
  36276. * Gets the class name of the current intput.
  36277. * @returns the class name
  36278. */
  36279. getClassName(): string;
  36280. /**
  36281. * Get the friendly name associated with the input class.
  36282. * @returns the input friendly name
  36283. */
  36284. getSimpleName(): string;
  36285. }
  36286. }
  36287. declare module BABYLON {
  36288. /**
  36289. * Manage the mouse wheel inputs to control an arc rotate camera.
  36290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36291. */
  36292. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36293. /**
  36294. * Defines the camera the input is attached to.
  36295. */
  36296. camera: ArcRotateCamera;
  36297. /**
  36298. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36299. */
  36300. wheelPrecision: number;
  36301. /**
  36302. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36303. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36304. */
  36305. wheelDeltaPercentage: number;
  36306. private _wheel;
  36307. private _observer;
  36308. private computeDeltaFromMouseWheelLegacyEvent;
  36309. /**
  36310. * Attach the input controls to a specific dom element to get the input from.
  36311. * @param element Defines the element the controls should be listened from
  36312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36313. */
  36314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36315. /**
  36316. * Detach the current controls from the specified dom element.
  36317. * @param element Defines the element to stop listening the inputs from
  36318. */
  36319. detachControl(element: Nullable<HTMLElement>): void;
  36320. /**
  36321. * Gets the class name of the current intput.
  36322. * @returns the class name
  36323. */
  36324. getClassName(): string;
  36325. /**
  36326. * Get the friendly name associated with the input class.
  36327. * @returns the input friendly name
  36328. */
  36329. getSimpleName(): string;
  36330. }
  36331. }
  36332. declare module BABYLON {
  36333. /**
  36334. * Default Inputs manager for the ArcRotateCamera.
  36335. * It groups all the default supported inputs for ease of use.
  36336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36337. */
  36338. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36339. /**
  36340. * Instantiates a new ArcRotateCameraInputsManager.
  36341. * @param camera Defines the camera the inputs belong to
  36342. */
  36343. constructor(camera: ArcRotateCamera);
  36344. /**
  36345. * Add mouse wheel input support to the input manager.
  36346. * @returns the current input manager
  36347. */
  36348. addMouseWheel(): ArcRotateCameraInputsManager;
  36349. /**
  36350. * Add pointers input support to the input manager.
  36351. * @returns the current input manager
  36352. */
  36353. addPointers(): ArcRotateCameraInputsManager;
  36354. /**
  36355. * Add keyboard input support to the input manager.
  36356. * @returns the current input manager
  36357. */
  36358. addKeyboard(): ArcRotateCameraInputsManager;
  36359. }
  36360. }
  36361. declare module BABYLON {
  36362. /**
  36363. * This represents an orbital type of camera.
  36364. *
  36365. * 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.
  36366. * 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.
  36367. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36368. */
  36369. export class ArcRotateCamera extends TargetCamera {
  36370. /**
  36371. * Defines the rotation angle of the camera along the longitudinal axis.
  36372. */
  36373. alpha: number;
  36374. /**
  36375. * Defines the rotation angle of the camera along the latitudinal axis.
  36376. */
  36377. beta: number;
  36378. /**
  36379. * Defines the radius of the camera from it s target point.
  36380. */
  36381. radius: number;
  36382. protected _target: Vector3;
  36383. protected _targetHost: Nullable<AbstractMesh>;
  36384. /**
  36385. * Defines the target point of the camera.
  36386. * The camera looks towards it form the radius distance.
  36387. */
  36388. target: Vector3;
  36389. /**
  36390. * Define the current local position of the camera in the scene
  36391. */
  36392. position: Vector3;
  36393. protected _upVector: Vector3;
  36394. protected _upToYMatrix: Matrix;
  36395. protected _YToUpMatrix: Matrix;
  36396. /**
  36397. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36398. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36399. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36400. */
  36401. upVector: Vector3;
  36402. /**
  36403. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36404. */
  36405. setMatUp(): void;
  36406. /**
  36407. * Current inertia value on the longitudinal axis.
  36408. * The bigger this number the longer it will take for the camera to stop.
  36409. */
  36410. inertialAlphaOffset: number;
  36411. /**
  36412. * Current inertia value on the latitudinal axis.
  36413. * The bigger this number the longer it will take for the camera to stop.
  36414. */
  36415. inertialBetaOffset: number;
  36416. /**
  36417. * Current inertia value on the radius axis.
  36418. * The bigger this number the longer it will take for the camera to stop.
  36419. */
  36420. inertialRadiusOffset: number;
  36421. /**
  36422. * Minimum allowed angle on the longitudinal axis.
  36423. * This can help limiting how the Camera is able to move in the scene.
  36424. */
  36425. lowerAlphaLimit: Nullable<number>;
  36426. /**
  36427. * Maximum allowed angle on the longitudinal axis.
  36428. * This can help limiting how the Camera is able to move in the scene.
  36429. */
  36430. upperAlphaLimit: Nullable<number>;
  36431. /**
  36432. * Minimum allowed angle on the latitudinal axis.
  36433. * This can help limiting how the Camera is able to move in the scene.
  36434. */
  36435. lowerBetaLimit: number;
  36436. /**
  36437. * Maximum allowed angle on the latitudinal axis.
  36438. * This can help limiting how the Camera is able to move in the scene.
  36439. */
  36440. upperBetaLimit: number;
  36441. /**
  36442. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36443. * This can help limiting how the Camera is able to move in the scene.
  36444. */
  36445. lowerRadiusLimit: Nullable<number>;
  36446. /**
  36447. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36448. * This can help limiting how the Camera is able to move in the scene.
  36449. */
  36450. upperRadiusLimit: Nullable<number>;
  36451. /**
  36452. * Defines the current inertia value used during panning of the camera along the X axis.
  36453. */
  36454. inertialPanningX: number;
  36455. /**
  36456. * Defines the current inertia value used during panning of the camera along the Y axis.
  36457. */
  36458. inertialPanningY: number;
  36459. /**
  36460. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36461. * Basically if your fingers moves away from more than this distance you will be considered
  36462. * in pinch mode.
  36463. */
  36464. pinchToPanMaxDistance: number;
  36465. /**
  36466. * Defines the maximum distance the camera can pan.
  36467. * This could help keeping the cammera always in your scene.
  36468. */
  36469. panningDistanceLimit: Nullable<number>;
  36470. /**
  36471. * Defines the target of the camera before paning.
  36472. */
  36473. panningOriginTarget: Vector3;
  36474. /**
  36475. * Defines the value of the inertia used during panning.
  36476. * 0 would mean stop inertia and one would mean no decelleration at all.
  36477. */
  36478. panningInertia: number;
  36479. /**
  36480. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36481. */
  36482. angularSensibilityX: number;
  36483. /**
  36484. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36485. */
  36486. angularSensibilityY: number;
  36487. /**
  36488. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36489. */
  36490. pinchPrecision: number;
  36491. /**
  36492. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36493. * It will be used instead of pinchDeltaPrecision if different from 0.
  36494. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36495. */
  36496. pinchDeltaPercentage: number;
  36497. /**
  36498. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36499. */
  36500. panningSensibility: number;
  36501. /**
  36502. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36503. */
  36504. keysUp: number[];
  36505. /**
  36506. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36507. */
  36508. keysDown: number[];
  36509. /**
  36510. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36511. */
  36512. keysLeft: number[];
  36513. /**
  36514. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36515. */
  36516. keysRight: number[];
  36517. /**
  36518. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36519. */
  36520. wheelPrecision: number;
  36521. /**
  36522. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36523. * It will be used instead of pinchDeltaPrecision if different from 0.
  36524. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36525. */
  36526. wheelDeltaPercentage: number;
  36527. /**
  36528. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36529. */
  36530. zoomOnFactor: number;
  36531. /**
  36532. * Defines a screen offset for the camera position.
  36533. */
  36534. targetScreenOffset: Vector2;
  36535. /**
  36536. * Allows the camera to be completely reversed.
  36537. * If false the camera can not arrive upside down.
  36538. */
  36539. allowUpsideDown: boolean;
  36540. /**
  36541. * Define if double tap/click is used to restore the previously saved state of the camera.
  36542. */
  36543. useInputToRestoreState: boolean;
  36544. /** @hidden */
  36545. _viewMatrix: Matrix;
  36546. /** @hidden */
  36547. _useCtrlForPanning: boolean;
  36548. /** @hidden */
  36549. _panningMouseButton: number;
  36550. /**
  36551. * Defines the input associated to the camera.
  36552. */
  36553. inputs: ArcRotateCameraInputsManager;
  36554. /** @hidden */
  36555. _reset: () => void;
  36556. /**
  36557. * Defines the allowed panning axis.
  36558. */
  36559. panningAxis: Vector3;
  36560. protected _localDirection: Vector3;
  36561. protected _transformedDirection: Vector3;
  36562. private _bouncingBehavior;
  36563. /**
  36564. * Gets the bouncing behavior of the camera if it has been enabled.
  36565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36566. */
  36567. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36568. /**
  36569. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36571. */
  36572. useBouncingBehavior: boolean;
  36573. private _framingBehavior;
  36574. /**
  36575. * Gets the framing behavior of the camera if it has been enabled.
  36576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36577. */
  36578. readonly framingBehavior: Nullable<FramingBehavior>;
  36579. /**
  36580. * Defines if the framing behavior of the camera is enabled on the camera.
  36581. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36582. */
  36583. useFramingBehavior: boolean;
  36584. private _autoRotationBehavior;
  36585. /**
  36586. * Gets the auto rotation behavior of the camera if it has been enabled.
  36587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36588. */
  36589. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36590. /**
  36591. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36592. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36593. */
  36594. useAutoRotationBehavior: boolean;
  36595. /**
  36596. * Observable triggered when the mesh target has been changed on the camera.
  36597. */
  36598. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36599. /**
  36600. * Event raised when the camera is colliding with a mesh.
  36601. */
  36602. onCollide: (collidedMesh: AbstractMesh) => void;
  36603. /**
  36604. * Defines whether the camera should check collision with the objects oh the scene.
  36605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36606. */
  36607. checkCollisions: boolean;
  36608. /**
  36609. * Defines the collision radius of the camera.
  36610. * This simulates a sphere around the camera.
  36611. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36612. */
  36613. collisionRadius: Vector3;
  36614. protected _collider: Collider;
  36615. protected _previousPosition: Vector3;
  36616. protected _collisionVelocity: Vector3;
  36617. protected _newPosition: Vector3;
  36618. protected _previousAlpha: number;
  36619. protected _previousBeta: number;
  36620. protected _previousRadius: number;
  36621. protected _collisionTriggered: boolean;
  36622. protected _targetBoundingCenter: Nullable<Vector3>;
  36623. private _computationVector;
  36624. /**
  36625. * Instantiates a new ArcRotateCamera in a given scene
  36626. * @param name Defines the name of the camera
  36627. * @param alpha Defines the camera rotation along the logitudinal axis
  36628. * @param beta Defines the camera rotation along the latitudinal axis
  36629. * @param radius Defines the camera distance from its target
  36630. * @param target Defines the camera target
  36631. * @param scene Defines the scene the camera belongs to
  36632. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36633. */
  36634. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36635. /** @hidden */
  36636. _initCache(): void;
  36637. /** @hidden */
  36638. _updateCache(ignoreParentClass?: boolean): void;
  36639. protected _getTargetPosition(): Vector3;
  36640. private _storedAlpha;
  36641. private _storedBeta;
  36642. private _storedRadius;
  36643. private _storedTarget;
  36644. private _storedTargetScreenOffset;
  36645. /**
  36646. * Stores the current state of the camera (alpha, beta, radius and target)
  36647. * @returns the camera itself
  36648. */
  36649. storeState(): Camera;
  36650. /**
  36651. * @hidden
  36652. * Restored camera state. You must call storeState() first
  36653. */
  36654. _restoreStateValues(): boolean;
  36655. /** @hidden */
  36656. _isSynchronizedViewMatrix(): boolean;
  36657. /**
  36658. * Attached controls to the current camera.
  36659. * @param element Defines the element the controls should be listened from
  36660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36661. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36662. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36663. */
  36664. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36665. /**
  36666. * Detach the current controls from the camera.
  36667. * The camera will stop reacting to inputs.
  36668. * @param element Defines the element to stop listening the inputs from
  36669. */
  36670. detachControl(element: HTMLElement): void;
  36671. /** @hidden */
  36672. _checkInputs(): void;
  36673. protected _checkLimits(): void;
  36674. /**
  36675. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36676. */
  36677. rebuildAnglesAndRadius(): void;
  36678. /**
  36679. * Use a position to define the current camera related information like alpha, beta and radius
  36680. * @param position Defines the position to set the camera at
  36681. */
  36682. setPosition(position: Vector3): void;
  36683. /**
  36684. * Defines the target the camera should look at.
  36685. * This will automatically adapt alpha beta and radius to fit within the new target.
  36686. * @param target Defines the new target as a Vector or a mesh
  36687. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36688. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36689. */
  36690. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36691. /** @hidden */
  36692. _getViewMatrix(): Matrix;
  36693. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36694. /**
  36695. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36696. * @param meshes Defines the mesh to zoom on
  36697. * @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)
  36698. */
  36699. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36700. /**
  36701. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36702. * The target will be changed but the radius
  36703. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36704. * @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)
  36705. */
  36706. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36707. min: Vector3;
  36708. max: Vector3;
  36709. distance: number;
  36710. }, doNotUpdateMaxZ?: boolean): void;
  36711. /**
  36712. * @override
  36713. * Override Camera.createRigCamera
  36714. */
  36715. createRigCamera(name: string, cameraIndex: number): Camera;
  36716. /**
  36717. * @hidden
  36718. * @override
  36719. * Override Camera._updateRigCameras
  36720. */
  36721. _updateRigCameras(): void;
  36722. /**
  36723. * Destroy the camera and release the current resources hold by it.
  36724. */
  36725. dispose(): void;
  36726. /**
  36727. * Gets the current object class name.
  36728. * @return the class name
  36729. */
  36730. getClassName(): string;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36737. */
  36738. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36739. /**
  36740. * Gets the name of the behavior.
  36741. */
  36742. readonly name: string;
  36743. private _zoomStopsAnimation;
  36744. private _idleRotationSpeed;
  36745. private _idleRotationWaitTime;
  36746. private _idleRotationSpinupTime;
  36747. /**
  36748. * Sets the flag that indicates if user zooming should stop animation.
  36749. */
  36750. /**
  36751. * Gets the flag that indicates if user zooming should stop animation.
  36752. */
  36753. zoomStopsAnimation: boolean;
  36754. /**
  36755. * Sets the default speed at which the camera rotates around the model.
  36756. */
  36757. /**
  36758. * Gets the default speed at which the camera rotates around the model.
  36759. */
  36760. idleRotationSpeed: number;
  36761. /**
  36762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36763. */
  36764. /**
  36765. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36766. */
  36767. idleRotationWaitTime: number;
  36768. /**
  36769. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36770. */
  36771. /**
  36772. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36773. */
  36774. idleRotationSpinupTime: number;
  36775. /**
  36776. * Gets a value indicating if the camera is currently rotating because of this behavior
  36777. */
  36778. readonly rotationInProgress: boolean;
  36779. private _onPrePointerObservableObserver;
  36780. private _onAfterCheckInputsObserver;
  36781. private _attachedCamera;
  36782. private _isPointerDown;
  36783. private _lastFrameTime;
  36784. private _lastInteractionTime;
  36785. private _cameraRotationSpeed;
  36786. /**
  36787. * Initializes the behavior.
  36788. */
  36789. init(): void;
  36790. /**
  36791. * Attaches the behavior to its arc rotate camera.
  36792. * @param camera Defines the camera to attach the behavior to
  36793. */
  36794. attach(camera: ArcRotateCamera): void;
  36795. /**
  36796. * Detaches the behavior from its current arc rotate camera.
  36797. */
  36798. detach(): void;
  36799. /**
  36800. * Returns true if user is scrolling.
  36801. * @return true if user is scrolling.
  36802. */
  36803. private _userIsZooming;
  36804. private _lastFrameRadius;
  36805. private _shouldAnimationStopForInteraction;
  36806. /**
  36807. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36808. */
  36809. private _applyUserInteraction;
  36810. private _userIsMoving;
  36811. }
  36812. }
  36813. declare module BABYLON {
  36814. /**
  36815. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36816. */
  36817. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36818. private ui;
  36819. /**
  36820. * The name of the behavior
  36821. */
  36822. name: string;
  36823. /**
  36824. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36825. */
  36826. distanceAwayFromFace: number;
  36827. /**
  36828. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36829. */
  36830. distanceAwayFromBottomOfFace: number;
  36831. private _faceVectors;
  36832. private _target;
  36833. private _scene;
  36834. private _onRenderObserver;
  36835. private _tmpMatrix;
  36836. private _tmpVector;
  36837. /**
  36838. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36839. * @param ui The transform node that should be attched to the mesh
  36840. */
  36841. constructor(ui: TransformNode);
  36842. /**
  36843. * Initializes the behavior
  36844. */
  36845. init(): void;
  36846. private _closestFace;
  36847. private _zeroVector;
  36848. private _lookAtTmpMatrix;
  36849. private _lookAtToRef;
  36850. /**
  36851. * Attaches the AttachToBoxBehavior to the passed in mesh
  36852. * @param target The mesh that the specified node will be attached to
  36853. */
  36854. attach(target: Mesh): void;
  36855. /**
  36856. * Detaches the behavior from the mesh
  36857. */
  36858. detach(): void;
  36859. }
  36860. }
  36861. declare module BABYLON {
  36862. /**
  36863. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36864. */
  36865. export class FadeInOutBehavior implements Behavior<Mesh> {
  36866. /**
  36867. * Time in milliseconds to delay before fading in (Default: 0)
  36868. */
  36869. delay: number;
  36870. /**
  36871. * Time in milliseconds for the mesh to fade in (Default: 300)
  36872. */
  36873. fadeInTime: number;
  36874. private _millisecondsPerFrame;
  36875. private _hovered;
  36876. private _hoverValue;
  36877. private _ownerNode;
  36878. /**
  36879. * Instatiates the FadeInOutBehavior
  36880. */
  36881. constructor();
  36882. /**
  36883. * The name of the behavior
  36884. */
  36885. readonly name: string;
  36886. /**
  36887. * Initializes the behavior
  36888. */
  36889. init(): void;
  36890. /**
  36891. * Attaches the fade behavior on the passed in mesh
  36892. * @param ownerNode The mesh that will be faded in/out once attached
  36893. */
  36894. attach(ownerNode: Mesh): void;
  36895. /**
  36896. * Detaches the behavior from the mesh
  36897. */
  36898. detach(): void;
  36899. /**
  36900. * Triggers the mesh to begin fading in or out
  36901. * @param value if the object should fade in or out (true to fade in)
  36902. */
  36903. fadeIn(value: boolean): void;
  36904. private _update;
  36905. private _setAllVisibility;
  36906. }
  36907. }
  36908. declare module BABYLON {
  36909. /**
  36910. * Class containing a set of static utilities functions for managing Pivots
  36911. * @hidden
  36912. */
  36913. export class PivotTools {
  36914. private static _PivotCached;
  36915. private static _OldPivotPoint;
  36916. private static _PivotTranslation;
  36917. private static _PivotTmpVector;
  36918. /** @hidden */
  36919. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36920. /** @hidden */
  36921. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. /**
  36926. * Class containing static functions to help procedurally build meshes
  36927. */
  36928. export class PlaneBuilder {
  36929. /**
  36930. * Creates a plane mesh
  36931. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36932. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36933. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36935. * * 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
  36936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36937. * @param name defines the name of the mesh
  36938. * @param options defines the options used to create the mesh
  36939. * @param scene defines the hosting scene
  36940. * @returns the plane mesh
  36941. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36942. */
  36943. static CreatePlane(name: string, options: {
  36944. size?: number;
  36945. width?: number;
  36946. height?: number;
  36947. sideOrientation?: number;
  36948. frontUVs?: Vector4;
  36949. backUVs?: Vector4;
  36950. updatable?: boolean;
  36951. sourcePlane?: Plane;
  36952. }, scene?: Nullable<Scene>): Mesh;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36958. */
  36959. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36960. private static _AnyMouseID;
  36961. /**
  36962. * Abstract mesh the behavior is set on
  36963. */
  36964. attachedNode: AbstractMesh;
  36965. private _dragPlane;
  36966. private _scene;
  36967. private _pointerObserver;
  36968. private _beforeRenderObserver;
  36969. private static _planeScene;
  36970. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36971. /**
  36972. * 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)
  36973. */
  36974. maxDragAngle: number;
  36975. /**
  36976. * @hidden
  36977. */
  36978. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36979. /**
  36980. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36981. */
  36982. currentDraggingPointerID: number;
  36983. /**
  36984. * The last position where the pointer hit the drag plane in world space
  36985. */
  36986. lastDragPosition: Vector3;
  36987. /**
  36988. * If the behavior is currently in a dragging state
  36989. */
  36990. dragging: boolean;
  36991. /**
  36992. * 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)
  36993. */
  36994. dragDeltaRatio: number;
  36995. /**
  36996. * If the drag plane orientation should be updated during the dragging (Default: true)
  36997. */
  36998. updateDragPlane: boolean;
  36999. private _debugMode;
  37000. private _moving;
  37001. /**
  37002. * Fires each time the attached mesh is dragged with the pointer
  37003. * * delta between last drag position and current drag position in world space
  37004. * * dragDistance along the drag axis
  37005. * * dragPlaneNormal normal of the current drag plane used during the drag
  37006. * * dragPlanePoint in world space where the drag intersects the drag plane
  37007. */
  37008. onDragObservable: Observable<{
  37009. delta: Vector3;
  37010. dragPlanePoint: Vector3;
  37011. dragPlaneNormal: Vector3;
  37012. dragDistance: number;
  37013. pointerId: number;
  37014. }>;
  37015. /**
  37016. * Fires each time a drag begins (eg. mouse down on mesh)
  37017. */
  37018. onDragStartObservable: Observable<{
  37019. dragPlanePoint: Vector3;
  37020. pointerId: number;
  37021. }>;
  37022. /**
  37023. * Fires each time a drag ends (eg. mouse release after drag)
  37024. */
  37025. onDragEndObservable: Observable<{
  37026. dragPlanePoint: Vector3;
  37027. pointerId: number;
  37028. }>;
  37029. /**
  37030. * If the attached mesh should be moved when dragged
  37031. */
  37032. moveAttached: boolean;
  37033. /**
  37034. * If the drag behavior will react to drag events (Default: true)
  37035. */
  37036. enabled: boolean;
  37037. /**
  37038. * If pointer events should start and release the drag (Default: true)
  37039. */
  37040. startAndReleaseDragOnPointerEvents: boolean;
  37041. /**
  37042. * If camera controls should be detached during the drag
  37043. */
  37044. detachCameraControls: boolean;
  37045. /**
  37046. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37047. */
  37048. useObjectOrienationForDragging: boolean;
  37049. private _options;
  37050. /**
  37051. * Creates a pointer drag behavior that can be attached to a mesh
  37052. * @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)
  37053. */
  37054. constructor(options?: {
  37055. dragAxis?: Vector3;
  37056. dragPlaneNormal?: Vector3;
  37057. });
  37058. /**
  37059. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37060. */
  37061. validateDrag: (targetPosition: Vector3) => boolean;
  37062. /**
  37063. * The name of the behavior
  37064. */
  37065. readonly name: string;
  37066. /**
  37067. * Initializes the behavior
  37068. */
  37069. init(): void;
  37070. private _tmpVector;
  37071. private _alternatePickedPoint;
  37072. private _worldDragAxis;
  37073. private _targetPosition;
  37074. private _attachedElement;
  37075. /**
  37076. * Attaches the drag behavior the passed in mesh
  37077. * @param ownerNode The mesh that will be dragged around once attached
  37078. * @param predicate Predicate to use for pick filtering
  37079. */
  37080. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37081. /**
  37082. * Force relase the drag action by code.
  37083. */
  37084. releaseDrag(): void;
  37085. private _startDragRay;
  37086. private _lastPointerRay;
  37087. /**
  37088. * Simulates the start of a pointer drag event on the behavior
  37089. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37090. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37091. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37092. */
  37093. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37094. private _startDrag;
  37095. private _dragDelta;
  37096. private _moveDrag;
  37097. private _pickWithRayOnDragPlane;
  37098. private _pointA;
  37099. private _pointB;
  37100. private _pointC;
  37101. private _lineA;
  37102. private _lineB;
  37103. private _localAxis;
  37104. private _lookAt;
  37105. private _updateDragPlanePosition;
  37106. /**
  37107. * Detaches the behavior from the mesh
  37108. */
  37109. detach(): void;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. /**
  37114. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37115. */
  37116. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37117. private _dragBehaviorA;
  37118. private _dragBehaviorB;
  37119. private _startDistance;
  37120. private _initialScale;
  37121. private _targetScale;
  37122. private _ownerNode;
  37123. private _sceneRenderObserver;
  37124. /**
  37125. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37126. */
  37127. constructor();
  37128. /**
  37129. * The name of the behavior
  37130. */
  37131. readonly name: string;
  37132. /**
  37133. * Initializes the behavior
  37134. */
  37135. init(): void;
  37136. private _getCurrentDistance;
  37137. /**
  37138. * Attaches the scale behavior the passed in mesh
  37139. * @param ownerNode The mesh that will be scaled around once attached
  37140. */
  37141. attach(ownerNode: Mesh): void;
  37142. /**
  37143. * Detaches the behavior from the mesh
  37144. */
  37145. detach(): void;
  37146. }
  37147. }
  37148. declare module BABYLON {
  37149. /**
  37150. * 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
  37151. */
  37152. export class SixDofDragBehavior implements Behavior<Mesh> {
  37153. private static _virtualScene;
  37154. private _ownerNode;
  37155. private _sceneRenderObserver;
  37156. private _scene;
  37157. private _targetPosition;
  37158. private _virtualOriginMesh;
  37159. private _virtualDragMesh;
  37160. private _pointerObserver;
  37161. private _moving;
  37162. private _startingOrientation;
  37163. /**
  37164. * 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)
  37165. */
  37166. private zDragFactor;
  37167. /**
  37168. * If the object should rotate to face the drag origin
  37169. */
  37170. rotateDraggedObject: boolean;
  37171. /**
  37172. * If the behavior is currently in a dragging state
  37173. */
  37174. dragging: boolean;
  37175. /**
  37176. * 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)
  37177. */
  37178. dragDeltaRatio: number;
  37179. /**
  37180. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37181. */
  37182. currentDraggingPointerID: number;
  37183. /**
  37184. * If camera controls should be detached during the drag
  37185. */
  37186. detachCameraControls: boolean;
  37187. /**
  37188. * Fires each time a drag starts
  37189. */
  37190. onDragStartObservable: Observable<{}>;
  37191. /**
  37192. * Fires each time a drag ends (eg. mouse release after drag)
  37193. */
  37194. onDragEndObservable: Observable<{}>;
  37195. /**
  37196. * 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
  37197. */
  37198. constructor();
  37199. /**
  37200. * The name of the behavior
  37201. */
  37202. readonly name: string;
  37203. /**
  37204. * Initializes the behavior
  37205. */
  37206. init(): void;
  37207. /**
  37208. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37209. */
  37210. private readonly _pointerCamera;
  37211. /**
  37212. * Attaches the scale behavior the passed in mesh
  37213. * @param ownerNode The mesh that will be scaled around once attached
  37214. */
  37215. attach(ownerNode: Mesh): void;
  37216. /**
  37217. * Detaches the behavior from the mesh
  37218. */
  37219. detach(): void;
  37220. }
  37221. }
  37222. declare module BABYLON {
  37223. /**
  37224. * Class used to apply inverse kinematics to bones
  37225. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37226. */
  37227. export class BoneIKController {
  37228. private static _tmpVecs;
  37229. private static _tmpQuat;
  37230. private static _tmpMats;
  37231. /**
  37232. * Gets or sets the target mesh
  37233. */
  37234. targetMesh: AbstractMesh;
  37235. /** Gets or sets the mesh used as pole */
  37236. poleTargetMesh: AbstractMesh;
  37237. /**
  37238. * Gets or sets the bone used as pole
  37239. */
  37240. poleTargetBone: Nullable<Bone>;
  37241. /**
  37242. * Gets or sets the target position
  37243. */
  37244. targetPosition: Vector3;
  37245. /**
  37246. * Gets or sets the pole target position
  37247. */
  37248. poleTargetPosition: Vector3;
  37249. /**
  37250. * Gets or sets the pole target local offset
  37251. */
  37252. poleTargetLocalOffset: Vector3;
  37253. /**
  37254. * Gets or sets the pole angle
  37255. */
  37256. poleAngle: number;
  37257. /**
  37258. * Gets or sets the mesh associated with the controller
  37259. */
  37260. mesh: AbstractMesh;
  37261. /**
  37262. * 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)
  37263. */
  37264. slerpAmount: number;
  37265. private _bone1Quat;
  37266. private _bone1Mat;
  37267. private _bone2Ang;
  37268. private _bone1;
  37269. private _bone2;
  37270. private _bone1Length;
  37271. private _bone2Length;
  37272. private _maxAngle;
  37273. private _maxReach;
  37274. private _rightHandedSystem;
  37275. private _bendAxis;
  37276. private _slerping;
  37277. private _adjustRoll;
  37278. /**
  37279. * Gets or sets maximum allowed angle
  37280. */
  37281. maxAngle: number;
  37282. /**
  37283. * Creates a new BoneIKController
  37284. * @param mesh defines the mesh to control
  37285. * @param bone defines the bone to control
  37286. * @param options defines options to set up the controller
  37287. */
  37288. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37289. targetMesh?: AbstractMesh;
  37290. poleTargetMesh?: AbstractMesh;
  37291. poleTargetBone?: Bone;
  37292. poleTargetLocalOffset?: Vector3;
  37293. poleAngle?: number;
  37294. bendAxis?: Vector3;
  37295. maxAngle?: number;
  37296. slerpAmount?: number;
  37297. });
  37298. private _setMaxAngle;
  37299. /**
  37300. * Force the controller to update the bones
  37301. */
  37302. update(): void;
  37303. }
  37304. }
  37305. declare module BABYLON {
  37306. /**
  37307. * Class used to make a bone look toward a point in space
  37308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37309. */
  37310. export class BoneLookController {
  37311. private static _tmpVecs;
  37312. private static _tmpQuat;
  37313. private static _tmpMats;
  37314. /**
  37315. * The target Vector3 that the bone will look at
  37316. */
  37317. target: Vector3;
  37318. /**
  37319. * The mesh that the bone is attached to
  37320. */
  37321. mesh: AbstractMesh;
  37322. /**
  37323. * The bone that will be looking to the target
  37324. */
  37325. bone: Bone;
  37326. /**
  37327. * The up axis of the coordinate system that is used when the bone is rotated
  37328. */
  37329. upAxis: Vector3;
  37330. /**
  37331. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37332. */
  37333. upAxisSpace: Space;
  37334. /**
  37335. * Used to make an adjustment to the yaw of the bone
  37336. */
  37337. adjustYaw: number;
  37338. /**
  37339. * Used to make an adjustment to the pitch of the bone
  37340. */
  37341. adjustPitch: number;
  37342. /**
  37343. * Used to make an adjustment to the roll of the bone
  37344. */
  37345. adjustRoll: number;
  37346. /**
  37347. * 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)
  37348. */
  37349. slerpAmount: number;
  37350. private _minYaw;
  37351. private _maxYaw;
  37352. private _minPitch;
  37353. private _maxPitch;
  37354. private _minYawSin;
  37355. private _minYawCos;
  37356. private _maxYawSin;
  37357. private _maxYawCos;
  37358. private _midYawConstraint;
  37359. private _minPitchTan;
  37360. private _maxPitchTan;
  37361. private _boneQuat;
  37362. private _slerping;
  37363. private _transformYawPitch;
  37364. private _transformYawPitchInv;
  37365. private _firstFrameSkipped;
  37366. private _yawRange;
  37367. private _fowardAxis;
  37368. /**
  37369. * Gets or sets the minimum yaw angle that the bone can look to
  37370. */
  37371. minYaw: number;
  37372. /**
  37373. * Gets or sets the maximum yaw angle that the bone can look to
  37374. */
  37375. maxYaw: number;
  37376. /**
  37377. * Gets or sets the minimum pitch angle that the bone can look to
  37378. */
  37379. minPitch: number;
  37380. /**
  37381. * Gets or sets the maximum pitch angle that the bone can look to
  37382. */
  37383. maxPitch: number;
  37384. /**
  37385. * Create a BoneLookController
  37386. * @param mesh the mesh that the bone belongs to
  37387. * @param bone the bone that will be looking to the target
  37388. * @param target the target Vector3 to look at
  37389. * @param options optional settings:
  37390. * * maxYaw: the maximum angle the bone will yaw to
  37391. * * minYaw: the minimum angle the bone will yaw to
  37392. * * maxPitch: the maximum angle the bone will pitch to
  37393. * * minPitch: the minimum angle the bone will yaw to
  37394. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37395. * * upAxis: the up axis of the coordinate system
  37396. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37397. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37398. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37399. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37400. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37401. * * adjustRoll: used to make an adjustment to the roll of the bone
  37402. **/
  37403. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37404. maxYaw?: number;
  37405. minYaw?: number;
  37406. maxPitch?: number;
  37407. minPitch?: number;
  37408. slerpAmount?: number;
  37409. upAxis?: Vector3;
  37410. upAxisSpace?: Space;
  37411. yawAxis?: Vector3;
  37412. pitchAxis?: Vector3;
  37413. adjustYaw?: number;
  37414. adjustPitch?: number;
  37415. adjustRoll?: number;
  37416. });
  37417. /**
  37418. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37419. */
  37420. update(): void;
  37421. private _getAngleDiff;
  37422. private _getAngleBetween;
  37423. private _isAngleBetween;
  37424. }
  37425. }
  37426. declare module BABYLON {
  37427. /**
  37428. * Manage the gamepad inputs to control an arc rotate camera.
  37429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37430. */
  37431. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37432. /**
  37433. * Defines the camera the input is attached to.
  37434. */
  37435. camera: ArcRotateCamera;
  37436. /**
  37437. * Defines the gamepad the input is gathering event from.
  37438. */
  37439. gamepad: Nullable<Gamepad>;
  37440. /**
  37441. * Defines the gamepad rotation sensiblity.
  37442. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37443. */
  37444. gamepadRotationSensibility: number;
  37445. /**
  37446. * Defines the gamepad move sensiblity.
  37447. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37448. */
  37449. gamepadMoveSensibility: number;
  37450. private _yAxisScale;
  37451. /**
  37452. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37453. */
  37454. invertYAxis: boolean;
  37455. private _onGamepadConnectedObserver;
  37456. private _onGamepadDisconnectedObserver;
  37457. /**
  37458. * Attach the input controls to a specific dom element to get the input from.
  37459. * @param element Defines the element the controls should be listened from
  37460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37461. */
  37462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37463. /**
  37464. * Detach the current controls from the specified dom element.
  37465. * @param element Defines the element to stop listening the inputs from
  37466. */
  37467. detachControl(element: Nullable<HTMLElement>): void;
  37468. /**
  37469. * Update the current camera state depending on the inputs that have been used this frame.
  37470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37471. */
  37472. checkInputs(): void;
  37473. /**
  37474. * Gets the class name of the current intput.
  37475. * @returns the class name
  37476. */
  37477. getClassName(): string;
  37478. /**
  37479. * Get the friendly name associated with the input class.
  37480. * @returns the input friendly name
  37481. */
  37482. getSimpleName(): string;
  37483. }
  37484. }
  37485. declare module BABYLON {
  37486. interface ArcRotateCameraInputsManager {
  37487. /**
  37488. * Add orientation input support to the input manager.
  37489. * @returns the current input manager
  37490. */
  37491. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37492. }
  37493. /**
  37494. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37496. */
  37497. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37498. /**
  37499. * Defines the camera the input is attached to.
  37500. */
  37501. camera: ArcRotateCamera;
  37502. /**
  37503. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37504. */
  37505. alphaCorrection: number;
  37506. /**
  37507. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37508. */
  37509. gammaCorrection: number;
  37510. private _alpha;
  37511. private _gamma;
  37512. private _dirty;
  37513. private _deviceOrientationHandler;
  37514. /**
  37515. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37516. */
  37517. constructor();
  37518. /**
  37519. * Attach the input controls to a specific dom element to get the input from.
  37520. * @param element Defines the element the controls should be listened from
  37521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37522. */
  37523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37524. /** @hidden */
  37525. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37526. /**
  37527. * Update the current camera state depending on the inputs that have been used this frame.
  37528. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37529. */
  37530. checkInputs(): void;
  37531. /**
  37532. * Detach the current controls from the specified dom element.
  37533. * @param element Defines the element to stop listening the inputs from
  37534. */
  37535. detachControl(element: Nullable<HTMLElement>): void;
  37536. /**
  37537. * Gets the class name of the current intput.
  37538. * @returns the class name
  37539. */
  37540. getClassName(): string;
  37541. /**
  37542. * Get the friendly name associated with the input class.
  37543. * @returns the input friendly name
  37544. */
  37545. getSimpleName(): string;
  37546. }
  37547. }
  37548. declare module BABYLON {
  37549. /**
  37550. * Listen to mouse events to control the camera.
  37551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37552. */
  37553. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37554. /**
  37555. * Defines the camera the input is attached to.
  37556. */
  37557. camera: FlyCamera;
  37558. /**
  37559. * Defines if touch is enabled. (Default is true.)
  37560. */
  37561. touchEnabled: boolean;
  37562. /**
  37563. * Defines the buttons associated with the input to handle camera rotation.
  37564. */
  37565. buttons: number[];
  37566. /**
  37567. * Assign buttons for Yaw control.
  37568. */
  37569. buttonsYaw: number[];
  37570. /**
  37571. * Assign buttons for Pitch control.
  37572. */
  37573. buttonsPitch: number[];
  37574. /**
  37575. * Assign buttons for Roll control.
  37576. */
  37577. buttonsRoll: number[];
  37578. /**
  37579. * Detect if any button is being pressed while mouse is moved.
  37580. * -1 = Mouse locked.
  37581. * 0 = Left button.
  37582. * 1 = Middle Button.
  37583. * 2 = Right Button.
  37584. */
  37585. activeButton: number;
  37586. /**
  37587. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37588. * Higher values reduce its sensitivity.
  37589. */
  37590. angularSensibility: number;
  37591. private _mousemoveCallback;
  37592. private _observer;
  37593. private _rollObserver;
  37594. private previousPosition;
  37595. private noPreventDefault;
  37596. private element;
  37597. /**
  37598. * Listen to mouse events to control the camera.
  37599. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37601. */
  37602. constructor(touchEnabled?: boolean);
  37603. /**
  37604. * Attach the mouse control to the HTML DOM element.
  37605. * @param element Defines the element that listens to the input events.
  37606. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37607. */
  37608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37609. /**
  37610. * Detach the current controls from the specified dom element.
  37611. * @param element Defines the element to stop listening the inputs from
  37612. */
  37613. detachControl(element: Nullable<HTMLElement>): void;
  37614. /**
  37615. * Gets the class name of the current input.
  37616. * @returns the class name.
  37617. */
  37618. getClassName(): string;
  37619. /**
  37620. * Get the friendly name associated with the input class.
  37621. * @returns the input's friendly name.
  37622. */
  37623. getSimpleName(): string;
  37624. private _pointerInput;
  37625. private _onMouseMove;
  37626. /**
  37627. * Rotate camera by mouse offset.
  37628. */
  37629. private rotateCamera;
  37630. }
  37631. }
  37632. declare module BABYLON {
  37633. /**
  37634. * Default Inputs manager for the FlyCamera.
  37635. * It groups all the default supported inputs for ease of use.
  37636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37637. */
  37638. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37639. /**
  37640. * Instantiates a new FlyCameraInputsManager.
  37641. * @param camera Defines the camera the inputs belong to.
  37642. */
  37643. constructor(camera: FlyCamera);
  37644. /**
  37645. * Add keyboard input support to the input manager.
  37646. * @returns the new FlyCameraKeyboardMoveInput().
  37647. */
  37648. addKeyboard(): FlyCameraInputsManager;
  37649. /**
  37650. * Add mouse input support to the input manager.
  37651. * @param touchEnabled Enable touch screen support.
  37652. * @returns the new FlyCameraMouseInput().
  37653. */
  37654. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37655. }
  37656. }
  37657. declare module BABYLON {
  37658. /**
  37659. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37660. * such as in a 3D Space Shooter or a Flight Simulator.
  37661. */
  37662. export class FlyCamera extends TargetCamera {
  37663. /**
  37664. * Define the collision ellipsoid of the camera.
  37665. * This is helpful for simulating a camera body, like a player's body.
  37666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37667. */
  37668. ellipsoid: Vector3;
  37669. /**
  37670. * Define an offset for the position of the ellipsoid around the camera.
  37671. * This can be helpful if the camera is attached away from the player's body center,
  37672. * such as at its head.
  37673. */
  37674. ellipsoidOffset: Vector3;
  37675. /**
  37676. * Enable or disable collisions of the camera with the rest of the scene objects.
  37677. */
  37678. checkCollisions: boolean;
  37679. /**
  37680. * Enable or disable gravity on the camera.
  37681. */
  37682. applyGravity: boolean;
  37683. /**
  37684. * Define the current direction the camera is moving to.
  37685. */
  37686. cameraDirection: Vector3;
  37687. /**
  37688. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37689. * This overrides and empties cameraRotation.
  37690. */
  37691. rotationQuaternion: Quaternion;
  37692. /**
  37693. * Track Roll to maintain the wanted Rolling when looking around.
  37694. */
  37695. _trackRoll: number;
  37696. /**
  37697. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37698. */
  37699. rollCorrect: number;
  37700. /**
  37701. * Mimic a banked turn, Rolling the camera when Yawing.
  37702. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37703. */
  37704. bankedTurn: boolean;
  37705. /**
  37706. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37707. */
  37708. bankedTurnLimit: number;
  37709. /**
  37710. * Value of 0 disables the banked Roll.
  37711. * Value of 1 is equal to the Yaw angle in radians.
  37712. */
  37713. bankedTurnMultiplier: number;
  37714. /**
  37715. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37716. */
  37717. inputs: FlyCameraInputsManager;
  37718. /**
  37719. * Gets the input sensibility for mouse input.
  37720. * Higher values reduce sensitivity.
  37721. */
  37722. /**
  37723. * Sets the input sensibility for a mouse input.
  37724. * Higher values reduce sensitivity.
  37725. */
  37726. angularSensibility: number;
  37727. /**
  37728. * Get the keys for camera movement forward.
  37729. */
  37730. /**
  37731. * Set the keys for camera movement forward.
  37732. */
  37733. keysForward: number[];
  37734. /**
  37735. * Get the keys for camera movement backward.
  37736. */
  37737. keysBackward: number[];
  37738. /**
  37739. * Get the keys for camera movement up.
  37740. */
  37741. /**
  37742. * Set the keys for camera movement up.
  37743. */
  37744. keysUp: number[];
  37745. /**
  37746. * Get the keys for camera movement down.
  37747. */
  37748. /**
  37749. * Set the keys for camera movement down.
  37750. */
  37751. keysDown: number[];
  37752. /**
  37753. * Get the keys for camera movement left.
  37754. */
  37755. /**
  37756. * Set the keys for camera movement left.
  37757. */
  37758. keysLeft: number[];
  37759. /**
  37760. * Set the keys for camera movement right.
  37761. */
  37762. /**
  37763. * Set the keys for camera movement right.
  37764. */
  37765. keysRight: number[];
  37766. /**
  37767. * Event raised when the camera collides with a mesh in the scene.
  37768. */
  37769. onCollide: (collidedMesh: AbstractMesh) => void;
  37770. private _collider;
  37771. private _needMoveForGravity;
  37772. private _oldPosition;
  37773. private _diffPosition;
  37774. private _newPosition;
  37775. /** @hidden */
  37776. _localDirection: Vector3;
  37777. /** @hidden */
  37778. _transformedDirection: Vector3;
  37779. /**
  37780. * Instantiates a FlyCamera.
  37781. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37782. * such as in a 3D Space Shooter or a Flight Simulator.
  37783. * @param name Define the name of the camera in the scene.
  37784. * @param position Define the starting position of the camera in the scene.
  37785. * @param scene Define the scene the camera belongs to.
  37786. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37787. */
  37788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37789. /**
  37790. * Attach a control to the HTML DOM element.
  37791. * @param element Defines the element that listens to the input events.
  37792. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37793. */
  37794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37795. /**
  37796. * Detach a control from the HTML DOM element.
  37797. * The camera will stop reacting to that input.
  37798. * @param element Defines the element that listens to the input events.
  37799. */
  37800. detachControl(element: HTMLElement): void;
  37801. private _collisionMask;
  37802. /**
  37803. * Get the mask that the camera ignores in collision events.
  37804. */
  37805. /**
  37806. * Set the mask that the camera ignores in collision events.
  37807. */
  37808. collisionMask: number;
  37809. /** @hidden */
  37810. _collideWithWorld(displacement: Vector3): void;
  37811. /** @hidden */
  37812. private _onCollisionPositionChange;
  37813. /** @hidden */
  37814. _checkInputs(): void;
  37815. /** @hidden */
  37816. _decideIfNeedsToMove(): boolean;
  37817. /** @hidden */
  37818. _updatePosition(): void;
  37819. /**
  37820. * Restore the Roll to its target value at the rate specified.
  37821. * @param rate - Higher means slower restoring.
  37822. * @hidden
  37823. */
  37824. restoreRoll(rate: number): void;
  37825. /**
  37826. * Destroy the camera and release the current resources held by it.
  37827. */
  37828. dispose(): void;
  37829. /**
  37830. * Get the current object class name.
  37831. * @returns the class name.
  37832. */
  37833. getClassName(): string;
  37834. }
  37835. }
  37836. declare module BABYLON {
  37837. /**
  37838. * Listen to keyboard events to control the camera.
  37839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37840. */
  37841. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37842. /**
  37843. * Defines the camera the input is attached to.
  37844. */
  37845. camera: FlyCamera;
  37846. /**
  37847. * The list of keyboard keys used to control the forward move of the camera.
  37848. */
  37849. keysForward: number[];
  37850. /**
  37851. * The list of keyboard keys used to control the backward move of the camera.
  37852. */
  37853. keysBackward: number[];
  37854. /**
  37855. * The list of keyboard keys used to control the forward move of the camera.
  37856. */
  37857. keysUp: number[];
  37858. /**
  37859. * The list of keyboard keys used to control the backward move of the camera.
  37860. */
  37861. keysDown: number[];
  37862. /**
  37863. * The list of keyboard keys used to control the right strafe move of the camera.
  37864. */
  37865. keysRight: number[];
  37866. /**
  37867. * The list of keyboard keys used to control the left strafe move of the camera.
  37868. */
  37869. keysLeft: number[];
  37870. private _keys;
  37871. private _onCanvasBlurObserver;
  37872. private _onKeyboardObserver;
  37873. private _engine;
  37874. private _scene;
  37875. /**
  37876. * Attach the input controls to a specific dom element to get the input from.
  37877. * @param element Defines the element the controls should be listened from
  37878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37879. */
  37880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37881. /**
  37882. * Detach the current controls from the specified dom element.
  37883. * @param element Defines the element to stop listening the inputs from
  37884. */
  37885. detachControl(element: Nullable<HTMLElement>): void;
  37886. /**
  37887. * Gets the class name of the current intput.
  37888. * @returns the class name
  37889. */
  37890. getClassName(): string;
  37891. /** @hidden */
  37892. _onLostFocus(e: FocusEvent): void;
  37893. /**
  37894. * Get the friendly name associated with the input class.
  37895. * @returns the input friendly name
  37896. */
  37897. getSimpleName(): string;
  37898. /**
  37899. * Update the current camera state depending on the inputs that have been used this frame.
  37900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37901. */
  37902. checkInputs(): void;
  37903. }
  37904. }
  37905. declare module BABYLON {
  37906. /**
  37907. * Manage the mouse wheel inputs to control a follow camera.
  37908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37909. */
  37910. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37911. /**
  37912. * Defines the camera the input is attached to.
  37913. */
  37914. camera: FollowCamera;
  37915. /**
  37916. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37917. */
  37918. axisControlRadius: boolean;
  37919. /**
  37920. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37921. */
  37922. axisControlHeight: boolean;
  37923. /**
  37924. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37925. */
  37926. axisControlRotation: boolean;
  37927. /**
  37928. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37929. * relation to mouseWheel events.
  37930. */
  37931. wheelPrecision: number;
  37932. /**
  37933. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37934. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37935. */
  37936. wheelDeltaPercentage: number;
  37937. private _wheel;
  37938. private _observer;
  37939. /**
  37940. * Attach the input controls to a specific dom element to get the input from.
  37941. * @param element Defines the element the controls should be listened from
  37942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37943. */
  37944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37945. /**
  37946. * Detach the current controls from the specified dom element.
  37947. * @param element Defines the element to stop listening the inputs from
  37948. */
  37949. detachControl(element: Nullable<HTMLElement>): void;
  37950. /**
  37951. * Gets the class name of the current intput.
  37952. * @returns the class name
  37953. */
  37954. getClassName(): string;
  37955. /**
  37956. * Get the friendly name associated with the input class.
  37957. * @returns the input friendly name
  37958. */
  37959. getSimpleName(): string;
  37960. }
  37961. }
  37962. declare module BABYLON {
  37963. /**
  37964. * Manage the pointers inputs to control an follow camera.
  37965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37966. */
  37967. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37968. /**
  37969. * Defines the camera the input is attached to.
  37970. */
  37971. camera: FollowCamera;
  37972. /**
  37973. * Gets the class name of the current input.
  37974. * @returns the class name
  37975. */
  37976. getClassName(): string;
  37977. /**
  37978. * Defines the pointer angular sensibility along the X axis or how fast is
  37979. * the camera rotating.
  37980. * A negative number will reverse the axis direction.
  37981. */
  37982. angularSensibilityX: number;
  37983. /**
  37984. * Defines the pointer angular sensibility along the Y axis or how fast is
  37985. * the camera rotating.
  37986. * A negative number will reverse the axis direction.
  37987. */
  37988. angularSensibilityY: number;
  37989. /**
  37990. * Defines the pointer pinch precision or how fast is the camera zooming.
  37991. * A negative number will reverse the axis direction.
  37992. */
  37993. pinchPrecision: number;
  37994. /**
  37995. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37996. * from 0.
  37997. * It defines the percentage of current camera.radius to use as delta when
  37998. * pinch zoom is used.
  37999. */
  38000. pinchDeltaPercentage: number;
  38001. /**
  38002. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38003. */
  38004. axisXControlRadius: boolean;
  38005. /**
  38006. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38007. */
  38008. axisXControlHeight: boolean;
  38009. /**
  38010. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38011. */
  38012. axisXControlRotation: boolean;
  38013. /**
  38014. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38015. */
  38016. axisYControlRadius: boolean;
  38017. /**
  38018. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38019. */
  38020. axisYControlHeight: boolean;
  38021. /**
  38022. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38023. */
  38024. axisYControlRotation: boolean;
  38025. /**
  38026. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38027. */
  38028. axisPinchControlRadius: boolean;
  38029. /**
  38030. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38031. */
  38032. axisPinchControlHeight: boolean;
  38033. /**
  38034. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38035. */
  38036. axisPinchControlRotation: boolean;
  38037. /**
  38038. * Log error messages if basic misconfiguration has occurred.
  38039. */
  38040. warningEnable: boolean;
  38041. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38042. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38043. private _warningCounter;
  38044. private _warning;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. /**
  38049. * Default Inputs manager for the FollowCamera.
  38050. * It groups all the default supported inputs for ease of use.
  38051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38052. */
  38053. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38054. /**
  38055. * Instantiates a new FollowCameraInputsManager.
  38056. * @param camera Defines the camera the inputs belong to
  38057. */
  38058. constructor(camera: FollowCamera);
  38059. /**
  38060. * Add keyboard input support to the input manager.
  38061. * @returns the current input manager
  38062. */
  38063. addKeyboard(): FollowCameraInputsManager;
  38064. /**
  38065. * Add mouse wheel input support to the input manager.
  38066. * @returns the current input manager
  38067. */
  38068. addMouseWheel(): FollowCameraInputsManager;
  38069. /**
  38070. * Add pointers input support to the input manager.
  38071. * @returns the current input manager
  38072. */
  38073. addPointers(): FollowCameraInputsManager;
  38074. /**
  38075. * Add orientation input support to the input manager.
  38076. * @returns the current input manager
  38077. */
  38078. addVRDeviceOrientation(): FollowCameraInputsManager;
  38079. }
  38080. }
  38081. declare module BABYLON {
  38082. /**
  38083. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38084. * an arc rotate version arcFollowCamera are available.
  38085. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38086. */
  38087. export class FollowCamera extends TargetCamera {
  38088. /**
  38089. * Distance the follow camera should follow an object at
  38090. */
  38091. radius: number;
  38092. /**
  38093. * Minimum allowed distance of the camera to the axis of rotation
  38094. * (The camera can not get closer).
  38095. * This can help limiting how the Camera is able to move in the scene.
  38096. */
  38097. lowerRadiusLimit: Nullable<number>;
  38098. /**
  38099. * Maximum allowed distance of the camera to the axis of rotation
  38100. * (The camera can not get further).
  38101. * This can help limiting how the Camera is able to move in the scene.
  38102. */
  38103. upperRadiusLimit: Nullable<number>;
  38104. /**
  38105. * Define a rotation offset between the camera and the object it follows
  38106. */
  38107. rotationOffset: number;
  38108. /**
  38109. * Minimum allowed angle to camera position relative to target object.
  38110. * This can help limiting how the Camera is able to move in the scene.
  38111. */
  38112. lowerRotationOffsetLimit: Nullable<number>;
  38113. /**
  38114. * Maximum allowed angle to camera position relative to target object.
  38115. * This can help limiting how the Camera is able to move in the scene.
  38116. */
  38117. upperRotationOffsetLimit: Nullable<number>;
  38118. /**
  38119. * Define a height offset between the camera and the object it follows.
  38120. * It can help following an object from the top (like a car chaing a plane)
  38121. */
  38122. heightOffset: number;
  38123. /**
  38124. * Minimum allowed height of camera position relative to target object.
  38125. * This can help limiting how the Camera is able to move in the scene.
  38126. */
  38127. lowerHeightOffsetLimit: Nullable<number>;
  38128. /**
  38129. * Maximum allowed height of camera position relative to target object.
  38130. * This can help limiting how the Camera is able to move in the scene.
  38131. */
  38132. upperHeightOffsetLimit: Nullable<number>;
  38133. /**
  38134. * Define how fast the camera can accelerate to follow it s target.
  38135. */
  38136. cameraAcceleration: number;
  38137. /**
  38138. * Define the speed limit of the camera following an object.
  38139. */
  38140. maxCameraSpeed: number;
  38141. /**
  38142. * Define the target of the camera.
  38143. */
  38144. lockedTarget: Nullable<AbstractMesh>;
  38145. /**
  38146. * Defines the input associated with the camera.
  38147. */
  38148. inputs: FollowCameraInputsManager;
  38149. /**
  38150. * Instantiates the follow camera.
  38151. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38152. * @param name Define the name of the camera in the scene
  38153. * @param position Define the position of the camera
  38154. * @param scene Define the scene the camera belong to
  38155. * @param lockedTarget Define the target of the camera
  38156. */
  38157. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38158. private _follow;
  38159. /**
  38160. * Attached controls to the current camera.
  38161. * @param element Defines the element the controls should be listened from
  38162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38163. */
  38164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38165. /**
  38166. * Detach the current controls from the camera.
  38167. * The camera will stop reacting to inputs.
  38168. * @param element Defines the element to stop listening the inputs from
  38169. */
  38170. detachControl(element: HTMLElement): void;
  38171. /** @hidden */
  38172. _checkInputs(): void;
  38173. private _checkLimits;
  38174. /**
  38175. * Gets the camera class name.
  38176. * @returns the class name
  38177. */
  38178. getClassName(): string;
  38179. }
  38180. /**
  38181. * Arc Rotate version of the follow camera.
  38182. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38183. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38184. */
  38185. export class ArcFollowCamera extends TargetCamera {
  38186. /** The longitudinal angle of the camera */
  38187. alpha: number;
  38188. /** The latitudinal angle of the camera */
  38189. beta: number;
  38190. /** The radius of the camera from its target */
  38191. radius: number;
  38192. /** Define the camera target (the messh it should follow) */
  38193. target: Nullable<AbstractMesh>;
  38194. private _cartesianCoordinates;
  38195. /**
  38196. * Instantiates a new ArcFollowCamera
  38197. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38198. * @param name Define the name of the camera
  38199. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38200. * @param beta Define the rotation angle of the camera around the elevation axis
  38201. * @param radius Define the radius of the camera from its target point
  38202. * @param target Define the target of the camera
  38203. * @param scene Define the scene the camera belongs to
  38204. */
  38205. constructor(name: string,
  38206. /** The longitudinal angle of the camera */
  38207. alpha: number,
  38208. /** The latitudinal angle of the camera */
  38209. beta: number,
  38210. /** The radius of the camera from its target */
  38211. radius: number,
  38212. /** Define the camera target (the messh it should follow) */
  38213. target: Nullable<AbstractMesh>, scene: Scene);
  38214. private _follow;
  38215. /** @hidden */
  38216. _checkInputs(): void;
  38217. /**
  38218. * Returns the class name of the object.
  38219. * It is mostly used internally for serialization purposes.
  38220. */
  38221. getClassName(): string;
  38222. }
  38223. }
  38224. declare module BABYLON {
  38225. /**
  38226. * Manage the keyboard inputs to control the movement of a follow camera.
  38227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38228. */
  38229. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38230. /**
  38231. * Defines the camera the input is attached to.
  38232. */
  38233. camera: FollowCamera;
  38234. /**
  38235. * Defines the list of key codes associated with the up action (increase heightOffset)
  38236. */
  38237. keysHeightOffsetIncr: number[];
  38238. /**
  38239. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38240. */
  38241. keysHeightOffsetDecr: number[];
  38242. /**
  38243. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38244. */
  38245. keysHeightOffsetModifierAlt: boolean;
  38246. /**
  38247. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38248. */
  38249. keysHeightOffsetModifierCtrl: boolean;
  38250. /**
  38251. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38252. */
  38253. keysHeightOffsetModifierShift: boolean;
  38254. /**
  38255. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38256. */
  38257. keysRotationOffsetIncr: number[];
  38258. /**
  38259. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38260. */
  38261. keysRotationOffsetDecr: number[];
  38262. /**
  38263. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38264. */
  38265. keysRotationOffsetModifierAlt: boolean;
  38266. /**
  38267. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38268. */
  38269. keysRotationOffsetModifierCtrl: boolean;
  38270. /**
  38271. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38272. */
  38273. keysRotationOffsetModifierShift: boolean;
  38274. /**
  38275. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38276. */
  38277. keysRadiusIncr: number[];
  38278. /**
  38279. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38280. */
  38281. keysRadiusDecr: number[];
  38282. /**
  38283. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38284. */
  38285. keysRadiusModifierAlt: boolean;
  38286. /**
  38287. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38288. */
  38289. keysRadiusModifierCtrl: boolean;
  38290. /**
  38291. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38292. */
  38293. keysRadiusModifierShift: boolean;
  38294. /**
  38295. * Defines the rate of change of heightOffset.
  38296. */
  38297. heightSensibility: number;
  38298. /**
  38299. * Defines the rate of change of rotationOffset.
  38300. */
  38301. rotationSensibility: number;
  38302. /**
  38303. * Defines the rate of change of radius.
  38304. */
  38305. radiusSensibility: number;
  38306. private _keys;
  38307. private _ctrlPressed;
  38308. private _altPressed;
  38309. private _shiftPressed;
  38310. private _onCanvasBlurObserver;
  38311. private _onKeyboardObserver;
  38312. private _engine;
  38313. private _scene;
  38314. /**
  38315. * Attach the input controls to a specific dom element to get the input from.
  38316. * @param element Defines the element the controls should be listened from
  38317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38318. */
  38319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38320. /**
  38321. * Detach the current controls from the specified dom element.
  38322. * @param element Defines the element to stop listening the inputs from
  38323. */
  38324. detachControl(element: Nullable<HTMLElement>): void;
  38325. /**
  38326. * Update the current camera state depending on the inputs that have been used this frame.
  38327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38328. */
  38329. checkInputs(): void;
  38330. /**
  38331. * Gets the class name of the current input.
  38332. * @returns the class name
  38333. */
  38334. getClassName(): string;
  38335. /**
  38336. * Get the friendly name associated with the input class.
  38337. * @returns the input friendly name
  38338. */
  38339. getSimpleName(): string;
  38340. /**
  38341. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38342. * allow modification of the heightOffset value.
  38343. */
  38344. private _modifierHeightOffset;
  38345. /**
  38346. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38347. * allow modification of the rotationOffset value.
  38348. */
  38349. private _modifierRotationOffset;
  38350. /**
  38351. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38352. * allow modification of the radius value.
  38353. */
  38354. private _modifierRadius;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. interface FreeCameraInputsManager {
  38359. /**
  38360. * @hidden
  38361. */
  38362. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38363. /**
  38364. * Add orientation input support to the input manager.
  38365. * @returns the current input manager
  38366. */
  38367. addDeviceOrientation(): FreeCameraInputsManager;
  38368. }
  38369. /**
  38370. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38371. * Screen rotation is taken into account.
  38372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38373. */
  38374. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38375. private _camera;
  38376. private _screenOrientationAngle;
  38377. private _constantTranform;
  38378. private _screenQuaternion;
  38379. private _alpha;
  38380. private _beta;
  38381. private _gamma;
  38382. /**
  38383. * Can be used to detect if a device orientation sensor is availible on a device
  38384. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38385. * @returns a promise that will resolve on orientation change
  38386. */
  38387. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38388. /**
  38389. * @hidden
  38390. */
  38391. _onDeviceOrientationChangedObservable: Observable<void>;
  38392. /**
  38393. * Instantiates a new input
  38394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38395. */
  38396. constructor();
  38397. /**
  38398. * Define the camera controlled by the input.
  38399. */
  38400. camera: FreeCamera;
  38401. /**
  38402. * Attach the input controls to a specific dom element to get the input from.
  38403. * @param element Defines the element the controls should be listened from
  38404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38405. */
  38406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38407. private _orientationChanged;
  38408. private _deviceOrientation;
  38409. /**
  38410. * Detach the current controls from the specified dom element.
  38411. * @param element Defines the element to stop listening the inputs from
  38412. */
  38413. detachControl(element: Nullable<HTMLElement>): void;
  38414. /**
  38415. * Update the current camera state depending on the inputs that have been used this frame.
  38416. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38417. */
  38418. checkInputs(): void;
  38419. /**
  38420. * Gets the class name of the current intput.
  38421. * @returns the class name
  38422. */
  38423. getClassName(): string;
  38424. /**
  38425. * Get the friendly name associated with the input class.
  38426. * @returns the input friendly name
  38427. */
  38428. getSimpleName(): string;
  38429. }
  38430. }
  38431. declare module BABYLON {
  38432. /**
  38433. * Manage the gamepad inputs to control a free camera.
  38434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38435. */
  38436. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38437. /**
  38438. * Define the camera the input is attached to.
  38439. */
  38440. camera: FreeCamera;
  38441. /**
  38442. * Define the Gamepad controlling the input
  38443. */
  38444. gamepad: Nullable<Gamepad>;
  38445. /**
  38446. * Defines the gamepad rotation sensiblity.
  38447. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38448. */
  38449. gamepadAngularSensibility: number;
  38450. /**
  38451. * Defines the gamepad move sensiblity.
  38452. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38453. */
  38454. gamepadMoveSensibility: number;
  38455. private _yAxisScale;
  38456. /**
  38457. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38458. */
  38459. invertYAxis: boolean;
  38460. private _onGamepadConnectedObserver;
  38461. private _onGamepadDisconnectedObserver;
  38462. private _cameraTransform;
  38463. private _deltaTransform;
  38464. private _vector3;
  38465. private _vector2;
  38466. /**
  38467. * Attach the input controls to a specific dom element to get the input from.
  38468. * @param element Defines the element the controls should be listened from
  38469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38470. */
  38471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38472. /**
  38473. * Detach the current controls from the specified dom element.
  38474. * @param element Defines the element to stop listening the inputs from
  38475. */
  38476. detachControl(element: Nullable<HTMLElement>): void;
  38477. /**
  38478. * Update the current camera state depending on the inputs that have been used this frame.
  38479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38480. */
  38481. checkInputs(): void;
  38482. /**
  38483. * Gets the class name of the current intput.
  38484. * @returns the class name
  38485. */
  38486. getClassName(): string;
  38487. /**
  38488. * Get the friendly name associated with the input class.
  38489. * @returns the input friendly name
  38490. */
  38491. getSimpleName(): string;
  38492. }
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * Defines the potential axis of a Joystick
  38497. */
  38498. export enum JoystickAxis {
  38499. /** X axis */
  38500. X = 0,
  38501. /** Y axis */
  38502. Y = 1,
  38503. /** Z axis */
  38504. Z = 2
  38505. }
  38506. /**
  38507. * Class used to define virtual joystick (used in touch mode)
  38508. */
  38509. export class VirtualJoystick {
  38510. /**
  38511. * Gets or sets a boolean indicating that left and right values must be inverted
  38512. */
  38513. reverseLeftRight: boolean;
  38514. /**
  38515. * Gets or sets a boolean indicating that up and down values must be inverted
  38516. */
  38517. reverseUpDown: boolean;
  38518. /**
  38519. * Gets the offset value for the position (ie. the change of the position value)
  38520. */
  38521. deltaPosition: Vector3;
  38522. /**
  38523. * Gets a boolean indicating if the virtual joystick was pressed
  38524. */
  38525. pressed: boolean;
  38526. /**
  38527. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38528. */
  38529. static Canvas: Nullable<HTMLCanvasElement>;
  38530. private static _globalJoystickIndex;
  38531. private static vjCanvasContext;
  38532. private static vjCanvasWidth;
  38533. private static vjCanvasHeight;
  38534. private static halfWidth;
  38535. private _action;
  38536. private _axisTargetedByLeftAndRight;
  38537. private _axisTargetedByUpAndDown;
  38538. private _joystickSensibility;
  38539. private _inversedSensibility;
  38540. private _joystickPointerID;
  38541. private _joystickColor;
  38542. private _joystickPointerPos;
  38543. private _joystickPreviousPointerPos;
  38544. private _joystickPointerStartPos;
  38545. private _deltaJoystickVector;
  38546. private _leftJoystick;
  38547. private _touches;
  38548. private _onPointerDownHandlerRef;
  38549. private _onPointerMoveHandlerRef;
  38550. private _onPointerUpHandlerRef;
  38551. private _onResize;
  38552. /**
  38553. * Creates a new virtual joystick
  38554. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38555. */
  38556. constructor(leftJoystick?: boolean);
  38557. /**
  38558. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38559. * @param newJoystickSensibility defines the new sensibility
  38560. */
  38561. setJoystickSensibility(newJoystickSensibility: number): void;
  38562. private _onPointerDown;
  38563. private _onPointerMove;
  38564. private _onPointerUp;
  38565. /**
  38566. * Change the color of the virtual joystick
  38567. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38568. */
  38569. setJoystickColor(newColor: string): void;
  38570. /**
  38571. * Defines a callback to call when the joystick is touched
  38572. * @param action defines the callback
  38573. */
  38574. setActionOnTouch(action: () => any): void;
  38575. /**
  38576. * Defines which axis you'd like to control for left & right
  38577. * @param axis defines the axis to use
  38578. */
  38579. setAxisForLeftRight(axis: JoystickAxis): void;
  38580. /**
  38581. * Defines which axis you'd like to control for up & down
  38582. * @param axis defines the axis to use
  38583. */
  38584. setAxisForUpDown(axis: JoystickAxis): void;
  38585. private _drawVirtualJoystick;
  38586. /**
  38587. * Release internal HTML canvas
  38588. */
  38589. releaseCanvas(): void;
  38590. }
  38591. }
  38592. declare module BABYLON {
  38593. interface FreeCameraInputsManager {
  38594. /**
  38595. * Add virtual joystick input support to the input manager.
  38596. * @returns the current input manager
  38597. */
  38598. addVirtualJoystick(): FreeCameraInputsManager;
  38599. }
  38600. /**
  38601. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38603. */
  38604. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38605. /**
  38606. * Defines the camera the input is attached to.
  38607. */
  38608. camera: FreeCamera;
  38609. private _leftjoystick;
  38610. private _rightjoystick;
  38611. /**
  38612. * Gets the left stick of the virtual joystick.
  38613. * @returns The virtual Joystick
  38614. */
  38615. getLeftJoystick(): VirtualJoystick;
  38616. /**
  38617. * Gets the right stick of the virtual joystick.
  38618. * @returns The virtual Joystick
  38619. */
  38620. getRightJoystick(): VirtualJoystick;
  38621. /**
  38622. * Update the current camera state depending on the inputs that have been used this frame.
  38623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38624. */
  38625. checkInputs(): void;
  38626. /**
  38627. * Attach the input controls to a specific dom element to get the input from.
  38628. * @param element Defines the element the controls should be listened from
  38629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38630. */
  38631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38632. /**
  38633. * Detach the current controls from the specified dom element.
  38634. * @param element Defines the element to stop listening the inputs from
  38635. */
  38636. detachControl(element: Nullable<HTMLElement>): void;
  38637. /**
  38638. * Gets the class name of the current intput.
  38639. * @returns the class name
  38640. */
  38641. getClassName(): string;
  38642. /**
  38643. * Get the friendly name associated with the input class.
  38644. * @returns the input friendly name
  38645. */
  38646. getSimpleName(): string;
  38647. }
  38648. }
  38649. declare module BABYLON {
  38650. /**
  38651. * This represents a FPS type of camera controlled by touch.
  38652. * This is like a universal camera minus the Gamepad controls.
  38653. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38654. */
  38655. export class TouchCamera extends FreeCamera {
  38656. /**
  38657. * Defines the touch sensibility for rotation.
  38658. * The higher the faster.
  38659. */
  38660. touchAngularSensibility: number;
  38661. /**
  38662. * Defines the touch sensibility for move.
  38663. * The higher the faster.
  38664. */
  38665. touchMoveSensibility: number;
  38666. /**
  38667. * Instantiates a new touch camera.
  38668. * This represents a FPS type of camera controlled by touch.
  38669. * This is like a universal camera minus the Gamepad controls.
  38670. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38671. * @param name Define the name of the camera in the scene
  38672. * @param position Define the start position of the camera in the scene
  38673. * @param scene Define the scene the camera belongs to
  38674. */
  38675. constructor(name: string, position: Vector3, scene: Scene);
  38676. /**
  38677. * Gets the current object class name.
  38678. * @return the class name
  38679. */
  38680. getClassName(): string;
  38681. /** @hidden */
  38682. _setupInputs(): void;
  38683. }
  38684. }
  38685. declare module BABYLON {
  38686. /**
  38687. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38688. * being tilted forward or back and left or right.
  38689. */
  38690. export class DeviceOrientationCamera extends FreeCamera {
  38691. private _initialQuaternion;
  38692. private _quaternionCache;
  38693. private _tmpDragQuaternion;
  38694. private _disablePointerInputWhenUsingDeviceOrientation;
  38695. /**
  38696. * Creates a new device orientation camera
  38697. * @param name The name of the camera
  38698. * @param position The start position camera
  38699. * @param scene The scene the camera belongs to
  38700. */
  38701. constructor(name: string, position: Vector3, scene: Scene);
  38702. /**
  38703. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38704. */
  38705. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38706. private _dragFactor;
  38707. /**
  38708. * Enabled turning on the y axis when the orientation sensor is active
  38709. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38710. */
  38711. enableHorizontalDragging(dragFactor?: number): void;
  38712. /**
  38713. * Gets the current instance class name ("DeviceOrientationCamera").
  38714. * This helps avoiding instanceof at run time.
  38715. * @returns the class name
  38716. */
  38717. getClassName(): string;
  38718. /**
  38719. * @hidden
  38720. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38721. */
  38722. _checkInputs(): void;
  38723. /**
  38724. * Reset the camera to its default orientation on the specified axis only.
  38725. * @param axis The axis to reset
  38726. */
  38727. resetToCurrentRotation(axis?: Axis): void;
  38728. }
  38729. }
  38730. declare module BABYLON {
  38731. /**
  38732. * Defines supported buttons for XBox360 compatible gamepads
  38733. */
  38734. export enum Xbox360Button {
  38735. /** A */
  38736. A = 0,
  38737. /** B */
  38738. B = 1,
  38739. /** X */
  38740. X = 2,
  38741. /** Y */
  38742. Y = 3,
  38743. /** Start */
  38744. Start = 4,
  38745. /** Back */
  38746. Back = 5,
  38747. /** Left button */
  38748. LB = 6,
  38749. /** Right button */
  38750. RB = 7,
  38751. /** Left stick */
  38752. LeftStick = 8,
  38753. /** Right stick */
  38754. RightStick = 9
  38755. }
  38756. /** Defines values for XBox360 DPad */
  38757. export enum Xbox360Dpad {
  38758. /** Up */
  38759. Up = 0,
  38760. /** Down */
  38761. Down = 1,
  38762. /** Left */
  38763. Left = 2,
  38764. /** Right */
  38765. Right = 3
  38766. }
  38767. /**
  38768. * Defines a XBox360 gamepad
  38769. */
  38770. export class Xbox360Pad extends Gamepad {
  38771. private _leftTrigger;
  38772. private _rightTrigger;
  38773. private _onlefttriggerchanged;
  38774. private _onrighttriggerchanged;
  38775. private _onbuttondown;
  38776. private _onbuttonup;
  38777. private _ondpaddown;
  38778. private _ondpadup;
  38779. /** Observable raised when a button is pressed */
  38780. onButtonDownObservable: Observable<Xbox360Button>;
  38781. /** Observable raised when a button is released */
  38782. onButtonUpObservable: Observable<Xbox360Button>;
  38783. /** Observable raised when a pad is pressed */
  38784. onPadDownObservable: Observable<Xbox360Dpad>;
  38785. /** Observable raised when a pad is released */
  38786. onPadUpObservable: Observable<Xbox360Dpad>;
  38787. private _buttonA;
  38788. private _buttonB;
  38789. private _buttonX;
  38790. private _buttonY;
  38791. private _buttonBack;
  38792. private _buttonStart;
  38793. private _buttonLB;
  38794. private _buttonRB;
  38795. private _buttonLeftStick;
  38796. private _buttonRightStick;
  38797. private _dPadUp;
  38798. private _dPadDown;
  38799. private _dPadLeft;
  38800. private _dPadRight;
  38801. private _isXboxOnePad;
  38802. /**
  38803. * Creates a new XBox360 gamepad object
  38804. * @param id defines the id of this gamepad
  38805. * @param index defines its index
  38806. * @param gamepad defines the internal HTML gamepad object
  38807. * @param xboxOne defines if it is a XBox One gamepad
  38808. */
  38809. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38810. /**
  38811. * Defines the callback to call when left trigger is pressed
  38812. * @param callback defines the callback to use
  38813. */
  38814. onlefttriggerchanged(callback: (value: number) => void): void;
  38815. /**
  38816. * Defines the callback to call when right trigger is pressed
  38817. * @param callback defines the callback to use
  38818. */
  38819. onrighttriggerchanged(callback: (value: number) => void): void;
  38820. /**
  38821. * Gets the left trigger value
  38822. */
  38823. /**
  38824. * Sets the left trigger value
  38825. */
  38826. leftTrigger: number;
  38827. /**
  38828. * Gets the right trigger value
  38829. */
  38830. /**
  38831. * Sets the right trigger value
  38832. */
  38833. rightTrigger: number;
  38834. /**
  38835. * Defines the callback to call when a button is pressed
  38836. * @param callback defines the callback to use
  38837. */
  38838. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38839. /**
  38840. * Defines the callback to call when a button is released
  38841. * @param callback defines the callback to use
  38842. */
  38843. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38844. /**
  38845. * Defines the callback to call when a pad is pressed
  38846. * @param callback defines the callback to use
  38847. */
  38848. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38849. /**
  38850. * Defines the callback to call when a pad is released
  38851. * @param callback defines the callback to use
  38852. */
  38853. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38854. private _setButtonValue;
  38855. private _setDPadValue;
  38856. /**
  38857. * Gets the value of the `A` button
  38858. */
  38859. /**
  38860. * Sets the value of the `A` button
  38861. */
  38862. buttonA: number;
  38863. /**
  38864. * Gets the value of the `B` button
  38865. */
  38866. /**
  38867. * Sets the value of the `B` button
  38868. */
  38869. buttonB: number;
  38870. /**
  38871. * Gets the value of the `X` button
  38872. */
  38873. /**
  38874. * Sets the value of the `X` button
  38875. */
  38876. buttonX: number;
  38877. /**
  38878. * Gets the value of the `Y` button
  38879. */
  38880. /**
  38881. * Sets the value of the `Y` button
  38882. */
  38883. buttonY: number;
  38884. /**
  38885. * Gets the value of the `Start` button
  38886. */
  38887. /**
  38888. * Sets the value of the `Start` button
  38889. */
  38890. buttonStart: number;
  38891. /**
  38892. * Gets the value of the `Back` button
  38893. */
  38894. /**
  38895. * Sets the value of the `Back` button
  38896. */
  38897. buttonBack: number;
  38898. /**
  38899. * Gets the value of the `Left` button
  38900. */
  38901. /**
  38902. * Sets the value of the `Left` button
  38903. */
  38904. buttonLB: number;
  38905. /**
  38906. * Gets the value of the `Right` button
  38907. */
  38908. /**
  38909. * Sets the value of the `Right` button
  38910. */
  38911. buttonRB: number;
  38912. /**
  38913. * Gets the value of the Left joystick
  38914. */
  38915. /**
  38916. * Sets the value of the Left joystick
  38917. */
  38918. buttonLeftStick: number;
  38919. /**
  38920. * Gets the value of the Right joystick
  38921. */
  38922. /**
  38923. * Sets the value of the Right joystick
  38924. */
  38925. buttonRightStick: number;
  38926. /**
  38927. * Gets the value of D-pad up
  38928. */
  38929. /**
  38930. * Sets the value of D-pad up
  38931. */
  38932. dPadUp: number;
  38933. /**
  38934. * Gets the value of D-pad down
  38935. */
  38936. /**
  38937. * Sets the value of D-pad down
  38938. */
  38939. dPadDown: number;
  38940. /**
  38941. * Gets the value of D-pad left
  38942. */
  38943. /**
  38944. * Sets the value of D-pad left
  38945. */
  38946. dPadLeft: number;
  38947. /**
  38948. * Gets the value of D-pad right
  38949. */
  38950. /**
  38951. * Sets the value of D-pad right
  38952. */
  38953. dPadRight: number;
  38954. /**
  38955. * Force the gamepad to synchronize with device values
  38956. */
  38957. update(): void;
  38958. /**
  38959. * Disposes the gamepad
  38960. */
  38961. dispose(): void;
  38962. }
  38963. }
  38964. declare module BABYLON {
  38965. /**
  38966. * Defines supported buttons for DualShock compatible gamepads
  38967. */
  38968. export enum DualShockButton {
  38969. /** Cross */
  38970. Cross = 0,
  38971. /** Circle */
  38972. Circle = 1,
  38973. /** Square */
  38974. Square = 2,
  38975. /** Triangle */
  38976. Triangle = 3,
  38977. /** Options */
  38978. Options = 4,
  38979. /** Share */
  38980. Share = 5,
  38981. /** L1 */
  38982. L1 = 6,
  38983. /** R1 */
  38984. R1 = 7,
  38985. /** Left stick */
  38986. LeftStick = 8,
  38987. /** Right stick */
  38988. RightStick = 9
  38989. }
  38990. /** Defines values for DualShock DPad */
  38991. export enum DualShockDpad {
  38992. /** Up */
  38993. Up = 0,
  38994. /** Down */
  38995. Down = 1,
  38996. /** Left */
  38997. Left = 2,
  38998. /** Right */
  38999. Right = 3
  39000. }
  39001. /**
  39002. * Defines a DualShock gamepad
  39003. */
  39004. export class DualShockPad extends Gamepad {
  39005. private _leftTrigger;
  39006. private _rightTrigger;
  39007. private _onlefttriggerchanged;
  39008. private _onrighttriggerchanged;
  39009. private _onbuttondown;
  39010. private _onbuttonup;
  39011. private _ondpaddown;
  39012. private _ondpadup;
  39013. /** Observable raised when a button is pressed */
  39014. onButtonDownObservable: Observable<DualShockButton>;
  39015. /** Observable raised when a button is released */
  39016. onButtonUpObservable: Observable<DualShockButton>;
  39017. /** Observable raised when a pad is pressed */
  39018. onPadDownObservable: Observable<DualShockDpad>;
  39019. /** Observable raised when a pad is released */
  39020. onPadUpObservable: Observable<DualShockDpad>;
  39021. private _buttonCross;
  39022. private _buttonCircle;
  39023. private _buttonSquare;
  39024. private _buttonTriangle;
  39025. private _buttonShare;
  39026. private _buttonOptions;
  39027. private _buttonL1;
  39028. private _buttonR1;
  39029. private _buttonLeftStick;
  39030. private _buttonRightStick;
  39031. private _dPadUp;
  39032. private _dPadDown;
  39033. private _dPadLeft;
  39034. private _dPadRight;
  39035. /**
  39036. * Creates a new DualShock gamepad object
  39037. * @param id defines the id of this gamepad
  39038. * @param index defines its index
  39039. * @param gamepad defines the internal HTML gamepad object
  39040. */
  39041. constructor(id: string, index: number, gamepad: any);
  39042. /**
  39043. * Defines the callback to call when left trigger is pressed
  39044. * @param callback defines the callback to use
  39045. */
  39046. onlefttriggerchanged(callback: (value: number) => void): void;
  39047. /**
  39048. * Defines the callback to call when right trigger is pressed
  39049. * @param callback defines the callback to use
  39050. */
  39051. onrighttriggerchanged(callback: (value: number) => void): void;
  39052. /**
  39053. * Gets the left trigger value
  39054. */
  39055. /**
  39056. * Sets the left trigger value
  39057. */
  39058. leftTrigger: number;
  39059. /**
  39060. * Gets the right trigger value
  39061. */
  39062. /**
  39063. * Sets the right trigger value
  39064. */
  39065. rightTrigger: number;
  39066. /**
  39067. * Defines the callback to call when a button is pressed
  39068. * @param callback defines the callback to use
  39069. */
  39070. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39071. /**
  39072. * Defines the callback to call when a button is released
  39073. * @param callback defines the callback to use
  39074. */
  39075. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39076. /**
  39077. * Defines the callback to call when a pad is pressed
  39078. * @param callback defines the callback to use
  39079. */
  39080. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39081. /**
  39082. * Defines the callback to call when a pad is released
  39083. * @param callback defines the callback to use
  39084. */
  39085. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39086. private _setButtonValue;
  39087. private _setDPadValue;
  39088. /**
  39089. * Gets the value of the `Cross` button
  39090. */
  39091. /**
  39092. * Sets the value of the `Cross` button
  39093. */
  39094. buttonCross: number;
  39095. /**
  39096. * Gets the value of the `Circle` button
  39097. */
  39098. /**
  39099. * Sets the value of the `Circle` button
  39100. */
  39101. buttonCircle: number;
  39102. /**
  39103. * Gets the value of the `Square` button
  39104. */
  39105. /**
  39106. * Sets the value of the `Square` button
  39107. */
  39108. buttonSquare: number;
  39109. /**
  39110. * Gets the value of the `Triangle` button
  39111. */
  39112. /**
  39113. * Sets the value of the `Triangle` button
  39114. */
  39115. buttonTriangle: number;
  39116. /**
  39117. * Gets the value of the `Options` button
  39118. */
  39119. /**
  39120. * Sets the value of the `Options` button
  39121. */
  39122. buttonOptions: number;
  39123. /**
  39124. * Gets the value of the `Share` button
  39125. */
  39126. /**
  39127. * Sets the value of the `Share` button
  39128. */
  39129. buttonShare: number;
  39130. /**
  39131. * Gets the value of the `L1` button
  39132. */
  39133. /**
  39134. * Sets the value of the `L1` button
  39135. */
  39136. buttonL1: number;
  39137. /**
  39138. * Gets the value of the `R1` button
  39139. */
  39140. /**
  39141. * Sets the value of the `R1` button
  39142. */
  39143. buttonR1: number;
  39144. /**
  39145. * Gets the value of the Left joystick
  39146. */
  39147. /**
  39148. * Sets the value of the Left joystick
  39149. */
  39150. buttonLeftStick: number;
  39151. /**
  39152. * Gets the value of the Right joystick
  39153. */
  39154. /**
  39155. * Sets the value of the Right joystick
  39156. */
  39157. buttonRightStick: number;
  39158. /**
  39159. * Gets the value of D-pad up
  39160. */
  39161. /**
  39162. * Sets the value of D-pad up
  39163. */
  39164. dPadUp: number;
  39165. /**
  39166. * Gets the value of D-pad down
  39167. */
  39168. /**
  39169. * Sets the value of D-pad down
  39170. */
  39171. dPadDown: number;
  39172. /**
  39173. * Gets the value of D-pad left
  39174. */
  39175. /**
  39176. * Sets the value of D-pad left
  39177. */
  39178. dPadLeft: number;
  39179. /**
  39180. * Gets the value of D-pad right
  39181. */
  39182. /**
  39183. * Sets the value of D-pad right
  39184. */
  39185. dPadRight: number;
  39186. /**
  39187. * Force the gamepad to synchronize with device values
  39188. */
  39189. update(): void;
  39190. /**
  39191. * Disposes the gamepad
  39192. */
  39193. dispose(): void;
  39194. }
  39195. }
  39196. declare module BABYLON {
  39197. /**
  39198. * Manager for handling gamepads
  39199. */
  39200. export class GamepadManager {
  39201. private _scene?;
  39202. private _babylonGamepads;
  39203. private _oneGamepadConnected;
  39204. /** @hidden */
  39205. _isMonitoring: boolean;
  39206. private _gamepadEventSupported;
  39207. private _gamepadSupport;
  39208. /**
  39209. * observable to be triggered when the gamepad controller has been connected
  39210. */
  39211. onGamepadConnectedObservable: Observable<Gamepad>;
  39212. /**
  39213. * observable to be triggered when the gamepad controller has been disconnected
  39214. */
  39215. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39216. private _onGamepadConnectedEvent;
  39217. private _onGamepadDisconnectedEvent;
  39218. /**
  39219. * Initializes the gamepad manager
  39220. * @param _scene BabylonJS scene
  39221. */
  39222. constructor(_scene?: Scene | undefined);
  39223. /**
  39224. * The gamepads in the game pad manager
  39225. */
  39226. readonly gamepads: Gamepad[];
  39227. /**
  39228. * Get the gamepad controllers based on type
  39229. * @param type The type of gamepad controller
  39230. * @returns Nullable gamepad
  39231. */
  39232. getGamepadByType(type?: number): Nullable<Gamepad>;
  39233. /**
  39234. * Disposes the gamepad manager
  39235. */
  39236. dispose(): void;
  39237. private _addNewGamepad;
  39238. private _startMonitoringGamepads;
  39239. private _stopMonitoringGamepads;
  39240. /** @hidden */
  39241. _checkGamepadsStatus(): void;
  39242. private _updateGamepadObjects;
  39243. }
  39244. }
  39245. declare module BABYLON {
  39246. interface Scene {
  39247. /** @hidden */
  39248. _gamepadManager: Nullable<GamepadManager>;
  39249. /**
  39250. * Gets the gamepad manager associated with the scene
  39251. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39252. */
  39253. gamepadManager: GamepadManager;
  39254. }
  39255. /**
  39256. * Interface representing a free camera inputs manager
  39257. */
  39258. interface FreeCameraInputsManager {
  39259. /**
  39260. * Adds gamepad input support to the FreeCameraInputsManager.
  39261. * @returns the FreeCameraInputsManager
  39262. */
  39263. addGamepad(): FreeCameraInputsManager;
  39264. }
  39265. /**
  39266. * Interface representing an arc rotate camera inputs manager
  39267. */
  39268. interface ArcRotateCameraInputsManager {
  39269. /**
  39270. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39271. * @returns the camera inputs manager
  39272. */
  39273. addGamepad(): ArcRotateCameraInputsManager;
  39274. }
  39275. /**
  39276. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39277. */
  39278. export class GamepadSystemSceneComponent implements ISceneComponent {
  39279. /**
  39280. * The component name helpfull to identify the component in the list of scene components.
  39281. */
  39282. readonly name: string;
  39283. /**
  39284. * The scene the component belongs to.
  39285. */
  39286. scene: Scene;
  39287. /**
  39288. * Creates a new instance of the component for the given scene
  39289. * @param scene Defines the scene to register the component in
  39290. */
  39291. constructor(scene: Scene);
  39292. /**
  39293. * Registers the component in a given scene
  39294. */
  39295. register(): void;
  39296. /**
  39297. * Rebuilds the elements related to this component in case of
  39298. * context lost for instance.
  39299. */
  39300. rebuild(): void;
  39301. /**
  39302. * Disposes the component and the associated ressources
  39303. */
  39304. dispose(): void;
  39305. private _beforeCameraUpdate;
  39306. }
  39307. }
  39308. declare module BABYLON {
  39309. /**
  39310. * 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,
  39311. * which still works and will still be found in many Playgrounds.
  39312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39313. */
  39314. export class UniversalCamera extends TouchCamera {
  39315. /**
  39316. * Defines the gamepad rotation sensiblity.
  39317. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39318. */
  39319. gamepadAngularSensibility: number;
  39320. /**
  39321. * Defines the gamepad move sensiblity.
  39322. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39323. */
  39324. gamepadMoveSensibility: number;
  39325. /**
  39326. * 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,
  39327. * which still works and will still be found in many Playgrounds.
  39328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39329. * @param name Define the name of the camera in the scene
  39330. * @param position Define the start position of the camera in the scene
  39331. * @param scene Define the scene the camera belongs to
  39332. */
  39333. constructor(name: string, position: Vector3, scene: Scene);
  39334. /**
  39335. * Gets the current object class name.
  39336. * @return the class name
  39337. */
  39338. getClassName(): string;
  39339. }
  39340. }
  39341. declare module BABYLON {
  39342. /**
  39343. * This represents a FPS type of camera. This is only here for back compat purpose.
  39344. * Please use the UniversalCamera instead as both are identical.
  39345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39346. */
  39347. export class GamepadCamera extends UniversalCamera {
  39348. /**
  39349. * Instantiates a new Gamepad Camera
  39350. * This represents a FPS type of camera. This is only here for back compat purpose.
  39351. * Please use the UniversalCamera instead as both are identical.
  39352. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39353. * @param name Define the name of the camera in the scene
  39354. * @param position Define the start position of the camera in the scene
  39355. * @param scene Define the scene the camera belongs to
  39356. */
  39357. constructor(name: string, position: Vector3, scene: Scene);
  39358. /**
  39359. * Gets the current object class name.
  39360. * @return the class name
  39361. */
  39362. getClassName(): string;
  39363. }
  39364. }
  39365. declare module BABYLON {
  39366. /** @hidden */
  39367. export var passPixelShader: {
  39368. name: string;
  39369. shader: string;
  39370. };
  39371. }
  39372. declare module BABYLON {
  39373. /** @hidden */
  39374. export var passCubePixelShader: {
  39375. name: string;
  39376. shader: string;
  39377. };
  39378. }
  39379. declare module BABYLON {
  39380. /**
  39381. * PassPostProcess which produces an output the same as it's input
  39382. */
  39383. export class PassPostProcess extends PostProcess {
  39384. /**
  39385. * Creates the PassPostProcess
  39386. * @param name The name of the effect.
  39387. * @param options The required width/height ratio to downsize to before computing the render pass.
  39388. * @param camera The camera to apply the render pass to.
  39389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39390. * @param engine The engine which the post process will be applied. (default: current engine)
  39391. * @param reusable If the post process can be reused on the same frame. (default: false)
  39392. * @param textureType The type of texture to be used when performing the post processing.
  39393. * @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)
  39394. */
  39395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39396. }
  39397. /**
  39398. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39399. */
  39400. export class PassCubePostProcess extends PostProcess {
  39401. private _face;
  39402. /**
  39403. * Gets or sets the cube face to display.
  39404. * * 0 is +X
  39405. * * 1 is -X
  39406. * * 2 is +Y
  39407. * * 3 is -Y
  39408. * * 4 is +Z
  39409. * * 5 is -Z
  39410. */
  39411. face: number;
  39412. /**
  39413. * Creates the PassCubePostProcess
  39414. * @param name The name of the effect.
  39415. * @param options The required width/height ratio to downsize to before computing the render pass.
  39416. * @param camera The camera to apply the render pass to.
  39417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39418. * @param engine The engine which the post process will be applied. (default: current engine)
  39419. * @param reusable If the post process can be reused on the same frame. (default: false)
  39420. * @param textureType The type of texture to be used when performing the post processing.
  39421. * @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)
  39422. */
  39423. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /** @hidden */
  39428. export var anaglyphPixelShader: {
  39429. name: string;
  39430. shader: string;
  39431. };
  39432. }
  39433. declare module BABYLON {
  39434. /**
  39435. * Postprocess used to generate anaglyphic rendering
  39436. */
  39437. export class AnaglyphPostProcess extends PostProcess {
  39438. private _passedProcess;
  39439. /**
  39440. * Creates a new AnaglyphPostProcess
  39441. * @param name defines postprocess name
  39442. * @param options defines creation options or target ratio scale
  39443. * @param rigCameras defines cameras using this postprocess
  39444. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39445. * @param engine defines hosting engine
  39446. * @param reusable defines if the postprocess will be reused multiple times per frame
  39447. */
  39448. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39449. }
  39450. }
  39451. declare module BABYLON {
  39452. /**
  39453. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39454. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39455. */
  39456. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39457. /**
  39458. * Creates a new AnaglyphArcRotateCamera
  39459. * @param name defines camera name
  39460. * @param alpha defines alpha angle (in radians)
  39461. * @param beta defines beta angle (in radians)
  39462. * @param radius defines radius
  39463. * @param target defines camera target
  39464. * @param interaxialDistance defines distance between each color axis
  39465. * @param scene defines the hosting scene
  39466. */
  39467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39468. /**
  39469. * Gets camera class name
  39470. * @returns AnaglyphArcRotateCamera
  39471. */
  39472. getClassName(): string;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39479. */
  39480. export class AnaglyphFreeCamera extends FreeCamera {
  39481. /**
  39482. * Creates a new AnaglyphFreeCamera
  39483. * @param name defines camera name
  39484. * @param position defines initial position
  39485. * @param interaxialDistance defines distance between each color axis
  39486. * @param scene defines the hosting scene
  39487. */
  39488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39489. /**
  39490. * Gets camera class name
  39491. * @returns AnaglyphFreeCamera
  39492. */
  39493. getClassName(): string;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39499. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39500. */
  39501. export class AnaglyphGamepadCamera extends GamepadCamera {
  39502. /**
  39503. * Creates a new AnaglyphGamepadCamera
  39504. * @param name defines camera name
  39505. * @param position defines initial position
  39506. * @param interaxialDistance defines distance between each color axis
  39507. * @param scene defines the hosting scene
  39508. */
  39509. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39510. /**
  39511. * Gets camera class name
  39512. * @returns AnaglyphGamepadCamera
  39513. */
  39514. getClassName(): string;
  39515. }
  39516. }
  39517. declare module BABYLON {
  39518. /**
  39519. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39520. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39521. */
  39522. export class AnaglyphUniversalCamera extends UniversalCamera {
  39523. /**
  39524. * Creates a new AnaglyphUniversalCamera
  39525. * @param name defines camera name
  39526. * @param position defines initial position
  39527. * @param interaxialDistance defines distance between each color axis
  39528. * @param scene defines the hosting scene
  39529. */
  39530. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39531. /**
  39532. * Gets camera class name
  39533. * @returns AnaglyphUniversalCamera
  39534. */
  39535. getClassName(): string;
  39536. }
  39537. }
  39538. declare module BABYLON {
  39539. /** @hidden */
  39540. export var stereoscopicInterlacePixelShader: {
  39541. name: string;
  39542. shader: string;
  39543. };
  39544. }
  39545. declare module BABYLON {
  39546. /**
  39547. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39548. */
  39549. export class StereoscopicInterlacePostProcess extends PostProcess {
  39550. private _stepSize;
  39551. private _passedProcess;
  39552. /**
  39553. * Initializes a StereoscopicInterlacePostProcess
  39554. * @param name The name of the effect.
  39555. * @param rigCameras The rig cameras to be appled to the post process
  39556. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39558. * @param engine The engine which the post process will be applied. (default: current engine)
  39559. * @param reusable If the post process can be reused on the same frame. (default: false)
  39560. */
  39561. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39562. }
  39563. }
  39564. declare module BABYLON {
  39565. /**
  39566. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39567. * @see http://doc.babylonjs.com/features/cameras
  39568. */
  39569. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39570. /**
  39571. * Creates a new StereoscopicArcRotateCamera
  39572. * @param name defines camera name
  39573. * @param alpha defines alpha angle (in radians)
  39574. * @param beta defines beta angle (in radians)
  39575. * @param radius defines radius
  39576. * @param target defines camera target
  39577. * @param interaxialDistance defines distance between each color axis
  39578. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39579. * @param scene defines the hosting scene
  39580. */
  39581. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39582. /**
  39583. * Gets camera class name
  39584. * @returns StereoscopicArcRotateCamera
  39585. */
  39586. getClassName(): string;
  39587. }
  39588. }
  39589. declare module BABYLON {
  39590. /**
  39591. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39592. * @see http://doc.babylonjs.com/features/cameras
  39593. */
  39594. export class StereoscopicFreeCamera extends FreeCamera {
  39595. /**
  39596. * Creates a new StereoscopicFreeCamera
  39597. * @param name defines camera name
  39598. * @param position defines initial position
  39599. * @param interaxialDistance defines distance between each color axis
  39600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39601. * @param scene defines the hosting scene
  39602. */
  39603. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39604. /**
  39605. * Gets camera class name
  39606. * @returns StereoscopicFreeCamera
  39607. */
  39608. getClassName(): string;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. /**
  39613. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39614. * @see http://doc.babylonjs.com/features/cameras
  39615. */
  39616. export class StereoscopicGamepadCamera extends GamepadCamera {
  39617. /**
  39618. * Creates a new StereoscopicGamepadCamera
  39619. * @param name defines camera name
  39620. * @param position defines initial position
  39621. * @param interaxialDistance defines distance between each color axis
  39622. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39623. * @param scene defines the hosting scene
  39624. */
  39625. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39626. /**
  39627. * Gets camera class name
  39628. * @returns StereoscopicGamepadCamera
  39629. */
  39630. getClassName(): string;
  39631. }
  39632. }
  39633. declare module BABYLON {
  39634. /**
  39635. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39636. * @see http://doc.babylonjs.com/features/cameras
  39637. */
  39638. export class StereoscopicUniversalCamera extends UniversalCamera {
  39639. /**
  39640. * Creates a new StereoscopicUniversalCamera
  39641. * @param name defines camera name
  39642. * @param position defines initial position
  39643. * @param interaxialDistance defines distance between each color axis
  39644. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39645. * @param scene defines the hosting scene
  39646. */
  39647. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39648. /**
  39649. * Gets camera class name
  39650. * @returns StereoscopicUniversalCamera
  39651. */
  39652. getClassName(): string;
  39653. }
  39654. }
  39655. declare module BABYLON {
  39656. /**
  39657. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39658. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39659. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39660. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39661. */
  39662. export class VirtualJoysticksCamera extends FreeCamera {
  39663. /**
  39664. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39665. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39666. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39667. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39668. * @param name Define the name of the camera in the scene
  39669. * @param position Define the start position of the camera in the scene
  39670. * @param scene Define the scene the camera belongs to
  39671. */
  39672. constructor(name: string, position: Vector3, scene: Scene);
  39673. /**
  39674. * Gets the current object class name.
  39675. * @return the class name
  39676. */
  39677. getClassName(): string;
  39678. }
  39679. }
  39680. declare module BABYLON {
  39681. /**
  39682. * This represents all the required metrics to create a VR camera.
  39683. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39684. */
  39685. export class VRCameraMetrics {
  39686. /**
  39687. * Define the horizontal resolution off the screen.
  39688. */
  39689. hResolution: number;
  39690. /**
  39691. * Define the vertical resolution off the screen.
  39692. */
  39693. vResolution: number;
  39694. /**
  39695. * Define the horizontal screen size.
  39696. */
  39697. hScreenSize: number;
  39698. /**
  39699. * Define the vertical screen size.
  39700. */
  39701. vScreenSize: number;
  39702. /**
  39703. * Define the vertical screen center position.
  39704. */
  39705. vScreenCenter: number;
  39706. /**
  39707. * Define the distance of the eyes to the screen.
  39708. */
  39709. eyeToScreenDistance: number;
  39710. /**
  39711. * Define the distance between both lenses
  39712. */
  39713. lensSeparationDistance: number;
  39714. /**
  39715. * Define the distance between both viewer's eyes.
  39716. */
  39717. interpupillaryDistance: number;
  39718. /**
  39719. * Define the distortion factor of the VR postprocess.
  39720. * Please, touch with care.
  39721. */
  39722. distortionK: number[];
  39723. /**
  39724. * Define the chromatic aberration correction factors for the VR post process.
  39725. */
  39726. chromaAbCorrection: number[];
  39727. /**
  39728. * Define the scale factor of the post process.
  39729. * The smaller the better but the slower.
  39730. */
  39731. postProcessScaleFactor: number;
  39732. /**
  39733. * Define an offset for the lens center.
  39734. */
  39735. lensCenterOffset: number;
  39736. /**
  39737. * Define if the current vr camera should compensate the distortion of the lense or not.
  39738. */
  39739. compensateDistortion: boolean;
  39740. /**
  39741. * Defines if multiview should be enabled when rendering (Default: false)
  39742. */
  39743. multiviewEnabled: boolean;
  39744. /**
  39745. * Gets the rendering aspect ratio based on the provided resolutions.
  39746. */
  39747. readonly aspectRatio: number;
  39748. /**
  39749. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39750. */
  39751. readonly aspectRatioFov: number;
  39752. /**
  39753. * @hidden
  39754. */
  39755. readonly leftHMatrix: Matrix;
  39756. /**
  39757. * @hidden
  39758. */
  39759. readonly rightHMatrix: Matrix;
  39760. /**
  39761. * @hidden
  39762. */
  39763. readonly leftPreViewMatrix: Matrix;
  39764. /**
  39765. * @hidden
  39766. */
  39767. readonly rightPreViewMatrix: Matrix;
  39768. /**
  39769. * Get the default VRMetrics based on the most generic setup.
  39770. * @returns the default vr metrics
  39771. */
  39772. static GetDefault(): VRCameraMetrics;
  39773. }
  39774. }
  39775. declare module BABYLON {
  39776. /** @hidden */
  39777. export var vrDistortionCorrectionPixelShader: {
  39778. name: string;
  39779. shader: string;
  39780. };
  39781. }
  39782. declare module BABYLON {
  39783. /**
  39784. * VRDistortionCorrectionPostProcess used for mobile VR
  39785. */
  39786. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39787. private _isRightEye;
  39788. private _distortionFactors;
  39789. private _postProcessScaleFactor;
  39790. private _lensCenterOffset;
  39791. private _scaleIn;
  39792. private _scaleFactor;
  39793. private _lensCenter;
  39794. /**
  39795. * Initializes the VRDistortionCorrectionPostProcess
  39796. * @param name The name of the effect.
  39797. * @param camera The camera to apply the render pass to.
  39798. * @param isRightEye If this is for the right eye distortion
  39799. * @param vrMetrics All the required metrics for the VR camera
  39800. */
  39801. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39802. }
  39803. }
  39804. declare module BABYLON {
  39805. /**
  39806. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39807. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39808. */
  39809. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39810. /**
  39811. * Creates a new VRDeviceOrientationArcRotateCamera
  39812. * @param name defines camera name
  39813. * @param alpha defines the camera rotation along the logitudinal axis
  39814. * @param beta defines the camera rotation along the latitudinal axis
  39815. * @param radius defines the camera distance from its target
  39816. * @param target defines the camera target
  39817. * @param scene defines the scene the camera belongs to
  39818. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39819. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39820. */
  39821. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39822. /**
  39823. * Gets camera class name
  39824. * @returns VRDeviceOrientationArcRotateCamera
  39825. */
  39826. getClassName(): string;
  39827. }
  39828. }
  39829. declare module BABYLON {
  39830. /**
  39831. * Camera used to simulate VR rendering (based on FreeCamera)
  39832. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39833. */
  39834. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39835. /**
  39836. * Creates a new VRDeviceOrientationFreeCamera
  39837. * @param name defines camera name
  39838. * @param position defines the start position of the camera
  39839. * @param scene defines the scene the camera belongs to
  39840. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39841. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39842. */
  39843. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39844. /**
  39845. * Gets camera class name
  39846. * @returns VRDeviceOrientationFreeCamera
  39847. */
  39848. getClassName(): string;
  39849. }
  39850. }
  39851. declare module BABYLON {
  39852. /**
  39853. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39854. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39855. */
  39856. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39857. /**
  39858. * Creates a new VRDeviceOrientationGamepadCamera
  39859. * @param name defines camera name
  39860. * @param position defines the start position of the camera
  39861. * @param scene defines the scene the camera belongs to
  39862. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39863. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39864. */
  39865. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39866. /**
  39867. * Gets camera class name
  39868. * @returns VRDeviceOrientationGamepadCamera
  39869. */
  39870. getClassName(): string;
  39871. }
  39872. }
  39873. declare module BABYLON {
  39874. /**
  39875. * Base class of materials working in push mode in babylon JS
  39876. * @hidden
  39877. */
  39878. export class PushMaterial extends Material {
  39879. protected _activeEffect: Effect;
  39880. protected _normalMatrix: Matrix;
  39881. /**
  39882. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39883. * This means that the material can keep using a previous shader while a new one is being compiled.
  39884. * This is mostly used when shader parallel compilation is supported (true by default)
  39885. */
  39886. allowShaderHotSwapping: boolean;
  39887. constructor(name: string, scene: Scene);
  39888. getEffect(): Effect;
  39889. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39890. /**
  39891. * Binds the given world matrix to the active effect
  39892. *
  39893. * @param world the matrix to bind
  39894. */
  39895. bindOnlyWorldMatrix(world: Matrix): void;
  39896. /**
  39897. * Binds the given normal matrix to the active effect
  39898. *
  39899. * @param normalMatrix the matrix to bind
  39900. */
  39901. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39902. bind(world: Matrix, mesh?: Mesh): void;
  39903. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39904. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. /**
  39909. * This groups all the flags used to control the materials channel.
  39910. */
  39911. export class MaterialFlags {
  39912. private static _DiffuseTextureEnabled;
  39913. /**
  39914. * Are diffuse textures enabled in the application.
  39915. */
  39916. static DiffuseTextureEnabled: boolean;
  39917. private static _AmbientTextureEnabled;
  39918. /**
  39919. * Are ambient textures enabled in the application.
  39920. */
  39921. static AmbientTextureEnabled: boolean;
  39922. private static _OpacityTextureEnabled;
  39923. /**
  39924. * Are opacity textures enabled in the application.
  39925. */
  39926. static OpacityTextureEnabled: boolean;
  39927. private static _ReflectionTextureEnabled;
  39928. /**
  39929. * Are reflection textures enabled in the application.
  39930. */
  39931. static ReflectionTextureEnabled: boolean;
  39932. private static _EmissiveTextureEnabled;
  39933. /**
  39934. * Are emissive textures enabled in the application.
  39935. */
  39936. static EmissiveTextureEnabled: boolean;
  39937. private static _SpecularTextureEnabled;
  39938. /**
  39939. * Are specular textures enabled in the application.
  39940. */
  39941. static SpecularTextureEnabled: boolean;
  39942. private static _BumpTextureEnabled;
  39943. /**
  39944. * Are bump textures enabled in the application.
  39945. */
  39946. static BumpTextureEnabled: boolean;
  39947. private static _LightmapTextureEnabled;
  39948. /**
  39949. * Are lightmap textures enabled in the application.
  39950. */
  39951. static LightmapTextureEnabled: boolean;
  39952. private static _RefractionTextureEnabled;
  39953. /**
  39954. * Are refraction textures enabled in the application.
  39955. */
  39956. static RefractionTextureEnabled: boolean;
  39957. private static _ColorGradingTextureEnabled;
  39958. /**
  39959. * Are color grading textures enabled in the application.
  39960. */
  39961. static ColorGradingTextureEnabled: boolean;
  39962. private static _FresnelEnabled;
  39963. /**
  39964. * Are fresnels enabled in the application.
  39965. */
  39966. static FresnelEnabled: boolean;
  39967. private static _ClearCoatTextureEnabled;
  39968. /**
  39969. * Are clear coat textures enabled in the application.
  39970. */
  39971. static ClearCoatTextureEnabled: boolean;
  39972. private static _ClearCoatBumpTextureEnabled;
  39973. /**
  39974. * Are clear coat bump textures enabled in the application.
  39975. */
  39976. static ClearCoatBumpTextureEnabled: boolean;
  39977. private static _ClearCoatTintTextureEnabled;
  39978. /**
  39979. * Are clear coat tint textures enabled in the application.
  39980. */
  39981. static ClearCoatTintTextureEnabled: boolean;
  39982. private static _SheenTextureEnabled;
  39983. /**
  39984. * Are sheen textures enabled in the application.
  39985. */
  39986. static SheenTextureEnabled: boolean;
  39987. private static _AnisotropicTextureEnabled;
  39988. /**
  39989. * Are anisotropic textures enabled in the application.
  39990. */
  39991. static AnisotropicTextureEnabled: boolean;
  39992. private static _ThicknessTextureEnabled;
  39993. /**
  39994. * Are thickness textures enabled in the application.
  39995. */
  39996. static ThicknessTextureEnabled: boolean;
  39997. }
  39998. }
  39999. declare module BABYLON {
  40000. /** @hidden */
  40001. export var defaultFragmentDeclaration: {
  40002. name: string;
  40003. shader: string;
  40004. };
  40005. }
  40006. declare module BABYLON {
  40007. /** @hidden */
  40008. export var defaultUboDeclaration: {
  40009. name: string;
  40010. shader: string;
  40011. };
  40012. }
  40013. declare module BABYLON {
  40014. /** @hidden */
  40015. export var lightFragmentDeclaration: {
  40016. name: string;
  40017. shader: string;
  40018. };
  40019. }
  40020. declare module BABYLON {
  40021. /** @hidden */
  40022. export var lightUboDeclaration: {
  40023. name: string;
  40024. shader: string;
  40025. };
  40026. }
  40027. declare module BABYLON {
  40028. /** @hidden */
  40029. export var lightsFragmentFunctions: {
  40030. name: string;
  40031. shader: string;
  40032. };
  40033. }
  40034. declare module BABYLON {
  40035. /** @hidden */
  40036. export var shadowsFragmentFunctions: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module BABYLON {
  40042. /** @hidden */
  40043. export var fresnelFunction: {
  40044. name: string;
  40045. shader: string;
  40046. };
  40047. }
  40048. declare module BABYLON {
  40049. /** @hidden */
  40050. export var reflectionFunction: {
  40051. name: string;
  40052. shader: string;
  40053. };
  40054. }
  40055. declare module BABYLON {
  40056. /** @hidden */
  40057. export var bumpFragmentFunctions: {
  40058. name: string;
  40059. shader: string;
  40060. };
  40061. }
  40062. declare module BABYLON {
  40063. /** @hidden */
  40064. export var logDepthDeclaration: {
  40065. name: string;
  40066. shader: string;
  40067. };
  40068. }
  40069. declare module BABYLON {
  40070. /** @hidden */
  40071. export var bumpFragment: {
  40072. name: string;
  40073. shader: string;
  40074. };
  40075. }
  40076. declare module BABYLON {
  40077. /** @hidden */
  40078. export var depthPrePass: {
  40079. name: string;
  40080. shader: string;
  40081. };
  40082. }
  40083. declare module BABYLON {
  40084. /** @hidden */
  40085. export var lightFragment: {
  40086. name: string;
  40087. shader: string;
  40088. };
  40089. }
  40090. declare module BABYLON {
  40091. /** @hidden */
  40092. export var logDepthFragment: {
  40093. name: string;
  40094. shader: string;
  40095. };
  40096. }
  40097. declare module BABYLON {
  40098. /** @hidden */
  40099. export var defaultPixelShader: {
  40100. name: string;
  40101. shader: string;
  40102. };
  40103. }
  40104. declare module BABYLON {
  40105. /** @hidden */
  40106. export var defaultVertexDeclaration: {
  40107. name: string;
  40108. shader: string;
  40109. };
  40110. }
  40111. declare module BABYLON {
  40112. /** @hidden */
  40113. export var bumpVertexDeclaration: {
  40114. name: string;
  40115. shader: string;
  40116. };
  40117. }
  40118. declare module BABYLON {
  40119. /** @hidden */
  40120. export var bumpVertex: {
  40121. name: string;
  40122. shader: string;
  40123. };
  40124. }
  40125. declare module BABYLON {
  40126. /** @hidden */
  40127. export var fogVertex: {
  40128. name: string;
  40129. shader: string;
  40130. };
  40131. }
  40132. declare module BABYLON {
  40133. /** @hidden */
  40134. export var shadowsVertex: {
  40135. name: string;
  40136. shader: string;
  40137. };
  40138. }
  40139. declare module BABYLON {
  40140. /** @hidden */
  40141. export var pointCloudVertex: {
  40142. name: string;
  40143. shader: string;
  40144. };
  40145. }
  40146. declare module BABYLON {
  40147. /** @hidden */
  40148. export var logDepthVertex: {
  40149. name: string;
  40150. shader: string;
  40151. };
  40152. }
  40153. declare module BABYLON {
  40154. /** @hidden */
  40155. export var defaultVertexShader: {
  40156. name: string;
  40157. shader: string;
  40158. };
  40159. }
  40160. declare module BABYLON {
  40161. /** @hidden */
  40162. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40163. MAINUV1: boolean;
  40164. MAINUV2: boolean;
  40165. DIFFUSE: boolean;
  40166. DIFFUSEDIRECTUV: number;
  40167. AMBIENT: boolean;
  40168. AMBIENTDIRECTUV: number;
  40169. OPACITY: boolean;
  40170. OPACITYDIRECTUV: number;
  40171. OPACITYRGB: boolean;
  40172. REFLECTION: boolean;
  40173. EMISSIVE: boolean;
  40174. EMISSIVEDIRECTUV: number;
  40175. SPECULAR: boolean;
  40176. SPECULARDIRECTUV: number;
  40177. BUMP: boolean;
  40178. BUMPDIRECTUV: number;
  40179. PARALLAX: boolean;
  40180. PARALLAXOCCLUSION: boolean;
  40181. SPECULAROVERALPHA: boolean;
  40182. CLIPPLANE: boolean;
  40183. CLIPPLANE2: boolean;
  40184. CLIPPLANE3: boolean;
  40185. CLIPPLANE4: boolean;
  40186. ALPHATEST: boolean;
  40187. DEPTHPREPASS: boolean;
  40188. ALPHAFROMDIFFUSE: boolean;
  40189. POINTSIZE: boolean;
  40190. FOG: boolean;
  40191. SPECULARTERM: boolean;
  40192. DIFFUSEFRESNEL: boolean;
  40193. OPACITYFRESNEL: boolean;
  40194. REFLECTIONFRESNEL: boolean;
  40195. REFRACTIONFRESNEL: boolean;
  40196. EMISSIVEFRESNEL: boolean;
  40197. FRESNEL: boolean;
  40198. NORMAL: boolean;
  40199. UV1: boolean;
  40200. UV2: boolean;
  40201. VERTEXCOLOR: boolean;
  40202. VERTEXALPHA: boolean;
  40203. NUM_BONE_INFLUENCERS: number;
  40204. BonesPerMesh: number;
  40205. BONETEXTURE: boolean;
  40206. INSTANCES: boolean;
  40207. GLOSSINESS: boolean;
  40208. ROUGHNESS: boolean;
  40209. EMISSIVEASILLUMINATION: boolean;
  40210. LINKEMISSIVEWITHDIFFUSE: boolean;
  40211. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40212. LIGHTMAP: boolean;
  40213. LIGHTMAPDIRECTUV: number;
  40214. OBJECTSPACE_NORMALMAP: boolean;
  40215. USELIGHTMAPASSHADOWMAP: boolean;
  40216. REFLECTIONMAP_3D: boolean;
  40217. REFLECTIONMAP_SPHERICAL: boolean;
  40218. REFLECTIONMAP_PLANAR: boolean;
  40219. REFLECTIONMAP_CUBIC: boolean;
  40220. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40221. REFLECTIONMAP_PROJECTION: boolean;
  40222. REFLECTIONMAP_SKYBOX: boolean;
  40223. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40224. REFLECTIONMAP_EXPLICIT: boolean;
  40225. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40226. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40227. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40228. INVERTCUBICMAP: boolean;
  40229. LOGARITHMICDEPTH: boolean;
  40230. REFRACTION: boolean;
  40231. REFRACTIONMAP_3D: boolean;
  40232. REFLECTIONOVERALPHA: boolean;
  40233. TWOSIDEDLIGHTING: boolean;
  40234. SHADOWFLOAT: boolean;
  40235. MORPHTARGETS: boolean;
  40236. MORPHTARGETS_NORMAL: boolean;
  40237. MORPHTARGETS_TANGENT: boolean;
  40238. MORPHTARGETS_UV: boolean;
  40239. NUM_MORPH_INFLUENCERS: number;
  40240. NONUNIFORMSCALING: boolean;
  40241. PREMULTIPLYALPHA: boolean;
  40242. IMAGEPROCESSING: boolean;
  40243. VIGNETTE: boolean;
  40244. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40245. VIGNETTEBLENDMODEOPAQUE: boolean;
  40246. TONEMAPPING: boolean;
  40247. TONEMAPPING_ACES: boolean;
  40248. CONTRAST: boolean;
  40249. COLORCURVES: boolean;
  40250. COLORGRADING: boolean;
  40251. COLORGRADING3D: boolean;
  40252. SAMPLER3DGREENDEPTH: boolean;
  40253. SAMPLER3DBGRMAP: boolean;
  40254. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40255. MULTIVIEW: boolean;
  40256. /**
  40257. * If the reflection texture on this material is in linear color space
  40258. * @hidden
  40259. */
  40260. IS_REFLECTION_LINEAR: boolean;
  40261. /**
  40262. * If the refraction texture on this material is in linear color space
  40263. * @hidden
  40264. */
  40265. IS_REFRACTION_LINEAR: boolean;
  40266. EXPOSURE: boolean;
  40267. constructor();
  40268. setReflectionMode(modeToEnable: string): void;
  40269. }
  40270. /**
  40271. * This is the default material used in Babylon. It is the best trade off between quality
  40272. * and performances.
  40273. * @see http://doc.babylonjs.com/babylon101/materials
  40274. */
  40275. export class StandardMaterial extends PushMaterial {
  40276. private _diffuseTexture;
  40277. /**
  40278. * The basic texture of the material as viewed under a light.
  40279. */
  40280. diffuseTexture: Nullable<BaseTexture>;
  40281. private _ambientTexture;
  40282. /**
  40283. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40284. */
  40285. ambientTexture: Nullable<BaseTexture>;
  40286. private _opacityTexture;
  40287. /**
  40288. * Define the transparency of the material from a texture.
  40289. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40290. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40291. */
  40292. opacityTexture: Nullable<BaseTexture>;
  40293. private _reflectionTexture;
  40294. /**
  40295. * Define the texture used to display the reflection.
  40296. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40297. */
  40298. reflectionTexture: Nullable<BaseTexture>;
  40299. private _emissiveTexture;
  40300. /**
  40301. * Define texture of the material as if self lit.
  40302. * This will be mixed in the final result even in the absence of light.
  40303. */
  40304. emissiveTexture: Nullable<BaseTexture>;
  40305. private _specularTexture;
  40306. /**
  40307. * Define how the color and intensity of the highlight given by the light in the material.
  40308. */
  40309. specularTexture: Nullable<BaseTexture>;
  40310. private _bumpTexture;
  40311. /**
  40312. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40313. * 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.
  40314. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40315. */
  40316. bumpTexture: Nullable<BaseTexture>;
  40317. private _lightmapTexture;
  40318. /**
  40319. * Complex lighting can be computationally expensive to compute at runtime.
  40320. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40321. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40322. */
  40323. lightmapTexture: Nullable<BaseTexture>;
  40324. private _refractionTexture;
  40325. /**
  40326. * Define the texture used to display the refraction.
  40327. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40328. */
  40329. refractionTexture: Nullable<BaseTexture>;
  40330. /**
  40331. * The color of the material lit by the environmental background lighting.
  40332. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40333. */
  40334. ambientColor: Color3;
  40335. /**
  40336. * The basic color of the material as viewed under a light.
  40337. */
  40338. diffuseColor: Color3;
  40339. /**
  40340. * Define how the color and intensity of the highlight given by the light in the material.
  40341. */
  40342. specularColor: Color3;
  40343. /**
  40344. * Define the color of the material as if self lit.
  40345. * This will be mixed in the final result even in the absence of light.
  40346. */
  40347. emissiveColor: Color3;
  40348. /**
  40349. * Defines how sharp are the highlights in the material.
  40350. * The bigger the value the sharper giving a more glossy feeling to the result.
  40351. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40352. */
  40353. specularPower: number;
  40354. private _useAlphaFromDiffuseTexture;
  40355. /**
  40356. * Does the transparency come from the diffuse texture alpha channel.
  40357. */
  40358. useAlphaFromDiffuseTexture: boolean;
  40359. private _useEmissiveAsIllumination;
  40360. /**
  40361. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40362. */
  40363. useEmissiveAsIllumination: boolean;
  40364. private _linkEmissiveWithDiffuse;
  40365. /**
  40366. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40367. * the emissive level when the final color is close to one.
  40368. */
  40369. linkEmissiveWithDiffuse: boolean;
  40370. private _useSpecularOverAlpha;
  40371. /**
  40372. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40373. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40374. */
  40375. useSpecularOverAlpha: boolean;
  40376. private _useReflectionOverAlpha;
  40377. /**
  40378. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40379. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40380. */
  40381. useReflectionOverAlpha: boolean;
  40382. private _disableLighting;
  40383. /**
  40384. * Does lights from the scene impacts this material.
  40385. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40386. */
  40387. disableLighting: boolean;
  40388. private _useObjectSpaceNormalMap;
  40389. /**
  40390. * Allows using an object space normal map (instead of tangent space).
  40391. */
  40392. useObjectSpaceNormalMap: boolean;
  40393. private _useParallax;
  40394. /**
  40395. * Is parallax enabled or not.
  40396. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40397. */
  40398. useParallax: boolean;
  40399. private _useParallaxOcclusion;
  40400. /**
  40401. * Is parallax occlusion enabled or not.
  40402. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40403. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40404. */
  40405. useParallaxOcclusion: boolean;
  40406. /**
  40407. * 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.
  40408. */
  40409. parallaxScaleBias: number;
  40410. private _roughness;
  40411. /**
  40412. * Helps to define how blurry the reflections should appears in the material.
  40413. */
  40414. roughness: number;
  40415. /**
  40416. * In case of refraction, define the value of the index of refraction.
  40417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40418. */
  40419. indexOfRefraction: number;
  40420. /**
  40421. * Invert the refraction texture alongside the y axis.
  40422. * It can be useful with procedural textures or probe for instance.
  40423. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40424. */
  40425. invertRefractionY: boolean;
  40426. /**
  40427. * Defines the alpha limits in alpha test mode.
  40428. */
  40429. alphaCutOff: number;
  40430. private _useLightmapAsShadowmap;
  40431. /**
  40432. * In case of light mapping, define whether the map contains light or shadow informations.
  40433. */
  40434. useLightmapAsShadowmap: boolean;
  40435. private _diffuseFresnelParameters;
  40436. /**
  40437. * Define the diffuse fresnel parameters of the material.
  40438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40439. */
  40440. diffuseFresnelParameters: FresnelParameters;
  40441. private _opacityFresnelParameters;
  40442. /**
  40443. * Define the opacity fresnel parameters of the material.
  40444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40445. */
  40446. opacityFresnelParameters: FresnelParameters;
  40447. private _reflectionFresnelParameters;
  40448. /**
  40449. * Define the reflection fresnel parameters of the material.
  40450. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40451. */
  40452. reflectionFresnelParameters: FresnelParameters;
  40453. private _refractionFresnelParameters;
  40454. /**
  40455. * Define the refraction fresnel parameters of the material.
  40456. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40457. */
  40458. refractionFresnelParameters: FresnelParameters;
  40459. private _emissiveFresnelParameters;
  40460. /**
  40461. * Define the emissive fresnel parameters of the material.
  40462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40463. */
  40464. emissiveFresnelParameters: FresnelParameters;
  40465. private _useReflectionFresnelFromSpecular;
  40466. /**
  40467. * If true automatically deducts the fresnels values from the material specularity.
  40468. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40469. */
  40470. useReflectionFresnelFromSpecular: boolean;
  40471. private _useGlossinessFromSpecularMapAlpha;
  40472. /**
  40473. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40474. */
  40475. useGlossinessFromSpecularMapAlpha: boolean;
  40476. private _maxSimultaneousLights;
  40477. /**
  40478. * Defines the maximum number of lights that can be used in the material
  40479. */
  40480. maxSimultaneousLights: number;
  40481. private _invertNormalMapX;
  40482. /**
  40483. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40484. */
  40485. invertNormalMapX: boolean;
  40486. private _invertNormalMapY;
  40487. /**
  40488. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40489. */
  40490. invertNormalMapY: boolean;
  40491. private _twoSidedLighting;
  40492. /**
  40493. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40494. */
  40495. twoSidedLighting: boolean;
  40496. /**
  40497. * Default configuration related to image processing available in the standard Material.
  40498. */
  40499. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40500. /**
  40501. * Gets the image processing configuration used either in this material.
  40502. */
  40503. /**
  40504. * Sets the Default image processing configuration used either in the this material.
  40505. *
  40506. * If sets to null, the scene one is in use.
  40507. */
  40508. imageProcessingConfiguration: ImageProcessingConfiguration;
  40509. /**
  40510. * Keep track of the image processing observer to allow dispose and replace.
  40511. */
  40512. private _imageProcessingObserver;
  40513. /**
  40514. * Attaches a new image processing configuration to the Standard Material.
  40515. * @param configuration
  40516. */
  40517. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40518. /**
  40519. * Gets wether the color curves effect is enabled.
  40520. */
  40521. /**
  40522. * Sets wether the color curves effect is enabled.
  40523. */
  40524. cameraColorCurvesEnabled: boolean;
  40525. /**
  40526. * Gets wether the color grading effect is enabled.
  40527. */
  40528. /**
  40529. * Gets wether the color grading effect is enabled.
  40530. */
  40531. cameraColorGradingEnabled: boolean;
  40532. /**
  40533. * Gets wether tonemapping is enabled or not.
  40534. */
  40535. /**
  40536. * Sets wether tonemapping is enabled or not
  40537. */
  40538. cameraToneMappingEnabled: boolean;
  40539. /**
  40540. * The camera exposure used on this material.
  40541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40542. * This corresponds to a photographic exposure.
  40543. */
  40544. /**
  40545. * The camera exposure used on this material.
  40546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40547. * This corresponds to a photographic exposure.
  40548. */
  40549. cameraExposure: number;
  40550. /**
  40551. * Gets The camera contrast used on this material.
  40552. */
  40553. /**
  40554. * Sets The camera contrast used on this material.
  40555. */
  40556. cameraContrast: number;
  40557. /**
  40558. * Gets the Color Grading 2D Lookup Texture.
  40559. */
  40560. /**
  40561. * Sets the Color Grading 2D Lookup Texture.
  40562. */
  40563. cameraColorGradingTexture: Nullable<BaseTexture>;
  40564. /**
  40565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40567. * 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;
  40568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40569. */
  40570. /**
  40571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40573. * 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;
  40574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40575. */
  40576. cameraColorCurves: Nullable<ColorCurves>;
  40577. /**
  40578. * Custom callback helping to override the default shader used in the material.
  40579. */
  40580. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40581. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40582. protected _worldViewProjectionMatrix: Matrix;
  40583. protected _globalAmbientColor: Color3;
  40584. protected _useLogarithmicDepth: boolean;
  40585. protected _rebuildInParallel: boolean;
  40586. /**
  40587. * Instantiates a new standard material.
  40588. * This is the default material used in Babylon. It is the best trade off between quality
  40589. * and performances.
  40590. * @see http://doc.babylonjs.com/babylon101/materials
  40591. * @param name Define the name of the material in the scene
  40592. * @param scene Define the scene the material belong to
  40593. */
  40594. constructor(name: string, scene: Scene);
  40595. /**
  40596. * Gets a boolean indicating that current material needs to register RTT
  40597. */
  40598. readonly hasRenderTargetTextures: boolean;
  40599. /**
  40600. * Gets the current class name of the material e.g. "StandardMaterial"
  40601. * Mainly use in serialization.
  40602. * @returns the class name
  40603. */
  40604. getClassName(): string;
  40605. /**
  40606. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40607. * You can try switching to logarithmic depth.
  40608. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40609. */
  40610. useLogarithmicDepth: boolean;
  40611. /**
  40612. * Specifies if the material will require alpha blending
  40613. * @returns a boolean specifying if alpha blending is needed
  40614. */
  40615. needAlphaBlending(): boolean;
  40616. /**
  40617. * Specifies if this material should be rendered in alpha test mode
  40618. * @returns a boolean specifying if an alpha test is needed.
  40619. */
  40620. needAlphaTesting(): boolean;
  40621. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40622. /**
  40623. * Get the texture used for alpha test purpose.
  40624. * @returns the diffuse texture in case of the standard material.
  40625. */
  40626. getAlphaTestTexture(): Nullable<BaseTexture>;
  40627. /**
  40628. * Get if the submesh is ready to be used and all its information available.
  40629. * Child classes can use it to update shaders
  40630. * @param mesh defines the mesh to check
  40631. * @param subMesh defines which submesh to check
  40632. * @param useInstances specifies that instances should be used
  40633. * @returns a boolean indicating that the submesh is ready or not
  40634. */
  40635. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40636. /**
  40637. * Builds the material UBO layouts.
  40638. * Used internally during the effect preparation.
  40639. */
  40640. buildUniformLayout(): void;
  40641. /**
  40642. * Unbinds the material from the mesh
  40643. */
  40644. unbind(): void;
  40645. /**
  40646. * Binds the submesh to this material by preparing the effect and shader to draw
  40647. * @param world defines the world transformation matrix
  40648. * @param mesh defines the mesh containing the submesh
  40649. * @param subMesh defines the submesh to bind the material to
  40650. */
  40651. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40652. /**
  40653. * Get the list of animatables in the material.
  40654. * @returns the list of animatables object used in the material
  40655. */
  40656. getAnimatables(): IAnimatable[];
  40657. /**
  40658. * Gets the active textures from the material
  40659. * @returns an array of textures
  40660. */
  40661. getActiveTextures(): BaseTexture[];
  40662. /**
  40663. * Specifies if the material uses a texture
  40664. * @param texture defines the texture to check against the material
  40665. * @returns a boolean specifying if the material uses the texture
  40666. */
  40667. hasTexture(texture: BaseTexture): boolean;
  40668. /**
  40669. * Disposes the material
  40670. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40671. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40672. */
  40673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40674. /**
  40675. * Makes a duplicate of the material, and gives it a new name
  40676. * @param name defines the new name for the duplicated material
  40677. * @returns the cloned material
  40678. */
  40679. clone(name: string): StandardMaterial;
  40680. /**
  40681. * Serializes this material in a JSON representation
  40682. * @returns the serialized material object
  40683. */
  40684. serialize(): any;
  40685. /**
  40686. * Creates a standard material from parsed material data
  40687. * @param source defines the JSON representation of the material
  40688. * @param scene defines the hosting scene
  40689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40690. * @returns a new standard material
  40691. */
  40692. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40693. /**
  40694. * Are diffuse textures enabled in the application.
  40695. */
  40696. static DiffuseTextureEnabled: boolean;
  40697. /**
  40698. * Are ambient textures enabled in the application.
  40699. */
  40700. static AmbientTextureEnabled: boolean;
  40701. /**
  40702. * Are opacity textures enabled in the application.
  40703. */
  40704. static OpacityTextureEnabled: boolean;
  40705. /**
  40706. * Are reflection textures enabled in the application.
  40707. */
  40708. static ReflectionTextureEnabled: boolean;
  40709. /**
  40710. * Are emissive textures enabled in the application.
  40711. */
  40712. static EmissiveTextureEnabled: boolean;
  40713. /**
  40714. * Are specular textures enabled in the application.
  40715. */
  40716. static SpecularTextureEnabled: boolean;
  40717. /**
  40718. * Are bump textures enabled in the application.
  40719. */
  40720. static BumpTextureEnabled: boolean;
  40721. /**
  40722. * Are lightmap textures enabled in the application.
  40723. */
  40724. static LightmapTextureEnabled: boolean;
  40725. /**
  40726. * Are refraction textures enabled in the application.
  40727. */
  40728. static RefractionTextureEnabled: boolean;
  40729. /**
  40730. * Are color grading textures enabled in the application.
  40731. */
  40732. static ColorGradingTextureEnabled: boolean;
  40733. /**
  40734. * Are fresnels enabled in the application.
  40735. */
  40736. static FresnelEnabled: boolean;
  40737. }
  40738. }
  40739. declare module BABYLON {
  40740. /** @hidden */
  40741. export var imageProcessingPixelShader: {
  40742. name: string;
  40743. shader: string;
  40744. };
  40745. }
  40746. declare module BABYLON {
  40747. /**
  40748. * ImageProcessingPostProcess
  40749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40750. */
  40751. export class ImageProcessingPostProcess extends PostProcess {
  40752. /**
  40753. * Default configuration related to image processing available in the PBR Material.
  40754. */
  40755. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40756. /**
  40757. * Gets the image processing configuration used either in this material.
  40758. */
  40759. /**
  40760. * Sets the Default image processing configuration used either in the this material.
  40761. *
  40762. * If sets to null, the scene one is in use.
  40763. */
  40764. imageProcessingConfiguration: ImageProcessingConfiguration;
  40765. /**
  40766. * Keep track of the image processing observer to allow dispose and replace.
  40767. */
  40768. private _imageProcessingObserver;
  40769. /**
  40770. * Attaches a new image processing configuration to the PBR Material.
  40771. * @param configuration
  40772. */
  40773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40774. /**
  40775. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40776. */
  40777. /**
  40778. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40779. */
  40780. colorCurves: Nullable<ColorCurves>;
  40781. /**
  40782. * Gets wether the color curves effect is enabled.
  40783. */
  40784. /**
  40785. * Sets wether the color curves effect is enabled.
  40786. */
  40787. colorCurvesEnabled: boolean;
  40788. /**
  40789. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40790. */
  40791. /**
  40792. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40793. */
  40794. colorGradingTexture: Nullable<BaseTexture>;
  40795. /**
  40796. * Gets wether the color grading effect is enabled.
  40797. */
  40798. /**
  40799. * Gets wether the color grading effect is enabled.
  40800. */
  40801. colorGradingEnabled: boolean;
  40802. /**
  40803. * Gets exposure used in the effect.
  40804. */
  40805. /**
  40806. * Sets exposure used in the effect.
  40807. */
  40808. exposure: number;
  40809. /**
  40810. * Gets wether tonemapping is enabled or not.
  40811. */
  40812. /**
  40813. * Sets wether tonemapping is enabled or not
  40814. */
  40815. toneMappingEnabled: boolean;
  40816. /**
  40817. * Gets the type of tone mapping effect.
  40818. */
  40819. /**
  40820. * Sets the type of tone mapping effect.
  40821. */
  40822. toneMappingType: number;
  40823. /**
  40824. * Gets contrast used in the effect.
  40825. */
  40826. /**
  40827. * Sets contrast used in the effect.
  40828. */
  40829. contrast: number;
  40830. /**
  40831. * Gets Vignette stretch size.
  40832. */
  40833. /**
  40834. * Sets Vignette stretch size.
  40835. */
  40836. vignetteStretch: number;
  40837. /**
  40838. * Gets Vignette centre X Offset.
  40839. */
  40840. /**
  40841. * Sets Vignette centre X Offset.
  40842. */
  40843. vignetteCentreX: number;
  40844. /**
  40845. * Gets Vignette centre Y Offset.
  40846. */
  40847. /**
  40848. * Sets Vignette centre Y Offset.
  40849. */
  40850. vignetteCentreY: number;
  40851. /**
  40852. * Gets Vignette weight or intensity of the vignette effect.
  40853. */
  40854. /**
  40855. * Sets Vignette weight or intensity of the vignette effect.
  40856. */
  40857. vignetteWeight: number;
  40858. /**
  40859. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40860. * if vignetteEnabled is set to true.
  40861. */
  40862. /**
  40863. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40864. * if vignetteEnabled is set to true.
  40865. */
  40866. vignetteColor: Color4;
  40867. /**
  40868. * Gets Camera field of view used by the Vignette effect.
  40869. */
  40870. /**
  40871. * Sets Camera field of view used by the Vignette effect.
  40872. */
  40873. vignetteCameraFov: number;
  40874. /**
  40875. * Gets the vignette blend mode allowing different kind of effect.
  40876. */
  40877. /**
  40878. * Sets the vignette blend mode allowing different kind of effect.
  40879. */
  40880. vignetteBlendMode: number;
  40881. /**
  40882. * Gets wether the vignette effect is enabled.
  40883. */
  40884. /**
  40885. * Sets wether the vignette effect is enabled.
  40886. */
  40887. vignetteEnabled: boolean;
  40888. private _fromLinearSpace;
  40889. /**
  40890. * Gets wether the input of the processing is in Gamma or Linear Space.
  40891. */
  40892. /**
  40893. * Sets wether the input of the processing is in Gamma or Linear Space.
  40894. */
  40895. fromLinearSpace: boolean;
  40896. /**
  40897. * Defines cache preventing GC.
  40898. */
  40899. private _defines;
  40900. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40901. /**
  40902. * "ImageProcessingPostProcess"
  40903. * @returns "ImageProcessingPostProcess"
  40904. */
  40905. getClassName(): string;
  40906. protected _updateParameters(): void;
  40907. dispose(camera?: Camera): void;
  40908. }
  40909. }
  40910. declare module BABYLON {
  40911. /**
  40912. * Class containing static functions to help procedurally build meshes
  40913. */
  40914. export class GroundBuilder {
  40915. /**
  40916. * Creates a ground mesh
  40917. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40918. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40920. * @param name defines the name of the mesh
  40921. * @param options defines the options used to create the mesh
  40922. * @param scene defines the hosting scene
  40923. * @returns the ground mesh
  40924. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40925. */
  40926. static CreateGround(name: string, options: {
  40927. width?: number;
  40928. height?: number;
  40929. subdivisions?: number;
  40930. subdivisionsX?: number;
  40931. subdivisionsY?: number;
  40932. updatable?: boolean;
  40933. }, scene: any): Mesh;
  40934. /**
  40935. * Creates a tiled ground mesh
  40936. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40937. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40938. * * 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
  40939. * * 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
  40940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40941. * @param name defines the name of the mesh
  40942. * @param options defines the options used to create the mesh
  40943. * @param scene defines the hosting scene
  40944. * @returns the tiled ground mesh
  40945. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40946. */
  40947. static CreateTiledGround(name: string, options: {
  40948. xmin: number;
  40949. zmin: number;
  40950. xmax: number;
  40951. zmax: number;
  40952. subdivisions?: {
  40953. w: number;
  40954. h: number;
  40955. };
  40956. precision?: {
  40957. w: number;
  40958. h: number;
  40959. };
  40960. updatable?: boolean;
  40961. }, scene?: Nullable<Scene>): Mesh;
  40962. /**
  40963. * Creates a ground mesh from a height map
  40964. * * The parameter `url` sets the URL of the height map image resource.
  40965. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40966. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40967. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40968. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40969. * * 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.
  40970. * * 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).
  40971. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40973. * @param name defines the name of the mesh
  40974. * @param url defines the url to the height map
  40975. * @param options defines the options used to create the mesh
  40976. * @param scene defines the hosting scene
  40977. * @returns the ground mesh
  40978. * @see https://doc.babylonjs.com/babylon101/height_map
  40979. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40980. */
  40981. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40982. width?: number;
  40983. height?: number;
  40984. subdivisions?: number;
  40985. minHeight?: number;
  40986. maxHeight?: number;
  40987. colorFilter?: Color3;
  40988. alphaFilter?: number;
  40989. updatable?: boolean;
  40990. onReady?: (mesh: GroundMesh) => void;
  40991. }, scene?: Nullable<Scene>): GroundMesh;
  40992. }
  40993. }
  40994. declare module BABYLON {
  40995. /**
  40996. * Class containing static functions to help procedurally build meshes
  40997. */
  40998. export class TorusBuilder {
  40999. /**
  41000. * Creates a torus mesh
  41001. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41002. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41003. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41005. * * 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
  41006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41007. * @param name defines the name of the mesh
  41008. * @param options defines the options used to create the mesh
  41009. * @param scene defines the hosting scene
  41010. * @returns the torus mesh
  41011. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41012. */
  41013. static CreateTorus(name: string, options: {
  41014. diameter?: number;
  41015. thickness?: number;
  41016. tessellation?: number;
  41017. updatable?: boolean;
  41018. sideOrientation?: number;
  41019. frontUVs?: Vector4;
  41020. backUVs?: Vector4;
  41021. }, scene: any): Mesh;
  41022. }
  41023. }
  41024. declare module BABYLON {
  41025. /**
  41026. * Class containing static functions to help procedurally build meshes
  41027. */
  41028. export class CylinderBuilder {
  41029. /**
  41030. * Creates a cylinder or a cone mesh
  41031. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41032. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41033. * * 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.
  41034. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41035. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41036. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41037. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41038. * * 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).
  41039. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41040. * * 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).
  41041. * * 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
  41042. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41043. * * 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
  41044. * * 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.
  41045. * * If `enclose` is false, a ring surface is one element.
  41046. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41047. * * 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
  41048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41049. * * 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
  41050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41051. * @param name defines the name of the mesh
  41052. * @param options defines the options used to create the mesh
  41053. * @param scene defines the hosting scene
  41054. * @returns the cylinder mesh
  41055. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41056. */
  41057. static CreateCylinder(name: string, options: {
  41058. height?: number;
  41059. diameterTop?: number;
  41060. diameterBottom?: number;
  41061. diameter?: number;
  41062. tessellation?: number;
  41063. subdivisions?: number;
  41064. arc?: number;
  41065. faceColors?: Color4[];
  41066. faceUV?: Vector4[];
  41067. updatable?: boolean;
  41068. hasRings?: boolean;
  41069. enclose?: boolean;
  41070. cap?: number;
  41071. sideOrientation?: number;
  41072. frontUVs?: Vector4;
  41073. backUVs?: Vector4;
  41074. }, scene: any): Mesh;
  41075. }
  41076. }
  41077. declare module BABYLON {
  41078. /**
  41079. * Options to modify the vr teleportation behavior.
  41080. */
  41081. export interface VRTeleportationOptions {
  41082. /**
  41083. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41084. */
  41085. floorMeshName?: string;
  41086. /**
  41087. * A list of meshes to be used as the teleportation floor. (default: empty)
  41088. */
  41089. floorMeshes?: Mesh[];
  41090. }
  41091. /**
  41092. * Options to modify the vr experience helper's behavior.
  41093. */
  41094. export interface VRExperienceHelperOptions extends WebVROptions {
  41095. /**
  41096. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41097. */
  41098. createDeviceOrientationCamera?: boolean;
  41099. /**
  41100. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41101. */
  41102. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41103. /**
  41104. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41105. */
  41106. laserToggle?: boolean;
  41107. /**
  41108. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41109. */
  41110. floorMeshes?: Mesh[];
  41111. /**
  41112. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41113. */
  41114. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41115. }
  41116. /**
  41117. * Event containing information after VR has been entered
  41118. */
  41119. export class OnAfterEnteringVRObservableEvent {
  41120. /**
  41121. * If entering vr was successful
  41122. */
  41123. success: boolean;
  41124. }
  41125. /**
  41126. * Helps to quickly add VR support to an existing scene.
  41127. * See http://doc.babylonjs.com/how_to/webvr_helper
  41128. */
  41129. export class VRExperienceHelper {
  41130. /** Options to modify the vr experience helper's behavior. */
  41131. webVROptions: VRExperienceHelperOptions;
  41132. private _scene;
  41133. private _position;
  41134. private _btnVR;
  41135. private _btnVRDisplayed;
  41136. private _webVRsupported;
  41137. private _webVRready;
  41138. private _webVRrequesting;
  41139. private _webVRpresenting;
  41140. private _hasEnteredVR;
  41141. private _fullscreenVRpresenting;
  41142. private _canvas;
  41143. private _webVRCamera;
  41144. private _vrDeviceOrientationCamera;
  41145. private _deviceOrientationCamera;
  41146. private _existingCamera;
  41147. private _onKeyDown;
  41148. private _onVrDisplayPresentChange;
  41149. private _onVRDisplayChanged;
  41150. private _onVRRequestPresentStart;
  41151. private _onVRRequestPresentComplete;
  41152. /**
  41153. * 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)
  41154. */
  41155. enableGazeEvenWhenNoPointerLock: boolean;
  41156. /**
  41157. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41158. */
  41159. exitVROnDoubleTap: boolean;
  41160. /**
  41161. * Observable raised right before entering VR.
  41162. */
  41163. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41164. /**
  41165. * Observable raised when entering VR has completed.
  41166. */
  41167. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41168. /**
  41169. * Observable raised when exiting VR.
  41170. */
  41171. onExitingVRObservable: Observable<VRExperienceHelper>;
  41172. /**
  41173. * Observable raised when controller mesh is loaded.
  41174. */
  41175. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41176. /** Return this.onEnteringVRObservable
  41177. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41178. */
  41179. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41180. /** Return this.onExitingVRObservable
  41181. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41182. */
  41183. readonly onExitingVR: Observable<VRExperienceHelper>;
  41184. /** Return this.onControllerMeshLoadedObservable
  41185. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41186. */
  41187. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41188. private _rayLength;
  41189. private _useCustomVRButton;
  41190. private _teleportationRequested;
  41191. private _teleportActive;
  41192. private _floorMeshName;
  41193. private _floorMeshesCollection;
  41194. private _rotationAllowed;
  41195. private _teleportBackwardsVector;
  41196. private _teleportationTarget;
  41197. private _isDefaultTeleportationTarget;
  41198. private _postProcessMove;
  41199. private _teleportationFillColor;
  41200. private _teleportationBorderColor;
  41201. private _rotationAngle;
  41202. private _haloCenter;
  41203. private _cameraGazer;
  41204. private _padSensibilityUp;
  41205. private _padSensibilityDown;
  41206. private _leftController;
  41207. private _rightController;
  41208. /**
  41209. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41210. */
  41211. onNewMeshSelected: Observable<AbstractMesh>;
  41212. /**
  41213. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41214. * This observable will provide the mesh and the controller used to select the mesh
  41215. */
  41216. onMeshSelectedWithController: Observable<{
  41217. mesh: AbstractMesh;
  41218. controller: WebVRController;
  41219. }>;
  41220. /**
  41221. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41222. */
  41223. onNewMeshPicked: Observable<PickingInfo>;
  41224. private _circleEase;
  41225. /**
  41226. * Observable raised before camera teleportation
  41227. */
  41228. onBeforeCameraTeleport: Observable<Vector3>;
  41229. /**
  41230. * Observable raised after camera teleportation
  41231. */
  41232. onAfterCameraTeleport: Observable<Vector3>;
  41233. /**
  41234. * Observable raised when current selected mesh gets unselected
  41235. */
  41236. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41237. private _raySelectionPredicate;
  41238. /**
  41239. * To be optionaly changed by user to define custom ray selection
  41240. */
  41241. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41242. /**
  41243. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41244. */
  41245. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41246. /**
  41247. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41248. */
  41249. teleportationEnabled: boolean;
  41250. private _defaultHeight;
  41251. private _teleportationInitialized;
  41252. private _interactionsEnabled;
  41253. private _interactionsRequested;
  41254. private _displayGaze;
  41255. private _displayLaserPointer;
  41256. /**
  41257. * The mesh used to display where the user is going to teleport.
  41258. */
  41259. /**
  41260. * Sets the mesh to be used to display where the user is going to teleport.
  41261. */
  41262. teleportationTarget: Mesh;
  41263. /**
  41264. * 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
  41265. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41266. * See http://doc.babylonjs.com/resources/baking_transformations
  41267. */
  41268. gazeTrackerMesh: Mesh;
  41269. /**
  41270. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41271. */
  41272. updateGazeTrackerScale: boolean;
  41273. /**
  41274. * If the gaze trackers color should be updated when selecting meshes
  41275. */
  41276. updateGazeTrackerColor: boolean;
  41277. /**
  41278. * If the controller laser color should be updated when selecting meshes
  41279. */
  41280. updateControllerLaserColor: boolean;
  41281. /**
  41282. * The gaze tracking mesh corresponding to the left controller
  41283. */
  41284. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41285. /**
  41286. * The gaze tracking mesh corresponding to the right controller
  41287. */
  41288. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41289. /**
  41290. * If the ray of the gaze should be displayed.
  41291. */
  41292. /**
  41293. * Sets if the ray of the gaze should be displayed.
  41294. */
  41295. displayGaze: boolean;
  41296. /**
  41297. * If the ray of the LaserPointer should be displayed.
  41298. */
  41299. /**
  41300. * Sets if the ray of the LaserPointer should be displayed.
  41301. */
  41302. displayLaserPointer: boolean;
  41303. /**
  41304. * The deviceOrientationCamera used as the camera when not in VR.
  41305. */
  41306. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41307. /**
  41308. * Based on the current WebVR support, returns the current VR camera used.
  41309. */
  41310. readonly currentVRCamera: Nullable<Camera>;
  41311. /**
  41312. * The webVRCamera which is used when in VR.
  41313. */
  41314. readonly webVRCamera: WebVRFreeCamera;
  41315. /**
  41316. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41317. */
  41318. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41319. /**
  41320. * The html button that is used to trigger entering into VR.
  41321. */
  41322. readonly vrButton: Nullable<HTMLButtonElement>;
  41323. private readonly _teleportationRequestInitiated;
  41324. /**
  41325. * Defines wether or not Pointer lock should be requested when switching to
  41326. * full screen.
  41327. */
  41328. requestPointerLockOnFullScreen: boolean;
  41329. /**
  41330. * Instantiates a VRExperienceHelper.
  41331. * Helps to quickly add VR support to an existing scene.
  41332. * @param scene The scene the VRExperienceHelper belongs to.
  41333. * @param webVROptions Options to modify the vr experience helper's behavior.
  41334. */
  41335. constructor(scene: Scene,
  41336. /** Options to modify the vr experience helper's behavior. */
  41337. webVROptions?: VRExperienceHelperOptions);
  41338. private _onDefaultMeshLoaded;
  41339. private _onResize;
  41340. private _onFullscreenChange;
  41341. /**
  41342. * Gets a value indicating if we are currently in VR mode.
  41343. */
  41344. readonly isInVRMode: boolean;
  41345. private onVrDisplayPresentChange;
  41346. private onVRDisplayChanged;
  41347. private moveButtonToBottomRight;
  41348. private displayVRButton;
  41349. private updateButtonVisibility;
  41350. private _cachedAngularSensibility;
  41351. /**
  41352. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41353. * Otherwise, will use the fullscreen API.
  41354. */
  41355. enterVR(): void;
  41356. /**
  41357. * Attempt to exit VR, or fullscreen.
  41358. */
  41359. exitVR(): void;
  41360. /**
  41361. * The position of the vr experience helper.
  41362. */
  41363. /**
  41364. * Sets the position of the vr experience helper.
  41365. */
  41366. position: Vector3;
  41367. /**
  41368. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41369. */
  41370. enableInteractions(): void;
  41371. private readonly _noControllerIsActive;
  41372. private beforeRender;
  41373. private _isTeleportationFloor;
  41374. /**
  41375. * Adds a floor mesh to be used for teleportation.
  41376. * @param floorMesh the mesh to be used for teleportation.
  41377. */
  41378. addFloorMesh(floorMesh: Mesh): void;
  41379. /**
  41380. * Removes a floor mesh from being used for teleportation.
  41381. * @param floorMesh the mesh to be removed.
  41382. */
  41383. removeFloorMesh(floorMesh: Mesh): void;
  41384. /**
  41385. * Enables interactions and teleportation using the VR controllers and gaze.
  41386. * @param vrTeleportationOptions options to modify teleportation behavior.
  41387. */
  41388. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41389. private _onNewGamepadConnected;
  41390. private _tryEnableInteractionOnController;
  41391. private _onNewGamepadDisconnected;
  41392. private _enableInteractionOnController;
  41393. private _checkTeleportWithRay;
  41394. private _checkRotate;
  41395. private _checkTeleportBackwards;
  41396. private _enableTeleportationOnController;
  41397. private _createTeleportationCircles;
  41398. private _displayTeleportationTarget;
  41399. private _hideTeleportationTarget;
  41400. private _rotateCamera;
  41401. private _moveTeleportationSelectorTo;
  41402. private _workingVector;
  41403. private _workingQuaternion;
  41404. private _workingMatrix;
  41405. /**
  41406. * Teleports the users feet to the desired location
  41407. * @param location The location where the user's feet should be placed
  41408. */
  41409. teleportCamera(location: Vector3): void;
  41410. private _convertNormalToDirectionOfRay;
  41411. private _castRayAndSelectObject;
  41412. private _notifySelectedMeshUnselected;
  41413. /**
  41414. * Sets the color of the laser ray from the vr controllers.
  41415. * @param color new color for the ray.
  41416. */
  41417. changeLaserColor(color: Color3): void;
  41418. /**
  41419. * Sets the color of the ray from the vr headsets gaze.
  41420. * @param color new color for the ray.
  41421. */
  41422. changeGazeColor(color: Color3): void;
  41423. /**
  41424. * Exits VR and disposes of the vr experience helper
  41425. */
  41426. dispose(): void;
  41427. /**
  41428. * Gets the name of the VRExperienceHelper class
  41429. * @returns "VRExperienceHelper"
  41430. */
  41431. getClassName(): string;
  41432. }
  41433. }
  41434. declare module BABYLON {
  41435. /**
  41436. * Manages an XRSession to work with Babylon's engine
  41437. * @see https://doc.babylonjs.com/how_to/webxr
  41438. */
  41439. export class WebXRSessionManager implements IDisposable {
  41440. private scene;
  41441. /**
  41442. * Fires every time a new xrFrame arrives which can be used to update the camera
  41443. */
  41444. onXRFrameObservable: Observable<any>;
  41445. /**
  41446. * Fires when the xr session is ended either by the device or manually done
  41447. */
  41448. onXRSessionEnded: Observable<any>;
  41449. /**
  41450. * Underlying xr session
  41451. */
  41452. session: XRSession;
  41453. /**
  41454. * Type of reference space used when creating the session
  41455. */
  41456. referenceSpace: XRReferenceSpace;
  41457. /** @hidden */
  41458. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41459. /**
  41460. * Current XR frame
  41461. */
  41462. currentFrame: Nullable<XRFrame>;
  41463. private _xrNavigator;
  41464. private baseLayer;
  41465. /**
  41466. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41467. * @param scene The scene which the session should be created for
  41468. */
  41469. constructor(scene: Scene);
  41470. /**
  41471. * Initializes the manager
  41472. * After initialization enterXR can be called to start an XR session
  41473. * @returns Promise which resolves after it is initialized
  41474. */
  41475. initializeAsync(): Promise<void>;
  41476. /**
  41477. * Initializes an xr session
  41478. * @param xrSessionMode mode to initialize
  41479. * @returns a promise which will resolve once the session has been initialized
  41480. */
  41481. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41482. /**
  41483. * Sets the reference space on the xr session
  41484. * @param referenceSpace space to set
  41485. * @returns a promise that will resolve once the reference space has been set
  41486. */
  41487. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41488. /**
  41489. * Updates the render state of the session
  41490. * @param state state to set
  41491. * @returns a promise that resolves once the render state has been updated
  41492. */
  41493. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41494. /**
  41495. * Starts rendering to the xr layer
  41496. * @returns a promise that will resolve once rendering has started
  41497. */
  41498. startRenderingToXRAsync(): Promise<void>;
  41499. /**
  41500. * Stops the xrSession and restores the renderloop
  41501. * @returns Promise which resolves after it exits XR
  41502. */
  41503. exitXRAsync(): Promise<unknown>;
  41504. /**
  41505. * Checks if a session would be supported for the creation options specified
  41506. * @param sessionMode session mode to check if supported eg. immersive-vr
  41507. * @returns true if supported
  41508. */
  41509. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41510. /**
  41511. * @hidden
  41512. * Converts the render layer of xrSession to a render target
  41513. * @param session session to create render target for
  41514. * @param scene scene the new render target should be created for
  41515. */
  41516. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41517. /**
  41518. * Disposes of the session manager
  41519. */
  41520. dispose(): void;
  41521. }
  41522. }
  41523. declare module BABYLON {
  41524. /**
  41525. * WebXR Camera which holds the views for the xrSession
  41526. * @see https://doc.babylonjs.com/how_to/webxr
  41527. */
  41528. export class WebXRCamera extends FreeCamera {
  41529. private static _TmpMatrix;
  41530. /**
  41531. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41532. * @param name the name of the camera
  41533. * @param scene the scene to add the camera to
  41534. */
  41535. constructor(name: string, scene: Scene);
  41536. private _updateNumberOfRigCameras;
  41537. /** @hidden */
  41538. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41539. /**
  41540. * Updates the cameras position from the current pose information of the XR session
  41541. * @param xrSessionManager the session containing pose information
  41542. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41543. */
  41544. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41545. }
  41546. }
  41547. declare module BABYLON {
  41548. /**
  41549. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41550. */
  41551. export class WebXRManagedOutputCanvas implements IDisposable {
  41552. private helper;
  41553. private _canvas;
  41554. /**
  41555. * xrpresent context of the canvas which can be used to display/mirror xr content
  41556. */
  41557. canvasContext: WebGLRenderingContext;
  41558. /**
  41559. * xr layer for the canvas
  41560. */
  41561. xrLayer: Nullable<XRWebGLLayer>;
  41562. /**
  41563. * Initializes the xr layer for the session
  41564. * @param xrSession xr session
  41565. * @returns a promise that will resolve once the XR Layer has been created
  41566. */
  41567. initializeXRLayerAsync(xrSession: any): any;
  41568. /**
  41569. * Initializes the canvas to be added/removed upon entering/exiting xr
  41570. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41571. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41572. */
  41573. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41574. /**
  41575. * Disposes of the object
  41576. */
  41577. dispose(): void;
  41578. private _setManagedOutputCanvas;
  41579. private _addCanvas;
  41580. private _removeCanvas;
  41581. }
  41582. }
  41583. declare module BABYLON {
  41584. /**
  41585. * States of the webXR experience
  41586. */
  41587. export enum WebXRState {
  41588. /**
  41589. * Transitioning to being in XR mode
  41590. */
  41591. ENTERING_XR = 0,
  41592. /**
  41593. * Transitioning to non XR mode
  41594. */
  41595. EXITING_XR = 1,
  41596. /**
  41597. * In XR mode and presenting
  41598. */
  41599. IN_XR = 2,
  41600. /**
  41601. * Not entered XR mode
  41602. */
  41603. NOT_IN_XR = 3
  41604. }
  41605. /**
  41606. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41607. * @see https://doc.babylonjs.com/how_to/webxr
  41608. */
  41609. export class WebXRExperienceHelper implements IDisposable {
  41610. private scene;
  41611. /**
  41612. * 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
  41613. */
  41614. container: AbstractMesh;
  41615. /**
  41616. * Camera used to render xr content
  41617. */
  41618. camera: WebXRCamera;
  41619. /**
  41620. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41621. */
  41622. state: WebXRState;
  41623. private _setState;
  41624. private static _TmpVector;
  41625. /**
  41626. * Fires when the state of the experience helper has changed
  41627. */
  41628. onStateChangedObservable: Observable<WebXRState>;
  41629. /** Session manager used to keep track of xr session */
  41630. sessionManager: WebXRSessionManager;
  41631. private _nonVRCamera;
  41632. private _originalSceneAutoClear;
  41633. private _supported;
  41634. /**
  41635. * Creates the experience helper
  41636. * @param scene the scene to attach the experience helper to
  41637. * @returns a promise for the experience helper
  41638. */
  41639. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41640. /**
  41641. * Creates a WebXRExperienceHelper
  41642. * @param scene The scene the helper should be created in
  41643. */
  41644. private constructor();
  41645. /**
  41646. * Exits XR mode and returns the scene to its original state
  41647. * @returns promise that resolves after xr mode has exited
  41648. */
  41649. exitXRAsync(): Promise<unknown>;
  41650. /**
  41651. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41652. * @param sessionCreationOptions options for the XR session
  41653. * @param referenceSpaceType frame of reference of the XR session
  41654. * @param outputCanvas the output canvas that will be used to enter XR mode
  41655. * @returns promise that resolves after xr mode has entered
  41656. */
  41657. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41658. /**
  41659. * Updates the global position of the camera by moving the camera's container
  41660. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41661. * @param position The desired global position of the camera
  41662. */
  41663. setPositionOfCameraUsingContainer(position: Vector3): void;
  41664. /**
  41665. * Rotates the xr camera by rotating the camera's container around the camera's position
  41666. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41667. * @param rotation the desired quaternion rotation to apply to the camera
  41668. */
  41669. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41670. /**
  41671. * Disposes of the experience helper
  41672. */
  41673. dispose(): void;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Button which can be used to enter a different mode of XR
  41679. */
  41680. export class WebXREnterExitUIButton {
  41681. /** button element */
  41682. element: HTMLElement;
  41683. /** XR initialization options for the button */
  41684. sessionMode: XRSessionMode;
  41685. /** Reference space type */
  41686. referenceSpaceType: XRReferenceSpaceType;
  41687. /**
  41688. * Creates a WebXREnterExitUIButton
  41689. * @param element button element
  41690. * @param sessionMode XR initialization session mode
  41691. * @param referenceSpaceType the type of reference space to be used
  41692. */
  41693. constructor(
  41694. /** button element */
  41695. element: HTMLElement,
  41696. /** XR initialization options for the button */
  41697. sessionMode: XRSessionMode,
  41698. /** Reference space type */
  41699. referenceSpaceType: XRReferenceSpaceType);
  41700. /**
  41701. * Overwritable function which can be used to update the button's visuals when the state changes
  41702. * @param activeButton the current active button in the UI
  41703. */
  41704. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41705. }
  41706. /**
  41707. * Options to create the webXR UI
  41708. */
  41709. export class WebXREnterExitUIOptions {
  41710. /**
  41711. * Context to enter xr with
  41712. */
  41713. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41714. /**
  41715. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41716. */
  41717. customButtons?: Array<WebXREnterExitUIButton>;
  41718. }
  41719. /**
  41720. * UI to allow the user to enter/exit XR mode
  41721. */
  41722. export class WebXREnterExitUI implements IDisposable {
  41723. private scene;
  41724. private _overlay;
  41725. private _buttons;
  41726. private _activeButton;
  41727. /**
  41728. * Fired every time the active button is changed.
  41729. *
  41730. * When xr is entered via a button that launches xr that button will be the callback parameter
  41731. *
  41732. * When exiting xr the callback parameter will be null)
  41733. */
  41734. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41735. /**
  41736. * Creates UI to allow the user to enter/exit XR mode
  41737. * @param scene the scene to add the ui to
  41738. * @param helper the xr experience helper to enter/exit xr with
  41739. * @param options options to configure the UI
  41740. * @returns the created ui
  41741. */
  41742. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41743. private constructor();
  41744. private _updateButtons;
  41745. /**
  41746. * Disposes of the object
  41747. */
  41748. dispose(): void;
  41749. }
  41750. }
  41751. declare module BABYLON {
  41752. /**
  41753. * Represents an XR input
  41754. */
  41755. export class WebXRController {
  41756. private scene;
  41757. /** The underlying input source for the controller */
  41758. inputSource: XRInputSource;
  41759. private parentContainer;
  41760. /**
  41761. * 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
  41762. */
  41763. grip?: AbstractMesh;
  41764. /**
  41765. * Pointer which can be used to select objects or attach a visible laser to
  41766. */
  41767. pointer: AbstractMesh;
  41768. /**
  41769. * Event that fires when the controller is removed/disposed
  41770. */
  41771. onDisposeObservable: Observable<{}>;
  41772. private _tmpMatrix;
  41773. private _tmpQuaternion;
  41774. private _tmpVector;
  41775. /**
  41776. * Creates the controller
  41777. * @see https://doc.babylonjs.com/how_to/webxr
  41778. * @param scene the scene which the controller should be associated to
  41779. * @param inputSource the underlying input source for the controller
  41780. * @param parentContainer parent that the controller meshes should be children of
  41781. */
  41782. constructor(scene: Scene,
  41783. /** The underlying input source for the controller */
  41784. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41785. /**
  41786. * Updates the controller pose based on the given XRFrame
  41787. * @param xrFrame xr frame to update the pose with
  41788. * @param referenceSpace reference space to use
  41789. */
  41790. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41791. /**
  41792. * Gets a world space ray coming from the controller
  41793. * @param result the resulting ray
  41794. */
  41795. getWorldPointerRayToRef(result: Ray): void;
  41796. /**
  41797. * Disposes of the object
  41798. */
  41799. dispose(): void;
  41800. }
  41801. }
  41802. declare module BABYLON {
  41803. /**
  41804. * XR input used to track XR inputs such as controllers/rays
  41805. */
  41806. export class WebXRInput implements IDisposable {
  41807. /**
  41808. * Base experience the input listens to
  41809. */
  41810. baseExperience: WebXRExperienceHelper;
  41811. /**
  41812. * XR controllers being tracked
  41813. */
  41814. controllers: Array<WebXRController>;
  41815. private _frameObserver;
  41816. private _stateObserver;
  41817. /**
  41818. * Event when a controller has been connected/added
  41819. */
  41820. onControllerAddedObservable: Observable<WebXRController>;
  41821. /**
  41822. * Event when a controller has been removed/disconnected
  41823. */
  41824. onControllerRemovedObservable: Observable<WebXRController>;
  41825. /**
  41826. * Initializes the WebXRInput
  41827. * @param baseExperience experience helper which the input should be created for
  41828. */
  41829. constructor(
  41830. /**
  41831. * Base experience the input listens to
  41832. */
  41833. baseExperience: WebXRExperienceHelper);
  41834. private _onInputSourcesChange;
  41835. private _addAndRemoveControllers;
  41836. /**
  41837. * Disposes of the object
  41838. */
  41839. dispose(): void;
  41840. }
  41841. }
  41842. declare module BABYLON {
  41843. /**
  41844. * Enables teleportation
  41845. */
  41846. export class WebXRControllerTeleportation {
  41847. private _teleportationFillColor;
  41848. private _teleportationBorderColor;
  41849. private _tmpRay;
  41850. private _tmpVector;
  41851. /**
  41852. * Creates a WebXRControllerTeleportation
  41853. * @param input input manager to add teleportation to
  41854. * @param floorMeshes floormeshes which can be teleported to
  41855. */
  41856. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Handles pointer input automatically for the pointer of XR controllers
  41862. */
  41863. export class WebXRControllerPointerSelection {
  41864. private static _idCounter;
  41865. private _tmpRay;
  41866. /**
  41867. * Creates a WebXRControllerPointerSelection
  41868. * @param input input manager to setup pointer selection
  41869. */
  41870. constructor(input: WebXRInput);
  41871. private _convertNormalToDirectionOfRay;
  41872. private _updatePointerDistance;
  41873. }
  41874. }
  41875. declare module BABYLON {
  41876. /**
  41877. * Class used to represent data loading progression
  41878. */
  41879. export class SceneLoaderProgressEvent {
  41880. /** defines if data length to load can be evaluated */
  41881. readonly lengthComputable: boolean;
  41882. /** defines the loaded data length */
  41883. readonly loaded: number;
  41884. /** defines the data length to load */
  41885. readonly total: number;
  41886. /**
  41887. * Create a new progress event
  41888. * @param lengthComputable defines if data length to load can be evaluated
  41889. * @param loaded defines the loaded data length
  41890. * @param total defines the data length to load
  41891. */
  41892. constructor(
  41893. /** defines if data length to load can be evaluated */
  41894. lengthComputable: boolean,
  41895. /** defines the loaded data length */
  41896. loaded: number,
  41897. /** defines the data length to load */
  41898. total: number);
  41899. /**
  41900. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41901. * @param event defines the source event
  41902. * @returns a new SceneLoaderProgressEvent
  41903. */
  41904. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41905. }
  41906. /**
  41907. * Interface used by SceneLoader plugins to define supported file extensions
  41908. */
  41909. export interface ISceneLoaderPluginExtensions {
  41910. /**
  41911. * Defines the list of supported extensions
  41912. */
  41913. [extension: string]: {
  41914. isBinary: boolean;
  41915. };
  41916. }
  41917. /**
  41918. * Interface used by SceneLoader plugin factory
  41919. */
  41920. export interface ISceneLoaderPluginFactory {
  41921. /**
  41922. * Defines the name of the factory
  41923. */
  41924. name: string;
  41925. /**
  41926. * Function called to create a new plugin
  41927. * @return the new plugin
  41928. */
  41929. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41930. /**
  41931. * Boolean indicating if the plugin can direct load specific data
  41932. */
  41933. canDirectLoad?: (data: string) => boolean;
  41934. }
  41935. /**
  41936. * Interface used to define a SceneLoader plugin
  41937. */
  41938. export interface ISceneLoaderPlugin {
  41939. /**
  41940. * The friendly name of this plugin.
  41941. */
  41942. name: string;
  41943. /**
  41944. * The file extensions supported by this plugin.
  41945. */
  41946. extensions: string | ISceneLoaderPluginExtensions;
  41947. /**
  41948. * Import meshes into a scene.
  41949. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41950. * @param scene The scene to import into
  41951. * @param data The data to import
  41952. * @param rootUrl The root url for scene and resources
  41953. * @param meshes The meshes array to import into
  41954. * @param particleSystems The particle systems array to import into
  41955. * @param skeletons The skeletons array to import into
  41956. * @param onError The callback when import fails
  41957. * @returns True if successful or false otherwise
  41958. */
  41959. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41960. /**
  41961. * Load into a scene.
  41962. * @param scene The scene to load into
  41963. * @param data The data to import
  41964. * @param rootUrl The root url for scene and resources
  41965. * @param onError The callback when import fails
  41966. * @returns true if successful or false otherwise
  41967. */
  41968. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41969. /**
  41970. * The callback that returns true if the data can be directly loaded.
  41971. */
  41972. canDirectLoad?: (data: string) => boolean;
  41973. /**
  41974. * The callback that allows custom handling of the root url based on the response url.
  41975. */
  41976. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41977. /**
  41978. * Load into an asset container.
  41979. * @param scene The scene to load into
  41980. * @param data The data to import
  41981. * @param rootUrl The root url for scene and resources
  41982. * @param onError The callback when import fails
  41983. * @returns The loaded asset container
  41984. */
  41985. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41986. }
  41987. /**
  41988. * Interface used to define an async SceneLoader plugin
  41989. */
  41990. export interface ISceneLoaderPluginAsync {
  41991. /**
  41992. * The friendly name of this plugin.
  41993. */
  41994. name: string;
  41995. /**
  41996. * The file extensions supported by this plugin.
  41997. */
  41998. extensions: string | ISceneLoaderPluginExtensions;
  41999. /**
  42000. * Import meshes into a scene.
  42001. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42002. * @param scene The scene to import into
  42003. * @param data The data to import
  42004. * @param rootUrl The root url for scene and resources
  42005. * @param onProgress The callback when the load progresses
  42006. * @param fileName Defines the name of the file to load
  42007. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42008. */
  42009. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42010. meshes: AbstractMesh[];
  42011. particleSystems: IParticleSystem[];
  42012. skeletons: Skeleton[];
  42013. animationGroups: AnimationGroup[];
  42014. }>;
  42015. /**
  42016. * Load into a scene.
  42017. * @param scene The scene to load into
  42018. * @param data The data to import
  42019. * @param rootUrl The root url for scene and resources
  42020. * @param onProgress The callback when the load progresses
  42021. * @param fileName Defines the name of the file to load
  42022. * @returns Nothing
  42023. */
  42024. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42025. /**
  42026. * The callback that returns true if the data can be directly loaded.
  42027. */
  42028. canDirectLoad?: (data: string) => boolean;
  42029. /**
  42030. * The callback that allows custom handling of the root url based on the response url.
  42031. */
  42032. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42033. /**
  42034. * Load into an asset container.
  42035. * @param scene The scene to load into
  42036. * @param data The data to import
  42037. * @param rootUrl The root url for scene and resources
  42038. * @param onProgress The callback when the load progresses
  42039. * @param fileName Defines the name of the file to load
  42040. * @returns The loaded asset container
  42041. */
  42042. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42043. }
  42044. /**
  42045. * Class used to load scene from various file formats using registered plugins
  42046. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42047. */
  42048. export class SceneLoader {
  42049. /**
  42050. * No logging while loading
  42051. */
  42052. static readonly NO_LOGGING: number;
  42053. /**
  42054. * Minimal logging while loading
  42055. */
  42056. static readonly MINIMAL_LOGGING: number;
  42057. /**
  42058. * Summary logging while loading
  42059. */
  42060. static readonly SUMMARY_LOGGING: number;
  42061. /**
  42062. * Detailled logging while loading
  42063. */
  42064. static readonly DETAILED_LOGGING: number;
  42065. /**
  42066. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42067. */
  42068. static ForceFullSceneLoadingForIncremental: boolean;
  42069. /**
  42070. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42071. */
  42072. static ShowLoadingScreen: boolean;
  42073. /**
  42074. * Defines the current logging level (while loading the scene)
  42075. * @ignorenaming
  42076. */
  42077. static loggingLevel: number;
  42078. /**
  42079. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42080. */
  42081. static CleanBoneMatrixWeights: boolean;
  42082. /**
  42083. * Event raised when a plugin is used to load a scene
  42084. */
  42085. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42086. private static _registeredPlugins;
  42087. private static _getDefaultPlugin;
  42088. private static _getPluginForExtension;
  42089. private static _getPluginForDirectLoad;
  42090. private static _getPluginForFilename;
  42091. private static _getDirectLoad;
  42092. private static _loadData;
  42093. private static _getFileInfo;
  42094. /**
  42095. * Gets a plugin that can load the given extension
  42096. * @param extension defines the extension to load
  42097. * @returns a plugin or null if none works
  42098. */
  42099. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42100. /**
  42101. * Gets a boolean indicating that the given extension can be loaded
  42102. * @param extension defines the extension to load
  42103. * @returns true if the extension is supported
  42104. */
  42105. static IsPluginForExtensionAvailable(extension: string): boolean;
  42106. /**
  42107. * Adds a new plugin to the list of registered plugins
  42108. * @param plugin defines the plugin to add
  42109. */
  42110. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42111. /**
  42112. * Import meshes into a scene
  42113. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42114. * @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)
  42115. * @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)
  42116. * @param scene the instance of BABYLON.Scene to append to
  42117. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42118. * @param onProgress a callback with a progress event for each file being loaded
  42119. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42120. * @param pluginExtension the extension used to determine the plugin
  42121. * @returns The loaded plugin
  42122. */
  42123. 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>;
  42124. /**
  42125. * Import meshes into a scene
  42126. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42127. * @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)
  42128. * @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)
  42129. * @param scene the instance of BABYLON.Scene to append to
  42130. * @param onProgress a callback with a progress event for each file being loaded
  42131. * @param pluginExtension the extension used to determine the plugin
  42132. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42133. */
  42134. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42135. meshes: AbstractMesh[];
  42136. particleSystems: IParticleSystem[];
  42137. skeletons: Skeleton[];
  42138. animationGroups: AnimationGroup[];
  42139. }>;
  42140. /**
  42141. * Load a scene
  42142. * @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)
  42143. * @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)
  42144. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42145. * @param onSuccess a callback with the scene when import succeeds
  42146. * @param onProgress a callback with a progress event for each file being loaded
  42147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42148. * @param pluginExtension the extension used to determine the plugin
  42149. * @returns The loaded plugin
  42150. */
  42151. 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>;
  42152. /**
  42153. * Load a scene
  42154. * @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)
  42155. * @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)
  42156. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42157. * @param onProgress a callback with a progress event for each file being loaded
  42158. * @param pluginExtension the extension used to determine the plugin
  42159. * @returns The loaded scene
  42160. */
  42161. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42162. /**
  42163. * Append a scene
  42164. * @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)
  42165. * @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)
  42166. * @param scene is the instance of BABYLON.Scene to append to
  42167. * @param onSuccess a callback with the scene when import succeeds
  42168. * @param onProgress a callback with a progress event for each file being loaded
  42169. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42170. * @param pluginExtension the extension used to determine the plugin
  42171. * @returns The loaded plugin
  42172. */
  42173. 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>;
  42174. /**
  42175. * Append a scene
  42176. * @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)
  42177. * @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)
  42178. * @param scene is the instance of BABYLON.Scene to append to
  42179. * @param onProgress a callback with a progress event for each file being loaded
  42180. * @param pluginExtension the extension used to determine the plugin
  42181. * @returns The given scene
  42182. */
  42183. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42184. /**
  42185. * Load a scene into an asset container
  42186. * @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)
  42187. * @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)
  42188. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42189. * @param onSuccess a callback with the scene when import succeeds
  42190. * @param onProgress a callback with a progress event for each file being loaded
  42191. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42192. * @param pluginExtension the extension used to determine the plugin
  42193. * @returns The loaded plugin
  42194. */
  42195. 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>;
  42196. /**
  42197. * Load a scene into an asset container
  42198. * @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)
  42199. * @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)
  42200. * @param scene is the instance of Scene to append to
  42201. * @param onProgress a callback with a progress event for each file being loaded
  42202. * @param pluginExtension the extension used to determine the plugin
  42203. * @returns The loaded asset container
  42204. */
  42205. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42206. }
  42207. }
  42208. declare module BABYLON {
  42209. /**
  42210. * Generic Controller
  42211. */
  42212. export class GenericController extends WebVRController {
  42213. /**
  42214. * Base Url for the controller model.
  42215. */
  42216. static readonly MODEL_BASE_URL: string;
  42217. /**
  42218. * File name for the controller model.
  42219. */
  42220. static readonly MODEL_FILENAME: string;
  42221. /**
  42222. * Creates a new GenericController from a gamepad
  42223. * @param vrGamepad the gamepad that the controller should be created from
  42224. */
  42225. constructor(vrGamepad: any);
  42226. /**
  42227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42228. * @param scene scene in which to add meshes
  42229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42230. */
  42231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42232. /**
  42233. * Called once for each button that changed state since the last frame
  42234. * @param buttonIdx Which button index changed
  42235. * @param state New state of the button
  42236. * @param changes Which properties on the state changed since last frame
  42237. */
  42238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * Defines the WindowsMotionController object that the state of the windows motion controller
  42244. */
  42245. export class WindowsMotionController extends WebVRController {
  42246. /**
  42247. * The base url used to load the left and right controller models
  42248. */
  42249. static MODEL_BASE_URL: string;
  42250. /**
  42251. * The name of the left controller model file
  42252. */
  42253. static MODEL_LEFT_FILENAME: string;
  42254. /**
  42255. * The name of the right controller model file
  42256. */
  42257. static MODEL_RIGHT_FILENAME: string;
  42258. /**
  42259. * The controller name prefix for this controller type
  42260. */
  42261. static readonly GAMEPAD_ID_PREFIX: string;
  42262. /**
  42263. * The controller id pattern for this controller type
  42264. */
  42265. private static readonly GAMEPAD_ID_PATTERN;
  42266. private _loadedMeshInfo;
  42267. private readonly _mapping;
  42268. /**
  42269. * Fired when the trackpad on this controller is clicked
  42270. */
  42271. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42272. /**
  42273. * Fired when the trackpad on this controller is modified
  42274. */
  42275. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42276. /**
  42277. * The current x and y values of this controller's trackpad
  42278. */
  42279. trackpad: StickValues;
  42280. /**
  42281. * Creates a new WindowsMotionController from a gamepad
  42282. * @param vrGamepad the gamepad that the controller should be created from
  42283. */
  42284. constructor(vrGamepad: any);
  42285. /**
  42286. * Fired when the trigger on this controller is modified
  42287. */
  42288. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42289. /**
  42290. * Fired when the menu button on this controller is modified
  42291. */
  42292. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42293. /**
  42294. * Fired when the grip button on this controller is modified
  42295. */
  42296. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42297. /**
  42298. * Fired when the thumbstick button on this controller is modified
  42299. */
  42300. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42301. /**
  42302. * Fired when the touchpad button on this controller is modified
  42303. */
  42304. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42305. /**
  42306. * Fired when the touchpad values on this controller are modified
  42307. */
  42308. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42309. private _updateTrackpad;
  42310. /**
  42311. * Called once per frame by the engine.
  42312. */
  42313. update(): void;
  42314. /**
  42315. * Called once for each button that changed state since the last frame
  42316. * @param buttonIdx Which button index changed
  42317. * @param state New state of the button
  42318. * @param changes Which properties on the state changed since last frame
  42319. */
  42320. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42321. /**
  42322. * Moves the buttons on the controller mesh based on their current state
  42323. * @param buttonName the name of the button to move
  42324. * @param buttonValue the value of the button which determines the buttons new position
  42325. */
  42326. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42327. /**
  42328. * Moves the axis on the controller mesh based on its current state
  42329. * @param axis the index of the axis
  42330. * @param axisValue the value of the axis which determines the meshes new position
  42331. * @hidden
  42332. */
  42333. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42334. /**
  42335. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42336. * @param scene scene in which to add meshes
  42337. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42338. */
  42339. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42340. /**
  42341. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42342. * can be transformed by button presses and axes values, based on this._mapping.
  42343. *
  42344. * @param scene scene in which the meshes exist
  42345. * @param meshes list of meshes that make up the controller model to process
  42346. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42347. */
  42348. private processModel;
  42349. private createMeshInfo;
  42350. /**
  42351. * Gets the ray of the controller in the direction the controller is pointing
  42352. * @param length the length the resulting ray should be
  42353. * @returns a ray in the direction the controller is pointing
  42354. */
  42355. getForwardRay(length?: number): Ray;
  42356. /**
  42357. * Disposes of the controller
  42358. */
  42359. dispose(): void;
  42360. }
  42361. }
  42362. declare module BABYLON {
  42363. /**
  42364. * Oculus Touch Controller
  42365. */
  42366. export class OculusTouchController extends WebVRController {
  42367. /**
  42368. * Base Url for the controller model.
  42369. */
  42370. static MODEL_BASE_URL: string;
  42371. /**
  42372. * File name for the left controller model.
  42373. */
  42374. static MODEL_LEFT_FILENAME: string;
  42375. /**
  42376. * File name for the right controller model.
  42377. */
  42378. static MODEL_RIGHT_FILENAME: string;
  42379. /**
  42380. * Base Url for the Quest controller model.
  42381. */
  42382. static QUEST_MODEL_BASE_URL: string;
  42383. /**
  42384. * @hidden
  42385. * If the controllers are running on a device that needs the updated Quest controller models
  42386. */
  42387. static _IsQuest: boolean;
  42388. /**
  42389. * Fired when the secondary trigger on this controller is modified
  42390. */
  42391. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42392. /**
  42393. * Fired when the thumb rest on this controller is modified
  42394. */
  42395. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42396. /**
  42397. * Creates a new OculusTouchController from a gamepad
  42398. * @param vrGamepad the gamepad that the controller should be created from
  42399. */
  42400. constructor(vrGamepad: any);
  42401. /**
  42402. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42403. * @param scene scene in which to add meshes
  42404. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42405. */
  42406. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42407. /**
  42408. * Fired when the A button on this controller is modified
  42409. */
  42410. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42411. /**
  42412. * Fired when the B button on this controller is modified
  42413. */
  42414. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42415. /**
  42416. * Fired when the X button on this controller is modified
  42417. */
  42418. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42419. /**
  42420. * Fired when the Y button on this controller is modified
  42421. */
  42422. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42423. /**
  42424. * Called once for each button that changed state since the last frame
  42425. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42426. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42427. * 2) secondary trigger (same)
  42428. * 3) A (right) X (left), touch, pressed = value
  42429. * 4) B / Y
  42430. * 5) thumb rest
  42431. * @param buttonIdx Which button index changed
  42432. * @param state New state of the button
  42433. * @param changes Which properties on the state changed since last frame
  42434. */
  42435. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42436. }
  42437. }
  42438. declare module BABYLON {
  42439. /**
  42440. * Vive Controller
  42441. */
  42442. export class ViveController extends WebVRController {
  42443. /**
  42444. * Base Url for the controller model.
  42445. */
  42446. static MODEL_BASE_URL: string;
  42447. /**
  42448. * File name for the controller model.
  42449. */
  42450. static MODEL_FILENAME: string;
  42451. /**
  42452. * Creates a new ViveController from a gamepad
  42453. * @param vrGamepad the gamepad that the controller should be created from
  42454. */
  42455. constructor(vrGamepad: any);
  42456. /**
  42457. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42458. * @param scene scene in which to add meshes
  42459. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42460. */
  42461. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42462. /**
  42463. * Fired when the left button on this controller is modified
  42464. */
  42465. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42466. /**
  42467. * Fired when the right button on this controller is modified
  42468. */
  42469. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42470. /**
  42471. * Fired when the menu button on this controller is modified
  42472. */
  42473. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42474. /**
  42475. * Called once for each button that changed state since the last frame
  42476. * Vive mapping:
  42477. * 0: touchpad
  42478. * 1: trigger
  42479. * 2: left AND right buttons
  42480. * 3: menu button
  42481. * @param buttonIdx Which button index changed
  42482. * @param state New state of the button
  42483. * @param changes Which properties on the state changed since last frame
  42484. */
  42485. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42486. }
  42487. }
  42488. declare module BABYLON {
  42489. /**
  42490. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42491. */
  42492. export class WebXRControllerModelLoader {
  42493. /**
  42494. * Creates the WebXRControllerModelLoader
  42495. * @param input xr input that creates the controllers
  42496. */
  42497. constructor(input: WebXRInput);
  42498. }
  42499. }
  42500. declare module BABYLON {
  42501. /**
  42502. * Contains an array of blocks representing the octree
  42503. */
  42504. export interface IOctreeContainer<T> {
  42505. /**
  42506. * Blocks within the octree
  42507. */
  42508. blocks: Array<OctreeBlock<T>>;
  42509. }
  42510. /**
  42511. * Class used to store a cell in an octree
  42512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42513. */
  42514. export class OctreeBlock<T> {
  42515. /**
  42516. * Gets the content of the current block
  42517. */
  42518. entries: T[];
  42519. /**
  42520. * Gets the list of block children
  42521. */
  42522. blocks: Array<OctreeBlock<T>>;
  42523. private _depth;
  42524. private _maxDepth;
  42525. private _capacity;
  42526. private _minPoint;
  42527. private _maxPoint;
  42528. private _boundingVectors;
  42529. private _creationFunc;
  42530. /**
  42531. * Creates a new block
  42532. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42533. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42534. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42535. * @param depth defines the current depth of this block in the octree
  42536. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42537. * @param creationFunc defines a callback to call when an element is added to the block
  42538. */
  42539. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42540. /**
  42541. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42542. */
  42543. readonly capacity: number;
  42544. /**
  42545. * Gets the minimum vector (in world space) of the block's bounding box
  42546. */
  42547. readonly minPoint: Vector3;
  42548. /**
  42549. * Gets the maximum vector (in world space) of the block's bounding box
  42550. */
  42551. readonly maxPoint: Vector3;
  42552. /**
  42553. * Add a new element to this block
  42554. * @param entry defines the element to add
  42555. */
  42556. addEntry(entry: T): void;
  42557. /**
  42558. * Remove an element from this block
  42559. * @param entry defines the element to remove
  42560. */
  42561. removeEntry(entry: T): void;
  42562. /**
  42563. * Add an array of elements to this block
  42564. * @param entries defines the array of elements to add
  42565. */
  42566. addEntries(entries: T[]): void;
  42567. /**
  42568. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42569. * @param frustumPlanes defines the frustum planes to test
  42570. * @param selection defines the array to store current content if selection is positive
  42571. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42572. */
  42573. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42574. /**
  42575. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42576. * @param sphereCenter defines the bounding sphere center
  42577. * @param sphereRadius defines the bounding sphere radius
  42578. * @param selection defines the array to store current content if selection is positive
  42579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42580. */
  42581. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42582. /**
  42583. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42584. * @param ray defines the ray to test with
  42585. * @param selection defines the array to store current content if selection is positive
  42586. */
  42587. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42588. /**
  42589. * Subdivide the content into child blocks (this block will then be empty)
  42590. */
  42591. createInnerBlocks(): void;
  42592. /**
  42593. * @hidden
  42594. */
  42595. 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;
  42596. }
  42597. }
  42598. declare module BABYLON {
  42599. /**
  42600. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42601. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42602. */
  42603. export class Octree<T> {
  42604. /** 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.) */
  42605. maxDepth: number;
  42606. /**
  42607. * Blocks within the octree containing objects
  42608. */
  42609. blocks: Array<OctreeBlock<T>>;
  42610. /**
  42611. * Content stored in the octree
  42612. */
  42613. dynamicContent: T[];
  42614. private _maxBlockCapacity;
  42615. private _selectionContent;
  42616. private _creationFunc;
  42617. /**
  42618. * Creates a octree
  42619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42620. * @param creationFunc function to be used to instatiate the octree
  42621. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42622. * @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.)
  42623. */
  42624. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42625. /** 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.) */
  42626. maxDepth?: number);
  42627. /**
  42628. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42629. * @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);
  42630. * @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);
  42631. * @param entries meshes to be added to the octree blocks
  42632. */
  42633. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42634. /**
  42635. * Adds a mesh to the octree
  42636. * @param entry Mesh to add to the octree
  42637. */
  42638. addMesh(entry: T): void;
  42639. /**
  42640. * Remove an element from the octree
  42641. * @param entry defines the element to remove
  42642. */
  42643. removeMesh(entry: T): void;
  42644. /**
  42645. * Selects an array of meshes within the frustum
  42646. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42647. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42648. * @returns array of meshes within the frustum
  42649. */
  42650. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42651. /**
  42652. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42653. * @param sphereCenter defines the bounding sphere center
  42654. * @param sphereRadius defines the bounding sphere radius
  42655. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42656. * @returns an array of objects that intersect the sphere
  42657. */
  42658. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42659. /**
  42660. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42661. * @param ray defines the ray to test with
  42662. * @returns array of intersected objects
  42663. */
  42664. intersectsRay(ray: Ray): SmartArray<T>;
  42665. /**
  42666. * Adds a mesh into the octree block if it intersects the block
  42667. */
  42668. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42669. /**
  42670. * Adds a submesh into the octree block if it intersects the block
  42671. */
  42672. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42673. }
  42674. }
  42675. declare module BABYLON {
  42676. interface Scene {
  42677. /**
  42678. * @hidden
  42679. * Backing Filed
  42680. */
  42681. _selectionOctree: Octree<AbstractMesh>;
  42682. /**
  42683. * Gets the octree used to boost mesh selection (picking)
  42684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42685. */
  42686. selectionOctree: Octree<AbstractMesh>;
  42687. /**
  42688. * Creates or updates the octree used to boost selection (picking)
  42689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42690. * @param maxCapacity defines the maximum capacity per leaf
  42691. * @param maxDepth defines the maximum depth of the octree
  42692. * @returns an octree of AbstractMesh
  42693. */
  42694. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42695. }
  42696. interface AbstractMesh {
  42697. /**
  42698. * @hidden
  42699. * Backing Field
  42700. */
  42701. _submeshesOctree: Octree<SubMesh>;
  42702. /**
  42703. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42704. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42705. * @param maxCapacity defines the maximum size of each block (64 by default)
  42706. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42707. * @returns the new octree
  42708. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42710. */
  42711. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42712. }
  42713. /**
  42714. * Defines the octree scene component responsible to manage any octrees
  42715. * in a given scene.
  42716. */
  42717. export class OctreeSceneComponent {
  42718. /**
  42719. * The component name help to identify the component in the list of scene components.
  42720. */
  42721. readonly name: string;
  42722. /**
  42723. * The scene the component belongs to.
  42724. */
  42725. scene: Scene;
  42726. /**
  42727. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42728. */
  42729. readonly checksIsEnabled: boolean;
  42730. /**
  42731. * Creates a new instance of the component for the given scene
  42732. * @param scene Defines the scene to register the component in
  42733. */
  42734. constructor(scene: Scene);
  42735. /**
  42736. * Registers the component in a given scene
  42737. */
  42738. register(): void;
  42739. /**
  42740. * Return the list of active meshes
  42741. * @returns the list of active meshes
  42742. */
  42743. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42744. /**
  42745. * Return the list of active sub meshes
  42746. * @param mesh The mesh to get the candidates sub meshes from
  42747. * @returns the list of active sub meshes
  42748. */
  42749. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42750. private _tempRay;
  42751. /**
  42752. * Return the list of sub meshes intersecting with a given local ray
  42753. * @param mesh defines the mesh to find the submesh for
  42754. * @param localRay defines the ray in local space
  42755. * @returns the list of intersecting sub meshes
  42756. */
  42757. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42758. /**
  42759. * Return the list of sub meshes colliding with a collider
  42760. * @param mesh defines the mesh to find the submesh for
  42761. * @param collider defines the collider to evaluate the collision against
  42762. * @returns the list of colliding sub meshes
  42763. */
  42764. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42765. /**
  42766. * Rebuilds the elements related to this component in case of
  42767. * context lost for instance.
  42768. */
  42769. rebuild(): void;
  42770. /**
  42771. * Disposes the component and the associated ressources.
  42772. */
  42773. dispose(): void;
  42774. }
  42775. }
  42776. declare module BABYLON {
  42777. /**
  42778. * Renders a layer on top of an existing scene
  42779. */
  42780. export class UtilityLayerRenderer implements IDisposable {
  42781. /** the original scene that will be rendered on top of */
  42782. originalScene: Scene;
  42783. private _pointerCaptures;
  42784. private _lastPointerEvents;
  42785. private static _DefaultUtilityLayer;
  42786. private static _DefaultKeepDepthUtilityLayer;
  42787. private _sharedGizmoLight;
  42788. private _renderCamera;
  42789. /**
  42790. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42791. * @returns the camera that is used when rendering the utility layer
  42792. */
  42793. getRenderCamera(): Nullable<Camera>;
  42794. /**
  42795. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42796. * @param cam the camera that should be used when rendering the utility layer
  42797. */
  42798. setRenderCamera(cam: Nullable<Camera>): void;
  42799. /**
  42800. * @hidden
  42801. * Light which used by gizmos to get light shading
  42802. */
  42803. _getSharedGizmoLight(): HemisphericLight;
  42804. /**
  42805. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42806. */
  42807. pickUtilitySceneFirst: boolean;
  42808. /**
  42809. * 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)
  42810. */
  42811. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42812. /**
  42813. * 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)
  42814. */
  42815. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42816. /**
  42817. * The scene that is rendered on top of the original scene
  42818. */
  42819. utilityLayerScene: Scene;
  42820. /**
  42821. * If the utility layer should automatically be rendered on top of existing scene
  42822. */
  42823. shouldRender: boolean;
  42824. /**
  42825. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42826. */
  42827. onlyCheckPointerDownEvents: boolean;
  42828. /**
  42829. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42830. */
  42831. processAllEvents: boolean;
  42832. /**
  42833. * Observable raised when the pointer move from the utility layer scene to the main scene
  42834. */
  42835. onPointerOutObservable: Observable<number>;
  42836. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42837. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42838. private _afterRenderObserver;
  42839. private _sceneDisposeObserver;
  42840. private _originalPointerObserver;
  42841. /**
  42842. * Instantiates a UtilityLayerRenderer
  42843. * @param originalScene the original scene that will be rendered on top of
  42844. * @param handleEvents boolean indicating if the utility layer should handle events
  42845. */
  42846. constructor(
  42847. /** the original scene that will be rendered on top of */
  42848. originalScene: Scene, handleEvents?: boolean);
  42849. private _notifyObservers;
  42850. /**
  42851. * Renders the utility layers scene on top of the original scene
  42852. */
  42853. render(): void;
  42854. /**
  42855. * Disposes of the renderer
  42856. */
  42857. dispose(): void;
  42858. private _updateCamera;
  42859. }
  42860. }
  42861. declare module BABYLON {
  42862. /**
  42863. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42864. */
  42865. export class Gizmo implements IDisposable {
  42866. /** The utility layer the gizmo will be added to */
  42867. gizmoLayer: UtilityLayerRenderer;
  42868. /**
  42869. * The root mesh of the gizmo
  42870. */
  42871. _rootMesh: Mesh;
  42872. private _attachedMesh;
  42873. /**
  42874. * Ratio for the scale of the gizmo (Default: 1)
  42875. */
  42876. scaleRatio: number;
  42877. /**
  42878. * If a custom mesh has been set (Default: false)
  42879. */
  42880. protected _customMeshSet: boolean;
  42881. /**
  42882. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42883. * * When set, interactions will be enabled
  42884. */
  42885. attachedMesh: Nullable<AbstractMesh>;
  42886. /**
  42887. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42888. * @param mesh The mesh to replace the default mesh of the gizmo
  42889. */
  42890. setCustomMesh(mesh: Mesh): void;
  42891. /**
  42892. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42893. */
  42894. updateGizmoRotationToMatchAttachedMesh: boolean;
  42895. /**
  42896. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42897. */
  42898. updateGizmoPositionToMatchAttachedMesh: boolean;
  42899. /**
  42900. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42901. */
  42902. updateScale: boolean;
  42903. protected _interactionsEnabled: boolean;
  42904. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42905. private _beforeRenderObserver;
  42906. private _tempVector;
  42907. /**
  42908. * Creates a gizmo
  42909. * @param gizmoLayer The utility layer the gizmo will be added to
  42910. */
  42911. constructor(
  42912. /** The utility layer the gizmo will be added to */
  42913. gizmoLayer?: UtilityLayerRenderer);
  42914. /**
  42915. * Updates the gizmo to match the attached mesh's position/rotation
  42916. */
  42917. protected _update(): void;
  42918. /**
  42919. * Disposes of the gizmo
  42920. */
  42921. dispose(): void;
  42922. }
  42923. }
  42924. declare module BABYLON {
  42925. /**
  42926. * Single plane drag gizmo
  42927. */
  42928. export class PlaneDragGizmo extends Gizmo {
  42929. /**
  42930. * Drag behavior responsible for the gizmos dragging interactions
  42931. */
  42932. dragBehavior: PointerDragBehavior;
  42933. private _pointerObserver;
  42934. /**
  42935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42936. */
  42937. snapDistance: number;
  42938. /**
  42939. * Event that fires each time the gizmo snaps to a new location.
  42940. * * snapDistance is the the change in distance
  42941. */
  42942. onSnapObservable: Observable<{
  42943. snapDistance: number;
  42944. }>;
  42945. private _plane;
  42946. private _coloredMaterial;
  42947. private _hoverMaterial;
  42948. private _isEnabled;
  42949. private _parent;
  42950. /** @hidden */
  42951. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42952. /** @hidden */
  42953. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42954. /**
  42955. * Creates a PlaneDragGizmo
  42956. * @param gizmoLayer The utility layer the gizmo will be added to
  42957. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42958. * @param color The color of the gizmo
  42959. */
  42960. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42962. /**
  42963. * If the gizmo is enabled
  42964. */
  42965. isEnabled: boolean;
  42966. /**
  42967. * Disposes of the gizmo
  42968. */
  42969. dispose(): void;
  42970. }
  42971. }
  42972. declare module BABYLON {
  42973. /**
  42974. * Gizmo that enables dragging a mesh along 3 axis
  42975. */
  42976. export class PositionGizmo extends Gizmo {
  42977. /**
  42978. * Internal gizmo used for interactions on the x axis
  42979. */
  42980. xGizmo: AxisDragGizmo;
  42981. /**
  42982. * Internal gizmo used for interactions on the y axis
  42983. */
  42984. yGizmo: AxisDragGizmo;
  42985. /**
  42986. * Internal gizmo used for interactions on the z axis
  42987. */
  42988. zGizmo: AxisDragGizmo;
  42989. /**
  42990. * Internal gizmo used for interactions on the yz plane
  42991. */
  42992. xPlaneGizmo: PlaneDragGizmo;
  42993. /**
  42994. * Internal gizmo used for interactions on the xz plane
  42995. */
  42996. yPlaneGizmo: PlaneDragGizmo;
  42997. /**
  42998. * Internal gizmo used for interactions on the xy plane
  42999. */
  43000. zPlaneGizmo: PlaneDragGizmo;
  43001. /**
  43002. * private variables
  43003. */
  43004. private _meshAttached;
  43005. private _updateGizmoRotationToMatchAttachedMesh;
  43006. private _snapDistance;
  43007. private _scaleRatio;
  43008. /** Fires an event when any of it's sub gizmos are dragged */
  43009. onDragStartObservable: Observable<unknown>;
  43010. /** Fires an event when any of it's sub gizmos are released from dragging */
  43011. onDragEndObservable: Observable<unknown>;
  43012. /**
  43013. * If set to true, planar drag is enabled
  43014. */
  43015. private _planarGizmoEnabled;
  43016. attachedMesh: Nullable<AbstractMesh>;
  43017. /**
  43018. * Creates a PositionGizmo
  43019. * @param gizmoLayer The utility layer the gizmo will be added to
  43020. */
  43021. constructor(gizmoLayer?: UtilityLayerRenderer);
  43022. /**
  43023. * If the planar drag gizmo is enabled
  43024. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43025. */
  43026. planarGizmoEnabled: boolean;
  43027. updateGizmoRotationToMatchAttachedMesh: boolean;
  43028. /**
  43029. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43030. */
  43031. snapDistance: number;
  43032. /**
  43033. * Ratio for the scale of the gizmo (Default: 1)
  43034. */
  43035. scaleRatio: number;
  43036. /**
  43037. * Disposes of the gizmo
  43038. */
  43039. dispose(): void;
  43040. /**
  43041. * CustomMeshes are not supported by this gizmo
  43042. * @param mesh The mesh to replace the default mesh of the gizmo
  43043. */
  43044. setCustomMesh(mesh: Mesh): void;
  43045. }
  43046. }
  43047. declare module BABYLON {
  43048. /**
  43049. * Single axis drag gizmo
  43050. */
  43051. export class AxisDragGizmo extends Gizmo {
  43052. /**
  43053. * Drag behavior responsible for the gizmos dragging interactions
  43054. */
  43055. dragBehavior: PointerDragBehavior;
  43056. private _pointerObserver;
  43057. /**
  43058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43059. */
  43060. snapDistance: number;
  43061. /**
  43062. * Event that fires each time the gizmo snaps to a new location.
  43063. * * snapDistance is the the change in distance
  43064. */
  43065. onSnapObservable: Observable<{
  43066. snapDistance: number;
  43067. }>;
  43068. private _isEnabled;
  43069. private _parent;
  43070. private _arrow;
  43071. private _coloredMaterial;
  43072. private _hoverMaterial;
  43073. /** @hidden */
  43074. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43075. /** @hidden */
  43076. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43077. /**
  43078. * Creates an AxisDragGizmo
  43079. * @param gizmoLayer The utility layer the gizmo will be added to
  43080. * @param dragAxis The axis which the gizmo will be able to drag on
  43081. * @param color The color of the gizmo
  43082. */
  43083. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43084. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43085. /**
  43086. * If the gizmo is enabled
  43087. */
  43088. isEnabled: boolean;
  43089. /**
  43090. * Disposes of the gizmo
  43091. */
  43092. dispose(): void;
  43093. }
  43094. }
  43095. declare module BABYLON.Debug {
  43096. /**
  43097. * The Axes viewer will show 3 axes in a specific point in space
  43098. */
  43099. export class AxesViewer {
  43100. private _xAxis;
  43101. private _yAxis;
  43102. private _zAxis;
  43103. private _scaleLinesFactor;
  43104. private _instanced;
  43105. /**
  43106. * Gets the hosting scene
  43107. */
  43108. scene: Scene;
  43109. /**
  43110. * Gets or sets a number used to scale line length
  43111. */
  43112. scaleLines: number;
  43113. /** Gets the node hierarchy used to render x-axis */
  43114. readonly xAxis: TransformNode;
  43115. /** Gets the node hierarchy used to render y-axis */
  43116. readonly yAxis: TransformNode;
  43117. /** Gets the node hierarchy used to render z-axis */
  43118. readonly zAxis: TransformNode;
  43119. /**
  43120. * Creates a new AxesViewer
  43121. * @param scene defines the hosting scene
  43122. * @param scaleLines defines a number used to scale line length (1 by default)
  43123. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43124. * @param xAxis defines the node hierarchy used to render the x-axis
  43125. * @param yAxis defines the node hierarchy used to render the y-axis
  43126. * @param zAxis defines the node hierarchy used to render the z-axis
  43127. */
  43128. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43129. /**
  43130. * Force the viewer to update
  43131. * @param position defines the position of the viewer
  43132. * @param xaxis defines the x axis of the viewer
  43133. * @param yaxis defines the y axis of the viewer
  43134. * @param zaxis defines the z axis of the viewer
  43135. */
  43136. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43137. /**
  43138. * Creates an instance of this axes viewer.
  43139. * @returns a new axes viewer with instanced meshes
  43140. */
  43141. createInstance(): AxesViewer;
  43142. /** Releases resources */
  43143. dispose(): void;
  43144. private static _SetRenderingGroupId;
  43145. }
  43146. }
  43147. declare module BABYLON.Debug {
  43148. /**
  43149. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43150. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43151. */
  43152. export class BoneAxesViewer extends AxesViewer {
  43153. /**
  43154. * Gets or sets the target mesh where to display the axes viewer
  43155. */
  43156. mesh: Nullable<Mesh>;
  43157. /**
  43158. * Gets or sets the target bone where to display the axes viewer
  43159. */
  43160. bone: Nullable<Bone>;
  43161. /** Gets current position */
  43162. pos: Vector3;
  43163. /** Gets direction of X axis */
  43164. xaxis: Vector3;
  43165. /** Gets direction of Y axis */
  43166. yaxis: Vector3;
  43167. /** Gets direction of Z axis */
  43168. zaxis: Vector3;
  43169. /**
  43170. * Creates a new BoneAxesViewer
  43171. * @param scene defines the hosting scene
  43172. * @param bone defines the target bone
  43173. * @param mesh defines the target mesh
  43174. * @param scaleLines defines a scaling factor for line length (1 by default)
  43175. */
  43176. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43177. /**
  43178. * Force the viewer to update
  43179. */
  43180. update(): void;
  43181. /** Releases resources */
  43182. dispose(): void;
  43183. }
  43184. }
  43185. declare module BABYLON {
  43186. /**
  43187. * Interface used to define scene explorer extensibility option
  43188. */
  43189. export interface IExplorerExtensibilityOption {
  43190. /**
  43191. * Define the option label
  43192. */
  43193. label: string;
  43194. /**
  43195. * Defines the action to execute on click
  43196. */
  43197. action: (entity: any) => void;
  43198. }
  43199. /**
  43200. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43201. */
  43202. export interface IExplorerExtensibilityGroup {
  43203. /**
  43204. * Defines a predicate to test if a given type mut be extended
  43205. */
  43206. predicate: (entity: any) => boolean;
  43207. /**
  43208. * Gets the list of options added to a type
  43209. */
  43210. entries: IExplorerExtensibilityOption[];
  43211. }
  43212. /**
  43213. * Interface used to define the options to use to create the Inspector
  43214. */
  43215. export interface IInspectorOptions {
  43216. /**
  43217. * Display in overlay mode (default: false)
  43218. */
  43219. overlay?: boolean;
  43220. /**
  43221. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43222. */
  43223. globalRoot?: HTMLElement;
  43224. /**
  43225. * Display the Scene explorer
  43226. */
  43227. showExplorer?: boolean;
  43228. /**
  43229. * Display the property inspector
  43230. */
  43231. showInspector?: boolean;
  43232. /**
  43233. * Display in embed mode (both panes on the right)
  43234. */
  43235. embedMode?: boolean;
  43236. /**
  43237. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43238. */
  43239. handleResize?: boolean;
  43240. /**
  43241. * Allow the panes to popup (default: true)
  43242. */
  43243. enablePopup?: boolean;
  43244. /**
  43245. * Allow the panes to be closed by users (default: true)
  43246. */
  43247. enableClose?: boolean;
  43248. /**
  43249. * Optional list of extensibility entries
  43250. */
  43251. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43252. /**
  43253. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43254. */
  43255. inspectorURL?: string;
  43256. }
  43257. interface Scene {
  43258. /**
  43259. * @hidden
  43260. * Backing field
  43261. */
  43262. _debugLayer: DebugLayer;
  43263. /**
  43264. * Gets the debug layer (aka Inspector) associated with the scene
  43265. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43266. */
  43267. debugLayer: DebugLayer;
  43268. }
  43269. /**
  43270. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43271. * what is happening in your scene
  43272. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43273. */
  43274. export class DebugLayer {
  43275. /**
  43276. * Define the url to get the inspector script from.
  43277. * By default it uses the babylonjs CDN.
  43278. * @ignoreNaming
  43279. */
  43280. static InspectorURL: string;
  43281. private _scene;
  43282. private BJSINSPECTOR;
  43283. private _onPropertyChangedObservable?;
  43284. /**
  43285. * Observable triggered when a property is changed through the inspector.
  43286. */
  43287. readonly onPropertyChangedObservable: any;
  43288. /**
  43289. * Instantiates a new debug layer.
  43290. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43291. * what is happening in your scene
  43292. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43293. * @param scene Defines the scene to inspect
  43294. */
  43295. constructor(scene: Scene);
  43296. /** Creates the inspector window. */
  43297. private _createInspector;
  43298. /**
  43299. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43300. * @param entity defines the entity to select
  43301. * @param lineContainerTitle defines the specific block to highlight
  43302. */
  43303. select(entity: any, lineContainerTitle?: string): void;
  43304. /** Get the inspector from bundle or global */
  43305. private _getGlobalInspector;
  43306. /**
  43307. * Get if the inspector is visible or not.
  43308. * @returns true if visible otherwise, false
  43309. */
  43310. isVisible(): boolean;
  43311. /**
  43312. * Hide the inspector and close its window.
  43313. */
  43314. hide(): void;
  43315. /**
  43316. * Launch the debugLayer.
  43317. * @param config Define the configuration of the inspector
  43318. * @return a promise fulfilled when the debug layer is visible
  43319. */
  43320. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43321. }
  43322. }
  43323. declare module BABYLON {
  43324. /**
  43325. * Class containing static functions to help procedurally build meshes
  43326. */
  43327. export class BoxBuilder {
  43328. /**
  43329. * Creates a box mesh
  43330. * * The parameter `size` sets the size (float) of each box side (default 1)
  43331. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43332. * * 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)
  43333. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43335. * * 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
  43336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43337. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43338. * @param name defines the name of the mesh
  43339. * @param options defines the options used to create the mesh
  43340. * @param scene defines the hosting scene
  43341. * @returns the box mesh
  43342. */
  43343. static CreateBox(name: string, options: {
  43344. size?: number;
  43345. width?: number;
  43346. height?: number;
  43347. depth?: number;
  43348. faceUV?: Vector4[];
  43349. faceColors?: Color4[];
  43350. sideOrientation?: number;
  43351. frontUVs?: Vector4;
  43352. backUVs?: Vector4;
  43353. wrap?: boolean;
  43354. topBaseAt?: number;
  43355. bottomBaseAt?: number;
  43356. updatable?: boolean;
  43357. }, scene?: Nullable<Scene>): Mesh;
  43358. }
  43359. }
  43360. declare module BABYLON {
  43361. /**
  43362. * Class containing static functions to help procedurally build meshes
  43363. */
  43364. export class SphereBuilder {
  43365. /**
  43366. * Creates a sphere mesh
  43367. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43368. * * 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`)
  43369. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43370. * * 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
  43371. * * 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)
  43372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43373. * * 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
  43374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43375. * @param name defines the name of the mesh
  43376. * @param options defines the options used to create the mesh
  43377. * @param scene defines the hosting scene
  43378. * @returns the sphere mesh
  43379. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43380. */
  43381. static CreateSphere(name: string, options: {
  43382. segments?: number;
  43383. diameter?: number;
  43384. diameterX?: number;
  43385. diameterY?: number;
  43386. diameterZ?: number;
  43387. arc?: number;
  43388. slice?: number;
  43389. sideOrientation?: number;
  43390. frontUVs?: Vector4;
  43391. backUVs?: Vector4;
  43392. updatable?: boolean;
  43393. }, scene?: Nullable<Scene>): Mesh;
  43394. }
  43395. }
  43396. declare module BABYLON.Debug {
  43397. /**
  43398. * Used to show the physics impostor around the specific mesh
  43399. */
  43400. export class PhysicsViewer {
  43401. /** @hidden */
  43402. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43403. /** @hidden */
  43404. protected _meshes: Array<Nullable<AbstractMesh>>;
  43405. /** @hidden */
  43406. protected _scene: Nullable<Scene>;
  43407. /** @hidden */
  43408. protected _numMeshes: number;
  43409. /** @hidden */
  43410. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43411. private _renderFunction;
  43412. private _utilityLayer;
  43413. private _debugBoxMesh;
  43414. private _debugSphereMesh;
  43415. private _debugCylinderMesh;
  43416. private _debugMaterial;
  43417. private _debugMeshMeshes;
  43418. /**
  43419. * Creates a new PhysicsViewer
  43420. * @param scene defines the hosting scene
  43421. */
  43422. constructor(scene: Scene);
  43423. /** @hidden */
  43424. protected _updateDebugMeshes(): void;
  43425. /**
  43426. * Renders a specified physic impostor
  43427. * @param impostor defines the impostor to render
  43428. * @param targetMesh defines the mesh represented by the impostor
  43429. * @returns the new debug mesh used to render the impostor
  43430. */
  43431. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43432. /**
  43433. * Hides a specified physic impostor
  43434. * @param impostor defines the impostor to hide
  43435. */
  43436. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43437. private _getDebugMaterial;
  43438. private _getDebugBoxMesh;
  43439. private _getDebugSphereMesh;
  43440. private _getDebugCylinderMesh;
  43441. private _getDebugMeshMesh;
  43442. private _getDebugMesh;
  43443. /** Releases all resources */
  43444. dispose(): void;
  43445. }
  43446. }
  43447. declare module BABYLON {
  43448. /**
  43449. * Class containing static functions to help procedurally build meshes
  43450. */
  43451. export class LinesBuilder {
  43452. /**
  43453. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43454. * * 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
  43455. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43456. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43457. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43458. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43459. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43460. * * 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
  43461. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43464. * @param name defines the name of the new line system
  43465. * @param options defines the options used to create the line system
  43466. * @param scene defines the hosting scene
  43467. * @returns a new line system mesh
  43468. */
  43469. static CreateLineSystem(name: string, options: {
  43470. lines: Vector3[][];
  43471. updatable?: boolean;
  43472. instance?: Nullable<LinesMesh>;
  43473. colors?: Nullable<Color4[][]>;
  43474. useVertexAlpha?: boolean;
  43475. }, scene: Nullable<Scene>): LinesMesh;
  43476. /**
  43477. * Creates a line mesh
  43478. * 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
  43479. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43480. * * The parameter `points` is an array successive Vector3
  43481. * * 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
  43482. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43484. * * When updating an instance, remember that only point positions can change, not the number of points
  43485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43487. * @param name defines the name of the new line system
  43488. * @param options defines the options used to create the line system
  43489. * @param scene defines the hosting scene
  43490. * @returns a new line mesh
  43491. */
  43492. static CreateLines(name: string, options: {
  43493. points: Vector3[];
  43494. updatable?: boolean;
  43495. instance?: Nullable<LinesMesh>;
  43496. colors?: Color4[];
  43497. useVertexAlpha?: boolean;
  43498. }, scene?: Nullable<Scene>): LinesMesh;
  43499. /**
  43500. * Creates a dashed line mesh
  43501. * * 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
  43502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43503. * * The parameter `points` is an array successive Vector3
  43504. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43505. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43506. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43507. * * 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
  43508. * * When updating an instance, remember that only point positions can change, not the number of points
  43509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43510. * @param name defines the name of the mesh
  43511. * @param options defines the options used to create the mesh
  43512. * @param scene defines the hosting scene
  43513. * @returns the dashed line mesh
  43514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43515. */
  43516. static CreateDashedLines(name: string, options: {
  43517. points: Vector3[];
  43518. dashSize?: number;
  43519. gapSize?: number;
  43520. dashNb?: number;
  43521. updatable?: boolean;
  43522. instance?: LinesMesh;
  43523. }, scene?: Nullable<Scene>): LinesMesh;
  43524. }
  43525. }
  43526. declare module BABYLON {
  43527. /**
  43528. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43529. * in order to better appreciate the issue one might have.
  43530. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43531. */
  43532. export class RayHelper {
  43533. /**
  43534. * Defines the ray we are currently tryin to visualize.
  43535. */
  43536. ray: Nullable<Ray>;
  43537. private _renderPoints;
  43538. private _renderLine;
  43539. private _renderFunction;
  43540. private _scene;
  43541. private _updateToMeshFunction;
  43542. private _attachedToMesh;
  43543. private _meshSpaceDirection;
  43544. private _meshSpaceOrigin;
  43545. /**
  43546. * Helper function to create a colored helper in a scene in one line.
  43547. * @param ray Defines the ray we are currently tryin to visualize
  43548. * @param scene Defines the scene the ray is used in
  43549. * @param color Defines the color we want to see the ray in
  43550. * @returns The newly created ray helper.
  43551. */
  43552. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43553. /**
  43554. * Instantiate a new ray helper.
  43555. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43556. * in order to better appreciate the issue one might have.
  43557. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43558. * @param ray Defines the ray we are currently tryin to visualize
  43559. */
  43560. constructor(ray: Ray);
  43561. /**
  43562. * Shows the ray we are willing to debug.
  43563. * @param scene Defines the scene the ray needs to be rendered in
  43564. * @param color Defines the color the ray needs to be rendered in
  43565. */
  43566. show(scene: Scene, color?: Color3): void;
  43567. /**
  43568. * Hides the ray we are debugging.
  43569. */
  43570. hide(): void;
  43571. private _render;
  43572. /**
  43573. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43574. * @param mesh Defines the mesh we want the helper attached to
  43575. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43576. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43577. * @param length Defines the length of the ray
  43578. */
  43579. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43580. /**
  43581. * Detach the ray helper from the mesh it has previously been attached to.
  43582. */
  43583. detachFromMesh(): void;
  43584. private _updateToMesh;
  43585. /**
  43586. * Dispose the helper and release its associated resources.
  43587. */
  43588. dispose(): void;
  43589. }
  43590. }
  43591. declare module BABYLON.Debug {
  43592. /**
  43593. * Class used to render a debug view of a given skeleton
  43594. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43595. */
  43596. export class SkeletonViewer {
  43597. /** defines the skeleton to render */
  43598. skeleton: Skeleton;
  43599. /** defines the mesh attached to the skeleton */
  43600. mesh: AbstractMesh;
  43601. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43602. autoUpdateBonesMatrices: boolean;
  43603. /** defines the rendering group id to use with the viewer */
  43604. renderingGroupId: number;
  43605. /** Gets or sets the color used to render the skeleton */
  43606. color: Color3;
  43607. private _scene;
  43608. private _debugLines;
  43609. private _debugMesh;
  43610. private _isEnabled;
  43611. private _renderFunction;
  43612. private _utilityLayer;
  43613. /**
  43614. * Returns the mesh used to render the bones
  43615. */
  43616. readonly debugMesh: Nullable<LinesMesh>;
  43617. /**
  43618. * Creates a new SkeletonViewer
  43619. * @param skeleton defines the skeleton to render
  43620. * @param mesh defines the mesh attached to the skeleton
  43621. * @param scene defines the hosting scene
  43622. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43623. * @param renderingGroupId defines the rendering group id to use with the viewer
  43624. */
  43625. constructor(
  43626. /** defines the skeleton to render */
  43627. skeleton: Skeleton,
  43628. /** defines the mesh attached to the skeleton */
  43629. mesh: AbstractMesh, scene: Scene,
  43630. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43631. autoUpdateBonesMatrices?: boolean,
  43632. /** defines the rendering group id to use with the viewer */
  43633. renderingGroupId?: number);
  43634. /** Gets or sets a boolean indicating if the viewer is enabled */
  43635. isEnabled: boolean;
  43636. private _getBonePosition;
  43637. private _getLinesForBonesWithLength;
  43638. private _getLinesForBonesNoLength;
  43639. /** Update the viewer to sync with current skeleton state */
  43640. update(): void;
  43641. /** Release associated resources */
  43642. dispose(): void;
  43643. }
  43644. }
  43645. declare module BABYLON {
  43646. /**
  43647. * Options to create the null engine
  43648. */
  43649. export class NullEngineOptions {
  43650. /**
  43651. * Render width (Default: 512)
  43652. */
  43653. renderWidth: number;
  43654. /**
  43655. * Render height (Default: 256)
  43656. */
  43657. renderHeight: number;
  43658. /**
  43659. * Texture size (Default: 512)
  43660. */
  43661. textureSize: number;
  43662. /**
  43663. * If delta time between frames should be constant
  43664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43665. */
  43666. deterministicLockstep: boolean;
  43667. /**
  43668. * Maximum about of steps between frames (Default: 4)
  43669. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43670. */
  43671. lockstepMaxSteps: number;
  43672. }
  43673. /**
  43674. * The null engine class provides support for headless version of babylon.js.
  43675. * This can be used in server side scenario or for testing purposes
  43676. */
  43677. export class NullEngine extends Engine {
  43678. private _options;
  43679. /**
  43680. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43681. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43682. * @returns true if engine is in deterministic lock step mode
  43683. */
  43684. isDeterministicLockStep(): boolean;
  43685. /**
  43686. * Gets the max steps when engine is running in deterministic lock step
  43687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43688. * @returns the max steps
  43689. */
  43690. getLockstepMaxSteps(): number;
  43691. /**
  43692. * Gets the current hardware scaling level.
  43693. * By default the hardware scaling level is computed from the window device ratio.
  43694. * 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.
  43695. * @returns a number indicating the current hardware scaling level
  43696. */
  43697. getHardwareScalingLevel(): number;
  43698. constructor(options?: NullEngineOptions);
  43699. /**
  43700. * Creates a vertex buffer
  43701. * @param vertices the data for the vertex buffer
  43702. * @returns the new WebGL static buffer
  43703. */
  43704. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43705. /**
  43706. * Creates a new index buffer
  43707. * @param indices defines the content of the index buffer
  43708. * @param updatable defines if the index buffer must be updatable
  43709. * @returns a new webGL buffer
  43710. */
  43711. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43712. /**
  43713. * Clear the current render buffer or the current render target (if any is set up)
  43714. * @param color defines the color to use
  43715. * @param backBuffer defines if the back buffer must be cleared
  43716. * @param depth defines if the depth buffer must be cleared
  43717. * @param stencil defines if the stencil buffer must be cleared
  43718. */
  43719. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43720. /**
  43721. * Gets the current render width
  43722. * @param useScreen defines if screen size must be used (or the current render target if any)
  43723. * @returns a number defining the current render width
  43724. */
  43725. getRenderWidth(useScreen?: boolean): number;
  43726. /**
  43727. * Gets the current render height
  43728. * @param useScreen defines if screen size must be used (or the current render target if any)
  43729. * @returns a number defining the current render height
  43730. */
  43731. getRenderHeight(useScreen?: boolean): number;
  43732. /**
  43733. * Set the WebGL's viewport
  43734. * @param viewport defines the viewport element to be used
  43735. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43736. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43737. */
  43738. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43739. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43740. /**
  43741. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43742. * @param pipelineContext defines the pipeline context to use
  43743. * @param uniformsNames defines the list of uniform names
  43744. * @returns an array of webGL uniform locations
  43745. */
  43746. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43747. /**
  43748. * Gets the lsit of active attributes for a given webGL program
  43749. * @param pipelineContext defines the pipeline context to use
  43750. * @param attributesNames defines the list of attribute names to get
  43751. * @returns an array of indices indicating the offset of each attribute
  43752. */
  43753. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43754. /**
  43755. * Binds an effect to the webGL context
  43756. * @param effect defines the effect to bind
  43757. */
  43758. bindSamplers(effect: Effect): void;
  43759. /**
  43760. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43761. * @param effect defines the effect to activate
  43762. */
  43763. enableEffect(effect: Effect): void;
  43764. /**
  43765. * Set various states to the webGL context
  43766. * @param culling defines backface culling state
  43767. * @param zOffset defines the value to apply to zOffset (0 by default)
  43768. * @param force defines if states must be applied even if cache is up to date
  43769. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43770. */
  43771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43772. /**
  43773. * Set the value of an uniform to an array of int32
  43774. * @param uniform defines the webGL uniform location where to store the value
  43775. * @param array defines the array of int32 to store
  43776. */
  43777. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43778. /**
  43779. * Set the value of an uniform to an array of int32 (stored as vec2)
  43780. * @param uniform defines the webGL uniform location where to store the value
  43781. * @param array defines the array of int32 to store
  43782. */
  43783. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43784. /**
  43785. * Set the value of an uniform to an array of int32 (stored as vec3)
  43786. * @param uniform defines the webGL uniform location where to store the value
  43787. * @param array defines the array of int32 to store
  43788. */
  43789. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43790. /**
  43791. * Set the value of an uniform to an array of int32 (stored as vec4)
  43792. * @param uniform defines the webGL uniform location where to store the value
  43793. * @param array defines the array of int32 to store
  43794. */
  43795. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43796. /**
  43797. * Set the value of an uniform to an array of float32
  43798. * @param uniform defines the webGL uniform location where to store the value
  43799. * @param array defines the array of float32 to store
  43800. */
  43801. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43802. /**
  43803. * Set the value of an uniform to an array of float32 (stored as vec2)
  43804. * @param uniform defines the webGL uniform location where to store the value
  43805. * @param array defines the array of float32 to store
  43806. */
  43807. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43808. /**
  43809. * Set the value of an uniform to an array of float32 (stored as vec3)
  43810. * @param uniform defines the webGL uniform location where to store the value
  43811. * @param array defines the array of float32 to store
  43812. */
  43813. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43814. /**
  43815. * Set the value of an uniform to an array of float32 (stored as vec4)
  43816. * @param uniform defines the webGL uniform location where to store the value
  43817. * @param array defines the array of float32 to store
  43818. */
  43819. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43820. /**
  43821. * Set the value of an uniform to an array of number
  43822. * @param uniform defines the webGL uniform location where to store the value
  43823. * @param array defines the array of number to store
  43824. */
  43825. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43826. /**
  43827. * Set the value of an uniform to an array of number (stored as vec2)
  43828. * @param uniform defines the webGL uniform location where to store the value
  43829. * @param array defines the array of number to store
  43830. */
  43831. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43832. /**
  43833. * Set the value of an uniform to an array of number (stored as vec3)
  43834. * @param uniform defines the webGL uniform location where to store the value
  43835. * @param array defines the array of number to store
  43836. */
  43837. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43838. /**
  43839. * Set the value of an uniform to an array of number (stored as vec4)
  43840. * @param uniform defines the webGL uniform location where to store the value
  43841. * @param array defines the array of number to store
  43842. */
  43843. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43844. /**
  43845. * Set the value of an uniform to an array of float32 (stored as matrices)
  43846. * @param uniform defines the webGL uniform location where to store the value
  43847. * @param matrices defines the array of float32 to store
  43848. */
  43849. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43850. /**
  43851. * Set the value of an uniform to a matrix (3x3)
  43852. * @param uniform defines the webGL uniform location where to store the value
  43853. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43854. */
  43855. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43856. /**
  43857. * Set the value of an uniform to a matrix (2x2)
  43858. * @param uniform defines the webGL uniform location where to store the value
  43859. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43860. */
  43861. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43862. /**
  43863. * Set the value of an uniform to a number (float)
  43864. * @param uniform defines the webGL uniform location where to store the value
  43865. * @param value defines the float number to store
  43866. */
  43867. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43868. /**
  43869. * Set the value of an uniform to a vec2
  43870. * @param uniform defines the webGL uniform location where to store the value
  43871. * @param x defines the 1st component of the value
  43872. * @param y defines the 2nd component of the value
  43873. */
  43874. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43875. /**
  43876. * Set the value of an uniform to a vec3
  43877. * @param uniform defines the webGL uniform location where to store the value
  43878. * @param x defines the 1st component of the value
  43879. * @param y defines the 2nd component of the value
  43880. * @param z defines the 3rd component of the value
  43881. */
  43882. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43883. /**
  43884. * Set the value of an uniform to a boolean
  43885. * @param uniform defines the webGL uniform location where to store the value
  43886. * @param bool defines the boolean to store
  43887. */
  43888. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43889. /**
  43890. * Set the value of an uniform to a vec4
  43891. * @param uniform defines the webGL uniform location where to store the value
  43892. * @param x defines the 1st component of the value
  43893. * @param y defines the 2nd component of the value
  43894. * @param z defines the 3rd component of the value
  43895. * @param w defines the 4th component of the value
  43896. */
  43897. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43898. /**
  43899. * Sets the current alpha mode
  43900. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43901. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43902. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43903. */
  43904. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43905. /**
  43906. * Bind webGl buffers directly to the webGL context
  43907. * @param vertexBuffers defines the vertex buffer to bind
  43908. * @param indexBuffer defines the index buffer to bind
  43909. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43910. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43911. * @param effect defines the effect associated with the vertex buffer
  43912. */
  43913. bindBuffers(vertexBuffers: {
  43914. [key: string]: VertexBuffer;
  43915. }, indexBuffer: DataBuffer, effect: Effect): void;
  43916. /**
  43917. * Force the entire cache to be cleared
  43918. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43919. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43920. */
  43921. wipeCaches(bruteForce?: boolean): void;
  43922. /**
  43923. * Send a draw order
  43924. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43925. * @param indexStart defines the starting index
  43926. * @param indexCount defines the number of index to draw
  43927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43928. */
  43929. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43930. /**
  43931. * Draw a list of indexed primitives
  43932. * @param fillMode defines the primitive to use
  43933. * @param indexStart defines the starting index
  43934. * @param indexCount defines the number of index to draw
  43935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43936. */
  43937. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43938. /**
  43939. * Draw a list of unindexed primitives
  43940. * @param fillMode defines the primitive to use
  43941. * @param verticesStart defines the index of first vertex to draw
  43942. * @param verticesCount defines the count of vertices to draw
  43943. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43944. */
  43945. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43946. /** @hidden */
  43947. _createTexture(): WebGLTexture;
  43948. /** @hidden */
  43949. _releaseTexture(texture: InternalTexture): void;
  43950. /**
  43951. * Usually called from Texture.ts.
  43952. * Passed information to create a WebGLTexture
  43953. * @param urlArg defines a value which contains one of the following:
  43954. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43955. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43956. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43957. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43958. * @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)
  43959. * @param scene needed for loading to the correct scene
  43960. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43961. * @param onLoad optional callback to be called upon successful completion
  43962. * @param onError optional callback to be called upon failure
  43963. * @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
  43964. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43965. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43966. * @param forcedExtension defines the extension to use to pick the right loader
  43967. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43968. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43969. */
  43970. 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;
  43971. /**
  43972. * Creates a new render target texture
  43973. * @param size defines the size of the texture
  43974. * @param options defines the options used to create the texture
  43975. * @returns a new render target texture stored in an InternalTexture
  43976. */
  43977. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43978. /**
  43979. * Update the sampling mode of a given texture
  43980. * @param samplingMode defines the required sampling mode
  43981. * @param texture defines the texture to update
  43982. */
  43983. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43984. /**
  43985. * Binds the frame buffer to the specified texture.
  43986. * @param texture The texture to render to or null for the default canvas
  43987. * @param faceIndex The face of the texture to render to in case of cube texture
  43988. * @param requiredWidth The width of the target to render to
  43989. * @param requiredHeight The height of the target to render to
  43990. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43991. * @param depthStencilTexture The depth stencil texture to use to render
  43992. * @param lodLevel defines le lod level to bind to the frame buffer
  43993. */
  43994. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43995. /**
  43996. * Unbind the current render target texture from the webGL context
  43997. * @param texture defines the render target texture to unbind
  43998. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43999. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44000. */
  44001. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44002. /**
  44003. * Creates a dynamic vertex buffer
  44004. * @param vertices the data for the dynamic vertex buffer
  44005. * @returns the new WebGL dynamic buffer
  44006. */
  44007. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44008. /**
  44009. * Update the content of a dynamic texture
  44010. * @param texture defines the texture to update
  44011. * @param canvas defines the canvas containing the source
  44012. * @param invertY defines if data must be stored with Y axis inverted
  44013. * @param premulAlpha defines if alpha is stored as premultiplied
  44014. * @param format defines the format of the data
  44015. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44016. */
  44017. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44018. /**
  44019. * Gets a boolean indicating if all created effects are ready
  44020. * @returns true if all effects are ready
  44021. */
  44022. areAllEffectsReady(): boolean;
  44023. /**
  44024. * @hidden
  44025. * Get the current error code of the webGL context
  44026. * @returns the error code
  44027. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44028. */
  44029. getError(): number;
  44030. /** @hidden */
  44031. _getUnpackAlignement(): number;
  44032. /** @hidden */
  44033. _unpackFlipY(value: boolean): void;
  44034. /**
  44035. * Update a dynamic index buffer
  44036. * @param indexBuffer defines the target index buffer
  44037. * @param indices defines the data to update
  44038. * @param offset defines the offset in the target index buffer where update should start
  44039. */
  44040. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44041. /**
  44042. * Updates a dynamic vertex buffer.
  44043. * @param vertexBuffer the vertex buffer to update
  44044. * @param vertices the data used to update the vertex buffer
  44045. * @param byteOffset the byte offset of the data (optional)
  44046. * @param byteLength the byte length of the data (optional)
  44047. */
  44048. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44049. /** @hidden */
  44050. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44051. /** @hidden */
  44052. _bindTexture(channel: number, texture: InternalTexture): void;
  44053. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44054. /**
  44055. * 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
  44056. */
  44057. releaseEffects(): void;
  44058. displayLoadingUI(): void;
  44059. hideLoadingUI(): void;
  44060. /** @hidden */
  44061. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44062. /** @hidden */
  44063. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44064. /** @hidden */
  44065. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44066. /** @hidden */
  44067. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44068. }
  44069. }
  44070. declare module BABYLON {
  44071. /** @hidden */
  44072. export class _OcclusionDataStorage {
  44073. /** @hidden */
  44074. occlusionInternalRetryCounter: number;
  44075. /** @hidden */
  44076. isOcclusionQueryInProgress: boolean;
  44077. /** @hidden */
  44078. isOccluded: boolean;
  44079. /** @hidden */
  44080. occlusionRetryCount: number;
  44081. /** @hidden */
  44082. occlusionType: number;
  44083. /** @hidden */
  44084. occlusionQueryAlgorithmType: number;
  44085. }
  44086. interface Engine {
  44087. /**
  44088. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44089. * @return the new query
  44090. */
  44091. createQuery(): WebGLQuery;
  44092. /**
  44093. * Delete and release a webGL query
  44094. * @param query defines the query to delete
  44095. * @return the current engine
  44096. */
  44097. deleteQuery(query: WebGLQuery): Engine;
  44098. /**
  44099. * Check if a given query has resolved and got its value
  44100. * @param query defines the query to check
  44101. * @returns true if the query got its value
  44102. */
  44103. isQueryResultAvailable(query: WebGLQuery): boolean;
  44104. /**
  44105. * Gets the value of a given query
  44106. * @param query defines the query to check
  44107. * @returns the value of the query
  44108. */
  44109. getQueryResult(query: WebGLQuery): number;
  44110. /**
  44111. * Initiates an occlusion query
  44112. * @param algorithmType defines the algorithm to use
  44113. * @param query defines the query to use
  44114. * @returns the current engine
  44115. * @see http://doc.babylonjs.com/features/occlusionquery
  44116. */
  44117. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44118. /**
  44119. * Ends an occlusion query
  44120. * @see http://doc.babylonjs.com/features/occlusionquery
  44121. * @param algorithmType defines the algorithm to use
  44122. * @returns the current engine
  44123. */
  44124. endOcclusionQuery(algorithmType: number): Engine;
  44125. /**
  44126. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44127. * Please note that only one query can be issued at a time
  44128. * @returns a time token used to track the time span
  44129. */
  44130. startTimeQuery(): Nullable<_TimeToken>;
  44131. /**
  44132. * Ends a time query
  44133. * @param token defines the token used to measure the time span
  44134. * @returns the time spent (in ns)
  44135. */
  44136. endTimeQuery(token: _TimeToken): int;
  44137. /** @hidden */
  44138. _currentNonTimestampToken: Nullable<_TimeToken>;
  44139. /** @hidden */
  44140. _createTimeQuery(): WebGLQuery;
  44141. /** @hidden */
  44142. _deleteTimeQuery(query: WebGLQuery): void;
  44143. /** @hidden */
  44144. _getGlAlgorithmType(algorithmType: number): number;
  44145. /** @hidden */
  44146. _getTimeQueryResult(query: WebGLQuery): any;
  44147. /** @hidden */
  44148. _getTimeQueryAvailability(query: WebGLQuery): any;
  44149. }
  44150. interface AbstractMesh {
  44151. /**
  44152. * Backing filed
  44153. * @hidden
  44154. */
  44155. __occlusionDataStorage: _OcclusionDataStorage;
  44156. /**
  44157. * Access property
  44158. * @hidden
  44159. */
  44160. _occlusionDataStorage: _OcclusionDataStorage;
  44161. /**
  44162. * 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.
  44163. * The default value is -1 which means don't break the query and wait till the result
  44164. * @see http://doc.babylonjs.com/features/occlusionquery
  44165. */
  44166. occlusionRetryCount: number;
  44167. /**
  44168. * 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:
  44169. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44170. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44171. * * 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.
  44172. * @see http://doc.babylonjs.com/features/occlusionquery
  44173. */
  44174. occlusionType: number;
  44175. /**
  44176. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44177. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44178. * * 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.
  44179. * @see http://doc.babylonjs.com/features/occlusionquery
  44180. */
  44181. occlusionQueryAlgorithmType: number;
  44182. /**
  44183. * 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
  44184. * @see http://doc.babylonjs.com/features/occlusionquery
  44185. */
  44186. isOccluded: boolean;
  44187. /**
  44188. * Flag to check the progress status of the query
  44189. * @see http://doc.babylonjs.com/features/occlusionquery
  44190. */
  44191. isOcclusionQueryInProgress: boolean;
  44192. }
  44193. }
  44194. declare module BABYLON {
  44195. /** @hidden */
  44196. export var _forceTransformFeedbackToBundle: boolean;
  44197. interface Engine {
  44198. /**
  44199. * Creates a webGL transform feedback object
  44200. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44201. * @returns the webGL transform feedback object
  44202. */
  44203. createTransformFeedback(): WebGLTransformFeedback;
  44204. /**
  44205. * Delete a webGL transform feedback object
  44206. * @param value defines the webGL transform feedback object to delete
  44207. */
  44208. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44209. /**
  44210. * Bind a webGL transform feedback object to the webgl context
  44211. * @param value defines the webGL transform feedback object to bind
  44212. */
  44213. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44214. /**
  44215. * Begins a transform feedback operation
  44216. * @param usePoints defines if points or triangles must be used
  44217. */
  44218. beginTransformFeedback(usePoints: boolean): void;
  44219. /**
  44220. * Ends a transform feedback operation
  44221. */
  44222. endTransformFeedback(): void;
  44223. /**
  44224. * Specify the varyings to use with transform feedback
  44225. * @param program defines the associated webGL program
  44226. * @param value defines the list of strings representing the varying names
  44227. */
  44228. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44229. /**
  44230. * Bind a webGL buffer for a transform feedback operation
  44231. * @param value defines the webGL buffer to bind
  44232. */
  44233. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44234. }
  44235. }
  44236. declare module BABYLON {
  44237. /**
  44238. * Creation options of the multi render target texture.
  44239. */
  44240. export interface IMultiRenderTargetOptions {
  44241. /**
  44242. * Define if the texture needs to create mip maps after render.
  44243. */
  44244. generateMipMaps?: boolean;
  44245. /**
  44246. * Define the types of all the draw buffers we want to create
  44247. */
  44248. types?: number[];
  44249. /**
  44250. * Define the sampling modes of all the draw buffers we want to create
  44251. */
  44252. samplingModes?: number[];
  44253. /**
  44254. * Define if a depth buffer is required
  44255. */
  44256. generateDepthBuffer?: boolean;
  44257. /**
  44258. * Define if a stencil buffer is required
  44259. */
  44260. generateStencilBuffer?: boolean;
  44261. /**
  44262. * Define if a depth texture is required instead of a depth buffer
  44263. */
  44264. generateDepthTexture?: boolean;
  44265. /**
  44266. * Define the number of desired draw buffers
  44267. */
  44268. textureCount?: number;
  44269. /**
  44270. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44271. */
  44272. doNotChangeAspectRatio?: boolean;
  44273. /**
  44274. * Define the default type of the buffers we are creating
  44275. */
  44276. defaultType?: number;
  44277. }
  44278. /**
  44279. * A multi render target, like a render target provides the ability to render to a texture.
  44280. * Unlike the render target, it can render to several draw buffers in one draw.
  44281. * This is specially interesting in deferred rendering or for any effects requiring more than
  44282. * just one color from a single pass.
  44283. */
  44284. export class MultiRenderTarget extends RenderTargetTexture {
  44285. private _internalTextures;
  44286. private _textures;
  44287. private _multiRenderTargetOptions;
  44288. /**
  44289. * Get if draw buffers are currently supported by the used hardware and browser.
  44290. */
  44291. readonly isSupported: boolean;
  44292. /**
  44293. * Get the list of textures generated by the multi render target.
  44294. */
  44295. readonly textures: Texture[];
  44296. /**
  44297. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44298. */
  44299. readonly depthTexture: Texture;
  44300. /**
  44301. * Set the wrapping mode on U of all the textures we are rendering to.
  44302. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44303. */
  44304. wrapU: number;
  44305. /**
  44306. * Set the wrapping mode on V of all the textures we are rendering to.
  44307. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44308. */
  44309. wrapV: number;
  44310. /**
  44311. * Instantiate a new multi render target texture.
  44312. * A multi render target, like a render target provides the ability to render to a texture.
  44313. * Unlike the render target, it can render to several draw buffers in one draw.
  44314. * This is specially interesting in deferred rendering or for any effects requiring more than
  44315. * just one color from a single pass.
  44316. * @param name Define the name of the texture
  44317. * @param size Define the size of the buffers to render to
  44318. * @param count Define the number of target we are rendering into
  44319. * @param scene Define the scene the texture belongs to
  44320. * @param options Define the options used to create the multi render target
  44321. */
  44322. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44323. /** @hidden */
  44324. _rebuild(): void;
  44325. private _createInternalTextures;
  44326. private _createTextures;
  44327. /**
  44328. * Define the number of samples used if MSAA is enabled.
  44329. */
  44330. samples: number;
  44331. /**
  44332. * Resize all the textures in the multi render target.
  44333. * Be carrefull as it will recreate all the data in the new texture.
  44334. * @param size Define the new size
  44335. */
  44336. resize(size: any): void;
  44337. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44338. /**
  44339. * Dispose the render targets and their associated resources
  44340. */
  44341. dispose(): void;
  44342. /**
  44343. * Release all the underlying texture used as draw buffers.
  44344. */
  44345. releaseInternalTextures(): void;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. interface ThinEngine {
  44350. /**
  44351. * Unbind a list of render target textures from the webGL context
  44352. * This is used only when drawBuffer extension or webGL2 are active
  44353. * @param textures defines the render target textures to unbind
  44354. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44355. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44356. */
  44357. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44358. /**
  44359. * Create a multi render target texture
  44360. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44361. * @param size defines the size of the texture
  44362. * @param options defines the creation options
  44363. * @returns the cube texture as an InternalTexture
  44364. */
  44365. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44366. /**
  44367. * Update the sample count for a given multiple render target texture
  44368. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44369. * @param textures defines the textures to update
  44370. * @param samples defines the sample count to set
  44371. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44372. */
  44373. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44374. }
  44375. }
  44376. declare module BABYLON {
  44377. /**
  44378. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44379. */
  44380. export interface CubeMapInfo {
  44381. /**
  44382. * The pixel array for the front face.
  44383. * This is stored in format, left to right, up to down format.
  44384. */
  44385. front: Nullable<ArrayBufferView>;
  44386. /**
  44387. * The pixel array for the back face.
  44388. * This is stored in format, left to right, up to down format.
  44389. */
  44390. back: Nullable<ArrayBufferView>;
  44391. /**
  44392. * The pixel array for the left face.
  44393. * This is stored in format, left to right, up to down format.
  44394. */
  44395. left: Nullable<ArrayBufferView>;
  44396. /**
  44397. * The pixel array for the right face.
  44398. * This is stored in format, left to right, up to down format.
  44399. */
  44400. right: Nullable<ArrayBufferView>;
  44401. /**
  44402. * The pixel array for the up face.
  44403. * This is stored in format, left to right, up to down format.
  44404. */
  44405. up: Nullable<ArrayBufferView>;
  44406. /**
  44407. * The pixel array for the down face.
  44408. * This is stored in format, left to right, up to down format.
  44409. */
  44410. down: Nullable<ArrayBufferView>;
  44411. /**
  44412. * The size of the cubemap stored.
  44413. *
  44414. * Each faces will be size * size pixels.
  44415. */
  44416. size: number;
  44417. /**
  44418. * The format of the texture.
  44419. *
  44420. * RGBA, RGB.
  44421. */
  44422. format: number;
  44423. /**
  44424. * The type of the texture data.
  44425. *
  44426. * UNSIGNED_INT, FLOAT.
  44427. */
  44428. type: number;
  44429. /**
  44430. * Specifies whether the texture is in gamma space.
  44431. */
  44432. gammaSpace: boolean;
  44433. }
  44434. /**
  44435. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44436. */
  44437. export class PanoramaToCubeMapTools {
  44438. private static FACE_FRONT;
  44439. private static FACE_BACK;
  44440. private static FACE_RIGHT;
  44441. private static FACE_LEFT;
  44442. private static FACE_DOWN;
  44443. private static FACE_UP;
  44444. /**
  44445. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44446. *
  44447. * @param float32Array The source data.
  44448. * @param inputWidth The width of the input panorama.
  44449. * @param inputHeight The height of the input panorama.
  44450. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44451. * @return The cubemap data
  44452. */
  44453. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44454. private static CreateCubemapTexture;
  44455. private static CalcProjectionSpherical;
  44456. }
  44457. }
  44458. declare module BABYLON {
  44459. /**
  44460. * Helper class dealing with the extraction of spherical polynomial dataArray
  44461. * from a cube map.
  44462. */
  44463. export class CubeMapToSphericalPolynomialTools {
  44464. private static FileFaces;
  44465. /**
  44466. * Converts a texture to the according Spherical Polynomial data.
  44467. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44468. *
  44469. * @param texture The texture to extract the information from.
  44470. * @return The Spherical Polynomial data.
  44471. */
  44472. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44473. /**
  44474. * Converts a cubemap to the according Spherical Polynomial data.
  44475. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44476. *
  44477. * @param cubeInfo The Cube map to extract the information from.
  44478. * @return The Spherical Polynomial data.
  44479. */
  44480. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44481. }
  44482. }
  44483. declare module BABYLON {
  44484. interface BaseTexture {
  44485. /**
  44486. * Get the polynomial representation of the texture data.
  44487. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44488. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44489. */
  44490. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44491. }
  44492. }
  44493. declare module BABYLON {
  44494. /** @hidden */
  44495. export var rgbdEncodePixelShader: {
  44496. name: string;
  44497. shader: string;
  44498. };
  44499. }
  44500. declare module BABYLON {
  44501. /** @hidden */
  44502. export var rgbdDecodePixelShader: {
  44503. name: string;
  44504. shader: string;
  44505. };
  44506. }
  44507. declare module BABYLON {
  44508. /**
  44509. * Raw texture data and descriptor sufficient for WebGL texture upload
  44510. */
  44511. export interface EnvironmentTextureInfo {
  44512. /**
  44513. * Version of the environment map
  44514. */
  44515. version: number;
  44516. /**
  44517. * Width of image
  44518. */
  44519. width: number;
  44520. /**
  44521. * Irradiance information stored in the file.
  44522. */
  44523. irradiance: any;
  44524. /**
  44525. * Specular information stored in the file.
  44526. */
  44527. specular: any;
  44528. }
  44529. /**
  44530. * Defines One Image in the file. It requires only the position in the file
  44531. * as well as the length.
  44532. */
  44533. interface BufferImageData {
  44534. /**
  44535. * Length of the image data.
  44536. */
  44537. length: number;
  44538. /**
  44539. * Position of the data from the null terminator delimiting the end of the JSON.
  44540. */
  44541. position: number;
  44542. }
  44543. /**
  44544. * Defines the specular data enclosed in the file.
  44545. * This corresponds to the version 1 of the data.
  44546. */
  44547. export interface EnvironmentTextureSpecularInfoV1 {
  44548. /**
  44549. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44550. */
  44551. specularDataPosition?: number;
  44552. /**
  44553. * This contains all the images data needed to reconstruct the cubemap.
  44554. */
  44555. mipmaps: Array<BufferImageData>;
  44556. /**
  44557. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44558. */
  44559. lodGenerationScale: number;
  44560. }
  44561. /**
  44562. * Sets of helpers addressing the serialization and deserialization of environment texture
  44563. * stored in a BabylonJS env file.
  44564. * Those files are usually stored as .env files.
  44565. */
  44566. export class EnvironmentTextureTools {
  44567. /**
  44568. * Magic number identifying the env file.
  44569. */
  44570. private static _MagicBytes;
  44571. /**
  44572. * Gets the environment info from an env file.
  44573. * @param data The array buffer containing the .env bytes.
  44574. * @returns the environment file info (the json header) if successfully parsed.
  44575. */
  44576. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44577. /**
  44578. * Creates an environment texture from a loaded cube texture.
  44579. * @param texture defines the cube texture to convert in env file
  44580. * @return a promise containing the environment data if succesfull.
  44581. */
  44582. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44583. /**
  44584. * Creates a JSON representation of the spherical data.
  44585. * @param texture defines the texture containing the polynomials
  44586. * @return the JSON representation of the spherical info
  44587. */
  44588. private static _CreateEnvTextureIrradiance;
  44589. /**
  44590. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44591. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44592. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44593. * @return the views described by info providing access to the underlying buffer
  44594. */
  44595. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44596. /**
  44597. * Uploads the texture info contained in the env file to the GPU.
  44598. * @param texture defines the internal texture to upload to
  44599. * @param arrayBuffer defines the buffer cotaining the data to load
  44600. * @param info defines the texture info retrieved through the GetEnvInfo method
  44601. * @returns a promise
  44602. */
  44603. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44604. private static _OnImageReadyAsync;
  44605. /**
  44606. * Uploads the levels of image data to the GPU.
  44607. * @param texture defines the internal texture to upload to
  44608. * @param imageData defines the array buffer views of image data [mipmap][face]
  44609. * @returns a promise
  44610. */
  44611. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44612. /**
  44613. * Uploads spherical polynomials information to the texture.
  44614. * @param texture defines the texture we are trying to upload the information to
  44615. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44616. */
  44617. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44618. /** @hidden */
  44619. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44620. }
  44621. }
  44622. declare module BABYLON {
  44623. /**
  44624. * Contains position and normal vectors for a vertex
  44625. */
  44626. export class PositionNormalVertex {
  44627. /** the position of the vertex (defaut: 0,0,0) */
  44628. position: Vector3;
  44629. /** the normal of the vertex (defaut: 0,1,0) */
  44630. normal: Vector3;
  44631. /**
  44632. * Creates a PositionNormalVertex
  44633. * @param position the position of the vertex (defaut: 0,0,0)
  44634. * @param normal the normal of the vertex (defaut: 0,1,0)
  44635. */
  44636. constructor(
  44637. /** the position of the vertex (defaut: 0,0,0) */
  44638. position?: Vector3,
  44639. /** the normal of the vertex (defaut: 0,1,0) */
  44640. normal?: Vector3);
  44641. /**
  44642. * Clones the PositionNormalVertex
  44643. * @returns the cloned PositionNormalVertex
  44644. */
  44645. clone(): PositionNormalVertex;
  44646. }
  44647. /**
  44648. * Contains position, normal and uv vectors for a vertex
  44649. */
  44650. export class PositionNormalTextureVertex {
  44651. /** the position of the vertex (defaut: 0,0,0) */
  44652. position: Vector3;
  44653. /** the normal of the vertex (defaut: 0,1,0) */
  44654. normal: Vector3;
  44655. /** the uv of the vertex (default: 0,0) */
  44656. uv: Vector2;
  44657. /**
  44658. * Creates a PositionNormalTextureVertex
  44659. * @param position the position of the vertex (defaut: 0,0,0)
  44660. * @param normal the normal of the vertex (defaut: 0,1,0)
  44661. * @param uv the uv of the vertex (default: 0,0)
  44662. */
  44663. constructor(
  44664. /** the position of the vertex (defaut: 0,0,0) */
  44665. position?: Vector3,
  44666. /** the normal of the vertex (defaut: 0,1,0) */
  44667. normal?: Vector3,
  44668. /** the uv of the vertex (default: 0,0) */
  44669. uv?: Vector2);
  44670. /**
  44671. * Clones the PositionNormalTextureVertex
  44672. * @returns the cloned PositionNormalTextureVertex
  44673. */
  44674. clone(): PositionNormalTextureVertex;
  44675. }
  44676. }
  44677. declare module BABYLON {
  44678. /** @hidden */
  44679. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44680. private _genericAttributeLocation;
  44681. private _varyingLocationCount;
  44682. private _varyingLocationMap;
  44683. private _replacements;
  44684. private _textureCount;
  44685. private _uniforms;
  44686. lineProcessor(line: string): string;
  44687. attributeProcessor(attribute: string): string;
  44688. varyingProcessor(varying: string, isFragment: boolean): string;
  44689. uniformProcessor(uniform: string): string;
  44690. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44691. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * Container for accessors for natively-stored mesh data buffers.
  44697. */
  44698. class NativeDataBuffer extends DataBuffer {
  44699. /**
  44700. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44701. */
  44702. nativeIndexBuffer?: any;
  44703. /**
  44704. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44705. */
  44706. nativeVertexBuffer?: any;
  44707. }
  44708. /** @hidden */
  44709. export class NativeEngine extends Engine {
  44710. private readonly _native;
  44711. getHardwareScalingLevel(): number;
  44712. constructor();
  44713. /**
  44714. * Can be used to override the current requestAnimationFrame requester.
  44715. * @hidden
  44716. */
  44717. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44718. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44719. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44720. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44721. recordVertexArrayObject(vertexBuffers: {
  44722. [key: string]: VertexBuffer;
  44723. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44724. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44725. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44726. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44727. /**
  44728. * Draw a list of indexed primitives
  44729. * @param fillMode defines the primitive to use
  44730. * @param indexStart defines the starting index
  44731. * @param indexCount defines the number of index to draw
  44732. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44733. */
  44734. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44735. /**
  44736. * Draw a list of unindexed primitives
  44737. * @param fillMode defines the primitive to use
  44738. * @param verticesStart defines the index of first vertex to draw
  44739. * @param verticesCount defines the count of vertices to draw
  44740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44741. */
  44742. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44743. createPipelineContext(): IPipelineContext;
  44744. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44745. /** @hidden */
  44746. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44747. /** @hidden */
  44748. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44749. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44750. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44751. protected _setProgram(program: WebGLProgram): void;
  44752. _releaseEffect(effect: Effect): void;
  44753. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44754. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44755. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44756. bindSamplers(effect: Effect): void;
  44757. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44758. getRenderWidth(useScreen?: boolean): number;
  44759. getRenderHeight(useScreen?: boolean): number;
  44760. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44761. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44762. /**
  44763. * Set the z offset to apply to current rendering
  44764. * @param value defines the offset to apply
  44765. */
  44766. setZOffset(value: number): void;
  44767. /**
  44768. * Gets the current value of the zOffset
  44769. * @returns the current zOffset state
  44770. */
  44771. getZOffset(): number;
  44772. /**
  44773. * Enable or disable depth buffering
  44774. * @param enable defines the state to set
  44775. */
  44776. setDepthBuffer(enable: boolean): void;
  44777. /**
  44778. * Gets a boolean indicating if depth writing is enabled
  44779. * @returns the current depth writing state
  44780. */
  44781. getDepthWrite(): boolean;
  44782. /**
  44783. * Enable or disable depth writing
  44784. * @param enable defines the state to set
  44785. */
  44786. setDepthWrite(enable: boolean): void;
  44787. /**
  44788. * Enable or disable color writing
  44789. * @param enable defines the state to set
  44790. */
  44791. setColorWrite(enable: boolean): void;
  44792. /**
  44793. * Gets a boolean indicating if color writing is enabled
  44794. * @returns the current color writing state
  44795. */
  44796. getColorWrite(): boolean;
  44797. /**
  44798. * Sets alpha constants used by some alpha blending modes
  44799. * @param r defines the red component
  44800. * @param g defines the green component
  44801. * @param b defines the blue component
  44802. * @param a defines the alpha component
  44803. */
  44804. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44805. /**
  44806. * Sets the current alpha mode
  44807. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44808. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44810. */
  44811. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44812. /**
  44813. * Gets the current alpha mode
  44814. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44815. * @returns the current alpha mode
  44816. */
  44817. getAlphaMode(): number;
  44818. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44819. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44820. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44821. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44822. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44823. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44824. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44825. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44826. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44827. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44828. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44829. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44830. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44831. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44832. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44833. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44834. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44835. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44836. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44837. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44838. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44839. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44840. wipeCaches(bruteForce?: boolean): void;
  44841. _createTexture(): WebGLTexture;
  44842. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44843. /**
  44844. * Usually called from BABYLON.Texture.ts.
  44845. * Passed information to create a WebGLTexture
  44846. * @param urlArg defines a value which contains one of the following:
  44847. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44848. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44849. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44850. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44851. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44852. * @param scene needed for loading to the correct scene
  44853. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44854. * @param onLoad optional callback to be called upon successful completion
  44855. * @param onError optional callback to be called upon failure
  44856. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44857. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44858. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44859. * @param forcedExtension defines the extension to use to pick the right loader
  44860. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44861. */
  44862. 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;
  44863. /**
  44864. * Creates a cube texture
  44865. * @param rootUrl defines the url where the files to load is located
  44866. * @param scene defines the current scene
  44867. * @param files defines the list of files to load (1 per face)
  44868. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44869. * @param onLoad defines an optional callback raised when the texture is loaded
  44870. * @param onError defines an optional callback raised if there is an issue to load the texture
  44871. * @param format defines the format of the data
  44872. * @param forcedExtension defines the extension to use to pick the right loader
  44873. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44874. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44875. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44876. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44877. * @returns the cube texture as an InternalTexture
  44878. */
  44879. 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;
  44880. private _getSamplingFilter;
  44881. private static _GetNativeTextureFormat;
  44882. createRenderTargetTexture(size: number | {
  44883. width: number;
  44884. height: number;
  44885. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44886. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44887. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44888. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44889. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44890. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44891. /**
  44892. * Updates a dynamic vertex buffer.
  44893. * @param vertexBuffer the vertex buffer to update
  44894. * @param data the data used to update the vertex buffer
  44895. * @param byteOffset the byte offset of the data (optional)
  44896. * @param byteLength the byte length of the data (optional)
  44897. */
  44898. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44899. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44900. private _updateAnisotropicLevel;
  44901. private _getAddressMode;
  44902. /** @hidden */
  44903. _bindTexture(channel: number, texture: InternalTexture): void;
  44904. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44905. releaseEffects(): void;
  44906. /** @hidden */
  44907. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44908. /** @hidden */
  44909. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44910. /** @hidden */
  44911. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44912. /** @hidden */
  44913. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44914. }
  44915. }
  44916. declare module BABYLON {
  44917. /**
  44918. * Gather the list of clipboard event types as constants.
  44919. */
  44920. export class ClipboardEventTypes {
  44921. /**
  44922. * The clipboard event is fired when a copy command is active (pressed).
  44923. */
  44924. static readonly COPY: number;
  44925. /**
  44926. * The clipboard event is fired when a cut command is active (pressed).
  44927. */
  44928. static readonly CUT: number;
  44929. /**
  44930. * The clipboard event is fired when a paste command is active (pressed).
  44931. */
  44932. static readonly PASTE: number;
  44933. }
  44934. /**
  44935. * This class is used to store clipboard related info for the onClipboardObservable event.
  44936. */
  44937. export class ClipboardInfo {
  44938. /**
  44939. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44940. */
  44941. type: number;
  44942. /**
  44943. * Defines the related dom event
  44944. */
  44945. event: ClipboardEvent;
  44946. /**
  44947. *Creates an instance of ClipboardInfo.
  44948. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44949. * @param event Defines the related dom event
  44950. */
  44951. constructor(
  44952. /**
  44953. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44954. */
  44955. type: number,
  44956. /**
  44957. * Defines the related dom event
  44958. */
  44959. event: ClipboardEvent);
  44960. /**
  44961. * Get the clipboard event's type from the keycode.
  44962. * @param keyCode Defines the keyCode for the current keyboard event.
  44963. * @return {number}
  44964. */
  44965. static GetTypeFromCharacter(keyCode: number): number;
  44966. }
  44967. }
  44968. declare module BABYLON {
  44969. /**
  44970. * Google Daydream controller
  44971. */
  44972. export class DaydreamController extends WebVRController {
  44973. /**
  44974. * Base Url for the controller model.
  44975. */
  44976. static MODEL_BASE_URL: string;
  44977. /**
  44978. * File name for the controller model.
  44979. */
  44980. static MODEL_FILENAME: string;
  44981. /**
  44982. * Gamepad Id prefix used to identify Daydream Controller.
  44983. */
  44984. static readonly GAMEPAD_ID_PREFIX: string;
  44985. /**
  44986. * Creates a new DaydreamController from a gamepad
  44987. * @param vrGamepad the gamepad that the controller should be created from
  44988. */
  44989. constructor(vrGamepad: any);
  44990. /**
  44991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44992. * @param scene scene in which to add meshes
  44993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44994. */
  44995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44996. /**
  44997. * Called once for each button that changed state since the last frame
  44998. * @param buttonIdx Which button index changed
  44999. * @param state New state of the button
  45000. * @param changes Which properties on the state changed since last frame
  45001. */
  45002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45003. }
  45004. }
  45005. declare module BABYLON {
  45006. /**
  45007. * Gear VR Controller
  45008. */
  45009. export class GearVRController extends WebVRController {
  45010. /**
  45011. * Base Url for the controller model.
  45012. */
  45013. static MODEL_BASE_URL: string;
  45014. /**
  45015. * File name for the controller model.
  45016. */
  45017. static MODEL_FILENAME: string;
  45018. /**
  45019. * Gamepad Id prefix used to identify this controller.
  45020. */
  45021. static readonly GAMEPAD_ID_PREFIX: string;
  45022. private readonly _buttonIndexToObservableNameMap;
  45023. /**
  45024. * Creates a new GearVRController from a gamepad
  45025. * @param vrGamepad the gamepad that the controller should be created from
  45026. */
  45027. constructor(vrGamepad: any);
  45028. /**
  45029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45030. * @param scene scene in which to add meshes
  45031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45032. */
  45033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45034. /**
  45035. * Called once for each button that changed state since the last frame
  45036. * @param buttonIdx Which button index changed
  45037. * @param state New state of the button
  45038. * @param changes Which properties on the state changed since last frame
  45039. */
  45040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. /**
  45045. * Class containing static functions to help procedurally build meshes
  45046. */
  45047. export class PolyhedronBuilder {
  45048. /**
  45049. * Creates a polyhedron mesh
  45050. * * 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
  45051. * * The parameter `size` (positive float, default 1) sets the polygon size
  45052. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45053. * * 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`
  45054. * * 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
  45055. * * 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)`)
  45056. * * 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
  45057. * * 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
  45058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45059. * * 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
  45060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45061. * @param name defines the name of the mesh
  45062. * @param options defines the options used to create the mesh
  45063. * @param scene defines the hosting scene
  45064. * @returns the polyhedron mesh
  45065. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45066. */
  45067. static CreatePolyhedron(name: string, options: {
  45068. type?: number;
  45069. size?: number;
  45070. sizeX?: number;
  45071. sizeY?: number;
  45072. sizeZ?: number;
  45073. custom?: any;
  45074. faceUV?: Vector4[];
  45075. faceColors?: Color4[];
  45076. flat?: boolean;
  45077. updatable?: boolean;
  45078. sideOrientation?: number;
  45079. frontUVs?: Vector4;
  45080. backUVs?: Vector4;
  45081. }, scene?: Nullable<Scene>): Mesh;
  45082. }
  45083. }
  45084. declare module BABYLON {
  45085. /**
  45086. * Gizmo that enables scaling a mesh along 3 axis
  45087. */
  45088. export class ScaleGizmo extends Gizmo {
  45089. /**
  45090. * Internal gizmo used for interactions on the x axis
  45091. */
  45092. xGizmo: AxisScaleGizmo;
  45093. /**
  45094. * Internal gizmo used for interactions on the y axis
  45095. */
  45096. yGizmo: AxisScaleGizmo;
  45097. /**
  45098. * Internal gizmo used for interactions on the z axis
  45099. */
  45100. zGizmo: AxisScaleGizmo;
  45101. /**
  45102. * Internal gizmo used to scale all axis equally
  45103. */
  45104. uniformScaleGizmo: AxisScaleGizmo;
  45105. private _meshAttached;
  45106. private _updateGizmoRotationToMatchAttachedMesh;
  45107. private _snapDistance;
  45108. private _scaleRatio;
  45109. private _uniformScalingMesh;
  45110. private _octahedron;
  45111. /** Fires an event when any of it's sub gizmos are dragged */
  45112. onDragStartObservable: Observable<unknown>;
  45113. /** Fires an event when any of it's sub gizmos are released from dragging */
  45114. onDragEndObservable: Observable<unknown>;
  45115. attachedMesh: Nullable<AbstractMesh>;
  45116. /**
  45117. * Creates a ScaleGizmo
  45118. * @param gizmoLayer The utility layer the gizmo will be added to
  45119. */
  45120. constructor(gizmoLayer?: UtilityLayerRenderer);
  45121. updateGizmoRotationToMatchAttachedMesh: boolean;
  45122. /**
  45123. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45124. */
  45125. snapDistance: number;
  45126. /**
  45127. * Ratio for the scale of the gizmo (Default: 1)
  45128. */
  45129. scaleRatio: number;
  45130. /**
  45131. * Disposes of the gizmo
  45132. */
  45133. dispose(): void;
  45134. }
  45135. }
  45136. declare module BABYLON {
  45137. /**
  45138. * Single axis scale gizmo
  45139. */
  45140. export class AxisScaleGizmo extends Gizmo {
  45141. /**
  45142. * Drag behavior responsible for the gizmos dragging interactions
  45143. */
  45144. dragBehavior: PointerDragBehavior;
  45145. private _pointerObserver;
  45146. /**
  45147. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45148. */
  45149. snapDistance: number;
  45150. /**
  45151. * Event that fires each time the gizmo snaps to a new location.
  45152. * * snapDistance is the the change in distance
  45153. */
  45154. onSnapObservable: Observable<{
  45155. snapDistance: number;
  45156. }>;
  45157. /**
  45158. * If the scaling operation should be done on all axis (default: false)
  45159. */
  45160. uniformScaling: boolean;
  45161. private _isEnabled;
  45162. private _parent;
  45163. private _arrow;
  45164. private _coloredMaterial;
  45165. private _hoverMaterial;
  45166. /**
  45167. * Creates an AxisScaleGizmo
  45168. * @param gizmoLayer The utility layer the gizmo will be added to
  45169. * @param dragAxis The axis which the gizmo will be able to scale on
  45170. * @param color The color of the gizmo
  45171. */
  45172. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45174. /**
  45175. * If the gizmo is enabled
  45176. */
  45177. isEnabled: boolean;
  45178. /**
  45179. * Disposes of the gizmo
  45180. */
  45181. dispose(): void;
  45182. /**
  45183. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45184. * @param mesh The mesh to replace the default mesh of the gizmo
  45185. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45186. */
  45187. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /**
  45192. * Bounding box gizmo
  45193. */
  45194. export class BoundingBoxGizmo extends Gizmo {
  45195. private _lineBoundingBox;
  45196. private _rotateSpheresParent;
  45197. private _scaleBoxesParent;
  45198. private _boundingDimensions;
  45199. private _renderObserver;
  45200. private _pointerObserver;
  45201. private _scaleDragSpeed;
  45202. private _tmpQuaternion;
  45203. private _tmpVector;
  45204. private _tmpRotationMatrix;
  45205. /**
  45206. * 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)
  45207. */
  45208. ignoreChildren: boolean;
  45209. /**
  45210. * 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)
  45211. */
  45212. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45213. /**
  45214. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45215. */
  45216. rotationSphereSize: number;
  45217. /**
  45218. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45219. */
  45220. scaleBoxSize: number;
  45221. /**
  45222. * 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)
  45223. */
  45224. fixedDragMeshScreenSize: boolean;
  45225. /**
  45226. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45227. */
  45228. fixedDragMeshScreenSizeDistanceFactor: number;
  45229. /**
  45230. * Fired when a rotation sphere or scale box is dragged
  45231. */
  45232. onDragStartObservable: Observable<{}>;
  45233. /**
  45234. * Fired when a scale box is dragged
  45235. */
  45236. onScaleBoxDragObservable: Observable<{}>;
  45237. /**
  45238. * Fired when a scale box drag is ended
  45239. */
  45240. onScaleBoxDragEndObservable: Observable<{}>;
  45241. /**
  45242. * Fired when a rotation sphere is dragged
  45243. */
  45244. onRotationSphereDragObservable: Observable<{}>;
  45245. /**
  45246. * Fired when a rotation sphere drag is ended
  45247. */
  45248. onRotationSphereDragEndObservable: Observable<{}>;
  45249. /**
  45250. * 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)
  45251. */
  45252. scalePivot: Nullable<Vector3>;
  45253. /**
  45254. * Mesh used as a pivot to rotate the attached mesh
  45255. */
  45256. private _anchorMesh;
  45257. private _existingMeshScale;
  45258. private _dragMesh;
  45259. private pointerDragBehavior;
  45260. private coloredMaterial;
  45261. private hoverColoredMaterial;
  45262. /**
  45263. * Sets the color of the bounding box gizmo
  45264. * @param color the color to set
  45265. */
  45266. setColor(color: Color3): void;
  45267. /**
  45268. * Creates an BoundingBoxGizmo
  45269. * @param gizmoLayer The utility layer the gizmo will be added to
  45270. * @param color The color of the gizmo
  45271. */
  45272. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45273. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45274. private _selectNode;
  45275. /**
  45276. * Updates the bounding box information for the Gizmo
  45277. */
  45278. updateBoundingBox(): void;
  45279. private _updateRotationSpheres;
  45280. private _updateScaleBoxes;
  45281. /**
  45282. * Enables rotation on the specified axis and disables rotation on the others
  45283. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45284. */
  45285. setEnabledRotationAxis(axis: string): void;
  45286. /**
  45287. * Enables/disables scaling
  45288. * @param enable if scaling should be enabled
  45289. */
  45290. setEnabledScaling(enable: boolean): void;
  45291. private _updateDummy;
  45292. /**
  45293. * Enables a pointer drag behavior on the bounding box of the gizmo
  45294. */
  45295. enableDragBehavior(): void;
  45296. /**
  45297. * Disposes of the gizmo
  45298. */
  45299. dispose(): void;
  45300. /**
  45301. * 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)
  45302. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45303. * @returns the bounding box mesh with the passed in mesh as a child
  45304. */
  45305. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45306. /**
  45307. * CustomMeshes are not supported by this gizmo
  45308. * @param mesh The mesh to replace the default mesh of the gizmo
  45309. */
  45310. setCustomMesh(mesh: Mesh): void;
  45311. }
  45312. }
  45313. declare module BABYLON {
  45314. /**
  45315. * Single plane rotation gizmo
  45316. */
  45317. export class PlaneRotationGizmo extends Gizmo {
  45318. /**
  45319. * Drag behavior responsible for the gizmos dragging interactions
  45320. */
  45321. dragBehavior: PointerDragBehavior;
  45322. private _pointerObserver;
  45323. /**
  45324. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45325. */
  45326. snapDistance: number;
  45327. /**
  45328. * Event that fires each time the gizmo snaps to a new location.
  45329. * * snapDistance is the the change in distance
  45330. */
  45331. onSnapObservable: Observable<{
  45332. snapDistance: number;
  45333. }>;
  45334. private _isEnabled;
  45335. private _parent;
  45336. /**
  45337. * Creates a PlaneRotationGizmo
  45338. * @param gizmoLayer The utility layer the gizmo will be added to
  45339. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45340. * @param color The color of the gizmo
  45341. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45342. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45343. */
  45344. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45346. /**
  45347. * If the gizmo is enabled
  45348. */
  45349. isEnabled: boolean;
  45350. /**
  45351. * Disposes of the gizmo
  45352. */
  45353. dispose(): void;
  45354. }
  45355. }
  45356. declare module BABYLON {
  45357. /**
  45358. * Gizmo that enables rotating a mesh along 3 axis
  45359. */
  45360. export class RotationGizmo extends Gizmo {
  45361. /**
  45362. * Internal gizmo used for interactions on the x axis
  45363. */
  45364. xGizmo: PlaneRotationGizmo;
  45365. /**
  45366. * Internal gizmo used for interactions on the y axis
  45367. */
  45368. yGizmo: PlaneRotationGizmo;
  45369. /**
  45370. * Internal gizmo used for interactions on the z axis
  45371. */
  45372. zGizmo: PlaneRotationGizmo;
  45373. /** Fires an event when any of it's sub gizmos are dragged */
  45374. onDragStartObservable: Observable<unknown>;
  45375. /** Fires an event when any of it's sub gizmos are released from dragging */
  45376. onDragEndObservable: Observable<unknown>;
  45377. private _meshAttached;
  45378. attachedMesh: Nullable<AbstractMesh>;
  45379. /**
  45380. * Creates a RotationGizmo
  45381. * @param gizmoLayer The utility layer the gizmo will be added to
  45382. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45383. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45384. */
  45385. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45386. updateGizmoRotationToMatchAttachedMesh: boolean;
  45387. /**
  45388. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45389. */
  45390. snapDistance: number;
  45391. /**
  45392. * Ratio for the scale of the gizmo (Default: 1)
  45393. */
  45394. scaleRatio: number;
  45395. /**
  45396. * Disposes of the gizmo
  45397. */
  45398. dispose(): void;
  45399. /**
  45400. * CustomMeshes are not supported by this gizmo
  45401. * @param mesh The mesh to replace the default mesh of the gizmo
  45402. */
  45403. setCustomMesh(mesh: Mesh): void;
  45404. }
  45405. }
  45406. declare module BABYLON {
  45407. /**
  45408. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45409. */
  45410. export class GizmoManager implements IDisposable {
  45411. private scene;
  45412. /**
  45413. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45414. */
  45415. gizmos: {
  45416. positionGizmo: Nullable<PositionGizmo>;
  45417. rotationGizmo: Nullable<RotationGizmo>;
  45418. scaleGizmo: Nullable<ScaleGizmo>;
  45419. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45420. };
  45421. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45422. clearGizmoOnEmptyPointerEvent: boolean;
  45423. /** Fires an event when the manager is attached to a mesh */
  45424. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45425. private _gizmosEnabled;
  45426. private _pointerObserver;
  45427. private _attachedMesh;
  45428. private _boundingBoxColor;
  45429. private _defaultUtilityLayer;
  45430. private _defaultKeepDepthUtilityLayer;
  45431. /**
  45432. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45433. */
  45434. boundingBoxDragBehavior: SixDofDragBehavior;
  45435. /**
  45436. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45437. */
  45438. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45439. /**
  45440. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45441. */
  45442. usePointerToAttachGizmos: boolean;
  45443. /**
  45444. * Utility layer that the bounding box gizmo belongs to
  45445. */
  45446. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45447. /**
  45448. * Utility layer that all gizmos besides bounding box belong to
  45449. */
  45450. readonly utilityLayer: UtilityLayerRenderer;
  45451. /**
  45452. * Instatiates a gizmo manager
  45453. * @param scene the scene to overlay the gizmos on top of
  45454. */
  45455. constructor(scene: Scene);
  45456. /**
  45457. * Attaches a set of gizmos to the specified mesh
  45458. * @param mesh The mesh the gizmo's should be attached to
  45459. */
  45460. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45461. /**
  45462. * If the position gizmo is enabled
  45463. */
  45464. positionGizmoEnabled: boolean;
  45465. /**
  45466. * If the rotation gizmo is enabled
  45467. */
  45468. rotationGizmoEnabled: boolean;
  45469. /**
  45470. * If the scale gizmo is enabled
  45471. */
  45472. scaleGizmoEnabled: boolean;
  45473. /**
  45474. * If the boundingBox gizmo is enabled
  45475. */
  45476. boundingBoxGizmoEnabled: boolean;
  45477. /**
  45478. * Disposes of the gizmo manager
  45479. */
  45480. dispose(): void;
  45481. }
  45482. }
  45483. declare module BABYLON {
  45484. /**
  45485. * A directional light is defined by a direction (what a surprise!).
  45486. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45487. * 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.
  45488. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45489. */
  45490. export class DirectionalLight extends ShadowLight {
  45491. private _shadowFrustumSize;
  45492. /**
  45493. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45494. */
  45495. /**
  45496. * Specifies a fix frustum size for the shadow generation.
  45497. */
  45498. shadowFrustumSize: number;
  45499. private _shadowOrthoScale;
  45500. /**
  45501. * Gets the shadow projection scale against the optimal computed one.
  45502. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45503. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45504. */
  45505. /**
  45506. * Sets the shadow projection scale against the optimal computed one.
  45507. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45508. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45509. */
  45510. shadowOrthoScale: number;
  45511. /**
  45512. * Automatically compute the projection matrix to best fit (including all the casters)
  45513. * on each frame.
  45514. */
  45515. autoUpdateExtends: boolean;
  45516. private _orthoLeft;
  45517. private _orthoRight;
  45518. private _orthoTop;
  45519. private _orthoBottom;
  45520. /**
  45521. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45522. * The directional light is emitted from everywhere in the given direction.
  45523. * It can cast shadows.
  45524. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45525. * @param name The friendly name of the light
  45526. * @param direction The direction of the light
  45527. * @param scene The scene the light belongs to
  45528. */
  45529. constructor(name: string, direction: Vector3, scene: Scene);
  45530. /**
  45531. * Returns the string "DirectionalLight".
  45532. * @return The class name
  45533. */
  45534. getClassName(): string;
  45535. /**
  45536. * Returns the integer 1.
  45537. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45538. */
  45539. getTypeID(): number;
  45540. /**
  45541. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45542. * Returns the DirectionalLight Shadow projection matrix.
  45543. */
  45544. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45545. /**
  45546. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45547. * Returns the DirectionalLight Shadow projection matrix.
  45548. */
  45549. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45550. /**
  45551. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45552. * Returns the DirectionalLight Shadow projection matrix.
  45553. */
  45554. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45555. protected _buildUniformLayout(): void;
  45556. /**
  45557. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45558. * @param effect The effect to update
  45559. * @param lightIndex The index of the light in the effect to update
  45560. * @returns The directional light
  45561. */
  45562. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45563. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45564. /**
  45565. * Gets the minZ used for shadow according to both the scene and the light.
  45566. *
  45567. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45568. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45569. * @param activeCamera The camera we are returning the min for
  45570. * @returns the depth min z
  45571. */
  45572. getDepthMinZ(activeCamera: Camera): number;
  45573. /**
  45574. * Gets the maxZ used for shadow according to both the scene and the light.
  45575. *
  45576. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45577. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45578. * @param activeCamera The camera we are returning the max for
  45579. * @returns the depth max z
  45580. */
  45581. getDepthMaxZ(activeCamera: Camera): number;
  45582. /**
  45583. * Prepares the list of defines specific to the light type.
  45584. * @param defines the list of defines
  45585. * @param lightIndex defines the index of the light for the effect
  45586. */
  45587. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /**
  45592. * Class containing static functions to help procedurally build meshes
  45593. */
  45594. export class HemisphereBuilder {
  45595. /**
  45596. * Creates a hemisphere mesh
  45597. * @param name defines the name of the mesh
  45598. * @param options defines the options used to create the mesh
  45599. * @param scene defines the hosting scene
  45600. * @returns the hemisphere mesh
  45601. */
  45602. static CreateHemisphere(name: string, options: {
  45603. segments?: number;
  45604. diameter?: number;
  45605. sideOrientation?: number;
  45606. }, scene: any): Mesh;
  45607. }
  45608. }
  45609. declare module BABYLON {
  45610. /**
  45611. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45612. * These values define a cone of light starting from the position, emitting toward the direction.
  45613. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45614. * and the exponent defines the speed of the decay of the light with distance (reach).
  45615. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45616. */
  45617. export class SpotLight extends ShadowLight {
  45618. private _angle;
  45619. private _innerAngle;
  45620. private _cosHalfAngle;
  45621. private _lightAngleScale;
  45622. private _lightAngleOffset;
  45623. /**
  45624. * Gets the cone angle of the spot light in Radians.
  45625. */
  45626. /**
  45627. * Sets the cone angle of the spot light in Radians.
  45628. */
  45629. angle: number;
  45630. /**
  45631. * Only used in gltf falloff mode, this defines the angle where
  45632. * the directional falloff will start before cutting at angle which could be seen
  45633. * as outer angle.
  45634. */
  45635. /**
  45636. * Only used in gltf falloff mode, this defines the angle where
  45637. * the directional falloff will start before cutting at angle which could be seen
  45638. * as outer angle.
  45639. */
  45640. innerAngle: number;
  45641. private _shadowAngleScale;
  45642. /**
  45643. * Allows scaling the angle of the light for shadow generation only.
  45644. */
  45645. /**
  45646. * Allows scaling the angle of the light for shadow generation only.
  45647. */
  45648. shadowAngleScale: number;
  45649. /**
  45650. * The light decay speed with the distance from the emission spot.
  45651. */
  45652. exponent: number;
  45653. private _projectionTextureMatrix;
  45654. /**
  45655. * Allows reading the projecton texture
  45656. */
  45657. readonly projectionTextureMatrix: Matrix;
  45658. protected _projectionTextureLightNear: number;
  45659. /**
  45660. * Gets the near clip of the Spotlight for texture projection.
  45661. */
  45662. /**
  45663. * Sets the near clip of the Spotlight for texture projection.
  45664. */
  45665. projectionTextureLightNear: number;
  45666. protected _projectionTextureLightFar: number;
  45667. /**
  45668. * Gets the far clip of the Spotlight for texture projection.
  45669. */
  45670. /**
  45671. * Sets the far clip of the Spotlight for texture projection.
  45672. */
  45673. projectionTextureLightFar: number;
  45674. protected _projectionTextureUpDirection: Vector3;
  45675. /**
  45676. * Gets the Up vector of the Spotlight for texture projection.
  45677. */
  45678. /**
  45679. * Sets the Up vector of the Spotlight for texture projection.
  45680. */
  45681. projectionTextureUpDirection: Vector3;
  45682. private _projectionTexture;
  45683. /**
  45684. * Gets the projection texture of the light.
  45685. */
  45686. /**
  45687. * Sets the projection texture of the light.
  45688. */
  45689. projectionTexture: Nullable<BaseTexture>;
  45690. private _projectionTextureViewLightDirty;
  45691. private _projectionTextureProjectionLightDirty;
  45692. private _projectionTextureDirty;
  45693. private _projectionTextureViewTargetVector;
  45694. private _projectionTextureViewLightMatrix;
  45695. private _projectionTextureProjectionLightMatrix;
  45696. private _projectionTextureScalingMatrix;
  45697. /**
  45698. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45699. * It can cast shadows.
  45700. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45701. * @param name The light friendly name
  45702. * @param position The position of the spot light in the scene
  45703. * @param direction The direction of the light in the scene
  45704. * @param angle The cone angle of the light in Radians
  45705. * @param exponent The light decay speed with the distance from the emission spot
  45706. * @param scene The scene the lights belongs to
  45707. */
  45708. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45709. /**
  45710. * Returns the string "SpotLight".
  45711. * @returns the class name
  45712. */
  45713. getClassName(): string;
  45714. /**
  45715. * Returns the integer 2.
  45716. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45717. */
  45718. getTypeID(): number;
  45719. /**
  45720. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45721. */
  45722. protected _setDirection(value: Vector3): void;
  45723. /**
  45724. * Overrides the position setter to recompute the projection texture view light Matrix.
  45725. */
  45726. protected _setPosition(value: Vector3): void;
  45727. /**
  45728. * 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.
  45729. * Returns the SpotLight.
  45730. */
  45731. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45732. protected _computeProjectionTextureViewLightMatrix(): void;
  45733. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45734. /**
  45735. * Main function for light texture projection matrix computing.
  45736. */
  45737. protected _computeProjectionTextureMatrix(): void;
  45738. protected _buildUniformLayout(): void;
  45739. private _computeAngleValues;
  45740. /**
  45741. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45742. * @param effect The effect to update
  45743. * @param lightIndex The index of the light in the effect to update
  45744. * @returns The spot light
  45745. */
  45746. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45747. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45748. /**
  45749. * Disposes the light and the associated resources.
  45750. */
  45751. dispose(): void;
  45752. /**
  45753. * Prepares the list of defines specific to the light type.
  45754. * @param defines the list of defines
  45755. * @param lightIndex defines the index of the light for the effect
  45756. */
  45757. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45758. }
  45759. }
  45760. declare module BABYLON {
  45761. /**
  45762. * Gizmo that enables viewing a light
  45763. */
  45764. export class LightGizmo extends Gizmo {
  45765. private _lightMesh;
  45766. private _material;
  45767. private cachedPosition;
  45768. private cachedForward;
  45769. /**
  45770. * Creates a LightGizmo
  45771. * @param gizmoLayer The utility layer the gizmo will be added to
  45772. */
  45773. constructor(gizmoLayer?: UtilityLayerRenderer);
  45774. private _light;
  45775. /**
  45776. * The light that the gizmo is attached to
  45777. */
  45778. light: Nullable<Light>;
  45779. /**
  45780. * Gets the material used to render the light gizmo
  45781. */
  45782. readonly material: StandardMaterial;
  45783. /**
  45784. * @hidden
  45785. * Updates the gizmo to match the attached mesh's position/rotation
  45786. */
  45787. protected _update(): void;
  45788. private static _Scale;
  45789. /**
  45790. * Creates the lines for a light mesh
  45791. */
  45792. private static _createLightLines;
  45793. /**
  45794. * Disposes of the light gizmo
  45795. */
  45796. dispose(): void;
  45797. private static _CreateHemisphericLightMesh;
  45798. private static _CreatePointLightMesh;
  45799. private static _CreateSpotLightMesh;
  45800. private static _CreateDirectionalLightMesh;
  45801. }
  45802. }
  45803. declare module BABYLON {
  45804. /** @hidden */
  45805. export var backgroundFragmentDeclaration: {
  45806. name: string;
  45807. shader: string;
  45808. };
  45809. }
  45810. declare module BABYLON {
  45811. /** @hidden */
  45812. export var backgroundUboDeclaration: {
  45813. name: string;
  45814. shader: string;
  45815. };
  45816. }
  45817. declare module BABYLON {
  45818. /** @hidden */
  45819. export var backgroundPixelShader: {
  45820. name: string;
  45821. shader: string;
  45822. };
  45823. }
  45824. declare module BABYLON {
  45825. /** @hidden */
  45826. export var backgroundVertexDeclaration: {
  45827. name: string;
  45828. shader: string;
  45829. };
  45830. }
  45831. declare module BABYLON {
  45832. /** @hidden */
  45833. export var backgroundVertexShader: {
  45834. name: string;
  45835. shader: string;
  45836. };
  45837. }
  45838. declare module BABYLON {
  45839. /**
  45840. * Background material used to create an efficient environement around your scene.
  45841. */
  45842. export class BackgroundMaterial extends PushMaterial {
  45843. /**
  45844. * Standard reflectance value at parallel view angle.
  45845. */
  45846. static StandardReflectance0: number;
  45847. /**
  45848. * Standard reflectance value at grazing angle.
  45849. */
  45850. static StandardReflectance90: number;
  45851. protected _primaryColor: Color3;
  45852. /**
  45853. * Key light Color (multiply against the environement texture)
  45854. */
  45855. primaryColor: Color3;
  45856. protected __perceptualColor: Nullable<Color3>;
  45857. /**
  45858. * Experimental Internal Use Only.
  45859. *
  45860. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45861. * This acts as a helper to set the primary color to a more "human friendly" value.
  45862. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45863. * output color as close as possible from the chosen value.
  45864. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45865. * part of lighting setup.)
  45866. */
  45867. _perceptualColor: Nullable<Color3>;
  45868. protected _primaryColorShadowLevel: float;
  45869. /**
  45870. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45871. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45872. */
  45873. primaryColorShadowLevel: float;
  45874. protected _primaryColorHighlightLevel: float;
  45875. /**
  45876. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45877. * The primary color is used at the level chosen to define what the white area would look.
  45878. */
  45879. primaryColorHighlightLevel: float;
  45880. protected _reflectionTexture: Nullable<BaseTexture>;
  45881. /**
  45882. * Reflection Texture used in the material.
  45883. * Should be author in a specific way for the best result (refer to the documentation).
  45884. */
  45885. reflectionTexture: Nullable<BaseTexture>;
  45886. protected _reflectionBlur: float;
  45887. /**
  45888. * Reflection Texture level of blur.
  45889. *
  45890. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45891. * texture twice.
  45892. */
  45893. reflectionBlur: float;
  45894. protected _diffuseTexture: Nullable<BaseTexture>;
  45895. /**
  45896. * Diffuse Texture used in the material.
  45897. * Should be author in a specific way for the best result (refer to the documentation).
  45898. */
  45899. diffuseTexture: Nullable<BaseTexture>;
  45900. protected _shadowLights: Nullable<IShadowLight[]>;
  45901. /**
  45902. * Specify the list of lights casting shadow on the material.
  45903. * All scene shadow lights will be included if null.
  45904. */
  45905. shadowLights: Nullable<IShadowLight[]>;
  45906. protected _shadowLevel: float;
  45907. /**
  45908. * Helps adjusting the shadow to a softer level if required.
  45909. * 0 means black shadows and 1 means no shadows.
  45910. */
  45911. shadowLevel: float;
  45912. protected _sceneCenter: Vector3;
  45913. /**
  45914. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45915. * It is usually zero but might be interesting to modify according to your setup.
  45916. */
  45917. sceneCenter: Vector3;
  45918. protected _opacityFresnel: boolean;
  45919. /**
  45920. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45921. * This helps ensuring a nice transition when the camera goes under the ground.
  45922. */
  45923. opacityFresnel: boolean;
  45924. protected _reflectionFresnel: boolean;
  45925. /**
  45926. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45927. * This helps adding a mirror texture on the ground.
  45928. */
  45929. reflectionFresnel: boolean;
  45930. protected _reflectionFalloffDistance: number;
  45931. /**
  45932. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45933. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45934. */
  45935. reflectionFalloffDistance: number;
  45936. protected _reflectionAmount: number;
  45937. /**
  45938. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45939. */
  45940. reflectionAmount: number;
  45941. protected _reflectionReflectance0: number;
  45942. /**
  45943. * This specifies the weight of the reflection at grazing angle.
  45944. */
  45945. reflectionReflectance0: number;
  45946. protected _reflectionReflectance90: number;
  45947. /**
  45948. * This specifies the weight of the reflection at a perpendicular point of view.
  45949. */
  45950. reflectionReflectance90: number;
  45951. /**
  45952. * Sets the reflection reflectance fresnel values according to the default standard
  45953. * empirically know to work well :-)
  45954. */
  45955. reflectionStandardFresnelWeight: number;
  45956. protected _useRGBColor: boolean;
  45957. /**
  45958. * Helps to directly use the maps channels instead of their level.
  45959. */
  45960. useRGBColor: boolean;
  45961. protected _enableNoise: boolean;
  45962. /**
  45963. * This helps reducing the banding effect that could occur on the background.
  45964. */
  45965. enableNoise: boolean;
  45966. /**
  45967. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45968. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45969. * Recommended to be keep at 1.0 except for special cases.
  45970. */
  45971. fovMultiplier: number;
  45972. private _fovMultiplier;
  45973. /**
  45974. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45975. */
  45976. useEquirectangularFOV: boolean;
  45977. private _maxSimultaneousLights;
  45978. /**
  45979. * Number of Simultaneous lights allowed on the material.
  45980. */
  45981. maxSimultaneousLights: int;
  45982. /**
  45983. * Default configuration related to image processing available in the Background Material.
  45984. */
  45985. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45986. /**
  45987. * Keep track of the image processing observer to allow dispose and replace.
  45988. */
  45989. private _imageProcessingObserver;
  45990. /**
  45991. * Attaches a new image processing configuration to the PBR Material.
  45992. * @param configuration (if null the scene configuration will be use)
  45993. */
  45994. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45995. /**
  45996. * Gets the image processing configuration used either in this material.
  45997. */
  45998. /**
  45999. * Sets the Default image processing configuration used either in the this material.
  46000. *
  46001. * If sets to null, the scene one is in use.
  46002. */
  46003. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46004. /**
  46005. * Gets wether the color curves effect is enabled.
  46006. */
  46007. /**
  46008. * Sets wether the color curves effect is enabled.
  46009. */
  46010. cameraColorCurvesEnabled: boolean;
  46011. /**
  46012. * Gets wether the color grading effect is enabled.
  46013. */
  46014. /**
  46015. * Gets wether the color grading effect is enabled.
  46016. */
  46017. cameraColorGradingEnabled: boolean;
  46018. /**
  46019. * Gets wether tonemapping is enabled or not.
  46020. */
  46021. /**
  46022. * Sets wether tonemapping is enabled or not
  46023. */
  46024. cameraToneMappingEnabled: boolean;
  46025. /**
  46026. * The camera exposure used on this material.
  46027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46028. * This corresponds to a photographic exposure.
  46029. */
  46030. /**
  46031. * The camera exposure used on this material.
  46032. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46033. * This corresponds to a photographic exposure.
  46034. */
  46035. cameraExposure: float;
  46036. /**
  46037. * Gets The camera contrast used on this material.
  46038. */
  46039. /**
  46040. * Sets The camera contrast used on this material.
  46041. */
  46042. cameraContrast: float;
  46043. /**
  46044. * Gets the Color Grading 2D Lookup Texture.
  46045. */
  46046. /**
  46047. * Sets the Color Grading 2D Lookup Texture.
  46048. */
  46049. cameraColorGradingTexture: Nullable<BaseTexture>;
  46050. /**
  46051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46053. * 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;
  46054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46055. */
  46056. /**
  46057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46059. * 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;
  46060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46061. */
  46062. cameraColorCurves: Nullable<ColorCurves>;
  46063. /**
  46064. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46065. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46066. */
  46067. switchToBGR: boolean;
  46068. private _renderTargets;
  46069. private _reflectionControls;
  46070. private _white;
  46071. private _primaryShadowColor;
  46072. private _primaryHighlightColor;
  46073. /**
  46074. * Instantiates a Background Material in the given scene
  46075. * @param name The friendly name of the material
  46076. * @param scene The scene to add the material to
  46077. */
  46078. constructor(name: string, scene: Scene);
  46079. /**
  46080. * Gets a boolean indicating that current material needs to register RTT
  46081. */
  46082. readonly hasRenderTargetTextures: boolean;
  46083. /**
  46084. * The entire material has been created in order to prevent overdraw.
  46085. * @returns false
  46086. */
  46087. needAlphaTesting(): boolean;
  46088. /**
  46089. * The entire material has been created in order to prevent overdraw.
  46090. * @returns true if blending is enable
  46091. */
  46092. needAlphaBlending(): boolean;
  46093. /**
  46094. * Checks wether the material is ready to be rendered for a given mesh.
  46095. * @param mesh The mesh to render
  46096. * @param subMesh The submesh to check against
  46097. * @param useInstances Specify wether or not the material is used with instances
  46098. * @returns true if all the dependencies are ready (Textures, Effects...)
  46099. */
  46100. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46101. /**
  46102. * Compute the primary color according to the chosen perceptual color.
  46103. */
  46104. private _computePrimaryColorFromPerceptualColor;
  46105. /**
  46106. * Compute the highlights and shadow colors according to their chosen levels.
  46107. */
  46108. private _computePrimaryColors;
  46109. /**
  46110. * Build the uniform buffer used in the material.
  46111. */
  46112. buildUniformLayout(): void;
  46113. /**
  46114. * Unbind the material.
  46115. */
  46116. unbind(): void;
  46117. /**
  46118. * Bind only the world matrix to the material.
  46119. * @param world The world matrix to bind.
  46120. */
  46121. bindOnlyWorldMatrix(world: Matrix): void;
  46122. /**
  46123. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46124. * @param world The world matrix to bind.
  46125. * @param subMesh The submesh to bind for.
  46126. */
  46127. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46128. /**
  46129. * Checks to see if a texture is used in the material.
  46130. * @param texture - Base texture to use.
  46131. * @returns - Boolean specifying if a texture is used in the material.
  46132. */
  46133. hasTexture(texture: BaseTexture): boolean;
  46134. /**
  46135. * Dispose the material.
  46136. * @param forceDisposeEffect Force disposal of the associated effect.
  46137. * @param forceDisposeTextures Force disposal of the associated textures.
  46138. */
  46139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46140. /**
  46141. * Clones the material.
  46142. * @param name The cloned name.
  46143. * @returns The cloned material.
  46144. */
  46145. clone(name: string): BackgroundMaterial;
  46146. /**
  46147. * Serializes the current material to its JSON representation.
  46148. * @returns The JSON representation.
  46149. */
  46150. serialize(): any;
  46151. /**
  46152. * Gets the class name of the material
  46153. * @returns "BackgroundMaterial"
  46154. */
  46155. getClassName(): string;
  46156. /**
  46157. * Parse a JSON input to create back a background material.
  46158. * @param source The JSON data to parse
  46159. * @param scene The scene to create the parsed material in
  46160. * @param rootUrl The root url of the assets the material depends upon
  46161. * @returns the instantiated BackgroundMaterial.
  46162. */
  46163. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46164. }
  46165. }
  46166. declare module BABYLON {
  46167. /**
  46168. * Represents the different options available during the creation of
  46169. * a Environment helper.
  46170. *
  46171. * This can control the default ground, skybox and image processing setup of your scene.
  46172. */
  46173. export interface IEnvironmentHelperOptions {
  46174. /**
  46175. * Specifies wether or not to create a ground.
  46176. * True by default.
  46177. */
  46178. createGround: boolean;
  46179. /**
  46180. * Specifies the ground size.
  46181. * 15 by default.
  46182. */
  46183. groundSize: number;
  46184. /**
  46185. * The texture used on the ground for the main color.
  46186. * Comes from the BabylonJS CDN by default.
  46187. *
  46188. * Remarks: Can be either a texture or a url.
  46189. */
  46190. groundTexture: string | BaseTexture;
  46191. /**
  46192. * The color mixed in the ground texture by default.
  46193. * BabylonJS clearColor by default.
  46194. */
  46195. groundColor: Color3;
  46196. /**
  46197. * Specifies the ground opacity.
  46198. * 1 by default.
  46199. */
  46200. groundOpacity: number;
  46201. /**
  46202. * Enables the ground to receive shadows.
  46203. * True by default.
  46204. */
  46205. enableGroundShadow: boolean;
  46206. /**
  46207. * Helps preventing the shadow to be fully black on the ground.
  46208. * 0.5 by default.
  46209. */
  46210. groundShadowLevel: number;
  46211. /**
  46212. * Creates a mirror texture attach to the ground.
  46213. * false by default.
  46214. */
  46215. enableGroundMirror: boolean;
  46216. /**
  46217. * Specifies the ground mirror size ratio.
  46218. * 0.3 by default as the default kernel is 64.
  46219. */
  46220. groundMirrorSizeRatio: number;
  46221. /**
  46222. * Specifies the ground mirror blur kernel size.
  46223. * 64 by default.
  46224. */
  46225. groundMirrorBlurKernel: number;
  46226. /**
  46227. * Specifies the ground mirror visibility amount.
  46228. * 1 by default
  46229. */
  46230. groundMirrorAmount: number;
  46231. /**
  46232. * Specifies the ground mirror reflectance weight.
  46233. * This uses the standard weight of the background material to setup the fresnel effect
  46234. * of the mirror.
  46235. * 1 by default.
  46236. */
  46237. groundMirrorFresnelWeight: number;
  46238. /**
  46239. * Specifies the ground mirror Falloff distance.
  46240. * This can helps reducing the size of the reflection.
  46241. * 0 by Default.
  46242. */
  46243. groundMirrorFallOffDistance: number;
  46244. /**
  46245. * Specifies the ground mirror texture type.
  46246. * Unsigned Int by Default.
  46247. */
  46248. groundMirrorTextureType: number;
  46249. /**
  46250. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46251. * the shown objects.
  46252. */
  46253. groundYBias: number;
  46254. /**
  46255. * Specifies wether or not to create a skybox.
  46256. * True by default.
  46257. */
  46258. createSkybox: boolean;
  46259. /**
  46260. * Specifies the skybox size.
  46261. * 20 by default.
  46262. */
  46263. skyboxSize: number;
  46264. /**
  46265. * The texture used on the skybox for the main color.
  46266. * Comes from the BabylonJS CDN by default.
  46267. *
  46268. * Remarks: Can be either a texture or a url.
  46269. */
  46270. skyboxTexture: string | BaseTexture;
  46271. /**
  46272. * The color mixed in the skybox texture by default.
  46273. * BabylonJS clearColor by default.
  46274. */
  46275. skyboxColor: Color3;
  46276. /**
  46277. * The background rotation around the Y axis of the scene.
  46278. * This helps aligning the key lights of your scene with the background.
  46279. * 0 by default.
  46280. */
  46281. backgroundYRotation: number;
  46282. /**
  46283. * Compute automatically the size of the elements to best fit with the scene.
  46284. */
  46285. sizeAuto: boolean;
  46286. /**
  46287. * Default position of the rootMesh if autoSize is not true.
  46288. */
  46289. rootPosition: Vector3;
  46290. /**
  46291. * Sets up the image processing in the scene.
  46292. * true by default.
  46293. */
  46294. setupImageProcessing: boolean;
  46295. /**
  46296. * The texture used as your environment texture in the scene.
  46297. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46298. *
  46299. * Remarks: Can be either a texture or a url.
  46300. */
  46301. environmentTexture: string | BaseTexture;
  46302. /**
  46303. * The value of the exposure to apply to the scene.
  46304. * 0.6 by default if setupImageProcessing is true.
  46305. */
  46306. cameraExposure: number;
  46307. /**
  46308. * The value of the contrast to apply to the scene.
  46309. * 1.6 by default if setupImageProcessing is true.
  46310. */
  46311. cameraContrast: number;
  46312. /**
  46313. * Specifies wether or not tonemapping should be enabled in the scene.
  46314. * true by default if setupImageProcessing is true.
  46315. */
  46316. toneMappingEnabled: boolean;
  46317. }
  46318. /**
  46319. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46320. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46321. * It also helps with the default setup of your imageProcessing configuration.
  46322. */
  46323. export class EnvironmentHelper {
  46324. /**
  46325. * Default ground texture URL.
  46326. */
  46327. private static _groundTextureCDNUrl;
  46328. /**
  46329. * Default skybox texture URL.
  46330. */
  46331. private static _skyboxTextureCDNUrl;
  46332. /**
  46333. * Default environment texture URL.
  46334. */
  46335. private static _environmentTextureCDNUrl;
  46336. /**
  46337. * Creates the default options for the helper.
  46338. */
  46339. private static _getDefaultOptions;
  46340. private _rootMesh;
  46341. /**
  46342. * Gets the root mesh created by the helper.
  46343. */
  46344. readonly rootMesh: Mesh;
  46345. private _skybox;
  46346. /**
  46347. * Gets the skybox created by the helper.
  46348. */
  46349. readonly skybox: Nullable<Mesh>;
  46350. private _skyboxTexture;
  46351. /**
  46352. * Gets the skybox texture created by the helper.
  46353. */
  46354. readonly skyboxTexture: Nullable<BaseTexture>;
  46355. private _skyboxMaterial;
  46356. /**
  46357. * Gets the skybox material created by the helper.
  46358. */
  46359. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46360. private _ground;
  46361. /**
  46362. * Gets the ground mesh created by the helper.
  46363. */
  46364. readonly ground: Nullable<Mesh>;
  46365. private _groundTexture;
  46366. /**
  46367. * Gets the ground texture created by the helper.
  46368. */
  46369. readonly groundTexture: Nullable<BaseTexture>;
  46370. private _groundMirror;
  46371. /**
  46372. * Gets the ground mirror created by the helper.
  46373. */
  46374. readonly groundMirror: Nullable<MirrorTexture>;
  46375. /**
  46376. * Gets the ground mirror render list to helps pushing the meshes
  46377. * you wish in the ground reflection.
  46378. */
  46379. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46380. private _groundMaterial;
  46381. /**
  46382. * Gets the ground material created by the helper.
  46383. */
  46384. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46385. /**
  46386. * Stores the creation options.
  46387. */
  46388. private readonly _scene;
  46389. private _options;
  46390. /**
  46391. * This observable will be notified with any error during the creation of the environment,
  46392. * mainly texture creation errors.
  46393. */
  46394. onErrorObservable: Observable<{
  46395. message?: string;
  46396. exception?: any;
  46397. }>;
  46398. /**
  46399. * constructor
  46400. * @param options Defines the options we want to customize the helper
  46401. * @param scene The scene to add the material to
  46402. */
  46403. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46404. /**
  46405. * Updates the background according to the new options
  46406. * @param options
  46407. */
  46408. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46409. /**
  46410. * Sets the primary color of all the available elements.
  46411. * @param color the main color to affect to the ground and the background
  46412. */
  46413. setMainColor(color: Color3): void;
  46414. /**
  46415. * Setup the image processing according to the specified options.
  46416. */
  46417. private _setupImageProcessing;
  46418. /**
  46419. * Setup the environment texture according to the specified options.
  46420. */
  46421. private _setupEnvironmentTexture;
  46422. /**
  46423. * Setup the background according to the specified options.
  46424. */
  46425. private _setupBackground;
  46426. /**
  46427. * Get the scene sizes according to the setup.
  46428. */
  46429. private _getSceneSize;
  46430. /**
  46431. * Setup the ground according to the specified options.
  46432. */
  46433. private _setupGround;
  46434. /**
  46435. * Setup the ground material according to the specified options.
  46436. */
  46437. private _setupGroundMaterial;
  46438. /**
  46439. * Setup the ground diffuse texture according to the specified options.
  46440. */
  46441. private _setupGroundDiffuseTexture;
  46442. /**
  46443. * Setup the ground mirror texture according to the specified options.
  46444. */
  46445. private _setupGroundMirrorTexture;
  46446. /**
  46447. * Setup the ground to receive the mirror texture.
  46448. */
  46449. private _setupMirrorInGroundMaterial;
  46450. /**
  46451. * Setup the skybox according to the specified options.
  46452. */
  46453. private _setupSkybox;
  46454. /**
  46455. * Setup the skybox material according to the specified options.
  46456. */
  46457. private _setupSkyboxMaterial;
  46458. /**
  46459. * Setup the skybox reflection texture according to the specified options.
  46460. */
  46461. private _setupSkyboxReflectionTexture;
  46462. private _errorHandler;
  46463. /**
  46464. * Dispose all the elements created by the Helper.
  46465. */
  46466. dispose(): void;
  46467. }
  46468. }
  46469. declare module BABYLON {
  46470. /**
  46471. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46472. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46473. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46474. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46475. */
  46476. export class PhotoDome extends TransformNode {
  46477. /**
  46478. * Define the image as a Monoscopic panoramic 360 image.
  46479. */
  46480. static readonly MODE_MONOSCOPIC: number;
  46481. /**
  46482. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46483. */
  46484. static readonly MODE_TOPBOTTOM: number;
  46485. /**
  46486. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46487. */
  46488. static readonly MODE_SIDEBYSIDE: number;
  46489. private _useDirectMapping;
  46490. /**
  46491. * The texture being displayed on the sphere
  46492. */
  46493. protected _photoTexture: Texture;
  46494. /**
  46495. * Gets or sets the texture being displayed on the sphere
  46496. */
  46497. photoTexture: Texture;
  46498. /**
  46499. * Observable raised when an error occured while loading the 360 image
  46500. */
  46501. onLoadErrorObservable: Observable<string>;
  46502. /**
  46503. * The skybox material
  46504. */
  46505. protected _material: BackgroundMaterial;
  46506. /**
  46507. * The surface used for the skybox
  46508. */
  46509. protected _mesh: Mesh;
  46510. /**
  46511. * Gets the mesh used for the skybox.
  46512. */
  46513. readonly mesh: Mesh;
  46514. /**
  46515. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46516. * Also see the options.resolution property.
  46517. */
  46518. fovMultiplier: number;
  46519. private _imageMode;
  46520. /**
  46521. * Gets or set the current video mode for the video. It can be:
  46522. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46523. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46524. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46525. */
  46526. imageMode: number;
  46527. /**
  46528. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46529. * @param name Element's name, child elements will append suffixes for their own names.
  46530. * @param urlsOfPhoto defines the url of the photo to display
  46531. * @param options defines an object containing optional or exposed sub element properties
  46532. * @param onError defines a callback called when an error occured while loading the texture
  46533. */
  46534. constructor(name: string, urlOfPhoto: string, options: {
  46535. resolution?: number;
  46536. size?: number;
  46537. useDirectMapping?: boolean;
  46538. faceForward?: boolean;
  46539. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46540. private _onBeforeCameraRenderObserver;
  46541. private _changeImageMode;
  46542. /**
  46543. * Releases resources associated with this node.
  46544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46546. */
  46547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46548. }
  46549. }
  46550. declare module BABYLON {
  46551. /**
  46552. * Class used to host RGBD texture specific utilities
  46553. */
  46554. export class RGBDTextureTools {
  46555. /**
  46556. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46557. * @param texture the texture to expand.
  46558. */
  46559. static ExpandRGBDTexture(texture: Texture): void;
  46560. }
  46561. }
  46562. declare module BABYLON {
  46563. /**
  46564. * Class used to host texture specific utilities
  46565. */
  46566. export class BRDFTextureTools {
  46567. /**
  46568. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46569. * @param scene defines the hosting scene
  46570. * @returns the environment BRDF texture
  46571. */
  46572. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46573. private static _environmentBRDFBase64Texture;
  46574. }
  46575. }
  46576. declare module BABYLON {
  46577. /**
  46578. * @hidden
  46579. */
  46580. export interface IMaterialClearCoatDefines {
  46581. CLEARCOAT: boolean;
  46582. CLEARCOAT_DEFAULTIOR: boolean;
  46583. CLEARCOAT_TEXTURE: boolean;
  46584. CLEARCOAT_TEXTUREDIRECTUV: number;
  46585. CLEARCOAT_BUMP: boolean;
  46586. CLEARCOAT_BUMPDIRECTUV: number;
  46587. CLEARCOAT_TINT: boolean;
  46588. CLEARCOAT_TINT_TEXTURE: boolean;
  46589. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46590. /** @hidden */
  46591. _areTexturesDirty: boolean;
  46592. }
  46593. /**
  46594. * Define the code related to the clear coat parameters of the pbr material.
  46595. */
  46596. export class PBRClearCoatConfiguration {
  46597. /**
  46598. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46599. * The default fits with a polyurethane material.
  46600. */
  46601. private static readonly _DefaultIndexOfRefraction;
  46602. private _isEnabled;
  46603. /**
  46604. * Defines if the clear coat is enabled in the material.
  46605. */
  46606. isEnabled: boolean;
  46607. /**
  46608. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46609. */
  46610. intensity: number;
  46611. /**
  46612. * Defines the clear coat layer roughness.
  46613. */
  46614. roughness: number;
  46615. private _indexOfRefraction;
  46616. /**
  46617. * Defines the index of refraction of the clear coat.
  46618. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46619. * The default fits with a polyurethane material.
  46620. * Changing the default value is more performance intensive.
  46621. */
  46622. indexOfRefraction: number;
  46623. private _texture;
  46624. /**
  46625. * Stores the clear coat values in a texture.
  46626. */
  46627. texture: Nullable<BaseTexture>;
  46628. private _bumpTexture;
  46629. /**
  46630. * Define the clear coat specific bump texture.
  46631. */
  46632. bumpTexture: Nullable<BaseTexture>;
  46633. private _isTintEnabled;
  46634. /**
  46635. * Defines if the clear coat tint is enabled in the material.
  46636. */
  46637. isTintEnabled: boolean;
  46638. /**
  46639. * Defines the clear coat tint of the material.
  46640. * This is only use if tint is enabled
  46641. */
  46642. tintColor: Color3;
  46643. /**
  46644. * Defines the distance at which the tint color should be found in the
  46645. * clear coat media.
  46646. * This is only use if tint is enabled
  46647. */
  46648. tintColorAtDistance: number;
  46649. /**
  46650. * Defines the clear coat layer thickness.
  46651. * This is only use if tint is enabled
  46652. */
  46653. tintThickness: number;
  46654. private _tintTexture;
  46655. /**
  46656. * Stores the clear tint values in a texture.
  46657. * rgb is tint
  46658. * a is a thickness factor
  46659. */
  46660. tintTexture: Nullable<BaseTexture>;
  46661. /** @hidden */
  46662. private _internalMarkAllSubMeshesAsTexturesDirty;
  46663. /** @hidden */
  46664. _markAllSubMeshesAsTexturesDirty(): void;
  46665. /**
  46666. * Instantiate a new istance of clear coat configuration.
  46667. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46668. */
  46669. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46670. /**
  46671. * Gets wehter the submesh is ready to be used or not.
  46672. * @param defines the list of "defines" to update.
  46673. * @param scene defines the scene the material belongs to.
  46674. * @param engine defines the engine the material belongs to.
  46675. * @param disableBumpMap defines wether the material disables bump or not.
  46676. * @returns - boolean indicating that the submesh is ready or not.
  46677. */
  46678. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46679. /**
  46680. * Checks to see if a texture is used in the material.
  46681. * @param defines the list of "defines" to update.
  46682. * @param scene defines the scene to the material belongs to.
  46683. */
  46684. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46685. /**
  46686. * Binds the material data.
  46687. * @param uniformBuffer defines the Uniform buffer to fill in.
  46688. * @param scene defines the scene the material belongs to.
  46689. * @param engine defines the engine the material belongs to.
  46690. * @param disableBumpMap defines wether the material disables bump or not.
  46691. * @param isFrozen defines wether the material is frozen or not.
  46692. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46693. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46694. */
  46695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46696. /**
  46697. * Checks to see if a texture is used in the material.
  46698. * @param texture - Base texture to use.
  46699. * @returns - Boolean specifying if a texture is used in the material.
  46700. */
  46701. hasTexture(texture: BaseTexture): boolean;
  46702. /**
  46703. * Returns an array of the actively used textures.
  46704. * @param activeTextures Array of BaseTextures
  46705. */
  46706. getActiveTextures(activeTextures: BaseTexture[]): void;
  46707. /**
  46708. * Returns the animatable textures.
  46709. * @param animatables Array of animatable textures.
  46710. */
  46711. getAnimatables(animatables: IAnimatable[]): void;
  46712. /**
  46713. * Disposes the resources of the material.
  46714. * @param forceDisposeTextures - Forces the disposal of all textures.
  46715. */
  46716. dispose(forceDisposeTextures?: boolean): void;
  46717. /**
  46718. * Get the current class name of the texture useful for serialization or dynamic coding.
  46719. * @returns "PBRClearCoatConfiguration"
  46720. */
  46721. getClassName(): string;
  46722. /**
  46723. * Add fallbacks to the effect fallbacks list.
  46724. * @param defines defines the Base texture to use.
  46725. * @param fallbacks defines the current fallback list.
  46726. * @param currentRank defines the current fallback rank.
  46727. * @returns the new fallback rank.
  46728. */
  46729. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46730. /**
  46731. * Add the required uniforms to the current list.
  46732. * @param uniforms defines the current uniform list.
  46733. */
  46734. static AddUniforms(uniforms: string[]): void;
  46735. /**
  46736. * Add the required samplers to the current list.
  46737. * @param samplers defines the current sampler list.
  46738. */
  46739. static AddSamplers(samplers: string[]): void;
  46740. /**
  46741. * Add the required uniforms to the current buffer.
  46742. * @param uniformBuffer defines the current uniform buffer.
  46743. */
  46744. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46745. /**
  46746. * Makes a duplicate of the current configuration into another one.
  46747. * @param clearCoatConfiguration define the config where to copy the info
  46748. */
  46749. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46750. /**
  46751. * Serializes this clear coat configuration.
  46752. * @returns - An object with the serialized config.
  46753. */
  46754. serialize(): any;
  46755. /**
  46756. * Parses a anisotropy Configuration from a serialized object.
  46757. * @param source - Serialized object.
  46758. * @param scene Defines the scene we are parsing for
  46759. * @param rootUrl Defines the rootUrl to load from
  46760. */
  46761. parse(source: any, scene: Scene, rootUrl: string): void;
  46762. }
  46763. }
  46764. declare module BABYLON {
  46765. /**
  46766. * @hidden
  46767. */
  46768. export interface IMaterialAnisotropicDefines {
  46769. ANISOTROPIC: boolean;
  46770. ANISOTROPIC_TEXTURE: boolean;
  46771. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46772. MAINUV1: boolean;
  46773. _areTexturesDirty: boolean;
  46774. _needUVs: boolean;
  46775. }
  46776. /**
  46777. * Define the code related to the anisotropic parameters of the pbr material.
  46778. */
  46779. export class PBRAnisotropicConfiguration {
  46780. private _isEnabled;
  46781. /**
  46782. * Defines if the anisotropy is enabled in the material.
  46783. */
  46784. isEnabled: boolean;
  46785. /**
  46786. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46787. */
  46788. intensity: number;
  46789. /**
  46790. * Defines if the effect is along the tangents, bitangents or in between.
  46791. * By default, the effect is "strectching" the highlights along the tangents.
  46792. */
  46793. direction: Vector2;
  46794. private _texture;
  46795. /**
  46796. * Stores the anisotropy values in a texture.
  46797. * rg is direction (like normal from -1 to 1)
  46798. * b is a intensity
  46799. */
  46800. texture: Nullable<BaseTexture>;
  46801. /** @hidden */
  46802. private _internalMarkAllSubMeshesAsTexturesDirty;
  46803. /** @hidden */
  46804. _markAllSubMeshesAsTexturesDirty(): void;
  46805. /**
  46806. * Instantiate a new istance of anisotropy configuration.
  46807. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46808. */
  46809. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46810. /**
  46811. * Specifies that the submesh is ready to be used.
  46812. * @param defines the list of "defines" to update.
  46813. * @param scene defines the scene the material belongs to.
  46814. * @returns - boolean indicating that the submesh is ready or not.
  46815. */
  46816. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46817. /**
  46818. * Checks to see if a texture is used in the material.
  46819. * @param defines the list of "defines" to update.
  46820. * @param mesh the mesh we are preparing the defines for.
  46821. * @param scene defines the scene the material belongs to.
  46822. */
  46823. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46824. /**
  46825. * Binds the material data.
  46826. * @param uniformBuffer defines the Uniform buffer to fill in.
  46827. * @param scene defines the scene the material belongs to.
  46828. * @param isFrozen defines wether the material is frozen or not.
  46829. */
  46830. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46831. /**
  46832. * Checks to see if a texture is used in the material.
  46833. * @param texture - Base texture to use.
  46834. * @returns - Boolean specifying if a texture is used in the material.
  46835. */
  46836. hasTexture(texture: BaseTexture): boolean;
  46837. /**
  46838. * Returns an array of the actively used textures.
  46839. * @param activeTextures Array of BaseTextures
  46840. */
  46841. getActiveTextures(activeTextures: BaseTexture[]): void;
  46842. /**
  46843. * Returns the animatable textures.
  46844. * @param animatables Array of animatable textures.
  46845. */
  46846. getAnimatables(animatables: IAnimatable[]): void;
  46847. /**
  46848. * Disposes the resources of the material.
  46849. * @param forceDisposeTextures - Forces the disposal of all textures.
  46850. */
  46851. dispose(forceDisposeTextures?: boolean): void;
  46852. /**
  46853. * Get the current class name of the texture useful for serialization or dynamic coding.
  46854. * @returns "PBRAnisotropicConfiguration"
  46855. */
  46856. getClassName(): string;
  46857. /**
  46858. * Add fallbacks to the effect fallbacks list.
  46859. * @param defines defines the Base texture to use.
  46860. * @param fallbacks defines the current fallback list.
  46861. * @param currentRank defines the current fallback rank.
  46862. * @returns the new fallback rank.
  46863. */
  46864. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46865. /**
  46866. * Add the required uniforms to the current list.
  46867. * @param uniforms defines the current uniform list.
  46868. */
  46869. static AddUniforms(uniforms: string[]): void;
  46870. /**
  46871. * Add the required uniforms to the current buffer.
  46872. * @param uniformBuffer defines the current uniform buffer.
  46873. */
  46874. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46875. /**
  46876. * Add the required samplers to the current list.
  46877. * @param samplers defines the current sampler list.
  46878. */
  46879. static AddSamplers(samplers: string[]): void;
  46880. /**
  46881. * Makes a duplicate of the current configuration into another one.
  46882. * @param anisotropicConfiguration define the config where to copy the info
  46883. */
  46884. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46885. /**
  46886. * Serializes this anisotropy configuration.
  46887. * @returns - An object with the serialized config.
  46888. */
  46889. serialize(): any;
  46890. /**
  46891. * Parses a anisotropy Configuration from a serialized object.
  46892. * @param source - Serialized object.
  46893. * @param scene Defines the scene we are parsing for
  46894. * @param rootUrl Defines the rootUrl to load from
  46895. */
  46896. parse(source: any, scene: Scene, rootUrl: string): void;
  46897. }
  46898. }
  46899. declare module BABYLON {
  46900. /**
  46901. * @hidden
  46902. */
  46903. export interface IMaterialBRDFDefines {
  46904. BRDF_V_HEIGHT_CORRELATED: boolean;
  46905. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46906. SPHERICAL_HARMONICS: boolean;
  46907. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46908. /** @hidden */
  46909. _areMiscDirty: boolean;
  46910. }
  46911. /**
  46912. * Define the code related to the BRDF parameters of the pbr material.
  46913. */
  46914. export class PBRBRDFConfiguration {
  46915. /**
  46916. * Default value used for the energy conservation.
  46917. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46918. */
  46919. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46920. /**
  46921. * Default value used for the Smith Visibility Height Correlated mode.
  46922. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46923. */
  46924. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46925. /**
  46926. * Default value used for the IBL diffuse part.
  46927. * This can help switching back to the polynomials mode globally which is a tiny bit
  46928. * less GPU intensive at the drawback of a lower quality.
  46929. */
  46930. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46931. /**
  46932. * Default value used for activating energy conservation for the specular workflow.
  46933. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46934. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46935. */
  46936. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46937. private _useEnergyConservation;
  46938. /**
  46939. * Defines if the material uses energy conservation.
  46940. */
  46941. useEnergyConservation: boolean;
  46942. private _useSmithVisibilityHeightCorrelated;
  46943. /**
  46944. * LEGACY Mode set to false
  46945. * Defines if the material uses height smith correlated visibility term.
  46946. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46947. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46948. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46949. * Not relying on height correlated will also disable energy conservation.
  46950. */
  46951. useSmithVisibilityHeightCorrelated: boolean;
  46952. private _useSphericalHarmonics;
  46953. /**
  46954. * LEGACY Mode set to false
  46955. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46956. * diffuse part of the IBL.
  46957. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46958. * to the ground truth.
  46959. */
  46960. useSphericalHarmonics: boolean;
  46961. private _useSpecularGlossinessInputEnergyConservation;
  46962. /**
  46963. * Defines if the material uses energy conservation, when the specular workflow is active.
  46964. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46965. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46966. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46967. */
  46968. useSpecularGlossinessInputEnergyConservation: boolean;
  46969. /** @hidden */
  46970. private _internalMarkAllSubMeshesAsMiscDirty;
  46971. /** @hidden */
  46972. _markAllSubMeshesAsMiscDirty(): void;
  46973. /**
  46974. * Instantiate a new istance of clear coat configuration.
  46975. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46976. */
  46977. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46978. /**
  46979. * Checks to see if a texture is used in the material.
  46980. * @param defines the list of "defines" to update.
  46981. */
  46982. prepareDefines(defines: IMaterialBRDFDefines): void;
  46983. /**
  46984. * Get the current class name of the texture useful for serialization or dynamic coding.
  46985. * @returns "PBRClearCoatConfiguration"
  46986. */
  46987. getClassName(): string;
  46988. /**
  46989. * Makes a duplicate of the current configuration into another one.
  46990. * @param brdfConfiguration define the config where to copy the info
  46991. */
  46992. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46993. /**
  46994. * Serializes this BRDF configuration.
  46995. * @returns - An object with the serialized config.
  46996. */
  46997. serialize(): any;
  46998. /**
  46999. * Parses a anisotropy Configuration from a serialized object.
  47000. * @param source - Serialized object.
  47001. * @param scene Defines the scene we are parsing for
  47002. * @param rootUrl Defines the rootUrl to load from
  47003. */
  47004. parse(source: any, scene: Scene, rootUrl: string): void;
  47005. }
  47006. }
  47007. declare module BABYLON {
  47008. /**
  47009. * @hidden
  47010. */
  47011. export interface IMaterialSheenDefines {
  47012. SHEEN: boolean;
  47013. SHEEN_TEXTURE: boolean;
  47014. SHEEN_TEXTUREDIRECTUV: number;
  47015. SHEEN_LINKWITHALBEDO: boolean;
  47016. /** @hidden */
  47017. _areTexturesDirty: boolean;
  47018. }
  47019. /**
  47020. * Define the code related to the Sheen parameters of the pbr material.
  47021. */
  47022. export class PBRSheenConfiguration {
  47023. private _isEnabled;
  47024. /**
  47025. * Defines if the material uses sheen.
  47026. */
  47027. isEnabled: boolean;
  47028. private _linkSheenWithAlbedo;
  47029. /**
  47030. * Defines if the sheen is linked to the sheen color.
  47031. */
  47032. linkSheenWithAlbedo: boolean;
  47033. /**
  47034. * Defines the sheen intensity.
  47035. */
  47036. intensity: number;
  47037. /**
  47038. * Defines the sheen color.
  47039. */
  47040. color: Color3;
  47041. private _texture;
  47042. /**
  47043. * Stores the sheen tint values in a texture.
  47044. * rgb is tint
  47045. * a is a intensity
  47046. */
  47047. texture: Nullable<BaseTexture>;
  47048. /** @hidden */
  47049. private _internalMarkAllSubMeshesAsTexturesDirty;
  47050. /** @hidden */
  47051. _markAllSubMeshesAsTexturesDirty(): void;
  47052. /**
  47053. * Instantiate a new istance of clear coat configuration.
  47054. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47055. */
  47056. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47057. /**
  47058. * Specifies that the submesh is ready to be used.
  47059. * @param defines the list of "defines" to update.
  47060. * @param scene defines the scene the material belongs to.
  47061. * @returns - boolean indicating that the submesh is ready or not.
  47062. */
  47063. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47064. /**
  47065. * Checks to see if a texture is used in the material.
  47066. * @param defines the list of "defines" to update.
  47067. * @param scene defines the scene the material belongs to.
  47068. */
  47069. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47070. /**
  47071. * Binds the material data.
  47072. * @param uniformBuffer defines the Uniform buffer to fill in.
  47073. * @param scene defines the scene the material belongs to.
  47074. * @param isFrozen defines wether the material is frozen or not.
  47075. */
  47076. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47077. /**
  47078. * Checks to see if a texture is used in the material.
  47079. * @param texture - Base texture to use.
  47080. * @returns - Boolean specifying if a texture is used in the material.
  47081. */
  47082. hasTexture(texture: BaseTexture): boolean;
  47083. /**
  47084. * Returns an array of the actively used textures.
  47085. * @param activeTextures Array of BaseTextures
  47086. */
  47087. getActiveTextures(activeTextures: BaseTexture[]): void;
  47088. /**
  47089. * Returns the animatable textures.
  47090. * @param animatables Array of animatable textures.
  47091. */
  47092. getAnimatables(animatables: IAnimatable[]): void;
  47093. /**
  47094. * Disposes the resources of the material.
  47095. * @param forceDisposeTextures - Forces the disposal of all textures.
  47096. */
  47097. dispose(forceDisposeTextures?: boolean): void;
  47098. /**
  47099. * Get the current class name of the texture useful for serialization or dynamic coding.
  47100. * @returns "PBRSheenConfiguration"
  47101. */
  47102. getClassName(): string;
  47103. /**
  47104. * Add fallbacks to the effect fallbacks list.
  47105. * @param defines defines the Base texture to use.
  47106. * @param fallbacks defines the current fallback list.
  47107. * @param currentRank defines the current fallback rank.
  47108. * @returns the new fallback rank.
  47109. */
  47110. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47111. /**
  47112. * Add the required uniforms to the current list.
  47113. * @param uniforms defines the current uniform list.
  47114. */
  47115. static AddUniforms(uniforms: string[]): void;
  47116. /**
  47117. * Add the required uniforms to the current buffer.
  47118. * @param uniformBuffer defines the current uniform buffer.
  47119. */
  47120. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47121. /**
  47122. * Add the required samplers to the current list.
  47123. * @param samplers defines the current sampler list.
  47124. */
  47125. static AddSamplers(samplers: string[]): void;
  47126. /**
  47127. * Makes a duplicate of the current configuration into another one.
  47128. * @param sheenConfiguration define the config where to copy the info
  47129. */
  47130. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47131. /**
  47132. * Serializes this BRDF configuration.
  47133. * @returns - An object with the serialized config.
  47134. */
  47135. serialize(): any;
  47136. /**
  47137. * Parses a anisotropy Configuration from a serialized object.
  47138. * @param source - Serialized object.
  47139. * @param scene Defines the scene we are parsing for
  47140. * @param rootUrl Defines the rootUrl to load from
  47141. */
  47142. parse(source: any, scene: Scene, rootUrl: string): void;
  47143. }
  47144. }
  47145. declare module BABYLON {
  47146. /**
  47147. * @hidden
  47148. */
  47149. export interface IMaterialSubSurfaceDefines {
  47150. SUBSURFACE: boolean;
  47151. SS_REFRACTION: boolean;
  47152. SS_TRANSLUCENCY: boolean;
  47153. SS_SCATERRING: boolean;
  47154. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47155. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47156. SS_REFRACTIONMAP_3D: boolean;
  47157. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47158. SS_LODINREFRACTIONALPHA: boolean;
  47159. SS_GAMMAREFRACTION: boolean;
  47160. SS_RGBDREFRACTION: boolean;
  47161. SS_LINEARSPECULARREFRACTION: boolean;
  47162. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47163. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47164. /** @hidden */
  47165. _areTexturesDirty: boolean;
  47166. }
  47167. /**
  47168. * Define the code related to the sub surface parameters of the pbr material.
  47169. */
  47170. export class PBRSubSurfaceConfiguration {
  47171. private _isRefractionEnabled;
  47172. /**
  47173. * Defines if the refraction is enabled in the material.
  47174. */
  47175. isRefractionEnabled: boolean;
  47176. private _isTranslucencyEnabled;
  47177. /**
  47178. * Defines if the translucency is enabled in the material.
  47179. */
  47180. isTranslucencyEnabled: boolean;
  47181. private _isScatteringEnabled;
  47182. /**
  47183. * Defines the refraction intensity of the material.
  47184. * The refraction when enabled replaces the Diffuse part of the material.
  47185. * The intensity helps transitionning between diffuse and refraction.
  47186. */
  47187. refractionIntensity: number;
  47188. /**
  47189. * Defines the translucency intensity of the material.
  47190. * When translucency has been enabled, this defines how much of the "translucency"
  47191. * is addded to the diffuse part of the material.
  47192. */
  47193. translucencyIntensity: number;
  47194. /**
  47195. * Defines the scattering intensity of the material.
  47196. * When scattering has been enabled, this defines how much of the "scattered light"
  47197. * is addded to the diffuse part of the material.
  47198. */
  47199. scatteringIntensity: number;
  47200. private _thicknessTexture;
  47201. /**
  47202. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47203. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47204. * 0 would mean minimumThickness
  47205. * 1 would mean maximumThickness
  47206. * The other channels might be use as a mask to vary the different effects intensity.
  47207. */
  47208. thicknessTexture: Nullable<BaseTexture>;
  47209. private _refractionTexture;
  47210. /**
  47211. * Defines the texture to use for refraction.
  47212. */
  47213. refractionTexture: Nullable<BaseTexture>;
  47214. private _indexOfRefraction;
  47215. /**
  47216. * Defines the index of refraction used in the material.
  47217. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47218. */
  47219. indexOfRefraction: number;
  47220. private _invertRefractionY;
  47221. /**
  47222. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47223. */
  47224. invertRefractionY: boolean;
  47225. private _linkRefractionWithTransparency;
  47226. /**
  47227. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47228. * Materials half opaque for instance using refraction could benefit from this control.
  47229. */
  47230. linkRefractionWithTransparency: boolean;
  47231. /**
  47232. * Defines the minimum thickness stored in the thickness map.
  47233. * If no thickness map is defined, this value will be used to simulate thickness.
  47234. */
  47235. minimumThickness: number;
  47236. /**
  47237. * Defines the maximum thickness stored in the thickness map.
  47238. */
  47239. maximumThickness: number;
  47240. /**
  47241. * Defines the volume tint of the material.
  47242. * This is used for both translucency and scattering.
  47243. */
  47244. tintColor: Color3;
  47245. /**
  47246. * Defines the distance at which the tint color should be found in the media.
  47247. * This is used for refraction only.
  47248. */
  47249. tintColorAtDistance: number;
  47250. /**
  47251. * Defines how far each channel transmit through the media.
  47252. * It is defined as a color to simplify it selection.
  47253. */
  47254. diffusionDistance: Color3;
  47255. private _useMaskFromThicknessTexture;
  47256. /**
  47257. * Stores the intensity of the different subsurface effects in the thickness texture.
  47258. * * the green channel is the translucency intensity.
  47259. * * the blue channel is the scattering intensity.
  47260. * * the alpha channel is the refraction intensity.
  47261. */
  47262. useMaskFromThicknessTexture: boolean;
  47263. /** @hidden */
  47264. private _internalMarkAllSubMeshesAsTexturesDirty;
  47265. /** @hidden */
  47266. _markAllSubMeshesAsTexturesDirty(): void;
  47267. /**
  47268. * Instantiate a new istance of sub surface configuration.
  47269. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47270. */
  47271. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47272. /**
  47273. * Gets wehter the submesh is ready to be used or not.
  47274. * @param defines the list of "defines" to update.
  47275. * @param scene defines the scene the material belongs to.
  47276. * @returns - boolean indicating that the submesh is ready or not.
  47277. */
  47278. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47279. /**
  47280. * Checks to see if a texture is used in the material.
  47281. * @param defines the list of "defines" to update.
  47282. * @param scene defines the scene to the material belongs to.
  47283. */
  47284. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47285. /**
  47286. * Binds the material data.
  47287. * @param uniformBuffer defines the Uniform buffer to fill in.
  47288. * @param scene defines the scene the material belongs to.
  47289. * @param engine defines the engine the material belongs to.
  47290. * @param isFrozen defines wether the material is frozen or not.
  47291. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47292. */
  47293. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47294. /**
  47295. * Unbinds the material from the mesh.
  47296. * @param activeEffect defines the effect that should be unbound from.
  47297. * @returns true if unbound, otherwise false
  47298. */
  47299. unbind(activeEffect: Effect): boolean;
  47300. /**
  47301. * Returns the texture used for refraction or null if none is used.
  47302. * @param scene defines the scene the material belongs to.
  47303. * @returns - Refraction texture if present. If no refraction texture and refraction
  47304. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47305. */
  47306. private _getRefractionTexture;
  47307. /**
  47308. * Returns true if alpha blending should be disabled.
  47309. */
  47310. readonly disableAlphaBlending: boolean;
  47311. /**
  47312. * Fills the list of render target textures.
  47313. * @param renderTargets the list of render targets to update
  47314. */
  47315. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47316. /**
  47317. * Checks to see if a texture is used in the material.
  47318. * @param texture - Base texture to use.
  47319. * @returns - Boolean specifying if a texture is used in the material.
  47320. */
  47321. hasTexture(texture: BaseTexture): boolean;
  47322. /**
  47323. * Gets a boolean indicating that current material needs to register RTT
  47324. * @returns true if this uses a render target otherwise false.
  47325. */
  47326. hasRenderTargetTextures(): boolean;
  47327. /**
  47328. * Returns an array of the actively used textures.
  47329. * @param activeTextures Array of BaseTextures
  47330. */
  47331. getActiveTextures(activeTextures: BaseTexture[]): void;
  47332. /**
  47333. * Returns the animatable textures.
  47334. * @param animatables Array of animatable textures.
  47335. */
  47336. getAnimatables(animatables: IAnimatable[]): void;
  47337. /**
  47338. * Disposes the resources of the material.
  47339. * @param forceDisposeTextures - Forces the disposal of all textures.
  47340. */
  47341. dispose(forceDisposeTextures?: boolean): void;
  47342. /**
  47343. * Get the current class name of the texture useful for serialization or dynamic coding.
  47344. * @returns "PBRSubSurfaceConfiguration"
  47345. */
  47346. getClassName(): string;
  47347. /**
  47348. * Add fallbacks to the effect fallbacks list.
  47349. * @param defines defines the Base texture to use.
  47350. * @param fallbacks defines the current fallback list.
  47351. * @param currentRank defines the current fallback rank.
  47352. * @returns the new fallback rank.
  47353. */
  47354. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47355. /**
  47356. * Add the required uniforms to the current list.
  47357. * @param uniforms defines the current uniform list.
  47358. */
  47359. static AddUniforms(uniforms: string[]): void;
  47360. /**
  47361. * Add the required samplers to the current list.
  47362. * @param samplers defines the current sampler list.
  47363. */
  47364. static AddSamplers(samplers: string[]): void;
  47365. /**
  47366. * Add the required uniforms to the current buffer.
  47367. * @param uniformBuffer defines the current uniform buffer.
  47368. */
  47369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47370. /**
  47371. * Makes a duplicate of the current configuration into another one.
  47372. * @param configuration define the config where to copy the info
  47373. */
  47374. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47375. /**
  47376. * Serializes this Sub Surface configuration.
  47377. * @returns - An object with the serialized config.
  47378. */
  47379. serialize(): any;
  47380. /**
  47381. * Parses a anisotropy Configuration from a serialized object.
  47382. * @param source - Serialized object.
  47383. * @param scene Defines the scene we are parsing for
  47384. * @param rootUrl Defines the rootUrl to load from
  47385. */
  47386. parse(source: any, scene: Scene, rootUrl: string): void;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /** @hidden */
  47391. export var pbrFragmentDeclaration: {
  47392. name: string;
  47393. shader: string;
  47394. };
  47395. }
  47396. declare module BABYLON {
  47397. /** @hidden */
  47398. export var pbrUboDeclaration: {
  47399. name: string;
  47400. shader: string;
  47401. };
  47402. }
  47403. declare module BABYLON {
  47404. /** @hidden */
  47405. export var pbrFragmentExtraDeclaration: {
  47406. name: string;
  47407. shader: string;
  47408. };
  47409. }
  47410. declare module BABYLON {
  47411. /** @hidden */
  47412. export var pbrFragmentSamplersDeclaration: {
  47413. name: string;
  47414. shader: string;
  47415. };
  47416. }
  47417. declare module BABYLON {
  47418. /** @hidden */
  47419. export var pbrHelperFunctions: {
  47420. name: string;
  47421. shader: string;
  47422. };
  47423. }
  47424. declare module BABYLON {
  47425. /** @hidden */
  47426. export var harmonicsFunctions: {
  47427. name: string;
  47428. shader: string;
  47429. };
  47430. }
  47431. declare module BABYLON {
  47432. /** @hidden */
  47433. export var pbrDirectLightingSetupFunctions: {
  47434. name: string;
  47435. shader: string;
  47436. };
  47437. }
  47438. declare module BABYLON {
  47439. /** @hidden */
  47440. export var pbrDirectLightingFalloffFunctions: {
  47441. name: string;
  47442. shader: string;
  47443. };
  47444. }
  47445. declare module BABYLON {
  47446. /** @hidden */
  47447. export var pbrBRDFFunctions: {
  47448. name: string;
  47449. shader: string;
  47450. };
  47451. }
  47452. declare module BABYLON {
  47453. /** @hidden */
  47454. export var pbrDirectLightingFunctions: {
  47455. name: string;
  47456. shader: string;
  47457. };
  47458. }
  47459. declare module BABYLON {
  47460. /** @hidden */
  47461. export var pbrIBLFunctions: {
  47462. name: string;
  47463. shader: string;
  47464. };
  47465. }
  47466. declare module BABYLON {
  47467. /** @hidden */
  47468. export var pbrDebug: {
  47469. name: string;
  47470. shader: string;
  47471. };
  47472. }
  47473. declare module BABYLON {
  47474. /** @hidden */
  47475. export var pbrPixelShader: {
  47476. name: string;
  47477. shader: string;
  47478. };
  47479. }
  47480. declare module BABYLON {
  47481. /** @hidden */
  47482. export var pbrVertexDeclaration: {
  47483. name: string;
  47484. shader: string;
  47485. };
  47486. }
  47487. declare module BABYLON {
  47488. /** @hidden */
  47489. export var pbrVertexShader: {
  47490. name: string;
  47491. shader: string;
  47492. };
  47493. }
  47494. declare module BABYLON {
  47495. /**
  47496. * Manages the defines for the PBR Material.
  47497. * @hidden
  47498. */
  47499. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47500. PBR: boolean;
  47501. MAINUV1: boolean;
  47502. MAINUV2: boolean;
  47503. UV1: boolean;
  47504. UV2: boolean;
  47505. ALBEDO: boolean;
  47506. ALBEDODIRECTUV: number;
  47507. VERTEXCOLOR: boolean;
  47508. AMBIENT: boolean;
  47509. AMBIENTDIRECTUV: number;
  47510. AMBIENTINGRAYSCALE: boolean;
  47511. OPACITY: boolean;
  47512. VERTEXALPHA: boolean;
  47513. OPACITYDIRECTUV: number;
  47514. OPACITYRGB: boolean;
  47515. ALPHATEST: boolean;
  47516. DEPTHPREPASS: boolean;
  47517. ALPHABLEND: boolean;
  47518. ALPHAFROMALBEDO: boolean;
  47519. ALPHATESTVALUE: string;
  47520. SPECULAROVERALPHA: boolean;
  47521. RADIANCEOVERALPHA: boolean;
  47522. ALPHAFRESNEL: boolean;
  47523. LINEARALPHAFRESNEL: boolean;
  47524. PREMULTIPLYALPHA: boolean;
  47525. EMISSIVE: boolean;
  47526. EMISSIVEDIRECTUV: number;
  47527. REFLECTIVITY: boolean;
  47528. REFLECTIVITYDIRECTUV: number;
  47529. SPECULARTERM: boolean;
  47530. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47531. MICROSURFACEAUTOMATIC: boolean;
  47532. LODBASEDMICROSFURACE: boolean;
  47533. MICROSURFACEMAP: boolean;
  47534. MICROSURFACEMAPDIRECTUV: number;
  47535. METALLICWORKFLOW: boolean;
  47536. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47537. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47538. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47539. AOSTOREINMETALMAPRED: boolean;
  47540. ENVIRONMENTBRDF: boolean;
  47541. ENVIRONMENTBRDF_RGBD: boolean;
  47542. NORMAL: boolean;
  47543. TANGENT: boolean;
  47544. BUMP: boolean;
  47545. BUMPDIRECTUV: number;
  47546. OBJECTSPACE_NORMALMAP: boolean;
  47547. PARALLAX: boolean;
  47548. PARALLAXOCCLUSION: boolean;
  47549. NORMALXYSCALE: boolean;
  47550. LIGHTMAP: boolean;
  47551. LIGHTMAPDIRECTUV: number;
  47552. USELIGHTMAPASSHADOWMAP: boolean;
  47553. GAMMALIGHTMAP: boolean;
  47554. RGBDLIGHTMAP: boolean;
  47555. REFLECTION: boolean;
  47556. REFLECTIONMAP_3D: boolean;
  47557. REFLECTIONMAP_SPHERICAL: boolean;
  47558. REFLECTIONMAP_PLANAR: boolean;
  47559. REFLECTIONMAP_CUBIC: boolean;
  47560. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47561. REFLECTIONMAP_PROJECTION: boolean;
  47562. REFLECTIONMAP_SKYBOX: boolean;
  47563. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47564. REFLECTIONMAP_EXPLICIT: boolean;
  47565. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47566. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47567. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47568. INVERTCUBICMAP: boolean;
  47569. USESPHERICALFROMREFLECTIONMAP: boolean;
  47570. USEIRRADIANCEMAP: boolean;
  47571. SPHERICAL_HARMONICS: boolean;
  47572. USESPHERICALINVERTEX: boolean;
  47573. REFLECTIONMAP_OPPOSITEZ: boolean;
  47574. LODINREFLECTIONALPHA: boolean;
  47575. GAMMAREFLECTION: boolean;
  47576. RGBDREFLECTION: boolean;
  47577. LINEARSPECULARREFLECTION: boolean;
  47578. RADIANCEOCCLUSION: boolean;
  47579. HORIZONOCCLUSION: boolean;
  47580. INSTANCES: boolean;
  47581. NUM_BONE_INFLUENCERS: number;
  47582. BonesPerMesh: number;
  47583. BONETEXTURE: boolean;
  47584. NONUNIFORMSCALING: boolean;
  47585. MORPHTARGETS: boolean;
  47586. MORPHTARGETS_NORMAL: boolean;
  47587. MORPHTARGETS_TANGENT: boolean;
  47588. MORPHTARGETS_UV: boolean;
  47589. NUM_MORPH_INFLUENCERS: number;
  47590. IMAGEPROCESSING: boolean;
  47591. VIGNETTE: boolean;
  47592. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47593. VIGNETTEBLENDMODEOPAQUE: boolean;
  47594. TONEMAPPING: boolean;
  47595. TONEMAPPING_ACES: boolean;
  47596. CONTRAST: boolean;
  47597. COLORCURVES: boolean;
  47598. COLORGRADING: boolean;
  47599. COLORGRADING3D: boolean;
  47600. SAMPLER3DGREENDEPTH: boolean;
  47601. SAMPLER3DBGRMAP: boolean;
  47602. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47603. EXPOSURE: boolean;
  47604. MULTIVIEW: boolean;
  47605. USEPHYSICALLIGHTFALLOFF: boolean;
  47606. USEGLTFLIGHTFALLOFF: boolean;
  47607. TWOSIDEDLIGHTING: boolean;
  47608. SHADOWFLOAT: boolean;
  47609. CLIPPLANE: boolean;
  47610. CLIPPLANE2: boolean;
  47611. CLIPPLANE3: boolean;
  47612. CLIPPLANE4: boolean;
  47613. POINTSIZE: boolean;
  47614. FOG: boolean;
  47615. LOGARITHMICDEPTH: boolean;
  47616. FORCENORMALFORWARD: boolean;
  47617. SPECULARAA: boolean;
  47618. CLEARCOAT: boolean;
  47619. CLEARCOAT_DEFAULTIOR: boolean;
  47620. CLEARCOAT_TEXTURE: boolean;
  47621. CLEARCOAT_TEXTUREDIRECTUV: number;
  47622. CLEARCOAT_BUMP: boolean;
  47623. CLEARCOAT_BUMPDIRECTUV: number;
  47624. CLEARCOAT_TINT: boolean;
  47625. CLEARCOAT_TINT_TEXTURE: boolean;
  47626. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47627. ANISOTROPIC: boolean;
  47628. ANISOTROPIC_TEXTURE: boolean;
  47629. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47630. BRDF_V_HEIGHT_CORRELATED: boolean;
  47631. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47632. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47633. SHEEN: boolean;
  47634. SHEEN_TEXTURE: boolean;
  47635. SHEEN_TEXTUREDIRECTUV: number;
  47636. SHEEN_LINKWITHALBEDO: boolean;
  47637. SUBSURFACE: boolean;
  47638. SS_REFRACTION: boolean;
  47639. SS_TRANSLUCENCY: boolean;
  47640. SS_SCATERRING: boolean;
  47641. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47642. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47643. SS_REFRACTIONMAP_3D: boolean;
  47644. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47645. SS_LODINREFRACTIONALPHA: boolean;
  47646. SS_GAMMAREFRACTION: boolean;
  47647. SS_RGBDREFRACTION: boolean;
  47648. SS_LINEARSPECULARREFRACTION: boolean;
  47649. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47650. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47651. UNLIT: boolean;
  47652. DEBUGMODE: number;
  47653. /**
  47654. * Initializes the PBR Material defines.
  47655. */
  47656. constructor();
  47657. /**
  47658. * Resets the PBR Material defines.
  47659. */
  47660. reset(): void;
  47661. }
  47662. /**
  47663. * The Physically based material base class of BJS.
  47664. *
  47665. * This offers the main features of a standard PBR material.
  47666. * For more information, please refer to the documentation :
  47667. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47668. */
  47669. export abstract class PBRBaseMaterial extends PushMaterial {
  47670. /**
  47671. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47672. */
  47673. static readonly PBRMATERIAL_OPAQUE: number;
  47674. /**
  47675. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47676. */
  47677. static readonly PBRMATERIAL_ALPHATEST: number;
  47678. /**
  47679. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47680. */
  47681. static readonly PBRMATERIAL_ALPHABLEND: number;
  47682. /**
  47683. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47684. * They are also discarded below the alpha cutoff threshold to improve performances.
  47685. */
  47686. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47687. /**
  47688. * Defines the default value of how much AO map is occluding the analytical lights
  47689. * (point spot...).
  47690. */
  47691. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47692. /**
  47693. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47694. */
  47695. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47696. /**
  47697. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47698. * to enhance interoperability with other engines.
  47699. */
  47700. static readonly LIGHTFALLOFF_GLTF: number;
  47701. /**
  47702. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47703. * to enhance interoperability with other materials.
  47704. */
  47705. static readonly LIGHTFALLOFF_STANDARD: number;
  47706. /**
  47707. * Intensity of the direct lights e.g. the four lights available in your scene.
  47708. * This impacts both the direct diffuse and specular highlights.
  47709. */
  47710. protected _directIntensity: number;
  47711. /**
  47712. * Intensity of the emissive part of the material.
  47713. * This helps controlling the emissive effect without modifying the emissive color.
  47714. */
  47715. protected _emissiveIntensity: number;
  47716. /**
  47717. * Intensity of the environment e.g. how much the environment will light the object
  47718. * either through harmonics for rough material or through the refelction for shiny ones.
  47719. */
  47720. protected _environmentIntensity: number;
  47721. /**
  47722. * This is a special control allowing the reduction of the specular highlights coming from the
  47723. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47724. */
  47725. protected _specularIntensity: number;
  47726. /**
  47727. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47728. */
  47729. private _lightingInfos;
  47730. /**
  47731. * Debug Control allowing disabling the bump map on this material.
  47732. */
  47733. protected _disableBumpMap: boolean;
  47734. /**
  47735. * AKA Diffuse Texture in standard nomenclature.
  47736. */
  47737. protected _albedoTexture: Nullable<BaseTexture>;
  47738. /**
  47739. * AKA Occlusion Texture in other nomenclature.
  47740. */
  47741. protected _ambientTexture: Nullable<BaseTexture>;
  47742. /**
  47743. * AKA Occlusion Texture Intensity in other nomenclature.
  47744. */
  47745. protected _ambientTextureStrength: number;
  47746. /**
  47747. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47748. * 1 means it completely occludes it
  47749. * 0 mean it has no impact
  47750. */
  47751. protected _ambientTextureImpactOnAnalyticalLights: number;
  47752. /**
  47753. * Stores the alpha values in a texture.
  47754. */
  47755. protected _opacityTexture: Nullable<BaseTexture>;
  47756. /**
  47757. * Stores the reflection values in a texture.
  47758. */
  47759. protected _reflectionTexture: Nullable<BaseTexture>;
  47760. /**
  47761. * Stores the emissive values in a texture.
  47762. */
  47763. protected _emissiveTexture: Nullable<BaseTexture>;
  47764. /**
  47765. * AKA Specular texture in other nomenclature.
  47766. */
  47767. protected _reflectivityTexture: Nullable<BaseTexture>;
  47768. /**
  47769. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47770. */
  47771. protected _metallicTexture: Nullable<BaseTexture>;
  47772. /**
  47773. * Specifies the metallic scalar of the metallic/roughness workflow.
  47774. * Can also be used to scale the metalness values of the metallic texture.
  47775. */
  47776. protected _metallic: Nullable<number>;
  47777. /**
  47778. * Specifies the roughness scalar of the metallic/roughness workflow.
  47779. * Can also be used to scale the roughness values of the metallic texture.
  47780. */
  47781. protected _roughness: Nullable<number>;
  47782. /**
  47783. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47784. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47785. */
  47786. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47787. /**
  47788. * Stores surface normal data used to displace a mesh in a texture.
  47789. */
  47790. protected _bumpTexture: Nullable<BaseTexture>;
  47791. /**
  47792. * Stores the pre-calculated light information of a mesh in a texture.
  47793. */
  47794. protected _lightmapTexture: Nullable<BaseTexture>;
  47795. /**
  47796. * The color of a material in ambient lighting.
  47797. */
  47798. protected _ambientColor: Color3;
  47799. /**
  47800. * AKA Diffuse Color in other nomenclature.
  47801. */
  47802. protected _albedoColor: Color3;
  47803. /**
  47804. * AKA Specular Color in other nomenclature.
  47805. */
  47806. protected _reflectivityColor: Color3;
  47807. /**
  47808. * The color applied when light is reflected from a material.
  47809. */
  47810. protected _reflectionColor: Color3;
  47811. /**
  47812. * The color applied when light is emitted from a material.
  47813. */
  47814. protected _emissiveColor: Color3;
  47815. /**
  47816. * AKA Glossiness in other nomenclature.
  47817. */
  47818. protected _microSurface: number;
  47819. /**
  47820. * Specifies that the material will use the light map as a show map.
  47821. */
  47822. protected _useLightmapAsShadowmap: boolean;
  47823. /**
  47824. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47825. * makes the reflect vector face the model (under horizon).
  47826. */
  47827. protected _useHorizonOcclusion: boolean;
  47828. /**
  47829. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47830. * too much the area relying on ambient texture to define their ambient occlusion.
  47831. */
  47832. protected _useRadianceOcclusion: boolean;
  47833. /**
  47834. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47835. */
  47836. protected _useAlphaFromAlbedoTexture: boolean;
  47837. /**
  47838. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47839. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47840. */
  47841. protected _useSpecularOverAlpha: boolean;
  47842. /**
  47843. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47844. */
  47845. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47846. /**
  47847. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47848. */
  47849. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47850. /**
  47851. * Specifies if the metallic texture contains the roughness information in its green channel.
  47852. */
  47853. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47854. /**
  47855. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47856. */
  47857. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47858. /**
  47859. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47860. */
  47861. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47862. /**
  47863. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47864. */
  47865. protected _useAmbientInGrayScale: boolean;
  47866. /**
  47867. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47868. * The material will try to infer what glossiness each pixel should be.
  47869. */
  47870. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47871. /**
  47872. * Defines the falloff type used in this material.
  47873. * It by default is Physical.
  47874. */
  47875. protected _lightFalloff: number;
  47876. /**
  47877. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47878. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47879. */
  47880. protected _useRadianceOverAlpha: boolean;
  47881. /**
  47882. * Allows using an object space normal map (instead of tangent space).
  47883. */
  47884. protected _useObjectSpaceNormalMap: boolean;
  47885. /**
  47886. * Allows using the bump map in parallax mode.
  47887. */
  47888. protected _useParallax: boolean;
  47889. /**
  47890. * Allows using the bump map in parallax occlusion mode.
  47891. */
  47892. protected _useParallaxOcclusion: boolean;
  47893. /**
  47894. * Controls the scale bias of the parallax mode.
  47895. */
  47896. protected _parallaxScaleBias: number;
  47897. /**
  47898. * If sets to true, disables all the lights affecting the material.
  47899. */
  47900. protected _disableLighting: boolean;
  47901. /**
  47902. * Number of Simultaneous lights allowed on the material.
  47903. */
  47904. protected _maxSimultaneousLights: number;
  47905. /**
  47906. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47907. */
  47908. protected _invertNormalMapX: boolean;
  47909. /**
  47910. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47911. */
  47912. protected _invertNormalMapY: boolean;
  47913. /**
  47914. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47915. */
  47916. protected _twoSidedLighting: boolean;
  47917. /**
  47918. * Defines the alpha limits in alpha test mode.
  47919. */
  47920. protected _alphaCutOff: number;
  47921. /**
  47922. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47923. */
  47924. protected _forceAlphaTest: boolean;
  47925. /**
  47926. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47927. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47928. */
  47929. protected _useAlphaFresnel: boolean;
  47930. /**
  47931. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47932. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47933. */
  47934. protected _useLinearAlphaFresnel: boolean;
  47935. /**
  47936. * The transparency mode of the material.
  47937. */
  47938. protected _transparencyMode: Nullable<number>;
  47939. /**
  47940. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47941. * from cos thetav and roughness:
  47942. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47943. */
  47944. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47945. /**
  47946. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47947. */
  47948. protected _forceIrradianceInFragment: boolean;
  47949. /**
  47950. * Force normal to face away from face.
  47951. */
  47952. protected _forceNormalForward: boolean;
  47953. /**
  47954. * Enables specular anti aliasing in the PBR shader.
  47955. * It will both interacts on the Geometry for analytical and IBL lighting.
  47956. * It also prefilter the roughness map based on the bump values.
  47957. */
  47958. protected _enableSpecularAntiAliasing: boolean;
  47959. /**
  47960. * Default configuration related to image processing available in the PBR Material.
  47961. */
  47962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47963. /**
  47964. * Keep track of the image processing observer to allow dispose and replace.
  47965. */
  47966. private _imageProcessingObserver;
  47967. /**
  47968. * Attaches a new image processing configuration to the PBR Material.
  47969. * @param configuration
  47970. */
  47971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47972. /**
  47973. * Stores the available render targets.
  47974. */
  47975. private _renderTargets;
  47976. /**
  47977. * Sets the global ambient color for the material used in lighting calculations.
  47978. */
  47979. private _globalAmbientColor;
  47980. /**
  47981. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47982. */
  47983. private _useLogarithmicDepth;
  47984. /**
  47985. * If set to true, no lighting calculations will be applied.
  47986. */
  47987. private _unlit;
  47988. private _debugMode;
  47989. /**
  47990. * @hidden
  47991. * This is reserved for the inspector.
  47992. * Defines the material debug mode.
  47993. * It helps seeing only some components of the material while troubleshooting.
  47994. */
  47995. debugMode: number;
  47996. /**
  47997. * @hidden
  47998. * This is reserved for the inspector.
  47999. * Specify from where on screen the debug mode should start.
  48000. * The value goes from -1 (full screen) to 1 (not visible)
  48001. * It helps with side by side comparison against the final render
  48002. * This defaults to -1
  48003. */
  48004. private debugLimit;
  48005. /**
  48006. * @hidden
  48007. * This is reserved for the inspector.
  48008. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48009. * You can use the factor to better multiply the final value.
  48010. */
  48011. private debugFactor;
  48012. /**
  48013. * Defines the clear coat layer parameters for the material.
  48014. */
  48015. readonly clearCoat: PBRClearCoatConfiguration;
  48016. /**
  48017. * Defines the anisotropic parameters for the material.
  48018. */
  48019. readonly anisotropy: PBRAnisotropicConfiguration;
  48020. /**
  48021. * Defines the BRDF parameters for the material.
  48022. */
  48023. readonly brdf: PBRBRDFConfiguration;
  48024. /**
  48025. * Defines the Sheen parameters for the material.
  48026. */
  48027. readonly sheen: PBRSheenConfiguration;
  48028. /**
  48029. * Defines the SubSurface parameters for the material.
  48030. */
  48031. readonly subSurface: PBRSubSurfaceConfiguration;
  48032. /**
  48033. * Custom callback helping to override the default shader used in the material.
  48034. */
  48035. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48036. protected _rebuildInParallel: boolean;
  48037. /**
  48038. * Instantiates a new PBRMaterial instance.
  48039. *
  48040. * @param name The material name
  48041. * @param scene The scene the material will be use in.
  48042. */
  48043. constructor(name: string, scene: Scene);
  48044. /**
  48045. * Gets a boolean indicating that current material needs to register RTT
  48046. */
  48047. readonly hasRenderTargetTextures: boolean;
  48048. /**
  48049. * Gets the name of the material class.
  48050. */
  48051. getClassName(): string;
  48052. /**
  48053. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48054. */
  48055. /**
  48056. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48057. */
  48058. useLogarithmicDepth: boolean;
  48059. /**
  48060. * Gets the current transparency mode.
  48061. */
  48062. /**
  48063. * Sets the transparency mode of the material.
  48064. *
  48065. * | Value | Type | Description |
  48066. * | ----- | ----------------------------------- | ----------- |
  48067. * | 0 | OPAQUE | |
  48068. * | 1 | ALPHATEST | |
  48069. * | 2 | ALPHABLEND | |
  48070. * | 3 | ALPHATESTANDBLEND | |
  48071. *
  48072. */
  48073. transparencyMode: Nullable<number>;
  48074. /**
  48075. * Returns true if alpha blending should be disabled.
  48076. */
  48077. private readonly _disableAlphaBlending;
  48078. /**
  48079. * Specifies whether or not this material should be rendered in alpha blend mode.
  48080. */
  48081. needAlphaBlending(): boolean;
  48082. /**
  48083. * Specifies if the mesh will require alpha blending.
  48084. * @param mesh - BJS mesh.
  48085. */
  48086. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48087. /**
  48088. * Specifies whether or not this material should be rendered in alpha test mode.
  48089. */
  48090. needAlphaTesting(): boolean;
  48091. /**
  48092. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48093. */
  48094. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48095. /**
  48096. * Gets the texture used for the alpha test.
  48097. */
  48098. getAlphaTestTexture(): Nullable<BaseTexture>;
  48099. /**
  48100. * Specifies that the submesh is ready to be used.
  48101. * @param mesh - BJS mesh.
  48102. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48103. * @param useInstances - Specifies that instances should be used.
  48104. * @returns - boolean indicating that the submesh is ready or not.
  48105. */
  48106. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48107. /**
  48108. * Specifies if the material uses metallic roughness workflow.
  48109. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48110. */
  48111. isMetallicWorkflow(): boolean;
  48112. private _prepareEffect;
  48113. private _prepareDefines;
  48114. /**
  48115. * Force shader compilation
  48116. */
  48117. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48118. clipPlane: boolean;
  48119. }>): void;
  48120. /**
  48121. * Initializes the uniform buffer layout for the shader.
  48122. */
  48123. buildUniformLayout(): void;
  48124. /**
  48125. * Unbinds the material from the mesh
  48126. */
  48127. unbind(): void;
  48128. /**
  48129. * Binds the submesh data.
  48130. * @param world - The world matrix.
  48131. * @param mesh - The BJS mesh.
  48132. * @param subMesh - A submesh of the BJS mesh.
  48133. */
  48134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48135. /**
  48136. * Returns the animatable textures.
  48137. * @returns - Array of animatable textures.
  48138. */
  48139. getAnimatables(): IAnimatable[];
  48140. /**
  48141. * Returns the texture used for reflections.
  48142. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48143. */
  48144. private _getReflectionTexture;
  48145. /**
  48146. * Returns an array of the actively used textures.
  48147. * @returns - Array of BaseTextures
  48148. */
  48149. getActiveTextures(): BaseTexture[];
  48150. /**
  48151. * Checks to see if a texture is used in the material.
  48152. * @param texture - Base texture to use.
  48153. * @returns - Boolean specifying if a texture is used in the material.
  48154. */
  48155. hasTexture(texture: BaseTexture): boolean;
  48156. /**
  48157. * Disposes the resources of the material.
  48158. * @param forceDisposeEffect - Forces the disposal of effects.
  48159. * @param forceDisposeTextures - Forces the disposal of all textures.
  48160. */
  48161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48162. }
  48163. }
  48164. declare module BABYLON {
  48165. /**
  48166. * The Physically based material of BJS.
  48167. *
  48168. * This offers the main features of a standard PBR material.
  48169. * For more information, please refer to the documentation :
  48170. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48171. */
  48172. export class PBRMaterial extends PBRBaseMaterial {
  48173. /**
  48174. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48175. */
  48176. static readonly PBRMATERIAL_OPAQUE: number;
  48177. /**
  48178. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48179. */
  48180. static readonly PBRMATERIAL_ALPHATEST: number;
  48181. /**
  48182. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48183. */
  48184. static readonly PBRMATERIAL_ALPHABLEND: number;
  48185. /**
  48186. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48187. * They are also discarded below the alpha cutoff threshold to improve performances.
  48188. */
  48189. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48190. /**
  48191. * Defines the default value of how much AO map is occluding the analytical lights
  48192. * (point spot...).
  48193. */
  48194. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48195. /**
  48196. * Intensity of the direct lights e.g. the four lights available in your scene.
  48197. * This impacts both the direct diffuse and specular highlights.
  48198. */
  48199. directIntensity: number;
  48200. /**
  48201. * Intensity of the emissive part of the material.
  48202. * This helps controlling the emissive effect without modifying the emissive color.
  48203. */
  48204. emissiveIntensity: number;
  48205. /**
  48206. * Intensity of the environment e.g. how much the environment will light the object
  48207. * either through harmonics for rough material or through the refelction for shiny ones.
  48208. */
  48209. environmentIntensity: number;
  48210. /**
  48211. * This is a special control allowing the reduction of the specular highlights coming from the
  48212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48213. */
  48214. specularIntensity: number;
  48215. /**
  48216. * Debug Control allowing disabling the bump map on this material.
  48217. */
  48218. disableBumpMap: boolean;
  48219. /**
  48220. * AKA Diffuse Texture in standard nomenclature.
  48221. */
  48222. albedoTexture: BaseTexture;
  48223. /**
  48224. * AKA Occlusion Texture in other nomenclature.
  48225. */
  48226. ambientTexture: BaseTexture;
  48227. /**
  48228. * AKA Occlusion Texture Intensity in other nomenclature.
  48229. */
  48230. ambientTextureStrength: number;
  48231. /**
  48232. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48233. * 1 means it completely occludes it
  48234. * 0 mean it has no impact
  48235. */
  48236. ambientTextureImpactOnAnalyticalLights: number;
  48237. /**
  48238. * Stores the alpha values in a texture.
  48239. */
  48240. opacityTexture: BaseTexture;
  48241. /**
  48242. * Stores the reflection values in a texture.
  48243. */
  48244. reflectionTexture: Nullable<BaseTexture>;
  48245. /**
  48246. * Stores the emissive values in a texture.
  48247. */
  48248. emissiveTexture: BaseTexture;
  48249. /**
  48250. * AKA Specular texture in other nomenclature.
  48251. */
  48252. reflectivityTexture: BaseTexture;
  48253. /**
  48254. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48255. */
  48256. metallicTexture: BaseTexture;
  48257. /**
  48258. * Specifies the metallic scalar of the metallic/roughness workflow.
  48259. * Can also be used to scale the metalness values of the metallic texture.
  48260. */
  48261. metallic: Nullable<number>;
  48262. /**
  48263. * Specifies the roughness scalar of the metallic/roughness workflow.
  48264. * Can also be used to scale the roughness values of the metallic texture.
  48265. */
  48266. roughness: Nullable<number>;
  48267. /**
  48268. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48269. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48270. */
  48271. microSurfaceTexture: BaseTexture;
  48272. /**
  48273. * Stores surface normal data used to displace a mesh in a texture.
  48274. */
  48275. bumpTexture: BaseTexture;
  48276. /**
  48277. * Stores the pre-calculated light information of a mesh in a texture.
  48278. */
  48279. lightmapTexture: BaseTexture;
  48280. /**
  48281. * Stores the refracted light information in a texture.
  48282. */
  48283. refractionTexture: Nullable<BaseTexture>;
  48284. /**
  48285. * The color of a material in ambient lighting.
  48286. */
  48287. ambientColor: Color3;
  48288. /**
  48289. * AKA Diffuse Color in other nomenclature.
  48290. */
  48291. albedoColor: Color3;
  48292. /**
  48293. * AKA Specular Color in other nomenclature.
  48294. */
  48295. reflectivityColor: Color3;
  48296. /**
  48297. * The color reflected from the material.
  48298. */
  48299. reflectionColor: Color3;
  48300. /**
  48301. * The color emitted from the material.
  48302. */
  48303. emissiveColor: Color3;
  48304. /**
  48305. * AKA Glossiness in other nomenclature.
  48306. */
  48307. microSurface: number;
  48308. /**
  48309. * source material index of refraction (IOR)' / 'destination material IOR.
  48310. */
  48311. indexOfRefraction: number;
  48312. /**
  48313. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48314. */
  48315. invertRefractionY: boolean;
  48316. /**
  48317. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48318. * Materials half opaque for instance using refraction could benefit from this control.
  48319. */
  48320. linkRefractionWithTransparency: boolean;
  48321. /**
  48322. * If true, the light map contains occlusion information instead of lighting info.
  48323. */
  48324. useLightmapAsShadowmap: boolean;
  48325. /**
  48326. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48327. */
  48328. useAlphaFromAlbedoTexture: boolean;
  48329. /**
  48330. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48331. */
  48332. forceAlphaTest: boolean;
  48333. /**
  48334. * Defines the alpha limits in alpha test mode.
  48335. */
  48336. alphaCutOff: number;
  48337. /**
  48338. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48339. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48340. */
  48341. useSpecularOverAlpha: boolean;
  48342. /**
  48343. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48344. */
  48345. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48346. /**
  48347. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48348. */
  48349. useRoughnessFromMetallicTextureAlpha: boolean;
  48350. /**
  48351. * Specifies if the metallic texture contains the roughness information in its green channel.
  48352. */
  48353. useRoughnessFromMetallicTextureGreen: boolean;
  48354. /**
  48355. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48356. */
  48357. useMetallnessFromMetallicTextureBlue: boolean;
  48358. /**
  48359. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48360. */
  48361. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48362. /**
  48363. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48364. */
  48365. useAmbientInGrayScale: boolean;
  48366. /**
  48367. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48368. * The material will try to infer what glossiness each pixel should be.
  48369. */
  48370. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48371. /**
  48372. * BJS is using an harcoded light falloff based on a manually sets up range.
  48373. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48374. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48375. */
  48376. /**
  48377. * BJS is using an harcoded light falloff based on a manually sets up range.
  48378. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48379. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48380. */
  48381. usePhysicalLightFalloff: boolean;
  48382. /**
  48383. * In order to support the falloff compatibility with gltf, a special mode has been added
  48384. * to reproduce the gltf light falloff.
  48385. */
  48386. /**
  48387. * In order to support the falloff compatibility with gltf, a special mode has been added
  48388. * to reproduce the gltf light falloff.
  48389. */
  48390. useGLTFLightFalloff: boolean;
  48391. /**
  48392. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48393. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48394. */
  48395. useRadianceOverAlpha: boolean;
  48396. /**
  48397. * Allows using an object space normal map (instead of tangent space).
  48398. */
  48399. useObjectSpaceNormalMap: boolean;
  48400. /**
  48401. * Allows using the bump map in parallax mode.
  48402. */
  48403. useParallax: boolean;
  48404. /**
  48405. * Allows using the bump map in parallax occlusion mode.
  48406. */
  48407. useParallaxOcclusion: boolean;
  48408. /**
  48409. * Controls the scale bias of the parallax mode.
  48410. */
  48411. parallaxScaleBias: number;
  48412. /**
  48413. * If sets to true, disables all the lights affecting the material.
  48414. */
  48415. disableLighting: boolean;
  48416. /**
  48417. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48418. */
  48419. forceIrradianceInFragment: boolean;
  48420. /**
  48421. * Number of Simultaneous lights allowed on the material.
  48422. */
  48423. maxSimultaneousLights: number;
  48424. /**
  48425. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48426. */
  48427. invertNormalMapX: boolean;
  48428. /**
  48429. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48430. */
  48431. invertNormalMapY: boolean;
  48432. /**
  48433. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48434. */
  48435. twoSidedLighting: boolean;
  48436. /**
  48437. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48438. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48439. */
  48440. useAlphaFresnel: boolean;
  48441. /**
  48442. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48443. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48444. */
  48445. useLinearAlphaFresnel: boolean;
  48446. /**
  48447. * Let user defines the brdf lookup texture used for IBL.
  48448. * A default 8bit version is embedded but you could point at :
  48449. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48450. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48451. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48452. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48453. */
  48454. environmentBRDFTexture: Nullable<BaseTexture>;
  48455. /**
  48456. * Force normal to face away from face.
  48457. */
  48458. forceNormalForward: boolean;
  48459. /**
  48460. * Enables specular anti aliasing in the PBR shader.
  48461. * It will both interacts on the Geometry for analytical and IBL lighting.
  48462. * It also prefilter the roughness map based on the bump values.
  48463. */
  48464. enableSpecularAntiAliasing: boolean;
  48465. /**
  48466. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48467. * makes the reflect vector face the model (under horizon).
  48468. */
  48469. useHorizonOcclusion: boolean;
  48470. /**
  48471. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48472. * too much the area relying on ambient texture to define their ambient occlusion.
  48473. */
  48474. useRadianceOcclusion: boolean;
  48475. /**
  48476. * If set to true, no lighting calculations will be applied.
  48477. */
  48478. unlit: boolean;
  48479. /**
  48480. * Gets the image processing configuration used either in this material.
  48481. */
  48482. /**
  48483. * Sets the Default image processing configuration used either in the this material.
  48484. *
  48485. * If sets to null, the scene one is in use.
  48486. */
  48487. imageProcessingConfiguration: ImageProcessingConfiguration;
  48488. /**
  48489. * Gets wether the color curves effect is enabled.
  48490. */
  48491. /**
  48492. * Sets wether the color curves effect is enabled.
  48493. */
  48494. cameraColorCurvesEnabled: boolean;
  48495. /**
  48496. * Gets wether the color grading effect is enabled.
  48497. */
  48498. /**
  48499. * Gets wether the color grading effect is enabled.
  48500. */
  48501. cameraColorGradingEnabled: boolean;
  48502. /**
  48503. * Gets wether tonemapping is enabled or not.
  48504. */
  48505. /**
  48506. * Sets wether tonemapping is enabled or not
  48507. */
  48508. cameraToneMappingEnabled: boolean;
  48509. /**
  48510. * The camera exposure used on this material.
  48511. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48512. * This corresponds to a photographic exposure.
  48513. */
  48514. /**
  48515. * The camera exposure used on this material.
  48516. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48517. * This corresponds to a photographic exposure.
  48518. */
  48519. cameraExposure: number;
  48520. /**
  48521. * Gets The camera contrast used on this material.
  48522. */
  48523. /**
  48524. * Sets The camera contrast used on this material.
  48525. */
  48526. cameraContrast: number;
  48527. /**
  48528. * Gets the Color Grading 2D Lookup Texture.
  48529. */
  48530. /**
  48531. * Sets the Color Grading 2D Lookup Texture.
  48532. */
  48533. cameraColorGradingTexture: Nullable<BaseTexture>;
  48534. /**
  48535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48537. * 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;
  48538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48539. */
  48540. /**
  48541. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48542. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48543. * 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;
  48544. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48545. */
  48546. cameraColorCurves: Nullable<ColorCurves>;
  48547. /**
  48548. * Instantiates a new PBRMaterial instance.
  48549. *
  48550. * @param name The material name
  48551. * @param scene The scene the material will be use in.
  48552. */
  48553. constructor(name: string, scene: Scene);
  48554. /**
  48555. * Returns the name of this material class.
  48556. */
  48557. getClassName(): string;
  48558. /**
  48559. * Makes a duplicate of the current material.
  48560. * @param name - name to use for the new material.
  48561. */
  48562. clone(name: string): PBRMaterial;
  48563. /**
  48564. * Serializes this PBR Material.
  48565. * @returns - An object with the serialized material.
  48566. */
  48567. serialize(): any;
  48568. /**
  48569. * Parses a PBR Material from a serialized object.
  48570. * @param source - Serialized object.
  48571. * @param scene - BJS scene instance.
  48572. * @param rootUrl - url for the scene object
  48573. * @returns - PBRMaterial
  48574. */
  48575. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. /**
  48580. * Direct draw surface info
  48581. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48582. */
  48583. export interface DDSInfo {
  48584. /**
  48585. * Width of the texture
  48586. */
  48587. width: number;
  48588. /**
  48589. * Width of the texture
  48590. */
  48591. height: number;
  48592. /**
  48593. * Number of Mipmaps for the texture
  48594. * @see https://en.wikipedia.org/wiki/Mipmap
  48595. */
  48596. mipmapCount: number;
  48597. /**
  48598. * If the textures format is a known fourCC format
  48599. * @see https://www.fourcc.org/
  48600. */
  48601. isFourCC: boolean;
  48602. /**
  48603. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48604. */
  48605. isRGB: boolean;
  48606. /**
  48607. * If the texture is a lumincance format
  48608. */
  48609. isLuminance: boolean;
  48610. /**
  48611. * If this is a cube texture
  48612. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48613. */
  48614. isCube: boolean;
  48615. /**
  48616. * If the texture is a compressed format eg. FOURCC_DXT1
  48617. */
  48618. isCompressed: boolean;
  48619. /**
  48620. * The dxgiFormat of the texture
  48621. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48622. */
  48623. dxgiFormat: number;
  48624. /**
  48625. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48626. */
  48627. textureType: number;
  48628. /**
  48629. * Sphericle polynomial created for the dds texture
  48630. */
  48631. sphericalPolynomial?: SphericalPolynomial;
  48632. }
  48633. /**
  48634. * Class used to provide DDS decompression tools
  48635. */
  48636. export class DDSTools {
  48637. /**
  48638. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48639. */
  48640. static StoreLODInAlphaChannel: boolean;
  48641. /**
  48642. * Gets DDS information from an array buffer
  48643. * @param arrayBuffer defines the array buffer to read data from
  48644. * @returns the DDS information
  48645. */
  48646. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48647. private static _FloatView;
  48648. private static _Int32View;
  48649. private static _ToHalfFloat;
  48650. private static _FromHalfFloat;
  48651. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48652. private static _GetHalfFloatRGBAArrayBuffer;
  48653. private static _GetFloatRGBAArrayBuffer;
  48654. private static _GetFloatAsUIntRGBAArrayBuffer;
  48655. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48656. private static _GetRGBAArrayBuffer;
  48657. private static _ExtractLongWordOrder;
  48658. private static _GetRGBArrayBuffer;
  48659. private static _GetLuminanceArrayBuffer;
  48660. /**
  48661. * Uploads DDS Levels to a Babylon Texture
  48662. * @hidden
  48663. */
  48664. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48665. }
  48666. interface ThinEngine {
  48667. /**
  48668. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48669. * @param rootUrl defines the url where the file to load is located
  48670. * @param scene defines the current scene
  48671. * @param lodScale defines scale to apply to the mip map selection
  48672. * @param lodOffset defines offset to apply to the mip map selection
  48673. * @param onLoad defines an optional callback raised when the texture is loaded
  48674. * @param onError defines an optional callback raised if there is an issue to load the texture
  48675. * @param format defines the format of the data
  48676. * @param forcedExtension defines the extension to use to pick the right loader
  48677. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48678. * @returns the cube texture as an InternalTexture
  48679. */
  48680. 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;
  48681. }
  48682. }
  48683. declare module BABYLON {
  48684. /**
  48685. * Implementation of the DDS Texture Loader.
  48686. * @hidden
  48687. */
  48688. export class _DDSTextureLoader implements IInternalTextureLoader {
  48689. /**
  48690. * Defines wether the loader supports cascade loading the different faces.
  48691. */
  48692. readonly supportCascades: boolean;
  48693. /**
  48694. * This returns if the loader support the current file information.
  48695. * @param extension defines the file extension of the file being loaded
  48696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48697. * @param fallback defines the fallback internal texture if any
  48698. * @param isBase64 defines whether the texture is encoded as a base64
  48699. * @param isBuffer defines whether the texture data are stored as a buffer
  48700. * @returns true if the loader can load the specified file
  48701. */
  48702. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48703. /**
  48704. * Transform the url before loading if required.
  48705. * @param rootUrl the url of the texture
  48706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48707. * @returns the transformed texture
  48708. */
  48709. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48710. /**
  48711. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48712. * @param rootUrl the url of the texture
  48713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48714. * @returns the fallback texture
  48715. */
  48716. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48717. /**
  48718. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48719. * @param data contains the texture data
  48720. * @param texture defines the BabylonJS internal texture
  48721. * @param createPolynomials will be true if polynomials have been requested
  48722. * @param onLoad defines the callback to trigger once the texture is ready
  48723. * @param onError defines the callback to trigger in case of error
  48724. */
  48725. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48726. /**
  48727. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48728. * @param data contains the texture data
  48729. * @param texture defines the BabylonJS internal texture
  48730. * @param callback defines the method to call once ready to upload
  48731. */
  48732. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48733. }
  48734. }
  48735. declare module BABYLON {
  48736. /**
  48737. * Implementation of the ENV Texture Loader.
  48738. * @hidden
  48739. */
  48740. export class _ENVTextureLoader implements IInternalTextureLoader {
  48741. /**
  48742. * Defines wether the loader supports cascade loading the different faces.
  48743. */
  48744. readonly supportCascades: boolean;
  48745. /**
  48746. * This returns if the loader support the current file information.
  48747. * @param extension defines the file extension of the file being loaded
  48748. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48749. * @param fallback defines the fallback internal texture if any
  48750. * @param isBase64 defines whether the texture is encoded as a base64
  48751. * @param isBuffer defines whether the texture data are stored as a buffer
  48752. * @returns true if the loader can load the specified file
  48753. */
  48754. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48755. /**
  48756. * Transform the url before loading if required.
  48757. * @param rootUrl the url of the texture
  48758. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48759. * @returns the transformed texture
  48760. */
  48761. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48762. /**
  48763. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48764. * @param rootUrl the url of the texture
  48765. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48766. * @returns the fallback texture
  48767. */
  48768. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48769. /**
  48770. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48771. * @param data contains the texture data
  48772. * @param texture defines the BabylonJS internal texture
  48773. * @param createPolynomials will be true if polynomials have been requested
  48774. * @param onLoad defines the callback to trigger once the texture is ready
  48775. * @param onError defines the callback to trigger in case of error
  48776. */
  48777. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48778. /**
  48779. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48780. * @param data contains the texture data
  48781. * @param texture defines the BabylonJS internal texture
  48782. * @param callback defines the method to call once ready to upload
  48783. */
  48784. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48785. }
  48786. }
  48787. declare module BABYLON {
  48788. /**
  48789. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48790. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48791. */
  48792. export class KhronosTextureContainer {
  48793. /** contents of the KTX container file */
  48794. arrayBuffer: any;
  48795. private static HEADER_LEN;
  48796. private static COMPRESSED_2D;
  48797. private static COMPRESSED_3D;
  48798. private static TEX_2D;
  48799. private static TEX_3D;
  48800. /**
  48801. * Gets the openGL type
  48802. */
  48803. glType: number;
  48804. /**
  48805. * Gets the openGL type size
  48806. */
  48807. glTypeSize: number;
  48808. /**
  48809. * Gets the openGL format
  48810. */
  48811. glFormat: number;
  48812. /**
  48813. * Gets the openGL internal format
  48814. */
  48815. glInternalFormat: number;
  48816. /**
  48817. * Gets the base internal format
  48818. */
  48819. glBaseInternalFormat: number;
  48820. /**
  48821. * Gets image width in pixel
  48822. */
  48823. pixelWidth: number;
  48824. /**
  48825. * Gets image height in pixel
  48826. */
  48827. pixelHeight: number;
  48828. /**
  48829. * Gets image depth in pixels
  48830. */
  48831. pixelDepth: number;
  48832. /**
  48833. * Gets the number of array elements
  48834. */
  48835. numberOfArrayElements: number;
  48836. /**
  48837. * Gets the number of faces
  48838. */
  48839. numberOfFaces: number;
  48840. /**
  48841. * Gets the number of mipmap levels
  48842. */
  48843. numberOfMipmapLevels: number;
  48844. /**
  48845. * Gets the bytes of key value data
  48846. */
  48847. bytesOfKeyValueData: number;
  48848. /**
  48849. * Gets the load type
  48850. */
  48851. loadType: number;
  48852. /**
  48853. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48854. */
  48855. isInvalid: boolean;
  48856. /**
  48857. * Creates a new KhronosTextureContainer
  48858. * @param arrayBuffer contents of the KTX container file
  48859. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48860. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48861. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48862. */
  48863. constructor(
  48864. /** contents of the KTX container file */
  48865. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48866. /**
  48867. * Uploads KTX content to a Babylon Texture.
  48868. * It is assumed that the texture has already been created & is currently bound
  48869. * @hidden
  48870. */
  48871. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48872. private _upload2DCompressedLevels;
  48873. }
  48874. }
  48875. declare module BABYLON {
  48876. /**
  48877. * Implementation of the KTX Texture Loader.
  48878. * @hidden
  48879. */
  48880. export class _KTXTextureLoader implements IInternalTextureLoader {
  48881. /**
  48882. * Defines wether the loader supports cascade loading the different faces.
  48883. */
  48884. readonly supportCascades: boolean;
  48885. /**
  48886. * This returns if the loader support the current file information.
  48887. * @param extension defines the file extension of the file being loaded
  48888. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48889. * @param fallback defines the fallback internal texture if any
  48890. * @param isBase64 defines whether the texture is encoded as a base64
  48891. * @param isBuffer defines whether the texture data are stored as a buffer
  48892. * @returns true if the loader can load the specified file
  48893. */
  48894. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48895. /**
  48896. * Transform the url before loading if required.
  48897. * @param rootUrl the url of the texture
  48898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48899. * @returns the transformed texture
  48900. */
  48901. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48902. /**
  48903. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48904. * @param rootUrl the url of the texture
  48905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48906. * @returns the fallback texture
  48907. */
  48908. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48909. /**
  48910. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48911. * @param data contains the texture data
  48912. * @param texture defines the BabylonJS internal texture
  48913. * @param createPolynomials will be true if polynomials have been requested
  48914. * @param onLoad defines the callback to trigger once the texture is ready
  48915. * @param onError defines the callback to trigger in case of error
  48916. */
  48917. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48918. /**
  48919. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48920. * @param data contains the texture data
  48921. * @param texture defines the BabylonJS internal texture
  48922. * @param callback defines the method to call once ready to upload
  48923. */
  48924. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48925. }
  48926. }
  48927. declare module BABYLON {
  48928. /**
  48929. * Options for the default xr helper
  48930. */
  48931. export class WebXRDefaultExperienceOptions {
  48932. /**
  48933. * Floor meshes that should be used for teleporting
  48934. */
  48935. floorMeshes: Array<AbstractMesh>;
  48936. }
  48937. /**
  48938. * Default experience which provides a similar setup to the previous webVRExperience
  48939. */
  48940. export class WebXRDefaultExperience {
  48941. /**
  48942. * Base experience
  48943. */
  48944. baseExperience: WebXRExperienceHelper;
  48945. /**
  48946. * Input experience extension
  48947. */
  48948. input: WebXRInput;
  48949. /**
  48950. * Loads the controller models
  48951. */
  48952. controllerModelLoader: WebXRControllerModelLoader;
  48953. /**
  48954. * Enables laser pointer and selection
  48955. */
  48956. pointerSelection: WebXRControllerPointerSelection;
  48957. /**
  48958. * Enables teleportation
  48959. */
  48960. teleportation: WebXRControllerTeleportation;
  48961. /**
  48962. * Enables ui for enetering/exiting xr
  48963. */
  48964. enterExitUI: WebXREnterExitUI;
  48965. /**
  48966. * Default output canvas xr should render to
  48967. */
  48968. outputCanvas: WebXRManagedOutputCanvas;
  48969. /**
  48970. * Creates the default xr experience
  48971. * @param scene scene
  48972. * @param options options for basic configuration
  48973. * @returns resulting WebXRDefaultExperience
  48974. */
  48975. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48976. private constructor();
  48977. /**
  48978. * DIsposes of the experience helper
  48979. */
  48980. dispose(): void;
  48981. }
  48982. }
  48983. declare module BABYLON {
  48984. /** @hidden */
  48985. export var _forceSceneHelpersToBundle: boolean;
  48986. interface Scene {
  48987. /**
  48988. * Creates a default light for the scene.
  48989. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48990. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48991. */
  48992. createDefaultLight(replace?: boolean): void;
  48993. /**
  48994. * Creates a default camera for the scene.
  48995. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48996. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48997. * @param replace has default false, when true replaces the active camera in the scene
  48998. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48999. */
  49000. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49001. /**
  49002. * Creates a default camera and a default light.
  49003. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49004. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49005. * @param replace has the default false, when true replaces the active camera/light in the scene
  49006. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49007. */
  49008. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49009. /**
  49010. * Creates a new sky box
  49011. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49012. * @param environmentTexture defines the texture to use as environment texture
  49013. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49014. * @param scale defines the overall scale of the skybox
  49015. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49016. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49017. * @returns a new mesh holding the sky box
  49018. */
  49019. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49020. /**
  49021. * Creates a new environment
  49022. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49023. * @param options defines the options you can use to configure the environment
  49024. * @returns the new EnvironmentHelper
  49025. */
  49026. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49027. /**
  49028. * Creates a new VREXperienceHelper
  49029. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49030. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49031. * @returns a new VREXperienceHelper
  49032. */
  49033. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49034. /**
  49035. * Creates a new WebXRDefaultExperience
  49036. * @see http://doc.babylonjs.com/how_to/webxr
  49037. * @param options experience options
  49038. * @returns a promise for a new WebXRDefaultExperience
  49039. */
  49040. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49041. }
  49042. }
  49043. declare module BABYLON {
  49044. /**
  49045. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49046. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49047. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49048. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49049. */
  49050. export class VideoDome extends TransformNode {
  49051. /**
  49052. * Define the video source as a Monoscopic panoramic 360 video.
  49053. */
  49054. static readonly MODE_MONOSCOPIC: number;
  49055. /**
  49056. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49057. */
  49058. static readonly MODE_TOPBOTTOM: number;
  49059. /**
  49060. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49061. */
  49062. static readonly MODE_SIDEBYSIDE: number;
  49063. private _halfDome;
  49064. private _useDirectMapping;
  49065. /**
  49066. * The video texture being displayed on the sphere
  49067. */
  49068. protected _videoTexture: VideoTexture;
  49069. /**
  49070. * Gets the video texture being displayed on the sphere
  49071. */
  49072. readonly videoTexture: VideoTexture;
  49073. /**
  49074. * The skybox material
  49075. */
  49076. protected _material: BackgroundMaterial;
  49077. /**
  49078. * The surface used for the skybox
  49079. */
  49080. protected _mesh: Mesh;
  49081. /**
  49082. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49083. */
  49084. private _halfDomeMask;
  49085. /**
  49086. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49087. * Also see the options.resolution property.
  49088. */
  49089. fovMultiplier: number;
  49090. private _videoMode;
  49091. /**
  49092. * Gets or set the current video mode for the video. It can be:
  49093. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49094. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49095. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49096. */
  49097. videoMode: number;
  49098. /**
  49099. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49100. *
  49101. */
  49102. /**
  49103. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49104. */
  49105. halfDome: boolean;
  49106. /**
  49107. * Oberserver used in Stereoscopic VR Mode.
  49108. */
  49109. private _onBeforeCameraRenderObserver;
  49110. /**
  49111. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49112. * @param name Element's name, child elements will append suffixes for their own names.
  49113. * @param urlsOrVideo defines the url(s) or the video element to use
  49114. * @param options An object containing optional or exposed sub element properties
  49115. */
  49116. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49117. resolution?: number;
  49118. clickToPlay?: boolean;
  49119. autoPlay?: boolean;
  49120. loop?: boolean;
  49121. size?: number;
  49122. poster?: string;
  49123. faceForward?: boolean;
  49124. useDirectMapping?: boolean;
  49125. halfDomeMode?: boolean;
  49126. }, scene: Scene);
  49127. private _changeVideoMode;
  49128. /**
  49129. * Releases resources associated with this node.
  49130. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49131. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49132. */
  49133. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. /**
  49138. * This class can be used to get instrumentation data from a Babylon engine
  49139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49140. */
  49141. export class EngineInstrumentation implements IDisposable {
  49142. /**
  49143. * Define the instrumented engine.
  49144. */
  49145. engine: Engine;
  49146. private _captureGPUFrameTime;
  49147. private _gpuFrameTimeToken;
  49148. private _gpuFrameTime;
  49149. private _captureShaderCompilationTime;
  49150. private _shaderCompilationTime;
  49151. private _onBeginFrameObserver;
  49152. private _onEndFrameObserver;
  49153. private _onBeforeShaderCompilationObserver;
  49154. private _onAfterShaderCompilationObserver;
  49155. /**
  49156. * Gets the perf counter used for GPU frame time
  49157. */
  49158. readonly gpuFrameTimeCounter: PerfCounter;
  49159. /**
  49160. * Gets the GPU frame time capture status
  49161. */
  49162. /**
  49163. * Enable or disable the GPU frame time capture
  49164. */
  49165. captureGPUFrameTime: boolean;
  49166. /**
  49167. * Gets the perf counter used for shader compilation time
  49168. */
  49169. readonly shaderCompilationTimeCounter: PerfCounter;
  49170. /**
  49171. * Gets the shader compilation time capture status
  49172. */
  49173. /**
  49174. * Enable or disable the shader compilation time capture
  49175. */
  49176. captureShaderCompilationTime: boolean;
  49177. /**
  49178. * Instantiates a new engine instrumentation.
  49179. * This class can be used to get instrumentation data from a Babylon engine
  49180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49181. * @param engine Defines the engine to instrument
  49182. */
  49183. constructor(
  49184. /**
  49185. * Define the instrumented engine.
  49186. */
  49187. engine: Engine);
  49188. /**
  49189. * Dispose and release associated resources.
  49190. */
  49191. dispose(): void;
  49192. }
  49193. }
  49194. declare module BABYLON {
  49195. /**
  49196. * This class can be used to get instrumentation data from a Babylon engine
  49197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49198. */
  49199. export class SceneInstrumentation implements IDisposable {
  49200. /**
  49201. * Defines the scene to instrument
  49202. */
  49203. scene: Scene;
  49204. private _captureActiveMeshesEvaluationTime;
  49205. private _activeMeshesEvaluationTime;
  49206. private _captureRenderTargetsRenderTime;
  49207. private _renderTargetsRenderTime;
  49208. private _captureFrameTime;
  49209. private _frameTime;
  49210. private _captureRenderTime;
  49211. private _renderTime;
  49212. private _captureInterFrameTime;
  49213. private _interFrameTime;
  49214. private _captureParticlesRenderTime;
  49215. private _particlesRenderTime;
  49216. private _captureSpritesRenderTime;
  49217. private _spritesRenderTime;
  49218. private _capturePhysicsTime;
  49219. private _physicsTime;
  49220. private _captureAnimationsTime;
  49221. private _animationsTime;
  49222. private _captureCameraRenderTime;
  49223. private _cameraRenderTime;
  49224. private _onBeforeActiveMeshesEvaluationObserver;
  49225. private _onAfterActiveMeshesEvaluationObserver;
  49226. private _onBeforeRenderTargetsRenderObserver;
  49227. private _onAfterRenderTargetsRenderObserver;
  49228. private _onAfterRenderObserver;
  49229. private _onBeforeDrawPhaseObserver;
  49230. private _onAfterDrawPhaseObserver;
  49231. private _onBeforeAnimationsObserver;
  49232. private _onBeforeParticlesRenderingObserver;
  49233. private _onAfterParticlesRenderingObserver;
  49234. private _onBeforeSpritesRenderingObserver;
  49235. private _onAfterSpritesRenderingObserver;
  49236. private _onBeforePhysicsObserver;
  49237. private _onAfterPhysicsObserver;
  49238. private _onAfterAnimationsObserver;
  49239. private _onBeforeCameraRenderObserver;
  49240. private _onAfterCameraRenderObserver;
  49241. /**
  49242. * Gets the perf counter used for active meshes evaluation time
  49243. */
  49244. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49245. /**
  49246. * Gets the active meshes evaluation time capture status
  49247. */
  49248. /**
  49249. * Enable or disable the active meshes evaluation time capture
  49250. */
  49251. captureActiveMeshesEvaluationTime: boolean;
  49252. /**
  49253. * Gets the perf counter used for render targets render time
  49254. */
  49255. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49256. /**
  49257. * Gets the render targets render time capture status
  49258. */
  49259. /**
  49260. * Enable or disable the render targets render time capture
  49261. */
  49262. captureRenderTargetsRenderTime: boolean;
  49263. /**
  49264. * Gets the perf counter used for particles render time
  49265. */
  49266. readonly particlesRenderTimeCounter: PerfCounter;
  49267. /**
  49268. * Gets the particles render time capture status
  49269. */
  49270. /**
  49271. * Enable or disable the particles render time capture
  49272. */
  49273. captureParticlesRenderTime: boolean;
  49274. /**
  49275. * Gets the perf counter used for sprites render time
  49276. */
  49277. readonly spritesRenderTimeCounter: PerfCounter;
  49278. /**
  49279. * Gets the sprites render time capture status
  49280. */
  49281. /**
  49282. * Enable or disable the sprites render time capture
  49283. */
  49284. captureSpritesRenderTime: boolean;
  49285. /**
  49286. * Gets the perf counter used for physics time
  49287. */
  49288. readonly physicsTimeCounter: PerfCounter;
  49289. /**
  49290. * Gets the physics time capture status
  49291. */
  49292. /**
  49293. * Enable or disable the physics time capture
  49294. */
  49295. capturePhysicsTime: boolean;
  49296. /**
  49297. * Gets the perf counter used for animations time
  49298. */
  49299. readonly animationsTimeCounter: PerfCounter;
  49300. /**
  49301. * Gets the animations time capture status
  49302. */
  49303. /**
  49304. * Enable or disable the animations time capture
  49305. */
  49306. captureAnimationsTime: boolean;
  49307. /**
  49308. * Gets the perf counter used for frame time capture
  49309. */
  49310. readonly frameTimeCounter: PerfCounter;
  49311. /**
  49312. * Gets the frame time capture status
  49313. */
  49314. /**
  49315. * Enable or disable the frame time capture
  49316. */
  49317. captureFrameTime: boolean;
  49318. /**
  49319. * Gets the perf counter used for inter-frames time capture
  49320. */
  49321. readonly interFrameTimeCounter: PerfCounter;
  49322. /**
  49323. * Gets the inter-frames time capture status
  49324. */
  49325. /**
  49326. * Enable or disable the inter-frames time capture
  49327. */
  49328. captureInterFrameTime: boolean;
  49329. /**
  49330. * Gets the perf counter used for render time capture
  49331. */
  49332. readonly renderTimeCounter: PerfCounter;
  49333. /**
  49334. * Gets the render time capture status
  49335. */
  49336. /**
  49337. * Enable or disable the render time capture
  49338. */
  49339. captureRenderTime: boolean;
  49340. /**
  49341. * Gets the perf counter used for camera render time capture
  49342. */
  49343. readonly cameraRenderTimeCounter: PerfCounter;
  49344. /**
  49345. * Gets the camera render time capture status
  49346. */
  49347. /**
  49348. * Enable or disable the camera render time capture
  49349. */
  49350. captureCameraRenderTime: boolean;
  49351. /**
  49352. * Gets the perf counter used for draw calls
  49353. */
  49354. readonly drawCallsCounter: PerfCounter;
  49355. /**
  49356. * Instantiates a new scene instrumentation.
  49357. * This class can be used to get instrumentation data from a Babylon engine
  49358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49359. * @param scene Defines the scene to instrument
  49360. */
  49361. constructor(
  49362. /**
  49363. * Defines the scene to instrument
  49364. */
  49365. scene: Scene);
  49366. /**
  49367. * Dispose and release associated resources.
  49368. */
  49369. dispose(): void;
  49370. }
  49371. }
  49372. declare module BABYLON {
  49373. /** @hidden */
  49374. export var glowMapGenerationPixelShader: {
  49375. name: string;
  49376. shader: string;
  49377. };
  49378. }
  49379. declare module BABYLON {
  49380. /** @hidden */
  49381. export var glowMapGenerationVertexShader: {
  49382. name: string;
  49383. shader: string;
  49384. };
  49385. }
  49386. declare module BABYLON {
  49387. /**
  49388. * Effect layer options. This helps customizing the behaviour
  49389. * of the effect layer.
  49390. */
  49391. export interface IEffectLayerOptions {
  49392. /**
  49393. * Multiplication factor apply to the canvas size to compute the render target size
  49394. * used to generated the objects (the smaller the faster).
  49395. */
  49396. mainTextureRatio: number;
  49397. /**
  49398. * Enforces a fixed size texture to ensure effect stability across devices.
  49399. */
  49400. mainTextureFixedSize?: number;
  49401. /**
  49402. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49403. */
  49404. alphaBlendingMode: number;
  49405. /**
  49406. * The camera attached to the layer.
  49407. */
  49408. camera: Nullable<Camera>;
  49409. /**
  49410. * The rendering group to draw the layer in.
  49411. */
  49412. renderingGroupId: number;
  49413. }
  49414. /**
  49415. * The effect layer Helps adding post process effect blended with the main pass.
  49416. *
  49417. * This can be for instance use to generate glow or higlight effects on the scene.
  49418. *
  49419. * The effect layer class can not be used directly and is intented to inherited from to be
  49420. * customized per effects.
  49421. */
  49422. export abstract class EffectLayer {
  49423. private _vertexBuffers;
  49424. private _indexBuffer;
  49425. private _cachedDefines;
  49426. private _effectLayerMapGenerationEffect;
  49427. private _effectLayerOptions;
  49428. private _mergeEffect;
  49429. protected _scene: Scene;
  49430. protected _engine: Engine;
  49431. protected _maxSize: number;
  49432. protected _mainTextureDesiredSize: ISize;
  49433. protected _mainTexture: RenderTargetTexture;
  49434. protected _shouldRender: boolean;
  49435. protected _postProcesses: PostProcess[];
  49436. protected _textures: BaseTexture[];
  49437. protected _emissiveTextureAndColor: {
  49438. texture: Nullable<BaseTexture>;
  49439. color: Color4;
  49440. };
  49441. /**
  49442. * The name of the layer
  49443. */
  49444. name: string;
  49445. /**
  49446. * The clear color of the texture used to generate the glow map.
  49447. */
  49448. neutralColor: Color4;
  49449. /**
  49450. * Specifies wether the highlight layer is enabled or not.
  49451. */
  49452. isEnabled: boolean;
  49453. /**
  49454. * Gets the camera attached to the layer.
  49455. */
  49456. readonly camera: Nullable<Camera>;
  49457. /**
  49458. * Gets the rendering group id the layer should render in.
  49459. */
  49460. renderingGroupId: number;
  49461. /**
  49462. * An event triggered when the effect layer has been disposed.
  49463. */
  49464. onDisposeObservable: Observable<EffectLayer>;
  49465. /**
  49466. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49467. */
  49468. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49469. /**
  49470. * An event triggered when the generated texture is being merged in the scene.
  49471. */
  49472. onBeforeComposeObservable: Observable<EffectLayer>;
  49473. /**
  49474. * An event triggered when the generated texture has been merged in the scene.
  49475. */
  49476. onAfterComposeObservable: Observable<EffectLayer>;
  49477. /**
  49478. * An event triggered when the efffect layer changes its size.
  49479. */
  49480. onSizeChangedObservable: Observable<EffectLayer>;
  49481. /** @hidden */
  49482. static _SceneComponentInitialization: (scene: Scene) => void;
  49483. /**
  49484. * Instantiates a new effect Layer and references it in the scene.
  49485. * @param name The name of the layer
  49486. * @param scene The scene to use the layer in
  49487. */
  49488. constructor(
  49489. /** The Friendly of the effect in the scene */
  49490. name: string, scene: Scene);
  49491. /**
  49492. * Get the effect name of the layer.
  49493. * @return The effect name
  49494. */
  49495. abstract getEffectName(): string;
  49496. /**
  49497. * Checks for the readiness of the element composing the layer.
  49498. * @param subMesh the mesh to check for
  49499. * @param useInstances specify wether or not to use instances to render the mesh
  49500. * @return true if ready otherwise, false
  49501. */
  49502. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49503. /**
  49504. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49505. * @returns true if the effect requires stencil during the main canvas render pass.
  49506. */
  49507. abstract needStencil(): boolean;
  49508. /**
  49509. * Create the merge effect. This is the shader use to blit the information back
  49510. * to the main canvas at the end of the scene rendering.
  49511. * @returns The effect containing the shader used to merge the effect on the main canvas
  49512. */
  49513. protected abstract _createMergeEffect(): Effect;
  49514. /**
  49515. * Creates the render target textures and post processes used in the effect layer.
  49516. */
  49517. protected abstract _createTextureAndPostProcesses(): void;
  49518. /**
  49519. * Implementation specific of rendering the generating effect on the main canvas.
  49520. * @param effect The effect used to render through
  49521. */
  49522. protected abstract _internalRender(effect: Effect): void;
  49523. /**
  49524. * Sets the required values for both the emissive texture and and the main color.
  49525. */
  49526. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49527. /**
  49528. * Free any resources and references associated to a mesh.
  49529. * Internal use
  49530. * @param mesh The mesh to free.
  49531. */
  49532. abstract _disposeMesh(mesh: Mesh): void;
  49533. /**
  49534. * Serializes this layer (Glow or Highlight for example)
  49535. * @returns a serialized layer object
  49536. */
  49537. abstract serialize?(): any;
  49538. /**
  49539. * Initializes the effect layer with the required options.
  49540. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49541. */
  49542. protected _init(options: Partial<IEffectLayerOptions>): void;
  49543. /**
  49544. * Generates the index buffer of the full screen quad blending to the main canvas.
  49545. */
  49546. private _generateIndexBuffer;
  49547. /**
  49548. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49549. */
  49550. private _generateVertexBuffer;
  49551. /**
  49552. * Sets the main texture desired size which is the closest power of two
  49553. * of the engine canvas size.
  49554. */
  49555. private _setMainTextureSize;
  49556. /**
  49557. * Creates the main texture for the effect layer.
  49558. */
  49559. protected _createMainTexture(): void;
  49560. /**
  49561. * Adds specific effects defines.
  49562. * @param defines The defines to add specifics to.
  49563. */
  49564. protected _addCustomEffectDefines(defines: string[]): void;
  49565. /**
  49566. * Checks for the readiness of the element composing the layer.
  49567. * @param subMesh the mesh to check for
  49568. * @param useInstances specify wether or not to use instances to render the mesh
  49569. * @param emissiveTexture the associated emissive texture used to generate the glow
  49570. * @return true if ready otherwise, false
  49571. */
  49572. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49573. /**
  49574. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49575. */
  49576. render(): void;
  49577. /**
  49578. * Determine if a given mesh will be used in the current effect.
  49579. * @param mesh mesh to test
  49580. * @returns true if the mesh will be used
  49581. */
  49582. hasMesh(mesh: AbstractMesh): boolean;
  49583. /**
  49584. * Returns true if the layer contains information to display, otherwise false.
  49585. * @returns true if the glow layer should be rendered
  49586. */
  49587. shouldRender(): boolean;
  49588. /**
  49589. * Returns true if the mesh should render, otherwise false.
  49590. * @param mesh The mesh to render
  49591. * @returns true if it should render otherwise false
  49592. */
  49593. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49594. /**
  49595. * Returns true if the mesh can be rendered, otherwise false.
  49596. * @param mesh The mesh to render
  49597. * @param material The material used on the mesh
  49598. * @returns true if it can be rendered otherwise false
  49599. */
  49600. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49601. /**
  49602. * Returns true if the mesh should render, otherwise false.
  49603. * @param mesh The mesh to render
  49604. * @returns true if it should render otherwise false
  49605. */
  49606. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49607. /**
  49608. * Renders the submesh passed in parameter to the generation map.
  49609. */
  49610. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49611. /**
  49612. * Rebuild the required buffers.
  49613. * @hidden Internal use only.
  49614. */
  49615. _rebuild(): void;
  49616. /**
  49617. * Dispose only the render target textures and post process.
  49618. */
  49619. private _disposeTextureAndPostProcesses;
  49620. /**
  49621. * Dispose the highlight layer and free resources.
  49622. */
  49623. dispose(): void;
  49624. /**
  49625. * Gets the class name of the effect layer
  49626. * @returns the string with the class name of the effect layer
  49627. */
  49628. getClassName(): string;
  49629. /**
  49630. * Creates an effect layer from parsed effect layer data
  49631. * @param parsedEffectLayer defines effect layer data
  49632. * @param scene defines the current scene
  49633. * @param rootUrl defines the root URL containing the effect layer information
  49634. * @returns a parsed effect Layer
  49635. */
  49636. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49637. }
  49638. }
  49639. declare module BABYLON {
  49640. interface AbstractScene {
  49641. /**
  49642. * The list of effect layers (highlights/glow) added to the scene
  49643. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49644. * @see http://doc.babylonjs.com/how_to/glow_layer
  49645. */
  49646. effectLayers: Array<EffectLayer>;
  49647. /**
  49648. * Removes the given effect layer from this scene.
  49649. * @param toRemove defines the effect layer to remove
  49650. * @returns the index of the removed effect layer
  49651. */
  49652. removeEffectLayer(toRemove: EffectLayer): number;
  49653. /**
  49654. * Adds the given effect layer to this scene
  49655. * @param newEffectLayer defines the effect layer to add
  49656. */
  49657. addEffectLayer(newEffectLayer: EffectLayer): void;
  49658. }
  49659. /**
  49660. * Defines the layer scene component responsible to manage any effect layers
  49661. * in a given scene.
  49662. */
  49663. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49664. /**
  49665. * The component name helpfull to identify the component in the list of scene components.
  49666. */
  49667. readonly name: string;
  49668. /**
  49669. * The scene the component belongs to.
  49670. */
  49671. scene: Scene;
  49672. private _engine;
  49673. private _renderEffects;
  49674. private _needStencil;
  49675. private _previousStencilState;
  49676. /**
  49677. * Creates a new instance of the component for the given scene
  49678. * @param scene Defines the scene to register the component in
  49679. */
  49680. constructor(scene: Scene);
  49681. /**
  49682. * Registers the component in a given scene
  49683. */
  49684. register(): void;
  49685. /**
  49686. * Rebuilds the elements related to this component in case of
  49687. * context lost for instance.
  49688. */
  49689. rebuild(): void;
  49690. /**
  49691. * Serializes the component data to the specified json object
  49692. * @param serializationObject The object to serialize to
  49693. */
  49694. serialize(serializationObject: any): void;
  49695. /**
  49696. * Adds all the elements from the container to the scene
  49697. * @param container the container holding the elements
  49698. */
  49699. addFromContainer(container: AbstractScene): void;
  49700. /**
  49701. * Removes all the elements in the container from the scene
  49702. * @param container contains the elements to remove
  49703. * @param dispose if the removed element should be disposed (default: false)
  49704. */
  49705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49706. /**
  49707. * Disposes the component and the associated ressources.
  49708. */
  49709. dispose(): void;
  49710. private _isReadyForMesh;
  49711. private _renderMainTexture;
  49712. private _setStencil;
  49713. private _setStencilBack;
  49714. private _draw;
  49715. private _drawCamera;
  49716. private _drawRenderingGroup;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /** @hidden */
  49721. export var glowMapMergePixelShader: {
  49722. name: string;
  49723. shader: string;
  49724. };
  49725. }
  49726. declare module BABYLON {
  49727. /** @hidden */
  49728. export var glowMapMergeVertexShader: {
  49729. name: string;
  49730. shader: string;
  49731. };
  49732. }
  49733. declare module BABYLON {
  49734. interface AbstractScene {
  49735. /**
  49736. * Return a the first highlight layer of the scene with a given name.
  49737. * @param name The name of the highlight layer to look for.
  49738. * @return The highlight layer if found otherwise null.
  49739. */
  49740. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49741. }
  49742. /**
  49743. * Glow layer options. This helps customizing the behaviour
  49744. * of the glow layer.
  49745. */
  49746. export interface IGlowLayerOptions {
  49747. /**
  49748. * Multiplication factor apply to the canvas size to compute the render target size
  49749. * used to generated the glowing objects (the smaller the faster).
  49750. */
  49751. mainTextureRatio: number;
  49752. /**
  49753. * Enforces a fixed size texture to ensure resize independant blur.
  49754. */
  49755. mainTextureFixedSize?: number;
  49756. /**
  49757. * How big is the kernel of the blur texture.
  49758. */
  49759. blurKernelSize: number;
  49760. /**
  49761. * The camera attached to the layer.
  49762. */
  49763. camera: Nullable<Camera>;
  49764. /**
  49765. * Enable MSAA by chosing the number of samples.
  49766. */
  49767. mainTextureSamples?: number;
  49768. /**
  49769. * The rendering group to draw the layer in.
  49770. */
  49771. renderingGroupId: number;
  49772. }
  49773. /**
  49774. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49775. *
  49776. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49777. * glowy meshes to your scene.
  49778. *
  49779. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49780. */
  49781. export class GlowLayer extends EffectLayer {
  49782. /**
  49783. * Effect Name of the layer.
  49784. */
  49785. static readonly EffectName: string;
  49786. /**
  49787. * The default blur kernel size used for the glow.
  49788. */
  49789. static DefaultBlurKernelSize: number;
  49790. /**
  49791. * The default texture size ratio used for the glow.
  49792. */
  49793. static DefaultTextureRatio: number;
  49794. /**
  49795. * Sets the kernel size of the blur.
  49796. */
  49797. /**
  49798. * Gets the kernel size of the blur.
  49799. */
  49800. blurKernelSize: number;
  49801. /**
  49802. * Sets the glow intensity.
  49803. */
  49804. /**
  49805. * Gets the glow intensity.
  49806. */
  49807. intensity: number;
  49808. private _options;
  49809. private _intensity;
  49810. private _horizontalBlurPostprocess1;
  49811. private _verticalBlurPostprocess1;
  49812. private _horizontalBlurPostprocess2;
  49813. private _verticalBlurPostprocess2;
  49814. private _blurTexture1;
  49815. private _blurTexture2;
  49816. private _postProcesses1;
  49817. private _postProcesses2;
  49818. private _includedOnlyMeshes;
  49819. private _excludedMeshes;
  49820. /**
  49821. * Callback used to let the user override the color selection on a per mesh basis
  49822. */
  49823. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49824. /**
  49825. * Callback used to let the user override the texture selection on a per mesh basis
  49826. */
  49827. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49828. /**
  49829. * Instantiates a new glow Layer and references it to the scene.
  49830. * @param name The name of the layer
  49831. * @param scene The scene to use the layer in
  49832. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49833. */
  49834. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49835. /**
  49836. * Get the effect name of the layer.
  49837. * @return The effect name
  49838. */
  49839. getEffectName(): string;
  49840. /**
  49841. * Create the merge effect. This is the shader use to blit the information back
  49842. * to the main canvas at the end of the scene rendering.
  49843. */
  49844. protected _createMergeEffect(): Effect;
  49845. /**
  49846. * Creates the render target textures and post processes used in the glow layer.
  49847. */
  49848. protected _createTextureAndPostProcesses(): void;
  49849. /**
  49850. * Checks for the readiness of the element composing the layer.
  49851. * @param subMesh the mesh to check for
  49852. * @param useInstances specify wether or not to use instances to render the mesh
  49853. * @param emissiveTexture the associated emissive texture used to generate the glow
  49854. * @return true if ready otherwise, false
  49855. */
  49856. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49857. /**
  49858. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49859. */
  49860. needStencil(): boolean;
  49861. /**
  49862. * Returns true if the mesh can be rendered, otherwise false.
  49863. * @param mesh The mesh to render
  49864. * @param material The material used on the mesh
  49865. * @returns true if it can be rendered otherwise false
  49866. */
  49867. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49868. /**
  49869. * Implementation specific of rendering the generating effect on the main canvas.
  49870. * @param effect The effect used to render through
  49871. */
  49872. protected _internalRender(effect: Effect): void;
  49873. /**
  49874. * Sets the required values for both the emissive texture and and the main color.
  49875. */
  49876. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49877. /**
  49878. * Returns true if the mesh should render, otherwise false.
  49879. * @param mesh The mesh to render
  49880. * @returns true if it should render otherwise false
  49881. */
  49882. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49883. /**
  49884. * Adds specific effects defines.
  49885. * @param defines The defines to add specifics to.
  49886. */
  49887. protected _addCustomEffectDefines(defines: string[]): void;
  49888. /**
  49889. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49890. * @param mesh The mesh to exclude from the glow layer
  49891. */
  49892. addExcludedMesh(mesh: Mesh): void;
  49893. /**
  49894. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49895. * @param mesh The mesh to remove
  49896. */
  49897. removeExcludedMesh(mesh: Mesh): void;
  49898. /**
  49899. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49900. * @param mesh The mesh to include in the glow layer
  49901. */
  49902. addIncludedOnlyMesh(mesh: Mesh): void;
  49903. /**
  49904. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49905. * @param mesh The mesh to remove
  49906. */
  49907. removeIncludedOnlyMesh(mesh: Mesh): void;
  49908. /**
  49909. * Determine if a given mesh will be used in the glow layer
  49910. * @param mesh The mesh to test
  49911. * @returns true if the mesh will be highlighted by the current glow layer
  49912. */
  49913. hasMesh(mesh: AbstractMesh): boolean;
  49914. /**
  49915. * Free any resources and references associated to a mesh.
  49916. * Internal use
  49917. * @param mesh The mesh to free.
  49918. * @hidden
  49919. */
  49920. _disposeMesh(mesh: Mesh): void;
  49921. /**
  49922. * Gets the class name of the effect layer
  49923. * @returns the string with the class name of the effect layer
  49924. */
  49925. getClassName(): string;
  49926. /**
  49927. * Serializes this glow layer
  49928. * @returns a serialized glow layer object
  49929. */
  49930. serialize(): any;
  49931. /**
  49932. * Creates a Glow Layer from parsed glow layer data
  49933. * @param parsedGlowLayer defines glow layer data
  49934. * @param scene defines the current scene
  49935. * @param rootUrl defines the root URL containing the glow layer information
  49936. * @returns a parsed Glow Layer
  49937. */
  49938. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49939. }
  49940. }
  49941. declare module BABYLON {
  49942. /** @hidden */
  49943. export var glowBlurPostProcessPixelShader: {
  49944. name: string;
  49945. shader: string;
  49946. };
  49947. }
  49948. declare module BABYLON {
  49949. interface AbstractScene {
  49950. /**
  49951. * Return a the first highlight layer of the scene with a given name.
  49952. * @param name The name of the highlight layer to look for.
  49953. * @return The highlight layer if found otherwise null.
  49954. */
  49955. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49956. }
  49957. /**
  49958. * Highlight layer options. This helps customizing the behaviour
  49959. * of the highlight layer.
  49960. */
  49961. export interface IHighlightLayerOptions {
  49962. /**
  49963. * Multiplication factor apply to the canvas size to compute the render target size
  49964. * used to generated the glowing objects (the smaller the faster).
  49965. */
  49966. mainTextureRatio: number;
  49967. /**
  49968. * Enforces a fixed size texture to ensure resize independant blur.
  49969. */
  49970. mainTextureFixedSize?: number;
  49971. /**
  49972. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49973. * of the picture to blur (the smaller the faster).
  49974. */
  49975. blurTextureSizeRatio: number;
  49976. /**
  49977. * How big in texel of the blur texture is the vertical blur.
  49978. */
  49979. blurVerticalSize: number;
  49980. /**
  49981. * How big in texel of the blur texture is the horizontal blur.
  49982. */
  49983. blurHorizontalSize: number;
  49984. /**
  49985. * Alpha blending mode used to apply the blur. Default is combine.
  49986. */
  49987. alphaBlendingMode: number;
  49988. /**
  49989. * The camera attached to the layer.
  49990. */
  49991. camera: Nullable<Camera>;
  49992. /**
  49993. * Should we display highlight as a solid stroke?
  49994. */
  49995. isStroke?: boolean;
  49996. /**
  49997. * The rendering group to draw the layer in.
  49998. */
  49999. renderingGroupId: number;
  50000. }
  50001. /**
  50002. * The highlight layer Helps adding a glow effect around a mesh.
  50003. *
  50004. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50005. * glowy meshes to your scene.
  50006. *
  50007. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50008. */
  50009. export class HighlightLayer extends EffectLayer {
  50010. name: string;
  50011. /**
  50012. * Effect Name of the highlight layer.
  50013. */
  50014. static readonly EffectName: string;
  50015. /**
  50016. * The neutral color used during the preparation of the glow effect.
  50017. * This is black by default as the blend operation is a blend operation.
  50018. */
  50019. static NeutralColor: Color4;
  50020. /**
  50021. * Stencil value used for glowing meshes.
  50022. */
  50023. static GlowingMeshStencilReference: number;
  50024. /**
  50025. * Stencil value used for the other meshes in the scene.
  50026. */
  50027. static NormalMeshStencilReference: number;
  50028. /**
  50029. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50030. */
  50031. innerGlow: boolean;
  50032. /**
  50033. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50034. */
  50035. outerGlow: boolean;
  50036. /**
  50037. * Specifies the horizontal size of the blur.
  50038. */
  50039. /**
  50040. * Gets the horizontal size of the blur.
  50041. */
  50042. blurHorizontalSize: number;
  50043. /**
  50044. * Specifies the vertical size of the blur.
  50045. */
  50046. /**
  50047. * Gets the vertical size of the blur.
  50048. */
  50049. blurVerticalSize: number;
  50050. /**
  50051. * An event triggered when the highlight layer is being blurred.
  50052. */
  50053. onBeforeBlurObservable: Observable<HighlightLayer>;
  50054. /**
  50055. * An event triggered when the highlight layer has been blurred.
  50056. */
  50057. onAfterBlurObservable: Observable<HighlightLayer>;
  50058. private _instanceGlowingMeshStencilReference;
  50059. private _options;
  50060. private _downSamplePostprocess;
  50061. private _horizontalBlurPostprocess;
  50062. private _verticalBlurPostprocess;
  50063. private _blurTexture;
  50064. private _meshes;
  50065. private _excludedMeshes;
  50066. /**
  50067. * Instantiates a new highlight Layer and references it to the scene..
  50068. * @param name The name of the layer
  50069. * @param scene The scene to use the layer in
  50070. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50071. */
  50072. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50073. /**
  50074. * Get the effect name of the layer.
  50075. * @return The effect name
  50076. */
  50077. getEffectName(): string;
  50078. /**
  50079. * Create the merge effect. This is the shader use to blit the information back
  50080. * to the main canvas at the end of the scene rendering.
  50081. */
  50082. protected _createMergeEffect(): Effect;
  50083. /**
  50084. * Creates the render target textures and post processes used in the highlight layer.
  50085. */
  50086. protected _createTextureAndPostProcesses(): void;
  50087. /**
  50088. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50089. */
  50090. needStencil(): boolean;
  50091. /**
  50092. * Checks for the readiness of the element composing the layer.
  50093. * @param subMesh the mesh to check for
  50094. * @param useInstances specify wether or not to use instances to render the mesh
  50095. * @param emissiveTexture the associated emissive texture used to generate the glow
  50096. * @return true if ready otherwise, false
  50097. */
  50098. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50099. /**
  50100. * Implementation specific of rendering the generating effect on the main canvas.
  50101. * @param effect The effect used to render through
  50102. */
  50103. protected _internalRender(effect: Effect): void;
  50104. /**
  50105. * Returns true if the layer contains information to display, otherwise false.
  50106. */
  50107. shouldRender(): boolean;
  50108. /**
  50109. * Returns true if the mesh should render, otherwise false.
  50110. * @param mesh The mesh to render
  50111. * @returns true if it should render otherwise false
  50112. */
  50113. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50114. /**
  50115. * Sets the required values for both the emissive texture and and the main color.
  50116. */
  50117. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50118. /**
  50119. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50120. * @param mesh The mesh to exclude from the highlight layer
  50121. */
  50122. addExcludedMesh(mesh: Mesh): void;
  50123. /**
  50124. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50125. * @param mesh The mesh to highlight
  50126. */
  50127. removeExcludedMesh(mesh: Mesh): void;
  50128. /**
  50129. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50130. * @param mesh mesh to test
  50131. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50132. */
  50133. hasMesh(mesh: AbstractMesh): boolean;
  50134. /**
  50135. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50136. * @param mesh The mesh to highlight
  50137. * @param color The color of the highlight
  50138. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50139. */
  50140. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50141. /**
  50142. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50143. * @param mesh The mesh to highlight
  50144. */
  50145. removeMesh(mesh: Mesh): void;
  50146. /**
  50147. * Force the stencil to the normal expected value for none glowing parts
  50148. */
  50149. private _defaultStencilReference;
  50150. /**
  50151. * Free any resources and references associated to a mesh.
  50152. * Internal use
  50153. * @param mesh The mesh to free.
  50154. * @hidden
  50155. */
  50156. _disposeMesh(mesh: Mesh): void;
  50157. /**
  50158. * Dispose the highlight layer and free resources.
  50159. */
  50160. dispose(): void;
  50161. /**
  50162. * Gets the class name of the effect layer
  50163. * @returns the string with the class name of the effect layer
  50164. */
  50165. getClassName(): string;
  50166. /**
  50167. * Serializes this Highlight layer
  50168. * @returns a serialized Highlight layer object
  50169. */
  50170. serialize(): any;
  50171. /**
  50172. * Creates a Highlight layer from parsed Highlight layer data
  50173. * @param parsedHightlightLayer defines the Highlight layer data
  50174. * @param scene defines the current scene
  50175. * @param rootUrl defines the root URL containing the Highlight layer information
  50176. * @returns a parsed Highlight layer
  50177. */
  50178. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50179. }
  50180. }
  50181. declare module BABYLON {
  50182. interface AbstractScene {
  50183. /**
  50184. * The list of layers (background and foreground) of the scene
  50185. */
  50186. layers: Array<Layer>;
  50187. }
  50188. /**
  50189. * Defines the layer scene component responsible to manage any layers
  50190. * in a given scene.
  50191. */
  50192. export class LayerSceneComponent implements ISceneComponent {
  50193. /**
  50194. * The component name helpfull to identify the component in the list of scene components.
  50195. */
  50196. readonly name: string;
  50197. /**
  50198. * The scene the component belongs to.
  50199. */
  50200. scene: Scene;
  50201. private _engine;
  50202. /**
  50203. * Creates a new instance of the component for the given scene
  50204. * @param scene Defines the scene to register the component in
  50205. */
  50206. constructor(scene: Scene);
  50207. /**
  50208. * Registers the component in a given scene
  50209. */
  50210. register(): void;
  50211. /**
  50212. * Rebuilds the elements related to this component in case of
  50213. * context lost for instance.
  50214. */
  50215. rebuild(): void;
  50216. /**
  50217. * Disposes the component and the associated ressources.
  50218. */
  50219. dispose(): void;
  50220. private _draw;
  50221. private _drawCameraPredicate;
  50222. private _drawCameraBackground;
  50223. private _drawCameraForeground;
  50224. private _drawRenderTargetPredicate;
  50225. private _drawRenderTargetBackground;
  50226. private _drawRenderTargetForeground;
  50227. /**
  50228. * Adds all the elements from the container to the scene
  50229. * @param container the container holding the elements
  50230. */
  50231. addFromContainer(container: AbstractScene): void;
  50232. /**
  50233. * Removes all the elements in the container from the scene
  50234. * @param container contains the elements to remove
  50235. * @param dispose if the removed element should be disposed (default: false)
  50236. */
  50237. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50238. }
  50239. }
  50240. declare module BABYLON {
  50241. /** @hidden */
  50242. export var layerPixelShader: {
  50243. name: string;
  50244. shader: string;
  50245. };
  50246. }
  50247. declare module BABYLON {
  50248. /** @hidden */
  50249. export var layerVertexShader: {
  50250. name: string;
  50251. shader: string;
  50252. };
  50253. }
  50254. declare module BABYLON {
  50255. /**
  50256. * This represents a full screen 2d layer.
  50257. * This can be useful to display a picture in the background of your scene for instance.
  50258. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50259. */
  50260. export class Layer {
  50261. /**
  50262. * Define the name of the layer.
  50263. */
  50264. name: string;
  50265. /**
  50266. * Define the texture the layer should display.
  50267. */
  50268. texture: Nullable<Texture>;
  50269. /**
  50270. * Is the layer in background or foreground.
  50271. */
  50272. isBackground: boolean;
  50273. /**
  50274. * Define the color of the layer (instead of texture).
  50275. */
  50276. color: Color4;
  50277. /**
  50278. * Define the scale of the layer in order to zoom in out of the texture.
  50279. */
  50280. scale: Vector2;
  50281. /**
  50282. * Define an offset for the layer in order to shift the texture.
  50283. */
  50284. offset: Vector2;
  50285. /**
  50286. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50287. */
  50288. alphaBlendingMode: number;
  50289. /**
  50290. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50291. * Alpha test will not mix with the background color in case of transparency.
  50292. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50293. */
  50294. alphaTest: boolean;
  50295. /**
  50296. * Define a mask to restrict the layer to only some of the scene cameras.
  50297. */
  50298. layerMask: number;
  50299. /**
  50300. * Define the list of render target the layer is visible into.
  50301. */
  50302. renderTargetTextures: RenderTargetTexture[];
  50303. /**
  50304. * Define if the layer is only used in renderTarget or if it also
  50305. * renders in the main frame buffer of the canvas.
  50306. */
  50307. renderOnlyInRenderTargetTextures: boolean;
  50308. private _scene;
  50309. private _vertexBuffers;
  50310. private _indexBuffer;
  50311. private _effect;
  50312. private _alphaTestEffect;
  50313. /**
  50314. * An event triggered when the layer is disposed.
  50315. */
  50316. onDisposeObservable: Observable<Layer>;
  50317. private _onDisposeObserver;
  50318. /**
  50319. * Back compatibility with callback before the onDisposeObservable existed.
  50320. * The set callback will be triggered when the layer has been disposed.
  50321. */
  50322. onDispose: () => void;
  50323. /**
  50324. * An event triggered before rendering the scene
  50325. */
  50326. onBeforeRenderObservable: Observable<Layer>;
  50327. private _onBeforeRenderObserver;
  50328. /**
  50329. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50330. * The set callback will be triggered just before rendering the layer.
  50331. */
  50332. onBeforeRender: () => void;
  50333. /**
  50334. * An event triggered after rendering the scene
  50335. */
  50336. onAfterRenderObservable: Observable<Layer>;
  50337. private _onAfterRenderObserver;
  50338. /**
  50339. * Back compatibility with callback before the onAfterRenderObservable existed.
  50340. * The set callback will be triggered just after rendering the layer.
  50341. */
  50342. onAfterRender: () => void;
  50343. /**
  50344. * Instantiates a new layer.
  50345. * This represents a full screen 2d layer.
  50346. * This can be useful to display a picture in the background of your scene for instance.
  50347. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50348. * @param name Define the name of the layer in the scene
  50349. * @param imgUrl Define the url of the texture to display in the layer
  50350. * @param scene Define the scene the layer belongs to
  50351. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50352. * @param color Defines a color for the layer
  50353. */
  50354. constructor(
  50355. /**
  50356. * Define the name of the layer.
  50357. */
  50358. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50359. private _createIndexBuffer;
  50360. /** @hidden */
  50361. _rebuild(): void;
  50362. /**
  50363. * Renders the layer in the scene.
  50364. */
  50365. render(): void;
  50366. /**
  50367. * Disposes and releases the associated ressources.
  50368. */
  50369. dispose(): void;
  50370. }
  50371. }
  50372. declare module BABYLON {
  50373. /** @hidden */
  50374. export var lensFlarePixelShader: {
  50375. name: string;
  50376. shader: string;
  50377. };
  50378. }
  50379. declare module BABYLON {
  50380. /** @hidden */
  50381. export var lensFlareVertexShader: {
  50382. name: string;
  50383. shader: string;
  50384. };
  50385. }
  50386. declare module BABYLON {
  50387. /**
  50388. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50389. * It is usually composed of several `lensFlare`.
  50390. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50391. */
  50392. export class LensFlareSystem {
  50393. /**
  50394. * Define the name of the lens flare system
  50395. */
  50396. name: string;
  50397. /**
  50398. * List of lens flares used in this system.
  50399. */
  50400. lensFlares: LensFlare[];
  50401. /**
  50402. * Define a limit from the border the lens flare can be visible.
  50403. */
  50404. borderLimit: number;
  50405. /**
  50406. * Define a viewport border we do not want to see the lens flare in.
  50407. */
  50408. viewportBorder: number;
  50409. /**
  50410. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50411. */
  50412. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50413. /**
  50414. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50415. */
  50416. layerMask: number;
  50417. /**
  50418. * Define the id of the lens flare system in the scene.
  50419. * (equal to name by default)
  50420. */
  50421. id: string;
  50422. private _scene;
  50423. private _emitter;
  50424. private _vertexBuffers;
  50425. private _indexBuffer;
  50426. private _effect;
  50427. private _positionX;
  50428. private _positionY;
  50429. private _isEnabled;
  50430. /** @hidden */
  50431. static _SceneComponentInitialization: (scene: Scene) => void;
  50432. /**
  50433. * Instantiates a lens flare system.
  50434. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50435. * It is usually composed of several `lensFlare`.
  50436. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50437. * @param name Define the name of the lens flare system in the scene
  50438. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50439. * @param scene Define the scene the lens flare system belongs to
  50440. */
  50441. constructor(
  50442. /**
  50443. * Define the name of the lens flare system
  50444. */
  50445. name: string, emitter: any, scene: Scene);
  50446. /**
  50447. * Define if the lens flare system is enabled.
  50448. */
  50449. isEnabled: boolean;
  50450. /**
  50451. * Get the scene the effects belongs to.
  50452. * @returns the scene holding the lens flare system
  50453. */
  50454. getScene(): Scene;
  50455. /**
  50456. * Get the emitter of the lens flare system.
  50457. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50458. * @returns the emitter of the lens flare system
  50459. */
  50460. getEmitter(): any;
  50461. /**
  50462. * Set the emitter of the lens flare system.
  50463. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50464. * @param newEmitter Define the new emitter of the system
  50465. */
  50466. setEmitter(newEmitter: any): void;
  50467. /**
  50468. * Get the lens flare system emitter position.
  50469. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50470. * @returns the position
  50471. */
  50472. getEmitterPosition(): Vector3;
  50473. /**
  50474. * @hidden
  50475. */
  50476. computeEffectivePosition(globalViewport: Viewport): boolean;
  50477. /** @hidden */
  50478. _isVisible(): boolean;
  50479. /**
  50480. * @hidden
  50481. */
  50482. render(): boolean;
  50483. /**
  50484. * Dispose and release the lens flare with its associated resources.
  50485. */
  50486. dispose(): void;
  50487. /**
  50488. * Parse a lens flare system from a JSON repressentation
  50489. * @param parsedLensFlareSystem Define the JSON to parse
  50490. * @param scene Define the scene the parsed system should be instantiated in
  50491. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50492. * @returns the parsed system
  50493. */
  50494. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50495. /**
  50496. * Serialize the current Lens Flare System into a JSON representation.
  50497. * @returns the serialized JSON
  50498. */
  50499. serialize(): any;
  50500. }
  50501. }
  50502. declare module BABYLON {
  50503. /**
  50504. * This represents one of the lens effect in a `lensFlareSystem`.
  50505. * It controls one of the indiviual texture used in the effect.
  50506. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50507. */
  50508. export class LensFlare {
  50509. /**
  50510. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50511. */
  50512. size: number;
  50513. /**
  50514. * 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.
  50515. */
  50516. position: number;
  50517. /**
  50518. * Define the lens color.
  50519. */
  50520. color: Color3;
  50521. /**
  50522. * Define the lens texture.
  50523. */
  50524. texture: Nullable<Texture>;
  50525. /**
  50526. * Define the alpha mode to render this particular lens.
  50527. */
  50528. alphaMode: number;
  50529. private _system;
  50530. /**
  50531. * Creates a new Lens Flare.
  50532. * This represents one of the lens effect in a `lensFlareSystem`.
  50533. * It controls one of the indiviual texture used in the effect.
  50534. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50535. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50536. * @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.
  50537. * @param color Define the lens color
  50538. * @param imgUrl Define the lens texture url
  50539. * @param system Define the `lensFlareSystem` this flare is part of
  50540. * @returns The newly created Lens Flare
  50541. */
  50542. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50543. /**
  50544. * Instantiates a new Lens Flare.
  50545. * This represents one of the lens effect in a `lensFlareSystem`.
  50546. * It controls one of the indiviual texture used in the effect.
  50547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50548. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50549. * @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.
  50550. * @param color Define the lens color
  50551. * @param imgUrl Define the lens texture url
  50552. * @param system Define the `lensFlareSystem` this flare is part of
  50553. */
  50554. constructor(
  50555. /**
  50556. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50557. */
  50558. size: number,
  50559. /**
  50560. * 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.
  50561. */
  50562. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50563. /**
  50564. * Dispose and release the lens flare with its associated resources.
  50565. */
  50566. dispose(): void;
  50567. }
  50568. }
  50569. declare module BABYLON {
  50570. interface AbstractScene {
  50571. /**
  50572. * The list of lens flare system added to the scene
  50573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50574. */
  50575. lensFlareSystems: Array<LensFlareSystem>;
  50576. /**
  50577. * Removes the given lens flare system from this scene.
  50578. * @param toRemove The lens flare system to remove
  50579. * @returns The index of the removed lens flare system
  50580. */
  50581. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50582. /**
  50583. * Adds the given lens flare system to this scene
  50584. * @param newLensFlareSystem The lens flare system to add
  50585. */
  50586. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50587. /**
  50588. * Gets a lens flare system using its name
  50589. * @param name defines the name to look for
  50590. * @returns the lens flare system or null if not found
  50591. */
  50592. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50593. /**
  50594. * Gets a lens flare system using its id
  50595. * @param id defines the id to look for
  50596. * @returns the lens flare system or null if not found
  50597. */
  50598. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50599. }
  50600. /**
  50601. * Defines the lens flare scene component responsible to manage any lens flares
  50602. * in a given scene.
  50603. */
  50604. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50605. /**
  50606. * The component name helpfull to identify the component in the list of scene components.
  50607. */
  50608. readonly name: string;
  50609. /**
  50610. * The scene the component belongs to.
  50611. */
  50612. scene: Scene;
  50613. /**
  50614. * Creates a new instance of the component for the given scene
  50615. * @param scene Defines the scene to register the component in
  50616. */
  50617. constructor(scene: Scene);
  50618. /**
  50619. * Registers the component in a given scene
  50620. */
  50621. register(): void;
  50622. /**
  50623. * Rebuilds the elements related to this component in case of
  50624. * context lost for instance.
  50625. */
  50626. rebuild(): void;
  50627. /**
  50628. * Adds all the elements from the container to the scene
  50629. * @param container the container holding the elements
  50630. */
  50631. addFromContainer(container: AbstractScene): void;
  50632. /**
  50633. * Removes all the elements in the container from the scene
  50634. * @param container contains the elements to remove
  50635. * @param dispose if the removed element should be disposed (default: false)
  50636. */
  50637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50638. /**
  50639. * Serializes the component data to the specified json object
  50640. * @param serializationObject The object to serialize to
  50641. */
  50642. serialize(serializationObject: any): void;
  50643. /**
  50644. * Disposes the component and the associated ressources.
  50645. */
  50646. dispose(): void;
  50647. private _draw;
  50648. }
  50649. }
  50650. declare module BABYLON {
  50651. /**
  50652. * Defines the shadow generator component responsible to manage any shadow generators
  50653. * in a given scene.
  50654. */
  50655. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50656. /**
  50657. * The component name helpfull to identify the component in the list of scene components.
  50658. */
  50659. readonly name: string;
  50660. /**
  50661. * The scene the component belongs to.
  50662. */
  50663. scene: Scene;
  50664. /**
  50665. * Creates a new instance of the component for the given scene
  50666. * @param scene Defines the scene to register the component in
  50667. */
  50668. constructor(scene: Scene);
  50669. /**
  50670. * Registers the component in a given scene
  50671. */
  50672. register(): void;
  50673. /**
  50674. * Rebuilds the elements related to this component in case of
  50675. * context lost for instance.
  50676. */
  50677. rebuild(): void;
  50678. /**
  50679. * Serializes the component data to the specified json object
  50680. * @param serializationObject The object to serialize to
  50681. */
  50682. serialize(serializationObject: any): void;
  50683. /**
  50684. * Adds all the elements from the container to the scene
  50685. * @param container the container holding the elements
  50686. */
  50687. addFromContainer(container: AbstractScene): void;
  50688. /**
  50689. * Removes all the elements in the container from the scene
  50690. * @param container contains the elements to remove
  50691. * @param dispose if the removed element should be disposed (default: false)
  50692. */
  50693. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50694. /**
  50695. * Rebuilds the elements related to this component in case of
  50696. * context lost for instance.
  50697. */
  50698. dispose(): void;
  50699. private _gatherRenderTargets;
  50700. }
  50701. }
  50702. declare module BABYLON {
  50703. /**
  50704. * A point light is a light defined by an unique point in world space.
  50705. * The light is emitted in every direction from this point.
  50706. * A good example of a point light is a standard light bulb.
  50707. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50708. */
  50709. export class PointLight extends ShadowLight {
  50710. private _shadowAngle;
  50711. /**
  50712. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50713. * This specifies what angle the shadow will use to be created.
  50714. *
  50715. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50716. */
  50717. /**
  50718. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50719. * This specifies what angle the shadow will use to be created.
  50720. *
  50721. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50722. */
  50723. shadowAngle: number;
  50724. /**
  50725. * Gets the direction if it has been set.
  50726. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50727. */
  50728. /**
  50729. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50730. */
  50731. direction: Vector3;
  50732. /**
  50733. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50734. * A PointLight emits the light in every direction.
  50735. * It can cast shadows.
  50736. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50737. * ```javascript
  50738. * var pointLight = new PointLight("pl", camera.position, scene);
  50739. * ```
  50740. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50741. * @param name The light friendly name
  50742. * @param position The position of the point light in the scene
  50743. * @param scene The scene the lights belongs to
  50744. */
  50745. constructor(name: string, position: Vector3, scene: Scene);
  50746. /**
  50747. * Returns the string "PointLight"
  50748. * @returns the class name
  50749. */
  50750. getClassName(): string;
  50751. /**
  50752. * Returns the integer 0.
  50753. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50754. */
  50755. getTypeID(): number;
  50756. /**
  50757. * Specifies wether or not the shadowmap should be a cube texture.
  50758. * @returns true if the shadowmap needs to be a cube texture.
  50759. */
  50760. needCube(): boolean;
  50761. /**
  50762. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50763. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50764. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50765. */
  50766. getShadowDirection(faceIndex?: number): Vector3;
  50767. /**
  50768. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50769. * - fov = PI / 2
  50770. * - aspect ratio : 1.0
  50771. * - z-near and far equal to the active camera minZ and maxZ.
  50772. * Returns the PointLight.
  50773. */
  50774. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50775. protected _buildUniformLayout(): void;
  50776. /**
  50777. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50778. * @param effect The effect to update
  50779. * @param lightIndex The index of the light in the effect to update
  50780. * @returns The point light
  50781. */
  50782. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50783. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50784. /**
  50785. * Prepares the list of defines specific to the light type.
  50786. * @param defines the list of defines
  50787. * @param lightIndex defines the index of the light for the effect
  50788. */
  50789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50790. }
  50791. }
  50792. declare module BABYLON {
  50793. /**
  50794. * Header information of HDR texture files.
  50795. */
  50796. export interface HDRInfo {
  50797. /**
  50798. * The height of the texture in pixels.
  50799. */
  50800. height: number;
  50801. /**
  50802. * The width of the texture in pixels.
  50803. */
  50804. width: number;
  50805. /**
  50806. * The index of the beginning of the data in the binary file.
  50807. */
  50808. dataPosition: number;
  50809. }
  50810. /**
  50811. * This groups tools to convert HDR texture to native colors array.
  50812. */
  50813. export class HDRTools {
  50814. private static Ldexp;
  50815. private static Rgbe2float;
  50816. private static readStringLine;
  50817. /**
  50818. * Reads header information from an RGBE texture stored in a native array.
  50819. * More information on this format are available here:
  50820. * https://en.wikipedia.org/wiki/RGBE_image_format
  50821. *
  50822. * @param uint8array The binary file stored in native array.
  50823. * @return The header information.
  50824. */
  50825. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50826. /**
  50827. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50828. * This RGBE texture needs to store the information as a panorama.
  50829. *
  50830. * More information on this format are available here:
  50831. * https://en.wikipedia.org/wiki/RGBE_image_format
  50832. *
  50833. * @param buffer The binary file stored in an array buffer.
  50834. * @param size The expected size of the extracted cubemap.
  50835. * @return The Cube Map information.
  50836. */
  50837. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50838. /**
  50839. * Returns the pixels data extracted from an RGBE texture.
  50840. * This pixels will be stored left to right up to down in the R G B order in one array.
  50841. *
  50842. * More information on this format are available here:
  50843. * https://en.wikipedia.org/wiki/RGBE_image_format
  50844. *
  50845. * @param uint8array The binary file stored in an array buffer.
  50846. * @param hdrInfo The header information of the file.
  50847. * @return The pixels data in RGB right to left up to down order.
  50848. */
  50849. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50850. private static RGBE_ReadPixels_RLE;
  50851. }
  50852. }
  50853. declare module BABYLON {
  50854. /**
  50855. * This represents a texture coming from an HDR input.
  50856. *
  50857. * The only supported format is currently panorama picture stored in RGBE format.
  50858. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50859. */
  50860. export class HDRCubeTexture extends BaseTexture {
  50861. private static _facesMapping;
  50862. private _generateHarmonics;
  50863. private _noMipmap;
  50864. private _textureMatrix;
  50865. private _size;
  50866. private _onLoad;
  50867. private _onError;
  50868. /**
  50869. * The texture URL.
  50870. */
  50871. url: string;
  50872. /**
  50873. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50874. */
  50875. coordinatesMode: number;
  50876. protected _isBlocking: boolean;
  50877. /**
  50878. * Sets wether or not the texture is blocking during loading.
  50879. */
  50880. /**
  50881. * Gets wether or not the texture is blocking during loading.
  50882. */
  50883. isBlocking: boolean;
  50884. protected _rotationY: number;
  50885. /**
  50886. * Sets texture matrix rotation angle around Y axis in radians.
  50887. */
  50888. /**
  50889. * Gets texture matrix rotation angle around Y axis radians.
  50890. */
  50891. rotationY: number;
  50892. /**
  50893. * Gets or sets the center of the bounding box associated with the cube texture
  50894. * It must define where the camera used to render the texture was set
  50895. */
  50896. boundingBoxPosition: Vector3;
  50897. private _boundingBoxSize;
  50898. /**
  50899. * Gets or sets the size of the bounding box associated with the cube texture
  50900. * When defined, the cubemap will switch to local mode
  50901. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50902. * @example https://www.babylonjs-playground.com/#RNASML
  50903. */
  50904. boundingBoxSize: Vector3;
  50905. /**
  50906. * Instantiates an HDRTexture from the following parameters.
  50907. *
  50908. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50909. * @param scene The scene the texture will be used in
  50910. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50911. * @param noMipmap Forces to not generate the mipmap if true
  50912. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50913. * @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)
  50914. * @param reserved Reserved flag for internal use.
  50915. */
  50916. 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>);
  50917. /**
  50918. * Get the current class name of the texture useful for serialization or dynamic coding.
  50919. * @returns "HDRCubeTexture"
  50920. */
  50921. getClassName(): string;
  50922. /**
  50923. * Occurs when the file is raw .hdr file.
  50924. */
  50925. private loadTexture;
  50926. clone(): HDRCubeTexture;
  50927. delayLoad(): void;
  50928. /**
  50929. * Get the texture reflection matrix used to rotate/transform the reflection.
  50930. * @returns the reflection matrix
  50931. */
  50932. getReflectionTextureMatrix(): Matrix;
  50933. /**
  50934. * Set the texture reflection matrix used to rotate/transform the reflection.
  50935. * @param value Define the reflection matrix to set
  50936. */
  50937. setReflectionTextureMatrix(value: Matrix): void;
  50938. /**
  50939. * Parses a JSON representation of an HDR Texture in order to create the texture
  50940. * @param parsedTexture Define the JSON representation
  50941. * @param scene Define the scene the texture should be created in
  50942. * @param rootUrl Define the root url in case we need to load relative dependencies
  50943. * @returns the newly created texture after parsing
  50944. */
  50945. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50946. serialize(): any;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * Class used to control physics engine
  50952. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50953. */
  50954. export class PhysicsEngine implements IPhysicsEngine {
  50955. private _physicsPlugin;
  50956. /**
  50957. * Global value used to control the smallest number supported by the simulation
  50958. */
  50959. static Epsilon: number;
  50960. private _impostors;
  50961. private _joints;
  50962. /**
  50963. * Gets the gravity vector used by the simulation
  50964. */
  50965. gravity: Vector3;
  50966. /**
  50967. * Factory used to create the default physics plugin.
  50968. * @returns The default physics plugin
  50969. */
  50970. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50971. /**
  50972. * Creates a new Physics Engine
  50973. * @param gravity defines the gravity vector used by the simulation
  50974. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50975. */
  50976. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50977. /**
  50978. * Sets the gravity vector used by the simulation
  50979. * @param gravity defines the gravity vector to use
  50980. */
  50981. setGravity(gravity: Vector3): void;
  50982. /**
  50983. * Set the time step of the physics engine.
  50984. * Default is 1/60.
  50985. * To slow it down, enter 1/600 for example.
  50986. * To speed it up, 1/30
  50987. * @param newTimeStep defines the new timestep to apply to this world.
  50988. */
  50989. setTimeStep(newTimeStep?: number): void;
  50990. /**
  50991. * Get the time step of the physics engine.
  50992. * @returns the current time step
  50993. */
  50994. getTimeStep(): number;
  50995. /**
  50996. * Release all resources
  50997. */
  50998. dispose(): void;
  50999. /**
  51000. * Gets the name of the current physics plugin
  51001. * @returns the name of the plugin
  51002. */
  51003. getPhysicsPluginName(): string;
  51004. /**
  51005. * Adding a new impostor for the impostor tracking.
  51006. * This will be done by the impostor itself.
  51007. * @param impostor the impostor to add
  51008. */
  51009. addImpostor(impostor: PhysicsImpostor): void;
  51010. /**
  51011. * Remove an impostor from the engine.
  51012. * This impostor and its mesh will not longer be updated by the physics engine.
  51013. * @param impostor the impostor to remove
  51014. */
  51015. removeImpostor(impostor: PhysicsImpostor): void;
  51016. /**
  51017. * Add a joint to the physics engine
  51018. * @param mainImpostor defines the main impostor to which the joint is added.
  51019. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51020. * @param joint defines the joint that will connect both impostors.
  51021. */
  51022. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51023. /**
  51024. * Removes a joint from the simulation
  51025. * @param mainImpostor defines the impostor used with the joint
  51026. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51027. * @param joint defines the joint to remove
  51028. */
  51029. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51030. /**
  51031. * Called by the scene. No need to call it.
  51032. * @param delta defines the timespam between frames
  51033. */
  51034. _step(delta: number): void;
  51035. /**
  51036. * Gets the current plugin used to run the simulation
  51037. * @returns current plugin
  51038. */
  51039. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51040. /**
  51041. * Gets the list of physic impostors
  51042. * @returns an array of PhysicsImpostor
  51043. */
  51044. getImpostors(): Array<PhysicsImpostor>;
  51045. /**
  51046. * Gets the impostor for a physics enabled object
  51047. * @param object defines the object impersonated by the impostor
  51048. * @returns the PhysicsImpostor or null if not found
  51049. */
  51050. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51051. /**
  51052. * Gets the impostor for a physics body object
  51053. * @param body defines physics body used by the impostor
  51054. * @returns the PhysicsImpostor or null if not found
  51055. */
  51056. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51057. /**
  51058. * Does a raycast in the physics world
  51059. * @param from when should the ray start?
  51060. * @param to when should the ray end?
  51061. * @returns PhysicsRaycastResult
  51062. */
  51063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51064. }
  51065. }
  51066. declare module BABYLON {
  51067. /** @hidden */
  51068. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51069. private _useDeltaForWorldStep;
  51070. world: any;
  51071. name: string;
  51072. private _physicsMaterials;
  51073. private _fixedTimeStep;
  51074. private _cannonRaycastResult;
  51075. private _raycastResult;
  51076. private _physicsBodysToRemoveAfterStep;
  51077. BJSCANNON: any;
  51078. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51079. setGravity(gravity: Vector3): void;
  51080. setTimeStep(timeStep: number): void;
  51081. getTimeStep(): number;
  51082. executeStep(delta: number): void;
  51083. private _removeMarkedPhysicsBodiesFromWorld;
  51084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51085. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51086. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51087. private _processChildMeshes;
  51088. removePhysicsBody(impostor: PhysicsImpostor): void;
  51089. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51091. private _addMaterial;
  51092. private _checkWithEpsilon;
  51093. private _createShape;
  51094. private _createHeightmap;
  51095. private _minus90X;
  51096. private _plus90X;
  51097. private _tmpPosition;
  51098. private _tmpDeltaPosition;
  51099. private _tmpUnityRotation;
  51100. private _updatePhysicsBodyTransformation;
  51101. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51102. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51103. isSupported(): boolean;
  51104. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51105. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51106. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51107. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51108. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51109. getBodyMass(impostor: PhysicsImpostor): number;
  51110. getBodyFriction(impostor: PhysicsImpostor): number;
  51111. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51112. getBodyRestitution(impostor: PhysicsImpostor): number;
  51113. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51114. sleepBody(impostor: PhysicsImpostor): void;
  51115. wakeUpBody(impostor: PhysicsImpostor): void;
  51116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51117. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51118. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51119. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51120. getRadius(impostor: PhysicsImpostor): number;
  51121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51122. dispose(): void;
  51123. private _extendNamespace;
  51124. /**
  51125. * Does a raycast in the physics world
  51126. * @param from when should the ray start?
  51127. * @param to when should the ray end?
  51128. * @returns PhysicsRaycastResult
  51129. */
  51130. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51131. }
  51132. }
  51133. declare module BABYLON {
  51134. /** @hidden */
  51135. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51136. world: any;
  51137. name: string;
  51138. BJSOIMO: any;
  51139. private _raycastResult;
  51140. constructor(iterations?: number, oimoInjection?: any);
  51141. setGravity(gravity: Vector3): void;
  51142. setTimeStep(timeStep: number): void;
  51143. getTimeStep(): number;
  51144. private _tmpImpostorsArray;
  51145. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51146. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51147. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51148. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51149. private _tmpPositionVector;
  51150. removePhysicsBody(impostor: PhysicsImpostor): void;
  51151. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51152. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51153. isSupported(): boolean;
  51154. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51155. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51156. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51157. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51159. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51160. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51161. getBodyMass(impostor: PhysicsImpostor): number;
  51162. getBodyFriction(impostor: PhysicsImpostor): number;
  51163. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51164. getBodyRestitution(impostor: PhysicsImpostor): number;
  51165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51166. sleepBody(impostor: PhysicsImpostor): void;
  51167. wakeUpBody(impostor: PhysicsImpostor): void;
  51168. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51169. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51170. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51171. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51172. getRadius(impostor: PhysicsImpostor): number;
  51173. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51174. dispose(): void;
  51175. /**
  51176. * Does a raycast in the physics world
  51177. * @param from when should the ray start?
  51178. * @param to when should the ray end?
  51179. * @returns PhysicsRaycastResult
  51180. */
  51181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51182. }
  51183. }
  51184. declare module BABYLON {
  51185. /**
  51186. * Class containing static functions to help procedurally build meshes
  51187. */
  51188. export class RibbonBuilder {
  51189. /**
  51190. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51191. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51192. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51193. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51194. * * 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
  51195. * * 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
  51196. * * 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
  51197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51198. * * 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
  51199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51200. * * 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
  51201. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51202. * * 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
  51203. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51205. * @param name defines the name of the mesh
  51206. * @param options defines the options used to create the mesh
  51207. * @param scene defines the hosting scene
  51208. * @returns the ribbon mesh
  51209. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51211. */
  51212. static CreateRibbon(name: string, options: {
  51213. pathArray: Vector3[][];
  51214. closeArray?: boolean;
  51215. closePath?: boolean;
  51216. offset?: number;
  51217. updatable?: boolean;
  51218. sideOrientation?: number;
  51219. frontUVs?: Vector4;
  51220. backUVs?: Vector4;
  51221. instance?: Mesh;
  51222. invertUV?: boolean;
  51223. uvs?: Vector2[];
  51224. colors?: Color4[];
  51225. }, scene?: Nullable<Scene>): Mesh;
  51226. }
  51227. }
  51228. declare module BABYLON {
  51229. /**
  51230. * Class containing static functions to help procedurally build meshes
  51231. */
  51232. export class ShapeBuilder {
  51233. /**
  51234. * 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.
  51235. * * 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.
  51236. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51237. * * 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.
  51238. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51239. * * 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
  51240. * * 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
  51241. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51243. * * 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
  51244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51246. * @param name defines the name of the mesh
  51247. * @param options defines the options used to create the mesh
  51248. * @param scene defines the hosting scene
  51249. * @returns the extruded shape mesh
  51250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51252. */
  51253. static ExtrudeShape(name: string, options: {
  51254. shape: Vector3[];
  51255. path: Vector3[];
  51256. scale?: number;
  51257. rotation?: number;
  51258. cap?: number;
  51259. updatable?: boolean;
  51260. sideOrientation?: number;
  51261. frontUVs?: Vector4;
  51262. backUVs?: Vector4;
  51263. instance?: Mesh;
  51264. invertUV?: boolean;
  51265. }, scene?: Nullable<Scene>): Mesh;
  51266. /**
  51267. * Creates an custom extruded shape mesh.
  51268. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51269. * * 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.
  51270. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51271. * * 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
  51272. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51273. * * 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
  51274. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51275. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51276. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51277. * * 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
  51278. * * 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
  51279. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51281. * * 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
  51282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51284. * @param name defines the name of the mesh
  51285. * @param options defines the options used to create the mesh
  51286. * @param scene defines the hosting scene
  51287. * @returns the custom extruded shape mesh
  51288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51289. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51291. */
  51292. static ExtrudeShapeCustom(name: string, options: {
  51293. shape: Vector3[];
  51294. path: Vector3[];
  51295. scaleFunction?: any;
  51296. rotationFunction?: any;
  51297. ribbonCloseArray?: boolean;
  51298. ribbonClosePath?: boolean;
  51299. cap?: number;
  51300. updatable?: boolean;
  51301. sideOrientation?: number;
  51302. frontUVs?: Vector4;
  51303. backUVs?: Vector4;
  51304. instance?: Mesh;
  51305. invertUV?: boolean;
  51306. }, scene?: Nullable<Scene>): Mesh;
  51307. private static _ExtrudeShapeGeneric;
  51308. }
  51309. }
  51310. declare module BABYLON {
  51311. /**
  51312. * AmmoJS Physics plugin
  51313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51314. * @see https://github.com/kripken/ammo.js/
  51315. */
  51316. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51317. private _useDeltaForWorldStep;
  51318. /**
  51319. * Reference to the Ammo library
  51320. */
  51321. bjsAMMO: any;
  51322. /**
  51323. * Created ammoJS world which physics bodies are added to
  51324. */
  51325. world: any;
  51326. /**
  51327. * Name of the plugin
  51328. */
  51329. name: string;
  51330. private _timeStep;
  51331. private _fixedTimeStep;
  51332. private _maxSteps;
  51333. private _tmpQuaternion;
  51334. private _tmpAmmoTransform;
  51335. private _tmpAmmoQuaternion;
  51336. private _tmpAmmoConcreteContactResultCallback;
  51337. private _collisionConfiguration;
  51338. private _dispatcher;
  51339. private _overlappingPairCache;
  51340. private _solver;
  51341. private _softBodySolver;
  51342. private _tmpAmmoVectorA;
  51343. private _tmpAmmoVectorB;
  51344. private _tmpAmmoVectorC;
  51345. private _tmpAmmoVectorD;
  51346. private _tmpContactCallbackResult;
  51347. private _tmpAmmoVectorRCA;
  51348. private _tmpAmmoVectorRCB;
  51349. private _raycastResult;
  51350. private static readonly DISABLE_COLLISION_FLAG;
  51351. private static readonly KINEMATIC_FLAG;
  51352. private static readonly DISABLE_DEACTIVATION_FLAG;
  51353. /**
  51354. * Initializes the ammoJS plugin
  51355. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51356. * @param ammoInjection can be used to inject your own ammo reference
  51357. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51358. */
  51359. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51360. /**
  51361. * Sets the gravity of the physics world (m/(s^2))
  51362. * @param gravity Gravity to set
  51363. */
  51364. setGravity(gravity: Vector3): void;
  51365. /**
  51366. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51367. * @param timeStep timestep to use in seconds
  51368. */
  51369. setTimeStep(timeStep: number): void;
  51370. /**
  51371. * 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)
  51372. * @param fixedTimeStep fixedTimeStep to use in seconds
  51373. */
  51374. setFixedTimeStep(fixedTimeStep: number): void;
  51375. /**
  51376. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51377. * @param maxSteps the maximum number of steps by the physics engine per frame
  51378. */
  51379. setMaxSteps(maxSteps: number): void;
  51380. /**
  51381. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51382. * @returns the current timestep in seconds
  51383. */
  51384. getTimeStep(): number;
  51385. private _isImpostorInContact;
  51386. private _isImpostorPairInContact;
  51387. private _stepSimulation;
  51388. /**
  51389. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51390. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51391. * After the step the babylon meshes are set to the position of the physics imposters
  51392. * @param delta amount of time to step forward
  51393. * @param impostors array of imposters to update before/after the step
  51394. */
  51395. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51396. /**
  51397. * Update babylon mesh to match physics world object
  51398. * @param impostor imposter to match
  51399. */
  51400. private _afterSoftStep;
  51401. /**
  51402. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51403. * @param impostor imposter to match
  51404. */
  51405. private _ropeStep;
  51406. /**
  51407. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51408. * @param impostor imposter to match
  51409. */
  51410. private _softbodyOrClothStep;
  51411. private _tmpVector;
  51412. private _tmpMatrix;
  51413. /**
  51414. * Applies an impulse on the imposter
  51415. * @param impostor imposter to apply impulse to
  51416. * @param force amount of force to be applied to the imposter
  51417. * @param contactPoint the location to apply the impulse on the imposter
  51418. */
  51419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51420. /**
  51421. * Applies a force on the imposter
  51422. * @param impostor imposter to apply force
  51423. * @param force amount of force to be applied to the imposter
  51424. * @param contactPoint the location to apply the force on the imposter
  51425. */
  51426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51427. /**
  51428. * Creates a physics body using the plugin
  51429. * @param impostor the imposter to create the physics body on
  51430. */
  51431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51432. /**
  51433. * Removes the physics body from the imposter and disposes of the body's memory
  51434. * @param impostor imposter to remove the physics body from
  51435. */
  51436. removePhysicsBody(impostor: PhysicsImpostor): void;
  51437. /**
  51438. * Generates a joint
  51439. * @param impostorJoint the imposter joint to create the joint with
  51440. */
  51441. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51442. /**
  51443. * Removes a joint
  51444. * @param impostorJoint the imposter joint to remove the joint from
  51445. */
  51446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51447. private _addMeshVerts;
  51448. /**
  51449. * Initialise the soft body vertices to match its object's (mesh) vertices
  51450. * Softbody vertices (nodes) are in world space and to match this
  51451. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51452. * @param impostor to create the softbody for
  51453. */
  51454. private _softVertexData;
  51455. /**
  51456. * Create an impostor's soft body
  51457. * @param impostor to create the softbody for
  51458. */
  51459. private _createSoftbody;
  51460. /**
  51461. * Create cloth for an impostor
  51462. * @param impostor to create the softbody for
  51463. */
  51464. private _createCloth;
  51465. /**
  51466. * Create rope for an impostor
  51467. * @param impostor to create the softbody for
  51468. */
  51469. private _createRope;
  51470. private _addHullVerts;
  51471. private _createShape;
  51472. /**
  51473. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51474. * @param impostor imposter containing the physics body and babylon object
  51475. */
  51476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51477. /**
  51478. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51479. * @param impostor imposter containing the physics body and babylon object
  51480. * @param newPosition new position
  51481. * @param newRotation new rotation
  51482. */
  51483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51484. /**
  51485. * If this plugin is supported
  51486. * @returns true if its supported
  51487. */
  51488. isSupported(): boolean;
  51489. /**
  51490. * Sets the linear velocity of the physics body
  51491. * @param impostor imposter to set the velocity on
  51492. * @param velocity velocity to set
  51493. */
  51494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51495. /**
  51496. * Sets the angular velocity of the physics body
  51497. * @param impostor imposter to set the velocity on
  51498. * @param velocity velocity to set
  51499. */
  51500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51501. /**
  51502. * gets the linear velocity
  51503. * @param impostor imposter to get linear velocity from
  51504. * @returns linear velocity
  51505. */
  51506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51507. /**
  51508. * gets the angular velocity
  51509. * @param impostor imposter to get angular velocity from
  51510. * @returns angular velocity
  51511. */
  51512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51513. /**
  51514. * Sets the mass of physics body
  51515. * @param impostor imposter to set the mass on
  51516. * @param mass mass to set
  51517. */
  51518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51519. /**
  51520. * Gets the mass of the physics body
  51521. * @param impostor imposter to get the mass from
  51522. * @returns mass
  51523. */
  51524. getBodyMass(impostor: PhysicsImpostor): number;
  51525. /**
  51526. * Gets friction of the impostor
  51527. * @param impostor impostor to get friction from
  51528. * @returns friction value
  51529. */
  51530. getBodyFriction(impostor: PhysicsImpostor): number;
  51531. /**
  51532. * Sets friction of the impostor
  51533. * @param impostor impostor to set friction on
  51534. * @param friction friction value
  51535. */
  51536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51537. /**
  51538. * Gets restitution of the impostor
  51539. * @param impostor impostor to get restitution from
  51540. * @returns restitution value
  51541. */
  51542. getBodyRestitution(impostor: PhysicsImpostor): number;
  51543. /**
  51544. * Sets resitution of the impostor
  51545. * @param impostor impostor to set resitution on
  51546. * @param restitution resitution value
  51547. */
  51548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51549. /**
  51550. * Gets pressure inside the impostor
  51551. * @param impostor impostor to get pressure from
  51552. * @returns pressure value
  51553. */
  51554. getBodyPressure(impostor: PhysicsImpostor): number;
  51555. /**
  51556. * Sets pressure inside a soft body impostor
  51557. * Cloth and rope must remain 0 pressure
  51558. * @param impostor impostor to set pressure on
  51559. * @param pressure pressure value
  51560. */
  51561. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51562. /**
  51563. * Gets stiffness of the impostor
  51564. * @param impostor impostor to get stiffness from
  51565. * @returns pressure value
  51566. */
  51567. getBodyStiffness(impostor: PhysicsImpostor): number;
  51568. /**
  51569. * Sets stiffness of the impostor
  51570. * @param impostor impostor to set stiffness on
  51571. * @param stiffness stiffness value from 0 to 1
  51572. */
  51573. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51574. /**
  51575. * Gets velocityIterations of the impostor
  51576. * @param impostor impostor to get velocity iterations from
  51577. * @returns velocityIterations value
  51578. */
  51579. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51580. /**
  51581. * Sets velocityIterations of the impostor
  51582. * @param impostor impostor to set velocity iterations on
  51583. * @param velocityIterations velocityIterations value
  51584. */
  51585. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51586. /**
  51587. * Gets positionIterations of the impostor
  51588. * @param impostor impostor to get position iterations from
  51589. * @returns positionIterations value
  51590. */
  51591. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51592. /**
  51593. * Sets positionIterations of the impostor
  51594. * @param impostor impostor to set position on
  51595. * @param positionIterations positionIterations value
  51596. */
  51597. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51598. /**
  51599. * Append an anchor to a cloth object
  51600. * @param impostor is the cloth impostor to add anchor to
  51601. * @param otherImpostor is the rigid impostor to anchor to
  51602. * @param width ratio across width from 0 to 1
  51603. * @param height ratio up height from 0 to 1
  51604. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51606. */
  51607. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51608. /**
  51609. * Append an hook to a rope object
  51610. * @param impostor is the rope impostor to add hook to
  51611. * @param otherImpostor is the rigid impostor to hook to
  51612. * @param length ratio along the rope from 0 to 1
  51613. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51614. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51615. */
  51616. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51617. /**
  51618. * Sleeps the physics body and stops it from being active
  51619. * @param impostor impostor to sleep
  51620. */
  51621. sleepBody(impostor: PhysicsImpostor): void;
  51622. /**
  51623. * Activates the physics body
  51624. * @param impostor impostor to activate
  51625. */
  51626. wakeUpBody(impostor: PhysicsImpostor): void;
  51627. /**
  51628. * Updates the distance parameters of the joint
  51629. * @param joint joint to update
  51630. * @param maxDistance maximum distance of the joint
  51631. * @param minDistance minimum distance of the joint
  51632. */
  51633. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51634. /**
  51635. * Sets a motor on the joint
  51636. * @param joint joint to set motor on
  51637. * @param speed speed of the motor
  51638. * @param maxForce maximum force of the motor
  51639. * @param motorIndex index of the motor
  51640. */
  51641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51642. /**
  51643. * Sets the motors limit
  51644. * @param joint joint to set limit on
  51645. * @param upperLimit upper limit
  51646. * @param lowerLimit lower limit
  51647. */
  51648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51649. /**
  51650. * Syncs the position and rotation of a mesh with the impostor
  51651. * @param mesh mesh to sync
  51652. * @param impostor impostor to update the mesh with
  51653. */
  51654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51655. /**
  51656. * Gets the radius of the impostor
  51657. * @param impostor impostor to get radius from
  51658. * @returns the radius
  51659. */
  51660. getRadius(impostor: PhysicsImpostor): number;
  51661. /**
  51662. * Gets the box size of the impostor
  51663. * @param impostor impostor to get box size from
  51664. * @param result the resulting box size
  51665. */
  51666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51667. /**
  51668. * Disposes of the impostor
  51669. */
  51670. dispose(): void;
  51671. /**
  51672. * Does a raycast in the physics world
  51673. * @param from when should the ray start?
  51674. * @param to when should the ray end?
  51675. * @returns PhysicsRaycastResult
  51676. */
  51677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51678. }
  51679. }
  51680. declare module BABYLON {
  51681. interface AbstractScene {
  51682. /**
  51683. * The list of reflection probes added to the scene
  51684. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51685. */
  51686. reflectionProbes: Array<ReflectionProbe>;
  51687. /**
  51688. * Removes the given reflection probe from this scene.
  51689. * @param toRemove The reflection probe to remove
  51690. * @returns The index of the removed reflection probe
  51691. */
  51692. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51693. /**
  51694. * Adds the given reflection probe to this scene.
  51695. * @param newReflectionProbe The reflection probe to add
  51696. */
  51697. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51698. }
  51699. /**
  51700. * Class used to generate realtime reflection / refraction cube textures
  51701. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51702. */
  51703. export class ReflectionProbe {
  51704. /** defines the name of the probe */
  51705. name: string;
  51706. private _scene;
  51707. private _renderTargetTexture;
  51708. private _projectionMatrix;
  51709. private _viewMatrix;
  51710. private _target;
  51711. private _add;
  51712. private _attachedMesh;
  51713. private _invertYAxis;
  51714. /** Gets or sets probe position (center of the cube map) */
  51715. position: Vector3;
  51716. /**
  51717. * Creates a new reflection probe
  51718. * @param name defines the name of the probe
  51719. * @param size defines the texture resolution (for each face)
  51720. * @param scene defines the hosting scene
  51721. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51722. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51723. */
  51724. constructor(
  51725. /** defines the name of the probe */
  51726. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51727. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51728. samples: number;
  51729. /** Gets or sets the refresh rate to use (on every frame by default) */
  51730. refreshRate: number;
  51731. /**
  51732. * Gets the hosting scene
  51733. * @returns a Scene
  51734. */
  51735. getScene(): Scene;
  51736. /** Gets the internal CubeTexture used to render to */
  51737. readonly cubeTexture: RenderTargetTexture;
  51738. /** Gets the list of meshes to render */
  51739. readonly renderList: Nullable<AbstractMesh[]>;
  51740. /**
  51741. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51742. * @param mesh defines the mesh to attach to
  51743. */
  51744. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51745. /**
  51746. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51747. * @param renderingGroupId The rendering group id corresponding to its index
  51748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51749. */
  51750. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51751. /**
  51752. * Clean all associated resources
  51753. */
  51754. dispose(): void;
  51755. /**
  51756. * Converts the reflection probe information to a readable string for debug purpose.
  51757. * @param fullDetails Supports for multiple levels of logging within scene loading
  51758. * @returns the human readable reflection probe info
  51759. */
  51760. toString(fullDetails?: boolean): string;
  51761. /**
  51762. * Get the class name of the relfection probe.
  51763. * @returns "ReflectionProbe"
  51764. */
  51765. getClassName(): string;
  51766. /**
  51767. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51768. * @returns The JSON representation of the texture
  51769. */
  51770. serialize(): any;
  51771. /**
  51772. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51773. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51774. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51775. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51776. * @returns The parsed reflection probe if successful
  51777. */
  51778. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51779. }
  51780. }
  51781. declare module BABYLON {
  51782. /** @hidden */
  51783. export var _BabylonLoaderRegistered: boolean;
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * The Physically based simple base material of BJS.
  51788. *
  51789. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51790. * It is used as the base class for both the specGloss and metalRough conventions.
  51791. */
  51792. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51793. /**
  51794. * Number of Simultaneous lights allowed on the material.
  51795. */
  51796. maxSimultaneousLights: number;
  51797. /**
  51798. * If sets to true, disables all the lights affecting the material.
  51799. */
  51800. disableLighting: boolean;
  51801. /**
  51802. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51803. */
  51804. environmentTexture: BaseTexture;
  51805. /**
  51806. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51807. */
  51808. invertNormalMapX: boolean;
  51809. /**
  51810. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51811. */
  51812. invertNormalMapY: boolean;
  51813. /**
  51814. * Normal map used in the model.
  51815. */
  51816. normalTexture: BaseTexture;
  51817. /**
  51818. * Emissivie color used to self-illuminate the model.
  51819. */
  51820. emissiveColor: Color3;
  51821. /**
  51822. * Emissivie texture used to self-illuminate the model.
  51823. */
  51824. emissiveTexture: BaseTexture;
  51825. /**
  51826. * Occlusion Channel Strenght.
  51827. */
  51828. occlusionStrength: number;
  51829. /**
  51830. * Occlusion Texture of the material (adding extra occlusion effects).
  51831. */
  51832. occlusionTexture: BaseTexture;
  51833. /**
  51834. * Defines the alpha limits in alpha test mode.
  51835. */
  51836. alphaCutOff: number;
  51837. /**
  51838. * Gets the current double sided mode.
  51839. */
  51840. /**
  51841. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51842. */
  51843. doubleSided: boolean;
  51844. /**
  51845. * Stores the pre-calculated light information of a mesh in a texture.
  51846. */
  51847. lightmapTexture: BaseTexture;
  51848. /**
  51849. * If true, the light map contains occlusion information instead of lighting info.
  51850. */
  51851. useLightmapAsShadowmap: boolean;
  51852. /**
  51853. * Instantiates a new PBRMaterial instance.
  51854. *
  51855. * @param name The material name
  51856. * @param scene The scene the material will be use in.
  51857. */
  51858. constructor(name: string, scene: Scene);
  51859. getClassName(): string;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * The PBR material of BJS following the metal roughness convention.
  51865. *
  51866. * This fits to the PBR convention in the GLTF definition:
  51867. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51868. */
  51869. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51870. /**
  51871. * The base color has two different interpretations depending on the value of metalness.
  51872. * When the material is a metal, the base color is the specific measured reflectance value
  51873. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51874. * of the material.
  51875. */
  51876. baseColor: Color3;
  51877. /**
  51878. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51879. * well as opacity information in the alpha channel.
  51880. */
  51881. baseTexture: BaseTexture;
  51882. /**
  51883. * Specifies the metallic scalar value of the material.
  51884. * Can also be used to scale the metalness values of the metallic texture.
  51885. */
  51886. metallic: number;
  51887. /**
  51888. * Specifies the roughness scalar value of the material.
  51889. * Can also be used to scale the roughness values of the metallic texture.
  51890. */
  51891. roughness: number;
  51892. /**
  51893. * Texture containing both the metallic value in the B channel and the
  51894. * roughness value in the G channel to keep better precision.
  51895. */
  51896. metallicRoughnessTexture: BaseTexture;
  51897. /**
  51898. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51899. *
  51900. * @param name The material name
  51901. * @param scene The scene the material will be use in.
  51902. */
  51903. constructor(name: string, scene: Scene);
  51904. /**
  51905. * Return the currrent class name of the material.
  51906. */
  51907. getClassName(): string;
  51908. /**
  51909. * Makes a duplicate of the current material.
  51910. * @param name - name to use for the new material.
  51911. */
  51912. clone(name: string): PBRMetallicRoughnessMaterial;
  51913. /**
  51914. * Serialize the material to a parsable JSON object.
  51915. */
  51916. serialize(): any;
  51917. /**
  51918. * Parses a JSON object correponding to the serialize function.
  51919. */
  51920. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /**
  51925. * The PBR material of BJS following the specular glossiness convention.
  51926. *
  51927. * This fits to the PBR convention in the GLTF definition:
  51928. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51929. */
  51930. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51931. /**
  51932. * Specifies the diffuse color of the material.
  51933. */
  51934. diffuseColor: Color3;
  51935. /**
  51936. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51937. * channel.
  51938. */
  51939. diffuseTexture: BaseTexture;
  51940. /**
  51941. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51942. */
  51943. specularColor: Color3;
  51944. /**
  51945. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51946. */
  51947. glossiness: number;
  51948. /**
  51949. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51950. */
  51951. specularGlossinessTexture: BaseTexture;
  51952. /**
  51953. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51954. *
  51955. * @param name The material name
  51956. * @param scene The scene the material will be use in.
  51957. */
  51958. constructor(name: string, scene: Scene);
  51959. /**
  51960. * Return the currrent class name of the material.
  51961. */
  51962. getClassName(): string;
  51963. /**
  51964. * Makes a duplicate of the current material.
  51965. * @param name - name to use for the new material.
  51966. */
  51967. clone(name: string): PBRSpecularGlossinessMaterial;
  51968. /**
  51969. * Serialize the material to a parsable JSON object.
  51970. */
  51971. serialize(): any;
  51972. /**
  51973. * Parses a JSON object correponding to the serialize function.
  51974. */
  51975. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51981. * It can help converting any input color in a desired output one. This can then be used to create effects
  51982. * from sepia, black and white to sixties or futuristic rendering...
  51983. *
  51984. * The only supported format is currently 3dl.
  51985. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51986. */
  51987. export class ColorGradingTexture extends BaseTexture {
  51988. /**
  51989. * The current texture matrix. (will always be identity in color grading texture)
  51990. */
  51991. private _textureMatrix;
  51992. /**
  51993. * The texture URL.
  51994. */
  51995. url: string;
  51996. /**
  51997. * Empty line regex stored for GC.
  51998. */
  51999. private static _noneEmptyLineRegex;
  52000. private _engine;
  52001. /**
  52002. * Instantiates a ColorGradingTexture from the following parameters.
  52003. *
  52004. * @param url The location of the color gradind data (currently only supporting 3dl)
  52005. * @param scene The scene the texture will be used in
  52006. */
  52007. constructor(url: string, scene: Scene);
  52008. /**
  52009. * Returns the texture matrix used in most of the material.
  52010. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52011. */
  52012. getTextureMatrix(): Matrix;
  52013. /**
  52014. * Occurs when the file being loaded is a .3dl LUT file.
  52015. */
  52016. private load3dlTexture;
  52017. /**
  52018. * Starts the loading process of the texture.
  52019. */
  52020. private loadTexture;
  52021. /**
  52022. * Clones the color gradind texture.
  52023. */
  52024. clone(): ColorGradingTexture;
  52025. /**
  52026. * Called during delayed load for textures.
  52027. */
  52028. delayLoad(): void;
  52029. /**
  52030. * Parses a color grading texture serialized by Babylon.
  52031. * @param parsedTexture The texture information being parsedTexture
  52032. * @param scene The scene to load the texture in
  52033. * @param rootUrl The root url of the data assets to load
  52034. * @return A color gradind texture
  52035. */
  52036. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52037. /**
  52038. * Serializes the LUT texture to json format.
  52039. */
  52040. serialize(): any;
  52041. }
  52042. }
  52043. declare module BABYLON {
  52044. /**
  52045. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52046. */
  52047. export class EquiRectangularCubeTexture extends BaseTexture {
  52048. /** The six faces of the cube. */
  52049. private static _FacesMapping;
  52050. private _noMipmap;
  52051. private _onLoad;
  52052. private _onError;
  52053. /** The size of the cubemap. */
  52054. private _size;
  52055. /** The buffer of the image. */
  52056. private _buffer;
  52057. /** The width of the input image. */
  52058. private _width;
  52059. /** The height of the input image. */
  52060. private _height;
  52061. /** The URL to the image. */
  52062. url: string;
  52063. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52064. coordinatesMode: number;
  52065. /**
  52066. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52067. * @param url The location of the image
  52068. * @param scene The scene the texture will be used in
  52069. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52070. * @param noMipmap Forces to not generate the mipmap if true
  52071. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52072. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52073. * @param onLoad — defines a callback called when texture is loaded
  52074. * @param onError — defines a callback called if there is an error
  52075. */
  52076. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52077. /**
  52078. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52079. */
  52080. private loadImage;
  52081. /**
  52082. * Convert the image buffer into a cubemap and create a CubeTexture.
  52083. */
  52084. private loadTexture;
  52085. /**
  52086. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52087. * @param buffer The ArrayBuffer that should be converted.
  52088. * @returns The buffer as Float32Array.
  52089. */
  52090. private getFloat32ArrayFromArrayBuffer;
  52091. /**
  52092. * Get the current class name of the texture useful for serialization or dynamic coding.
  52093. * @returns "EquiRectangularCubeTexture"
  52094. */
  52095. getClassName(): string;
  52096. /**
  52097. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52098. * @returns A clone of the current EquiRectangularCubeTexture.
  52099. */
  52100. clone(): EquiRectangularCubeTexture;
  52101. }
  52102. }
  52103. declare module BABYLON {
  52104. /**
  52105. * Based on jsTGALoader - Javascript loader for TGA file
  52106. * By Vincent Thibault
  52107. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52108. */
  52109. export class TGATools {
  52110. private static _TYPE_INDEXED;
  52111. private static _TYPE_RGB;
  52112. private static _TYPE_GREY;
  52113. private static _TYPE_RLE_INDEXED;
  52114. private static _TYPE_RLE_RGB;
  52115. private static _TYPE_RLE_GREY;
  52116. private static _ORIGIN_MASK;
  52117. private static _ORIGIN_SHIFT;
  52118. private static _ORIGIN_BL;
  52119. private static _ORIGIN_BR;
  52120. private static _ORIGIN_UL;
  52121. private static _ORIGIN_UR;
  52122. /**
  52123. * Gets the header of a TGA file
  52124. * @param data defines the TGA data
  52125. * @returns the header
  52126. */
  52127. static GetTGAHeader(data: Uint8Array): any;
  52128. /**
  52129. * Uploads TGA content to a Babylon Texture
  52130. * @hidden
  52131. */
  52132. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52133. /** @hidden */
  52134. 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;
  52135. /** @hidden */
  52136. 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;
  52137. /** @hidden */
  52138. 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;
  52139. /** @hidden */
  52140. 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;
  52141. /** @hidden */
  52142. 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;
  52143. /** @hidden */
  52144. 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;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Implementation of the TGA Texture Loader.
  52150. * @hidden
  52151. */
  52152. export class _TGATextureLoader implements IInternalTextureLoader {
  52153. /**
  52154. * Defines wether the loader supports cascade loading the different faces.
  52155. */
  52156. readonly supportCascades: boolean;
  52157. /**
  52158. * This returns if the loader support the current file information.
  52159. * @param extension defines the file extension of the file being loaded
  52160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52161. * @param fallback defines the fallback internal texture if any
  52162. * @param isBase64 defines whether the texture is encoded as a base64
  52163. * @param isBuffer defines whether the texture data are stored as a buffer
  52164. * @returns true if the loader can load the specified file
  52165. */
  52166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52167. /**
  52168. * Transform the url before loading if required.
  52169. * @param rootUrl the url of the texture
  52170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52171. * @returns the transformed texture
  52172. */
  52173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52174. /**
  52175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52176. * @param rootUrl the url of the texture
  52177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52178. * @returns the fallback texture
  52179. */
  52180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52181. /**
  52182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52183. * @param data contains the texture data
  52184. * @param texture defines the BabylonJS internal texture
  52185. * @param createPolynomials will be true if polynomials have been requested
  52186. * @param onLoad defines the callback to trigger once the texture is ready
  52187. * @param onError defines the callback to trigger in case of error
  52188. */
  52189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52190. /**
  52191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52192. * @param data contains the texture data
  52193. * @param texture defines the BabylonJS internal texture
  52194. * @param callback defines the method to call once ready to upload
  52195. */
  52196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * Info about the .basis files
  52202. */
  52203. class BasisFileInfo {
  52204. /**
  52205. * If the file has alpha
  52206. */
  52207. hasAlpha: boolean;
  52208. /**
  52209. * Info about each image of the basis file
  52210. */
  52211. images: Array<{
  52212. levels: Array<{
  52213. width: number;
  52214. height: number;
  52215. transcodedPixels: ArrayBufferView;
  52216. }>;
  52217. }>;
  52218. }
  52219. /**
  52220. * Result of transcoding a basis file
  52221. */
  52222. class TranscodeResult {
  52223. /**
  52224. * Info about the .basis file
  52225. */
  52226. fileInfo: BasisFileInfo;
  52227. /**
  52228. * Format to use when loading the file
  52229. */
  52230. format: number;
  52231. }
  52232. /**
  52233. * Configuration options for the Basis transcoder
  52234. */
  52235. export class BasisTranscodeConfiguration {
  52236. /**
  52237. * Supported compression formats used to determine the supported output format of the transcoder
  52238. */
  52239. supportedCompressionFormats?: {
  52240. /**
  52241. * etc1 compression format
  52242. */
  52243. etc1?: boolean;
  52244. /**
  52245. * s3tc compression format
  52246. */
  52247. s3tc?: boolean;
  52248. /**
  52249. * pvrtc compression format
  52250. */
  52251. pvrtc?: boolean;
  52252. /**
  52253. * etc2 compression format
  52254. */
  52255. etc2?: boolean;
  52256. };
  52257. /**
  52258. * If mipmap levels should be loaded for transcoded images (Default: true)
  52259. */
  52260. loadMipmapLevels?: boolean;
  52261. /**
  52262. * Index of a single image to load (Default: all images)
  52263. */
  52264. loadSingleImage?: number;
  52265. }
  52266. /**
  52267. * Used to load .Basis files
  52268. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52269. */
  52270. export class BasisTools {
  52271. private static _IgnoreSupportedFormats;
  52272. /**
  52273. * URL to use when loading the basis transcoder
  52274. */
  52275. static JSModuleURL: string;
  52276. /**
  52277. * URL to use when loading the wasm module for the transcoder
  52278. */
  52279. static WasmModuleURL: string;
  52280. /**
  52281. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52282. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52283. * @returns internal format corresponding to the Basis format
  52284. */
  52285. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52286. private static _WorkerPromise;
  52287. private static _Worker;
  52288. private static _actionId;
  52289. private static _CreateWorkerAsync;
  52290. /**
  52291. * Transcodes a loaded image file to compressed pixel data
  52292. * @param imageData image data to transcode
  52293. * @param config configuration options for the transcoding
  52294. * @returns a promise resulting in the transcoded image
  52295. */
  52296. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52297. /**
  52298. * Loads a texture from the transcode result
  52299. * @param texture texture load to
  52300. * @param transcodeResult the result of transcoding the basis file to load from
  52301. */
  52302. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52303. }
  52304. }
  52305. declare module BABYLON {
  52306. /**
  52307. * Loader for .basis file format
  52308. */
  52309. export class _BasisTextureLoader implements IInternalTextureLoader {
  52310. /**
  52311. * Defines whether the loader supports cascade loading the different faces.
  52312. */
  52313. readonly supportCascades: boolean;
  52314. /**
  52315. * This returns if the loader support the current file information.
  52316. * @param extension defines the file extension of the file being loaded
  52317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52318. * @param fallback defines the fallback internal texture if any
  52319. * @param isBase64 defines whether the texture is encoded as a base64
  52320. * @param isBuffer defines whether the texture data are stored as a buffer
  52321. * @returns true if the loader can load the specified file
  52322. */
  52323. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52324. /**
  52325. * Transform the url before loading if required.
  52326. * @param rootUrl the url of the texture
  52327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52328. * @returns the transformed texture
  52329. */
  52330. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52331. /**
  52332. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52333. * @param rootUrl the url of the texture
  52334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52335. * @returns the fallback texture
  52336. */
  52337. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52338. /**
  52339. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52340. * @param data contains the texture data
  52341. * @param texture defines the BabylonJS internal texture
  52342. * @param createPolynomials will be true if polynomials have been requested
  52343. * @param onLoad defines the callback to trigger once the texture is ready
  52344. * @param onError defines the callback to trigger in case of error
  52345. */
  52346. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52347. /**
  52348. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52349. * @param data contains the texture data
  52350. * @param texture defines the BabylonJS internal texture
  52351. * @param callback defines the method to call once ready to upload
  52352. */
  52353. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52354. }
  52355. }
  52356. declare module BABYLON {
  52357. /**
  52358. * 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.
  52359. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52360. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52361. */
  52362. export class CustomProceduralTexture extends ProceduralTexture {
  52363. private _animate;
  52364. private _time;
  52365. private _config;
  52366. private _texturePath;
  52367. /**
  52368. * Instantiates a new Custom Procedural Texture.
  52369. * 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.
  52370. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52371. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52372. * @param name Define the name of the texture
  52373. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52374. * @param size Define the size of the texture to create
  52375. * @param scene Define the scene the texture belongs to
  52376. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52377. * @param generateMipMaps Define if the texture should creates mip maps or not
  52378. */
  52379. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52380. private _loadJson;
  52381. /**
  52382. * Is the texture ready to be used ? (rendered at least once)
  52383. * @returns true if ready, otherwise, false.
  52384. */
  52385. isReady(): boolean;
  52386. /**
  52387. * Render the texture to its associated render target.
  52388. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52389. */
  52390. render(useCameraPostProcess?: boolean): void;
  52391. /**
  52392. * Update the list of dependant textures samplers in the shader.
  52393. */
  52394. updateTextures(): void;
  52395. /**
  52396. * Update the uniform values of the procedural texture in the shader.
  52397. */
  52398. updateShaderUniforms(): void;
  52399. /**
  52400. * Define if the texture animates or not.
  52401. */
  52402. animate: boolean;
  52403. }
  52404. }
  52405. declare module BABYLON {
  52406. /** @hidden */
  52407. export var noisePixelShader: {
  52408. name: string;
  52409. shader: string;
  52410. };
  52411. }
  52412. declare module BABYLON {
  52413. /**
  52414. * Class used to generate noise procedural textures
  52415. */
  52416. export class NoiseProceduralTexture extends ProceduralTexture {
  52417. private _time;
  52418. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52419. brightness: number;
  52420. /** Defines the number of octaves to process */
  52421. octaves: number;
  52422. /** Defines the level of persistence (0.8 by default) */
  52423. persistence: number;
  52424. /** Gets or sets animation speed factor (default is 1) */
  52425. animationSpeedFactor: number;
  52426. /**
  52427. * Creates a new NoiseProceduralTexture
  52428. * @param name defines the name fo the texture
  52429. * @param size defines the size of the texture (default is 256)
  52430. * @param scene defines the hosting scene
  52431. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52432. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52433. */
  52434. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52435. private _updateShaderUniforms;
  52436. protected _getDefines(): string;
  52437. /** Generate the current state of the procedural texture */
  52438. render(useCameraPostProcess?: boolean): void;
  52439. /**
  52440. * Serializes this noise procedural texture
  52441. * @returns a serialized noise procedural texture object
  52442. */
  52443. serialize(): any;
  52444. /**
  52445. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52446. * @param parsedTexture defines parsed texture data
  52447. * @param scene defines the current scene
  52448. * @param rootUrl defines the root URL containing noise procedural texture information
  52449. * @returns a parsed NoiseProceduralTexture
  52450. */
  52451. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /**
  52456. * Raw cube texture where the raw buffers are passed in
  52457. */
  52458. export class RawCubeTexture extends CubeTexture {
  52459. /**
  52460. * Creates a cube texture where the raw buffers are passed in.
  52461. * @param scene defines the scene the texture is attached to
  52462. * @param data defines the array of data to use to create each face
  52463. * @param size defines the size of the textures
  52464. * @param format defines the format of the data
  52465. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52466. * @param generateMipMaps defines if the engine should generate the mip levels
  52467. * @param invertY defines if data must be stored with Y axis inverted
  52468. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52469. * @param compression defines the compression used (null by default)
  52470. */
  52471. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52472. /**
  52473. * Updates the raw cube texture.
  52474. * @param data defines the data to store
  52475. * @param format defines the data format
  52476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52477. * @param invertY defines if data must be stored with Y axis inverted
  52478. * @param compression defines the compression used (null by default)
  52479. * @param level defines which level of the texture to update
  52480. */
  52481. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52482. /**
  52483. * Updates a raw cube texture with RGBD encoded data.
  52484. * @param data defines the array of data [mipmap][face] to use to create each face
  52485. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52486. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52487. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52488. * @returns a promsie that resolves when the operation is complete
  52489. */
  52490. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52491. /**
  52492. * Clones the raw cube texture.
  52493. * @return a new cube texture
  52494. */
  52495. clone(): CubeTexture;
  52496. /** @hidden */
  52497. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52498. }
  52499. }
  52500. declare module BABYLON {
  52501. /**
  52502. * Class used to store 3D textures containing user data
  52503. */
  52504. export class RawTexture3D extends Texture {
  52505. /** Gets or sets the texture format to use */
  52506. format: number;
  52507. private _engine;
  52508. /**
  52509. * Create a new RawTexture3D
  52510. * @param data defines the data of the texture
  52511. * @param width defines the width of the texture
  52512. * @param height defines the height of the texture
  52513. * @param depth defines the depth of the texture
  52514. * @param format defines the texture format to use
  52515. * @param scene defines the hosting scene
  52516. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52517. * @param invertY defines if texture must be stored with Y axis inverted
  52518. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52519. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52520. */
  52521. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52522. /** Gets or sets the texture format to use */
  52523. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52524. /**
  52525. * Update the texture with new data
  52526. * @param data defines the data to store in the texture
  52527. */
  52528. update(data: ArrayBufferView): void;
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. /**
  52533. * Creates a refraction texture used by refraction channel of the standard material.
  52534. * It is like a mirror but to see through a material.
  52535. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52536. */
  52537. export class RefractionTexture extends RenderTargetTexture {
  52538. /**
  52539. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52540. * 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.
  52541. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52542. */
  52543. refractionPlane: Plane;
  52544. /**
  52545. * Define how deep under the surface we should see.
  52546. */
  52547. depth: number;
  52548. /**
  52549. * Creates a refraction texture used by refraction channel of the standard material.
  52550. * It is like a mirror but to see through a material.
  52551. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52552. * @param name Define the texture name
  52553. * @param size Define the size of the underlying texture
  52554. * @param scene Define the scene the refraction belongs to
  52555. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52556. */
  52557. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52558. /**
  52559. * Clone the refraction texture.
  52560. * @returns the cloned texture
  52561. */
  52562. clone(): RefractionTexture;
  52563. /**
  52564. * Serialize the texture to a JSON representation you could use in Parse later on
  52565. * @returns the serialized JSON representation
  52566. */
  52567. serialize(): any;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Defines the options related to the creation of an HtmlElementTexture
  52573. */
  52574. export interface IHtmlElementTextureOptions {
  52575. /**
  52576. * Defines wether mip maps should be created or not.
  52577. */
  52578. generateMipMaps?: boolean;
  52579. /**
  52580. * Defines the sampling mode of the texture.
  52581. */
  52582. samplingMode?: number;
  52583. /**
  52584. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52585. */
  52586. engine: Nullable<ThinEngine>;
  52587. /**
  52588. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52589. */
  52590. scene: Nullable<Scene>;
  52591. }
  52592. /**
  52593. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52594. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52595. * is automatically managed.
  52596. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52597. * in your application.
  52598. *
  52599. * As the update is not automatic, you need to call them manually.
  52600. */
  52601. export class HtmlElementTexture extends BaseTexture {
  52602. /**
  52603. * The texture URL.
  52604. */
  52605. element: HTMLVideoElement | HTMLCanvasElement;
  52606. private static readonly DefaultOptions;
  52607. private _textureMatrix;
  52608. private _engine;
  52609. private _isVideo;
  52610. private _generateMipMaps;
  52611. private _samplingMode;
  52612. /**
  52613. * Instantiates a HtmlElementTexture from the following parameters.
  52614. *
  52615. * @param name Defines the name of the texture
  52616. * @param element Defines the video or canvas the texture is filled with
  52617. * @param options Defines the other none mandatory texture creation options
  52618. */
  52619. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52620. private _createInternalTexture;
  52621. /**
  52622. * Returns the texture matrix used in most of the material.
  52623. */
  52624. getTextureMatrix(): Matrix;
  52625. /**
  52626. * Updates the content of the texture.
  52627. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52628. */
  52629. update(invertY?: Nullable<boolean>): void;
  52630. }
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * Enum used to define the target of a block
  52635. */
  52636. export enum NodeMaterialBlockTargets {
  52637. /** Vertex shader */
  52638. Vertex = 1,
  52639. /** Fragment shader */
  52640. Fragment = 2,
  52641. /** Neutral */
  52642. Neutral = 4,
  52643. /** Vertex and Fragment */
  52644. VertexAndFragment = 3
  52645. }
  52646. }
  52647. declare module BABYLON {
  52648. /**
  52649. * Defines the kind of connection point for node based material
  52650. */
  52651. export enum NodeMaterialBlockConnectionPointTypes {
  52652. /** Float */
  52653. Float = 1,
  52654. /** Int */
  52655. Int = 2,
  52656. /** Vector2 */
  52657. Vector2 = 4,
  52658. /** Vector3 */
  52659. Vector3 = 8,
  52660. /** Vector4 */
  52661. Vector4 = 16,
  52662. /** Color3 */
  52663. Color3 = 32,
  52664. /** Color4 */
  52665. Color4 = 64,
  52666. /** Matrix */
  52667. Matrix = 128,
  52668. /** Detect type based on connection */
  52669. AutoDetect = 1024,
  52670. /** Output type that will be defined by input type */
  52671. BasedOnInput = 2048
  52672. }
  52673. }
  52674. declare module BABYLON {
  52675. /**
  52676. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52677. */
  52678. export enum NodeMaterialBlockConnectionPointMode {
  52679. /** Value is an uniform */
  52680. Uniform = 0,
  52681. /** Value is a mesh attribute */
  52682. Attribute = 1,
  52683. /** Value is a varying between vertex and fragment shaders */
  52684. Varying = 2,
  52685. /** Mode is undefined */
  52686. Undefined = 3
  52687. }
  52688. }
  52689. declare module BABYLON {
  52690. /**
  52691. * Enum used to define system values e.g. values automatically provided by the system
  52692. */
  52693. export enum NodeMaterialSystemValues {
  52694. /** World */
  52695. World = 1,
  52696. /** View */
  52697. View = 2,
  52698. /** Projection */
  52699. Projection = 3,
  52700. /** ViewProjection */
  52701. ViewProjection = 4,
  52702. /** WorldView */
  52703. WorldView = 5,
  52704. /** WorldViewProjection */
  52705. WorldViewProjection = 6,
  52706. /** CameraPosition */
  52707. CameraPosition = 7,
  52708. /** Fog Color */
  52709. FogColor = 8,
  52710. /** Delta time */
  52711. DeltaTime = 9
  52712. }
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Root class for all node material optimizers
  52717. */
  52718. export class NodeMaterialOptimizer {
  52719. /**
  52720. * Function used to optimize a NodeMaterial graph
  52721. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52722. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52723. */
  52724. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52725. }
  52726. }
  52727. declare module BABYLON {
  52728. /**
  52729. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52730. */
  52731. export class TransformBlock extends NodeMaterialBlock {
  52732. /**
  52733. * Defines the value to use to complement W value to transform it to a Vector4
  52734. */
  52735. complementW: number;
  52736. /**
  52737. * Defines the value to use to complement z value to transform it to a Vector4
  52738. */
  52739. complementZ: number;
  52740. /**
  52741. * Creates a new TransformBlock
  52742. * @param name defines the block name
  52743. */
  52744. constructor(name: string);
  52745. /**
  52746. * Gets the current class name
  52747. * @returns the class name
  52748. */
  52749. getClassName(): string;
  52750. /**
  52751. * Gets the vector input
  52752. */
  52753. readonly vector: NodeMaterialConnectionPoint;
  52754. /**
  52755. * Gets the output component
  52756. */
  52757. readonly output: NodeMaterialConnectionPoint;
  52758. /**
  52759. * Gets the matrix transform input
  52760. */
  52761. readonly transform: NodeMaterialConnectionPoint;
  52762. protected _buildBlock(state: NodeMaterialBuildState): this;
  52763. serialize(): any;
  52764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52765. protected _dumpPropertiesCode(): string;
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /**
  52770. * Block used to output the vertex position
  52771. */
  52772. export class VertexOutputBlock extends NodeMaterialBlock {
  52773. /**
  52774. * Creates a new VertexOutputBlock
  52775. * @param name defines the block name
  52776. */
  52777. constructor(name: string);
  52778. /**
  52779. * Gets the current class name
  52780. * @returns the class name
  52781. */
  52782. getClassName(): string;
  52783. /**
  52784. * Gets the vector input component
  52785. */
  52786. readonly vector: NodeMaterialConnectionPoint;
  52787. protected _buildBlock(state: NodeMaterialBuildState): this;
  52788. }
  52789. }
  52790. declare module BABYLON {
  52791. /**
  52792. * Block used to output the final color
  52793. */
  52794. export class FragmentOutputBlock extends NodeMaterialBlock {
  52795. /**
  52796. * Create a new FragmentOutputBlock
  52797. * @param name defines the block name
  52798. */
  52799. constructor(name: string);
  52800. /**
  52801. * Gets the current class name
  52802. * @returns the class name
  52803. */
  52804. getClassName(): string;
  52805. /**
  52806. * Gets the rgba input component
  52807. */
  52808. readonly rgba: NodeMaterialConnectionPoint;
  52809. /**
  52810. * Gets the rgb input component
  52811. */
  52812. readonly rgb: NodeMaterialConnectionPoint;
  52813. /**
  52814. * Gets the a input component
  52815. */
  52816. readonly a: NodeMaterialConnectionPoint;
  52817. protected _buildBlock(state: NodeMaterialBuildState): this;
  52818. }
  52819. }
  52820. declare module BABYLON {
  52821. /**
  52822. * Block used to read a reflection texture from a sampler
  52823. */
  52824. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52825. private _define3DName;
  52826. private _defineCubicName;
  52827. private _defineExplicitName;
  52828. private _defineProjectionName;
  52829. private _defineLocalCubicName;
  52830. private _defineSphericalName;
  52831. private _definePlanarName;
  52832. private _defineEquirectangularName;
  52833. private _defineMirroredEquirectangularFixedName;
  52834. private _defineEquirectangularFixedName;
  52835. private _defineSkyboxName;
  52836. private _cubeSamplerName;
  52837. private _2DSamplerName;
  52838. private _positionUVWName;
  52839. private _directionWName;
  52840. private _reflectionCoordsName;
  52841. private _reflection2DCoordsName;
  52842. private _reflectionColorName;
  52843. private _reflectionMatrixName;
  52844. /**
  52845. * Gets or sets the texture associated with the node
  52846. */
  52847. texture: Nullable<BaseTexture>;
  52848. /**
  52849. * Create a new TextureBlock
  52850. * @param name defines the block name
  52851. */
  52852. constructor(name: string);
  52853. /**
  52854. * Gets the current class name
  52855. * @returns the class name
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Gets the world position input component
  52860. */
  52861. readonly position: NodeMaterialConnectionPoint;
  52862. /**
  52863. * Gets the world position input component
  52864. */
  52865. readonly worldPosition: NodeMaterialConnectionPoint;
  52866. /**
  52867. * Gets the world normal input component
  52868. */
  52869. readonly worldNormal: NodeMaterialConnectionPoint;
  52870. /**
  52871. * Gets the world input component
  52872. */
  52873. readonly world: NodeMaterialConnectionPoint;
  52874. /**
  52875. * Gets the camera (or eye) position component
  52876. */
  52877. readonly cameraPosition: NodeMaterialConnectionPoint;
  52878. /**
  52879. * Gets the view input component
  52880. */
  52881. readonly view: NodeMaterialConnectionPoint;
  52882. /**
  52883. * Gets the rgb output component
  52884. */
  52885. readonly rgb: NodeMaterialConnectionPoint;
  52886. /**
  52887. * Gets the r output component
  52888. */
  52889. readonly r: NodeMaterialConnectionPoint;
  52890. /**
  52891. * Gets the g output component
  52892. */
  52893. readonly g: NodeMaterialConnectionPoint;
  52894. /**
  52895. * Gets the b output component
  52896. */
  52897. readonly b: NodeMaterialConnectionPoint;
  52898. autoConfigure(material: NodeMaterial): void;
  52899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52900. isReady(): boolean;
  52901. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52902. private _injectVertexCode;
  52903. private _writeOutput;
  52904. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52905. serialize(): any;
  52906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52907. }
  52908. }
  52909. declare module BABYLON {
  52910. /**
  52911. * Interface used to configure the node material editor
  52912. */
  52913. export interface INodeMaterialEditorOptions {
  52914. /** Define the URl to load node editor script */
  52915. editorURL?: string;
  52916. }
  52917. /** @hidden */
  52918. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52919. /** BONES */
  52920. NUM_BONE_INFLUENCERS: number;
  52921. BonesPerMesh: number;
  52922. BONETEXTURE: boolean;
  52923. /** MORPH TARGETS */
  52924. MORPHTARGETS: boolean;
  52925. MORPHTARGETS_NORMAL: boolean;
  52926. MORPHTARGETS_TANGENT: boolean;
  52927. MORPHTARGETS_UV: boolean;
  52928. NUM_MORPH_INFLUENCERS: number;
  52929. /** IMAGE PROCESSING */
  52930. IMAGEPROCESSING: boolean;
  52931. VIGNETTE: boolean;
  52932. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52933. VIGNETTEBLENDMODEOPAQUE: boolean;
  52934. TONEMAPPING: boolean;
  52935. TONEMAPPING_ACES: boolean;
  52936. CONTRAST: boolean;
  52937. EXPOSURE: boolean;
  52938. COLORCURVES: boolean;
  52939. COLORGRADING: boolean;
  52940. COLORGRADING3D: boolean;
  52941. SAMPLER3DGREENDEPTH: boolean;
  52942. SAMPLER3DBGRMAP: boolean;
  52943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52944. /** MISC. */
  52945. BUMPDIRECTUV: number;
  52946. constructor();
  52947. setValue(name: string, value: boolean): void;
  52948. }
  52949. /**
  52950. * Class used to configure NodeMaterial
  52951. */
  52952. export interface INodeMaterialOptions {
  52953. /**
  52954. * Defines if blocks should emit comments
  52955. */
  52956. emitComments: boolean;
  52957. }
  52958. /**
  52959. * Class used to create a node based material built by assembling shader blocks
  52960. */
  52961. export class NodeMaterial extends PushMaterial {
  52962. private static _BuildIdGenerator;
  52963. private _options;
  52964. private _vertexCompilationState;
  52965. private _fragmentCompilationState;
  52966. private _sharedData;
  52967. private _buildId;
  52968. private _buildWasSuccessful;
  52969. private _cachedWorldViewMatrix;
  52970. private _cachedWorldViewProjectionMatrix;
  52971. private _optimizers;
  52972. private _animationFrame;
  52973. /** Define the URl to load node editor script */
  52974. static EditorURL: string;
  52975. private BJSNODEMATERIALEDITOR;
  52976. /** Get the inspector from bundle or global */
  52977. private _getGlobalNodeMaterialEditor;
  52978. /**
  52979. * 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)
  52980. */
  52981. ignoreAlpha: boolean;
  52982. /**
  52983. * Defines the maximum number of lights that can be used in the material
  52984. */
  52985. maxSimultaneousLights: number;
  52986. /**
  52987. * Observable raised when the material is built
  52988. */
  52989. onBuildObservable: Observable<NodeMaterial>;
  52990. /**
  52991. * Gets or sets the root nodes of the material vertex shader
  52992. */
  52993. _vertexOutputNodes: NodeMaterialBlock[];
  52994. /**
  52995. * Gets or sets the root nodes of the material fragment (pixel) shader
  52996. */
  52997. _fragmentOutputNodes: NodeMaterialBlock[];
  52998. /** Gets or sets options to control the node material overall behavior */
  52999. options: INodeMaterialOptions;
  53000. /**
  53001. * Default configuration related to image processing available in the standard Material.
  53002. */
  53003. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53004. /**
  53005. * Gets the image processing configuration used either in this material.
  53006. */
  53007. /**
  53008. * Sets the Default image processing configuration used either in the this material.
  53009. *
  53010. * If sets to null, the scene one is in use.
  53011. */
  53012. imageProcessingConfiguration: ImageProcessingConfiguration;
  53013. /**
  53014. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53015. */
  53016. attachedBlocks: NodeMaterialBlock[];
  53017. /**
  53018. * Create a new node based material
  53019. * @param name defines the material name
  53020. * @param scene defines the hosting scene
  53021. * @param options defines creation option
  53022. */
  53023. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53024. /**
  53025. * Gets the current class name of the material e.g. "NodeMaterial"
  53026. * @returns the class name
  53027. */
  53028. getClassName(): string;
  53029. /**
  53030. * Keep track of the image processing observer to allow dispose and replace.
  53031. */
  53032. private _imageProcessingObserver;
  53033. /**
  53034. * Attaches a new image processing configuration to the Standard Material.
  53035. * @param configuration
  53036. */
  53037. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53038. /**
  53039. * Get a block by its name
  53040. * @param name defines the name of the block to retrieve
  53041. * @returns the required block or null if not found
  53042. */
  53043. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53044. /**
  53045. * Get a block by its name
  53046. * @param predicate defines the predicate used to find the good candidate
  53047. * @returns the required block or null if not found
  53048. */
  53049. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53050. /**
  53051. * Get an input block by its name
  53052. * @param predicate defines the predicate used to find the good candidate
  53053. * @returns the required input block or null if not found
  53054. */
  53055. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53056. /**
  53057. * Gets the list of input blocks attached to this material
  53058. * @returns an array of InputBlocks
  53059. */
  53060. getInputBlocks(): InputBlock[];
  53061. /**
  53062. * Adds a new optimizer to the list of optimizers
  53063. * @param optimizer defines the optimizers to add
  53064. * @returns the current material
  53065. */
  53066. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53067. /**
  53068. * Remove an optimizer from the list of optimizers
  53069. * @param optimizer defines the optimizers to remove
  53070. * @returns the current material
  53071. */
  53072. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53073. /**
  53074. * Add a new block to the list of output nodes
  53075. * @param node defines the node to add
  53076. * @returns the current material
  53077. */
  53078. addOutputNode(node: NodeMaterialBlock): this;
  53079. /**
  53080. * Remove a block from the list of root nodes
  53081. * @param node defines the node to remove
  53082. * @returns the current material
  53083. */
  53084. removeOutputNode(node: NodeMaterialBlock): this;
  53085. private _addVertexOutputNode;
  53086. private _removeVertexOutputNode;
  53087. private _addFragmentOutputNode;
  53088. private _removeFragmentOutputNode;
  53089. /**
  53090. * Specifies if the material will require alpha blending
  53091. * @returns a boolean specifying if alpha blending is needed
  53092. */
  53093. needAlphaBlending(): boolean;
  53094. /**
  53095. * Specifies if this material should be rendered in alpha test mode
  53096. * @returns a boolean specifying if an alpha test is needed.
  53097. */
  53098. needAlphaTesting(): boolean;
  53099. private _initializeBlock;
  53100. private _resetDualBlocks;
  53101. /**
  53102. * Build the material and generates the inner effect
  53103. * @param verbose defines if the build should log activity
  53104. */
  53105. build(verbose?: boolean): void;
  53106. /**
  53107. * Runs an otpimization phase to try to improve the shader code
  53108. */
  53109. optimize(): void;
  53110. private _prepareDefinesForAttributes;
  53111. /**
  53112. * Get if the submesh is ready to be used and all its information available.
  53113. * Child classes can use it to update shaders
  53114. * @param mesh defines the mesh to check
  53115. * @param subMesh defines which submesh to check
  53116. * @param useInstances specifies that instances should be used
  53117. * @returns a boolean indicating that the submesh is ready or not
  53118. */
  53119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53120. /**
  53121. * Get a string representing the shaders built by the current node graph
  53122. */
  53123. readonly compiledShaders: string;
  53124. /**
  53125. * Binds the world matrix to the material
  53126. * @param world defines the world transformation matrix
  53127. */
  53128. bindOnlyWorldMatrix(world: Matrix): void;
  53129. /**
  53130. * Binds the submesh to this material by preparing the effect and shader to draw
  53131. * @param world defines the world transformation matrix
  53132. * @param mesh defines the mesh containing the submesh
  53133. * @param subMesh defines the submesh to bind the material to
  53134. */
  53135. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53136. /**
  53137. * Gets the active textures from the material
  53138. * @returns an array of textures
  53139. */
  53140. getActiveTextures(): BaseTexture[];
  53141. /**
  53142. * Gets the list of texture blocks
  53143. * @returns an array of texture blocks
  53144. */
  53145. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53146. /**
  53147. * Specifies if the material uses a texture
  53148. * @param texture defines the texture to check against the material
  53149. * @returns a boolean specifying if the material uses the texture
  53150. */
  53151. hasTexture(texture: BaseTexture): boolean;
  53152. /**
  53153. * Disposes the material
  53154. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53155. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53156. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53157. */
  53158. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53159. /** Creates the node editor window. */
  53160. private _createNodeEditor;
  53161. /**
  53162. * Launch the node material editor
  53163. * @param config Define the configuration of the editor
  53164. * @return a promise fulfilled when the node editor is visible
  53165. */
  53166. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53167. /**
  53168. * Clear the current material
  53169. */
  53170. clear(): void;
  53171. /**
  53172. * Clear the current material and set it to a default state
  53173. */
  53174. setToDefault(): void;
  53175. /**
  53176. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53177. * @param url defines the url to load from
  53178. * @returns a promise that will fullfil when the material is fully loaded
  53179. */
  53180. loadAsync(url: string): Promise<unknown>;
  53181. private _gatherBlocks;
  53182. /**
  53183. * Generate a string containing the code declaration required to create an equivalent of this material
  53184. * @returns a string
  53185. */
  53186. generateCode(): string;
  53187. /**
  53188. * Serializes this material in a JSON representation
  53189. * @returns the serialized material object
  53190. */
  53191. serialize(): any;
  53192. private _restoreConnections;
  53193. /**
  53194. * Clear the current graph and load a new one from a serialization object
  53195. * @param source defines the JSON representation of the material
  53196. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53197. */
  53198. loadFromSerialization(source: any, rootUrl?: string): void;
  53199. /**
  53200. * Creates a node material from parsed material data
  53201. * @param source defines the JSON representation of the material
  53202. * @param scene defines the hosting scene
  53203. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53204. * @returns a new node material
  53205. */
  53206. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53207. /**
  53208. * Creates a new node material set to default basic configuration
  53209. * @param name defines the name of the material
  53210. * @param scene defines the hosting scene
  53211. * @returns a new NodeMaterial
  53212. */
  53213. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53214. }
  53215. }
  53216. declare module BABYLON {
  53217. /**
  53218. * Block used to read a texture from a sampler
  53219. */
  53220. export class TextureBlock extends NodeMaterialBlock {
  53221. private _defineName;
  53222. private _linearDefineName;
  53223. private _samplerName;
  53224. private _transformedUVName;
  53225. private _textureTransformName;
  53226. private _textureInfoName;
  53227. private _mainUVName;
  53228. private _mainUVDefineName;
  53229. /**
  53230. * Gets or sets the texture associated with the node
  53231. */
  53232. texture: Nullable<Texture>;
  53233. /**
  53234. * Create a new TextureBlock
  53235. * @param name defines the block name
  53236. */
  53237. constructor(name: string);
  53238. /**
  53239. * Gets the current class name
  53240. * @returns the class name
  53241. */
  53242. getClassName(): string;
  53243. /**
  53244. * Gets the uv input component
  53245. */
  53246. readonly uv: NodeMaterialConnectionPoint;
  53247. /**
  53248. * Gets the rgba output component
  53249. */
  53250. readonly rgba: NodeMaterialConnectionPoint;
  53251. /**
  53252. * Gets the rgb output component
  53253. */
  53254. readonly rgb: NodeMaterialConnectionPoint;
  53255. /**
  53256. * Gets the r output component
  53257. */
  53258. readonly r: NodeMaterialConnectionPoint;
  53259. /**
  53260. * Gets the g output component
  53261. */
  53262. readonly g: NodeMaterialConnectionPoint;
  53263. /**
  53264. * Gets the b output component
  53265. */
  53266. readonly b: NodeMaterialConnectionPoint;
  53267. /**
  53268. * Gets the a output component
  53269. */
  53270. readonly a: NodeMaterialConnectionPoint;
  53271. readonly target: NodeMaterialBlockTargets;
  53272. autoConfigure(material: NodeMaterial): void;
  53273. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53274. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53275. isReady(): boolean;
  53276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53277. private readonly _isMixed;
  53278. private _injectVertexCode;
  53279. private _writeOutput;
  53280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53281. protected _dumpPropertiesCode(): string;
  53282. serialize(): any;
  53283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53284. }
  53285. }
  53286. declare module BABYLON {
  53287. /**
  53288. * Class used to store shared data between 2 NodeMaterialBuildState
  53289. */
  53290. export class NodeMaterialBuildStateSharedData {
  53291. /**
  53292. * Gets the list of emitted varyings
  53293. */
  53294. temps: string[];
  53295. /**
  53296. * Gets the list of emitted varyings
  53297. */
  53298. varyings: string[];
  53299. /**
  53300. * Gets the varying declaration string
  53301. */
  53302. varyingDeclaration: string;
  53303. /**
  53304. * Input blocks
  53305. */
  53306. inputBlocks: InputBlock[];
  53307. /**
  53308. * Input blocks
  53309. */
  53310. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53311. /**
  53312. * Bindable blocks (Blocks that need to set data to the effect)
  53313. */
  53314. bindableBlocks: NodeMaterialBlock[];
  53315. /**
  53316. * List of blocks that can provide a compilation fallback
  53317. */
  53318. blocksWithFallbacks: NodeMaterialBlock[];
  53319. /**
  53320. * List of blocks that can provide a define update
  53321. */
  53322. blocksWithDefines: NodeMaterialBlock[];
  53323. /**
  53324. * List of blocks that can provide a repeatable content
  53325. */
  53326. repeatableContentBlocks: NodeMaterialBlock[];
  53327. /**
  53328. * List of blocks that can provide a dynamic list of uniforms
  53329. */
  53330. dynamicUniformBlocks: NodeMaterialBlock[];
  53331. /**
  53332. * List of blocks that can block the isReady function for the material
  53333. */
  53334. blockingBlocks: NodeMaterialBlock[];
  53335. /**
  53336. * Gets the list of animated inputs
  53337. */
  53338. animatedInputs: InputBlock[];
  53339. /**
  53340. * Build Id used to avoid multiple recompilations
  53341. */
  53342. buildId: number;
  53343. /** List of emitted variables */
  53344. variableNames: {
  53345. [key: string]: number;
  53346. };
  53347. /** List of emitted defines */
  53348. defineNames: {
  53349. [key: string]: number;
  53350. };
  53351. /** Should emit comments? */
  53352. emitComments: boolean;
  53353. /** Emit build activity */
  53354. verbose: boolean;
  53355. /** Gets or sets the hosting scene */
  53356. scene: Scene;
  53357. /**
  53358. * Gets the compilation hints emitted at compilation time
  53359. */
  53360. hints: {
  53361. needWorldViewMatrix: boolean;
  53362. needWorldViewProjectionMatrix: boolean;
  53363. needAlphaBlending: boolean;
  53364. needAlphaTesting: boolean;
  53365. };
  53366. /**
  53367. * List of compilation checks
  53368. */
  53369. checks: {
  53370. emitVertex: boolean;
  53371. emitFragment: boolean;
  53372. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53373. };
  53374. /** Creates a new shared data */
  53375. constructor();
  53376. /**
  53377. * Emits console errors and exceptions if there is a failing check
  53378. */
  53379. emitErrors(): void;
  53380. }
  53381. }
  53382. declare module BABYLON {
  53383. /**
  53384. * Class used to store node based material build state
  53385. */
  53386. export class NodeMaterialBuildState {
  53387. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53388. supportUniformBuffers: boolean;
  53389. /**
  53390. * Gets the list of emitted attributes
  53391. */
  53392. attributes: string[];
  53393. /**
  53394. * Gets the list of emitted uniforms
  53395. */
  53396. uniforms: string[];
  53397. /**
  53398. * Gets the list of emitted constants
  53399. */
  53400. constants: string[];
  53401. /**
  53402. * Gets the list of emitted samplers
  53403. */
  53404. samplers: string[];
  53405. /**
  53406. * Gets the list of emitted functions
  53407. */
  53408. functions: {
  53409. [key: string]: string;
  53410. };
  53411. /**
  53412. * Gets the list of emitted extensions
  53413. */
  53414. extensions: {
  53415. [key: string]: string;
  53416. };
  53417. /**
  53418. * Gets the target of the compilation state
  53419. */
  53420. target: NodeMaterialBlockTargets;
  53421. /**
  53422. * Gets the list of emitted counters
  53423. */
  53424. counters: {
  53425. [key: string]: number;
  53426. };
  53427. /**
  53428. * Shared data between multiple NodeMaterialBuildState instances
  53429. */
  53430. sharedData: NodeMaterialBuildStateSharedData;
  53431. /** @hidden */
  53432. _vertexState: NodeMaterialBuildState;
  53433. /** @hidden */
  53434. _attributeDeclaration: string;
  53435. /** @hidden */
  53436. _uniformDeclaration: string;
  53437. /** @hidden */
  53438. _constantDeclaration: string;
  53439. /** @hidden */
  53440. _samplerDeclaration: string;
  53441. /** @hidden */
  53442. _varyingTransfer: string;
  53443. private _repeatableContentAnchorIndex;
  53444. /** @hidden */
  53445. _builtCompilationString: string;
  53446. /**
  53447. * Gets the emitted compilation strings
  53448. */
  53449. compilationString: string;
  53450. /**
  53451. * Finalize the compilation strings
  53452. * @param state defines the current compilation state
  53453. */
  53454. finalize(state: NodeMaterialBuildState): void;
  53455. /** @hidden */
  53456. readonly _repeatableContentAnchor: string;
  53457. /** @hidden */
  53458. _getFreeVariableName(prefix: string): string;
  53459. /** @hidden */
  53460. _getFreeDefineName(prefix: string): string;
  53461. /** @hidden */
  53462. _excludeVariableName(name: string): void;
  53463. /** @hidden */
  53464. _emit2DSampler(name: string): void;
  53465. /** @hidden */
  53466. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53467. /** @hidden */
  53468. _emitExtension(name: string, extension: string): void;
  53469. /** @hidden */
  53470. _emitFunction(name: string, code: string, comments: string): void;
  53471. /** @hidden */
  53472. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53473. replaceStrings?: {
  53474. search: RegExp;
  53475. replace: string;
  53476. }[];
  53477. repeatKey?: string;
  53478. }): string;
  53479. /** @hidden */
  53480. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53481. repeatKey?: string;
  53482. removeAttributes?: boolean;
  53483. removeUniforms?: boolean;
  53484. removeVaryings?: boolean;
  53485. removeIfDef?: boolean;
  53486. replaceStrings?: {
  53487. search: RegExp;
  53488. replace: string;
  53489. }[];
  53490. }, storeKey?: string): void;
  53491. /** @hidden */
  53492. _registerTempVariable(name: string): boolean;
  53493. /** @hidden */
  53494. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53495. /** @hidden */
  53496. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53497. /** @hidden */
  53498. _emitFloat(value: number): string;
  53499. }
  53500. }
  53501. declare module BABYLON {
  53502. /**
  53503. * Defines a block that can be used inside a node based material
  53504. */
  53505. export class NodeMaterialBlock {
  53506. private _buildId;
  53507. private _buildTarget;
  53508. private _target;
  53509. private _isFinalMerger;
  53510. private _isInput;
  53511. /** @hidden */
  53512. _codeVariableName: string;
  53513. /** @hidden */
  53514. _inputs: NodeMaterialConnectionPoint[];
  53515. /** @hidden */
  53516. _outputs: NodeMaterialConnectionPoint[];
  53517. /** @hidden */
  53518. _preparationId: number;
  53519. /**
  53520. * Gets or sets the name of the block
  53521. */
  53522. name: string;
  53523. /**
  53524. * Gets or sets the unique id of the node
  53525. */
  53526. uniqueId: number;
  53527. /**
  53528. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53529. */
  53530. readonly isFinalMerger: boolean;
  53531. /**
  53532. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53533. */
  53534. readonly isInput: boolean;
  53535. /**
  53536. * Gets or sets the build Id
  53537. */
  53538. buildId: number;
  53539. /**
  53540. * Gets or sets the target of the block
  53541. */
  53542. target: NodeMaterialBlockTargets;
  53543. /**
  53544. * Gets the list of input points
  53545. */
  53546. readonly inputs: NodeMaterialConnectionPoint[];
  53547. /** Gets the list of output points */
  53548. readonly outputs: NodeMaterialConnectionPoint[];
  53549. /**
  53550. * Find an input by its name
  53551. * @param name defines the name of the input to look for
  53552. * @returns the input or null if not found
  53553. */
  53554. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53555. /**
  53556. * Find an output by its name
  53557. * @param name defines the name of the outputto look for
  53558. * @returns the output or null if not found
  53559. */
  53560. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53561. /**
  53562. * Creates a new NodeMaterialBlock
  53563. * @param name defines the block name
  53564. * @param target defines the target of that block (Vertex by default)
  53565. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53566. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53567. */
  53568. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53569. /**
  53570. * Initialize the block and prepare the context for build
  53571. * @param state defines the state that will be used for the build
  53572. */
  53573. initialize(state: NodeMaterialBuildState): void;
  53574. /**
  53575. * Bind data to effect. Will only be called for blocks with isBindable === true
  53576. * @param effect defines the effect to bind data to
  53577. * @param nodeMaterial defines the hosting NodeMaterial
  53578. * @param mesh defines the mesh that will be rendered
  53579. */
  53580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53581. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53582. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53583. protected _writeFloat(value: number): string;
  53584. /**
  53585. * Gets the current class name e.g. "NodeMaterialBlock"
  53586. * @returns the class name
  53587. */
  53588. getClassName(): string;
  53589. /**
  53590. * Register a new input. Must be called inside a block constructor
  53591. * @param name defines the connection point name
  53592. * @param type defines the connection point type
  53593. * @param isOptional defines a boolean indicating that this input can be omitted
  53594. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53595. * @returns the current block
  53596. */
  53597. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53598. /**
  53599. * Register a new output. Must be called inside a block constructor
  53600. * @param name defines the connection point name
  53601. * @param type defines the connection point type
  53602. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53603. * @returns the current block
  53604. */
  53605. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53606. /**
  53607. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53608. * @param forOutput defines an optional connection point to check compatibility with
  53609. * @returns the first available input or null
  53610. */
  53611. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53612. /**
  53613. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53614. * @param forBlock defines an optional block to check compatibility with
  53615. * @returns the first available input or null
  53616. */
  53617. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53618. /**
  53619. * Gets the sibling of the given output
  53620. * @param current defines the current output
  53621. * @returns the next output in the list or null
  53622. */
  53623. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53624. /**
  53625. * Connect current block with another block
  53626. * @param other defines the block to connect with
  53627. * @param options define the various options to help pick the right connections
  53628. * @returns the current block
  53629. */
  53630. connectTo(other: NodeMaterialBlock, options?: {
  53631. input?: string;
  53632. output?: string;
  53633. outputSwizzle?: string;
  53634. }): this | undefined;
  53635. protected _buildBlock(state: NodeMaterialBuildState): void;
  53636. /**
  53637. * Add uniforms, samplers and uniform buffers at compilation time
  53638. * @param state defines the state to update
  53639. * @param nodeMaterial defines the node material requesting the update
  53640. * @param defines defines the material defines to update
  53641. * @param uniformBuffers defines the list of uniform buffer names
  53642. */
  53643. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53644. /**
  53645. * Add potential fallbacks if shader compilation fails
  53646. * @param mesh defines the mesh to be rendered
  53647. * @param fallbacks defines the current prioritized list of fallbacks
  53648. */
  53649. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53650. /**
  53651. * Initialize defines for shader compilation
  53652. * @param mesh defines the mesh to be rendered
  53653. * @param nodeMaterial defines the node material requesting the update
  53654. * @param defines defines the material defines to update
  53655. * @param useInstances specifies that instances should be used
  53656. */
  53657. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53658. /**
  53659. * Update defines for shader compilation
  53660. * @param mesh defines the mesh to be rendered
  53661. * @param nodeMaterial defines the node material requesting the update
  53662. * @param defines defines the material defines to update
  53663. * @param useInstances specifies that instances should be used
  53664. */
  53665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53666. /**
  53667. * Lets the block try to connect some inputs automatically
  53668. * @param material defines the hosting NodeMaterial
  53669. */
  53670. autoConfigure(material: NodeMaterial): void;
  53671. /**
  53672. * Function called when a block is declared as repeatable content generator
  53673. * @param vertexShaderState defines the current compilation state for the vertex shader
  53674. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53675. * @param mesh defines the mesh to be rendered
  53676. * @param defines defines the material defines to update
  53677. */
  53678. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53679. /**
  53680. * Checks if the block is ready
  53681. * @param mesh defines the mesh to be rendered
  53682. * @param nodeMaterial defines the node material requesting the update
  53683. * @param defines defines the material defines to update
  53684. * @param useInstances specifies that instances should be used
  53685. * @returns true if the block is ready
  53686. */
  53687. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53688. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53689. private _processBuild;
  53690. /**
  53691. * Compile the current node and generate the shader code
  53692. * @param state defines the current compilation state (uniforms, samplers, current string)
  53693. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53694. * @returns true if already built
  53695. */
  53696. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53697. protected _inputRename(name: string): string;
  53698. protected _outputRename(name: string): string;
  53699. protected _dumpPropertiesCode(): string;
  53700. /** @hidden */
  53701. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53702. /**
  53703. * Clone the current block to a new identical block
  53704. * @param scene defines the hosting scene
  53705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53706. * @returns a copy of the current block
  53707. */
  53708. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53709. /**
  53710. * Serializes this block in a JSON representation
  53711. * @returns the serialized block object
  53712. */
  53713. serialize(): any;
  53714. /** @hidden */
  53715. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53716. }
  53717. }
  53718. declare module BABYLON {
  53719. /**
  53720. * Enum defining the type of animations supported by InputBlock
  53721. */
  53722. export enum AnimatedInputBlockTypes {
  53723. /** No animation */
  53724. None = 0,
  53725. /** Time based animation. Will only work for floats */
  53726. Time = 1
  53727. }
  53728. }
  53729. declare module BABYLON {
  53730. /**
  53731. * Block used to expose an input value
  53732. */
  53733. export class InputBlock extends NodeMaterialBlock {
  53734. private _mode;
  53735. private _associatedVariableName;
  53736. private _storedValue;
  53737. private _valueCallback;
  53738. private _type;
  53739. private _animationType;
  53740. /** Gets or set a value used to limit the range of float values */
  53741. min: number;
  53742. /** Gets or set a value used to limit the range of float values */
  53743. max: number;
  53744. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53745. matrixMode: number;
  53746. /** @hidden */
  53747. _systemValue: Nullable<NodeMaterialSystemValues>;
  53748. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53749. visibleInInspector: boolean;
  53750. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53751. isConstant: boolean;
  53752. /**
  53753. * Gets or sets the connection point type (default is float)
  53754. */
  53755. readonly type: NodeMaterialBlockConnectionPointTypes;
  53756. /**
  53757. * Creates a new InputBlock
  53758. * @param name defines the block name
  53759. * @param target defines the target of that block (Vertex by default)
  53760. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53761. */
  53762. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53763. /**
  53764. * Gets the output component
  53765. */
  53766. readonly output: NodeMaterialConnectionPoint;
  53767. /**
  53768. * Set the source of this connection point to a vertex attribute
  53769. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53770. * @returns the current connection point
  53771. */
  53772. setAsAttribute(attributeName?: string): InputBlock;
  53773. /**
  53774. * Set the source of this connection point to a system value
  53775. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53776. * @returns the current connection point
  53777. */
  53778. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53779. /**
  53780. * Gets or sets the value of that point.
  53781. * Please note that this value will be ignored if valueCallback is defined
  53782. */
  53783. value: any;
  53784. /**
  53785. * Gets or sets a callback used to get the value of that point.
  53786. * Please note that setting this value will force the connection point to ignore the value property
  53787. */
  53788. valueCallback: () => any;
  53789. /**
  53790. * Gets or sets the associated variable name in the shader
  53791. */
  53792. associatedVariableName: string;
  53793. /** Gets or sets the type of animation applied to the input */
  53794. animationType: AnimatedInputBlockTypes;
  53795. /**
  53796. * Gets a boolean indicating that this connection point not defined yet
  53797. */
  53798. readonly isUndefined: boolean;
  53799. /**
  53800. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53801. * In this case the connection point name must be the name of the uniform to use.
  53802. * Can only be set on inputs
  53803. */
  53804. isUniform: boolean;
  53805. /**
  53806. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53807. * In this case the connection point name must be the name of the attribute to use
  53808. * Can only be set on inputs
  53809. */
  53810. isAttribute: boolean;
  53811. /**
  53812. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53813. * Can only be set on exit points
  53814. */
  53815. isVarying: boolean;
  53816. /**
  53817. * Gets a boolean indicating that the current connection point is a system value
  53818. */
  53819. readonly isSystemValue: boolean;
  53820. /**
  53821. * Gets or sets the current well known value or null if not defined as a system value
  53822. */
  53823. systemValue: Nullable<NodeMaterialSystemValues>;
  53824. /**
  53825. * Gets the current class name
  53826. * @returns the class name
  53827. */
  53828. getClassName(): string;
  53829. /**
  53830. * Animate the input if animationType !== None
  53831. * @param scene defines the rendering scene
  53832. */
  53833. animate(scene: Scene): void;
  53834. private _emitDefine;
  53835. initialize(state: NodeMaterialBuildState): void;
  53836. /**
  53837. * Set the input block to its default value (based on its type)
  53838. */
  53839. setDefaultValue(): void;
  53840. private _emitConstant;
  53841. private _emit;
  53842. /** @hidden */
  53843. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53844. /** @hidden */
  53845. _transmit(effect: Effect, scene: Scene): void;
  53846. protected _buildBlock(state: NodeMaterialBuildState): void;
  53847. protected _dumpPropertiesCode(): string;
  53848. serialize(): any;
  53849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53850. }
  53851. }
  53852. declare module BABYLON {
  53853. /**
  53854. * Defines a connection point for a block
  53855. */
  53856. export class NodeMaterialConnectionPoint {
  53857. /** @hidden */
  53858. _ownerBlock: NodeMaterialBlock;
  53859. /** @hidden */
  53860. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53861. private _endpoints;
  53862. private _associatedVariableName;
  53863. /** @hidden */
  53864. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53865. /** @hidden */
  53866. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53867. private _type;
  53868. /** @hidden */
  53869. _enforceAssociatedVariableName: boolean;
  53870. /**
  53871. * Gets or sets the additional types supported by this connection point
  53872. */
  53873. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53874. /**
  53875. * Gets or sets the additional types excluded by this connection point
  53876. */
  53877. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53878. /**
  53879. * Gets or sets the associated variable name in the shader
  53880. */
  53881. associatedVariableName: string;
  53882. /**
  53883. * Gets or sets the connection point type (default is float)
  53884. */
  53885. type: NodeMaterialBlockConnectionPointTypes;
  53886. /**
  53887. * Gets or sets the connection point name
  53888. */
  53889. name: string;
  53890. /**
  53891. * Gets or sets a boolean indicating that this connection point can be omitted
  53892. */
  53893. isOptional: boolean;
  53894. /**
  53895. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53896. */
  53897. define: string;
  53898. /** Gets or sets the target of that connection point */
  53899. target: NodeMaterialBlockTargets;
  53900. /**
  53901. * Gets a boolean indicating that the current point is connected
  53902. */
  53903. readonly isConnected: boolean;
  53904. /**
  53905. * Gets a boolean indicating that the current point is connected to an input block
  53906. */
  53907. readonly isConnectedToInputBlock: boolean;
  53908. /**
  53909. * Gets a the connected input block (if any)
  53910. */
  53911. readonly connectInputBlock: Nullable<InputBlock>;
  53912. /** Get the other side of the connection (if any) */
  53913. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53914. /** Get the block that owns this connection point */
  53915. readonly ownerBlock: NodeMaterialBlock;
  53916. /** Get the block connected on the other side of this connection (if any) */
  53917. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53918. /** Get the block connected on the endpoints of this connection (if any) */
  53919. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53920. /** Gets the list of connected endpoints */
  53921. readonly endpoints: NodeMaterialConnectionPoint[];
  53922. /** Gets a boolean indicating if that output point is connected to at least one input */
  53923. readonly hasEndpoints: boolean;
  53924. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  53925. readonly isConnectedInVertexShader: boolean;
  53926. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  53927. readonly isConnectedInFragmentShader: boolean;
  53928. /**
  53929. * Creates a new connection point
  53930. * @param name defines the connection point name
  53931. * @param ownerBlock defines the block hosting this connection point
  53932. */
  53933. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53934. /**
  53935. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53936. * @returns the class name
  53937. */
  53938. getClassName(): string;
  53939. /**
  53940. * Gets an boolean indicating if the current point can be connected to another point
  53941. * @param connectionPoint defines the other connection point
  53942. * @returns true if the connection is possible
  53943. */
  53944. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53945. /**
  53946. * Connect this point to another connection point
  53947. * @param connectionPoint defines the other connection point
  53948. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53949. * @returns the current connection point
  53950. */
  53951. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53952. /**
  53953. * Disconnect this point from one of his endpoint
  53954. * @param endpoint defines the other connection point
  53955. * @returns the current connection point
  53956. */
  53957. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53958. /**
  53959. * Serializes this point in a JSON representation
  53960. * @returns the serialized point object
  53961. */
  53962. serialize(): any;
  53963. }
  53964. }
  53965. declare module BABYLON {
  53966. /**
  53967. * Block used to add support for vertex skinning (bones)
  53968. */
  53969. export class BonesBlock extends NodeMaterialBlock {
  53970. /**
  53971. * Creates a new BonesBlock
  53972. * @param name defines the block name
  53973. */
  53974. constructor(name: string);
  53975. /**
  53976. * Initialize the block and prepare the context for build
  53977. * @param state defines the state that will be used for the build
  53978. */
  53979. initialize(state: NodeMaterialBuildState): void;
  53980. /**
  53981. * Gets the current class name
  53982. * @returns the class name
  53983. */
  53984. getClassName(): string;
  53985. /**
  53986. * Gets the matrix indices input component
  53987. */
  53988. readonly matricesIndices: NodeMaterialConnectionPoint;
  53989. /**
  53990. * Gets the matrix weights input component
  53991. */
  53992. readonly matricesWeights: NodeMaterialConnectionPoint;
  53993. /**
  53994. * Gets the extra matrix indices input component
  53995. */
  53996. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53997. /**
  53998. * Gets the extra matrix weights input component
  53999. */
  54000. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54001. /**
  54002. * Gets the world input component
  54003. */
  54004. readonly world: NodeMaterialConnectionPoint;
  54005. /**
  54006. * Gets the output component
  54007. */
  54008. readonly output: NodeMaterialConnectionPoint;
  54009. autoConfigure(material: NodeMaterial): void;
  54010. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54013. protected _buildBlock(state: NodeMaterialBuildState): this;
  54014. }
  54015. }
  54016. declare module BABYLON {
  54017. /**
  54018. * Block used to add support for instances
  54019. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54020. */
  54021. export class InstancesBlock extends NodeMaterialBlock {
  54022. /**
  54023. * Creates a new InstancesBlock
  54024. * @param name defines the block name
  54025. */
  54026. constructor(name: string);
  54027. /**
  54028. * Gets the current class name
  54029. * @returns the class name
  54030. */
  54031. getClassName(): string;
  54032. /**
  54033. * Gets the first world row input component
  54034. */
  54035. readonly world0: NodeMaterialConnectionPoint;
  54036. /**
  54037. * Gets the second world row input component
  54038. */
  54039. readonly world1: NodeMaterialConnectionPoint;
  54040. /**
  54041. * Gets the third world row input component
  54042. */
  54043. readonly world2: NodeMaterialConnectionPoint;
  54044. /**
  54045. * Gets the forth world row input component
  54046. */
  54047. readonly world3: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the world input component
  54050. */
  54051. readonly world: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the output component
  54054. */
  54055. readonly output: NodeMaterialConnectionPoint;
  54056. autoConfigure(material: NodeMaterial): void;
  54057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54058. protected _buildBlock(state: NodeMaterialBuildState): this;
  54059. }
  54060. }
  54061. declare module BABYLON {
  54062. /**
  54063. * Block used to add morph targets support to vertex shader
  54064. */
  54065. export class MorphTargetsBlock extends NodeMaterialBlock {
  54066. private _repeatableContentAnchor;
  54067. private _repeatebleContentGenerated;
  54068. /**
  54069. * Create a new MorphTargetsBlock
  54070. * @param name defines the block name
  54071. */
  54072. constructor(name: string);
  54073. /**
  54074. * Gets the current class name
  54075. * @returns the class name
  54076. */
  54077. getClassName(): string;
  54078. /**
  54079. * Gets the position input component
  54080. */
  54081. readonly position: NodeMaterialConnectionPoint;
  54082. /**
  54083. * Gets the normal input component
  54084. */
  54085. readonly normal: NodeMaterialConnectionPoint;
  54086. /**
  54087. * Gets the tangent input component
  54088. */
  54089. readonly tangent: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the tangent input component
  54092. */
  54093. readonly uv: NodeMaterialConnectionPoint;
  54094. /**
  54095. * Gets the position output component
  54096. */
  54097. readonly positionOutput: NodeMaterialConnectionPoint;
  54098. /**
  54099. * Gets the normal output component
  54100. */
  54101. readonly normalOutput: NodeMaterialConnectionPoint;
  54102. /**
  54103. * Gets the tangent output component
  54104. */
  54105. readonly tangentOutput: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Gets the tangent output component
  54108. */
  54109. readonly uvOutput: NodeMaterialConnectionPoint;
  54110. initialize(state: NodeMaterialBuildState): void;
  54111. autoConfigure(material: NodeMaterial): void;
  54112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54114. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54115. protected _buildBlock(state: NodeMaterialBuildState): this;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. /**
  54120. * Block used to get data information from a light
  54121. */
  54122. export class LightInformationBlock extends NodeMaterialBlock {
  54123. private _lightDataUniformName;
  54124. private _lightColorUniformName;
  54125. private _lightTypeDefineName;
  54126. /**
  54127. * Gets or sets the light associated with this block
  54128. */
  54129. light: Nullable<Light>;
  54130. /**
  54131. * Creates a new LightInformationBlock
  54132. * @param name defines the block name
  54133. */
  54134. constructor(name: string);
  54135. /**
  54136. * Gets the current class name
  54137. * @returns the class name
  54138. */
  54139. getClassName(): string;
  54140. /**
  54141. * Gets the world position input component
  54142. */
  54143. readonly worldPosition: NodeMaterialConnectionPoint;
  54144. /**
  54145. * Gets the direction output component
  54146. */
  54147. readonly direction: NodeMaterialConnectionPoint;
  54148. /**
  54149. * Gets the direction output component
  54150. */
  54151. readonly color: NodeMaterialConnectionPoint;
  54152. /**
  54153. * Gets the direction output component
  54154. */
  54155. readonly intensity: NodeMaterialConnectionPoint;
  54156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54158. protected _buildBlock(state: NodeMaterialBuildState): this;
  54159. serialize(): any;
  54160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54161. }
  54162. }
  54163. declare module BABYLON {
  54164. /**
  54165. * Block used to add image processing support to fragment shader
  54166. */
  54167. export class ImageProcessingBlock extends NodeMaterialBlock {
  54168. /**
  54169. * Create a new ImageProcessingBlock
  54170. * @param name defines the block name
  54171. */
  54172. constructor(name: string);
  54173. /**
  54174. * Gets the current class name
  54175. * @returns the class name
  54176. */
  54177. getClassName(): string;
  54178. /**
  54179. * Gets the color input component
  54180. */
  54181. readonly color: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the output component
  54184. */
  54185. readonly output: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Initialize the block and prepare the context for build
  54188. * @param state defines the state that will be used for the build
  54189. */
  54190. initialize(state: NodeMaterialBuildState): void;
  54191. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54194. protected _buildBlock(state: NodeMaterialBuildState): this;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * Block used to pertub normals based on a normal map
  54200. */
  54201. export class PerturbNormalBlock extends NodeMaterialBlock {
  54202. private _tangentSpaceParameterName;
  54203. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54204. invertX: boolean;
  54205. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54206. invertY: boolean;
  54207. /**
  54208. * Create a new PerturbNormalBlock
  54209. * @param name defines the block name
  54210. */
  54211. constructor(name: string);
  54212. /**
  54213. * Gets the current class name
  54214. * @returns the class name
  54215. */
  54216. getClassName(): string;
  54217. /**
  54218. * Gets the world position input component
  54219. */
  54220. readonly worldPosition: NodeMaterialConnectionPoint;
  54221. /**
  54222. * Gets the world normal input component
  54223. */
  54224. readonly worldNormal: NodeMaterialConnectionPoint;
  54225. /**
  54226. * Gets the uv input component
  54227. */
  54228. readonly uv: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the normal map color input component
  54231. */
  54232. readonly normalMapColor: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the strength input component
  54235. */
  54236. readonly strength: NodeMaterialConnectionPoint;
  54237. /**
  54238. * Gets the output component
  54239. */
  54240. readonly output: NodeMaterialConnectionPoint;
  54241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54243. autoConfigure(material: NodeMaterial): void;
  54244. protected _buildBlock(state: NodeMaterialBuildState): this;
  54245. protected _dumpPropertiesCode(): string;
  54246. serialize(): any;
  54247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54248. }
  54249. }
  54250. declare module BABYLON {
  54251. /**
  54252. * Block used to discard a pixel if a value is smaller than a cutoff
  54253. */
  54254. export class DiscardBlock extends NodeMaterialBlock {
  54255. /**
  54256. * Create a new DiscardBlock
  54257. * @param name defines the block name
  54258. */
  54259. constructor(name: string);
  54260. /**
  54261. * Gets the current class name
  54262. * @returns the class name
  54263. */
  54264. getClassName(): string;
  54265. /**
  54266. * Gets the color input component
  54267. */
  54268. readonly value: NodeMaterialConnectionPoint;
  54269. /**
  54270. * Gets the cutoff input component
  54271. */
  54272. readonly cutoff: NodeMaterialConnectionPoint;
  54273. protected _buildBlock(state: NodeMaterialBuildState): this;
  54274. }
  54275. }
  54276. declare module BABYLON {
  54277. /**
  54278. * Block used to add support for scene fog
  54279. */
  54280. export class FogBlock extends NodeMaterialBlock {
  54281. private _fogDistanceName;
  54282. private _fogParameters;
  54283. /**
  54284. * Create a new FogBlock
  54285. * @param name defines the block name
  54286. */
  54287. constructor(name: string);
  54288. /**
  54289. * Gets the current class name
  54290. * @returns the class name
  54291. */
  54292. getClassName(): string;
  54293. /**
  54294. * Gets the world position input component
  54295. */
  54296. readonly worldPosition: NodeMaterialConnectionPoint;
  54297. /**
  54298. * Gets the view input component
  54299. */
  54300. readonly view: NodeMaterialConnectionPoint;
  54301. /**
  54302. * Gets the color input component
  54303. */
  54304. readonly input: NodeMaterialConnectionPoint;
  54305. /**
  54306. * Gets the fog color input component
  54307. */
  54308. readonly fogColor: NodeMaterialConnectionPoint;
  54309. /**
  54310. * Gets the output component
  54311. */
  54312. readonly output: NodeMaterialConnectionPoint;
  54313. autoConfigure(material: NodeMaterial): void;
  54314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54316. protected _buildBlock(state: NodeMaterialBuildState): this;
  54317. }
  54318. }
  54319. declare module BABYLON {
  54320. /**
  54321. * Block used to add light in the fragment shader
  54322. */
  54323. export class LightBlock extends NodeMaterialBlock {
  54324. private _lightId;
  54325. /**
  54326. * Gets or sets the light associated with this block
  54327. */
  54328. light: Nullable<Light>;
  54329. /**
  54330. * Create a new LightBlock
  54331. * @param name defines the block name
  54332. */
  54333. constructor(name: string);
  54334. /**
  54335. * Gets the current class name
  54336. * @returns the class name
  54337. */
  54338. getClassName(): string;
  54339. /**
  54340. * Gets the world position input component
  54341. */
  54342. readonly worldPosition: NodeMaterialConnectionPoint;
  54343. /**
  54344. * Gets the world normal input component
  54345. */
  54346. readonly worldNormal: NodeMaterialConnectionPoint;
  54347. /**
  54348. * Gets the camera (or eye) position component
  54349. */
  54350. readonly cameraPosition: NodeMaterialConnectionPoint;
  54351. /**
  54352. * Gets the glossiness component
  54353. */
  54354. readonly glossiness: NodeMaterialConnectionPoint;
  54355. /**
  54356. * Gets the glossinness power component
  54357. */
  54358. readonly glossPower: NodeMaterialConnectionPoint;
  54359. /**
  54360. * Gets the diffuse color component
  54361. */
  54362. readonly diffuseColor: NodeMaterialConnectionPoint;
  54363. /**
  54364. * Gets the specular color component
  54365. */
  54366. readonly specularColor: NodeMaterialConnectionPoint;
  54367. /**
  54368. * Gets the diffuse output component
  54369. */
  54370. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54371. /**
  54372. * Gets the specular output component
  54373. */
  54374. readonly specularOutput: NodeMaterialConnectionPoint;
  54375. autoConfigure(material: NodeMaterial): void;
  54376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54377. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54379. private _injectVertexCode;
  54380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54381. serialize(): any;
  54382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /**
  54387. * Block used to multiply 2 values
  54388. */
  54389. export class MultiplyBlock extends NodeMaterialBlock {
  54390. /**
  54391. * Creates a new MultiplyBlock
  54392. * @param name defines the block name
  54393. */
  54394. constructor(name: string);
  54395. /**
  54396. * Gets the current class name
  54397. * @returns the class name
  54398. */
  54399. getClassName(): string;
  54400. /**
  54401. * Gets the left operand input component
  54402. */
  54403. readonly left: NodeMaterialConnectionPoint;
  54404. /**
  54405. * Gets the right operand input component
  54406. */
  54407. readonly right: NodeMaterialConnectionPoint;
  54408. /**
  54409. * Gets the output component
  54410. */
  54411. readonly output: NodeMaterialConnectionPoint;
  54412. protected _buildBlock(state: NodeMaterialBuildState): this;
  54413. }
  54414. }
  54415. declare module BABYLON {
  54416. /**
  54417. * Block used to add 2 vectors
  54418. */
  54419. export class AddBlock extends NodeMaterialBlock {
  54420. /**
  54421. * Creates a new AddBlock
  54422. * @param name defines the block name
  54423. */
  54424. constructor(name: string);
  54425. /**
  54426. * Gets the current class name
  54427. * @returns the class name
  54428. */
  54429. getClassName(): string;
  54430. /**
  54431. * Gets the left operand input component
  54432. */
  54433. readonly left: NodeMaterialConnectionPoint;
  54434. /**
  54435. * Gets the right operand input component
  54436. */
  54437. readonly right: NodeMaterialConnectionPoint;
  54438. /**
  54439. * Gets the output component
  54440. */
  54441. readonly output: NodeMaterialConnectionPoint;
  54442. protected _buildBlock(state: NodeMaterialBuildState): this;
  54443. }
  54444. }
  54445. declare module BABYLON {
  54446. /**
  54447. * Block used to scale a vector by a float
  54448. */
  54449. export class ScaleBlock extends NodeMaterialBlock {
  54450. /**
  54451. * Creates a new ScaleBlock
  54452. * @param name defines the block name
  54453. */
  54454. constructor(name: string);
  54455. /**
  54456. * Gets the current class name
  54457. * @returns the class name
  54458. */
  54459. getClassName(): string;
  54460. /**
  54461. * Gets the input component
  54462. */
  54463. readonly input: NodeMaterialConnectionPoint;
  54464. /**
  54465. * Gets the factor input component
  54466. */
  54467. readonly factor: NodeMaterialConnectionPoint;
  54468. /**
  54469. * Gets the output component
  54470. */
  54471. readonly output: NodeMaterialConnectionPoint;
  54472. protected _buildBlock(state: NodeMaterialBuildState): this;
  54473. }
  54474. }
  54475. declare module BABYLON {
  54476. /**
  54477. * Block used to clamp a float
  54478. */
  54479. export class ClampBlock extends NodeMaterialBlock {
  54480. /** Gets or sets the minimum range */
  54481. minimum: number;
  54482. /** Gets or sets the maximum range */
  54483. maximum: number;
  54484. /**
  54485. * Creates a new ClampBlock
  54486. * @param name defines the block name
  54487. */
  54488. constructor(name: string);
  54489. /**
  54490. * Gets the current class name
  54491. * @returns the class name
  54492. */
  54493. getClassName(): string;
  54494. /**
  54495. * Gets the value input component
  54496. */
  54497. readonly value: NodeMaterialConnectionPoint;
  54498. /**
  54499. * Gets the output component
  54500. */
  54501. readonly output: NodeMaterialConnectionPoint;
  54502. protected _buildBlock(state: NodeMaterialBuildState): this;
  54503. protected _dumpPropertiesCode(): string;
  54504. serialize(): any;
  54505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54506. }
  54507. }
  54508. declare module BABYLON {
  54509. /**
  54510. * Block used to apply a cross product between 2 vectors
  54511. */
  54512. export class CrossBlock extends NodeMaterialBlock {
  54513. /**
  54514. * Creates a new CrossBlock
  54515. * @param name defines the block name
  54516. */
  54517. constructor(name: string);
  54518. /**
  54519. * Gets the current class name
  54520. * @returns the class name
  54521. */
  54522. getClassName(): string;
  54523. /**
  54524. * Gets the left operand input component
  54525. */
  54526. readonly left: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the right operand input component
  54529. */
  54530. readonly right: NodeMaterialConnectionPoint;
  54531. /**
  54532. * Gets the output component
  54533. */
  54534. readonly output: NodeMaterialConnectionPoint;
  54535. protected _buildBlock(state: NodeMaterialBuildState): this;
  54536. }
  54537. }
  54538. declare module BABYLON {
  54539. /**
  54540. * Block used to apply a dot product between 2 vectors
  54541. */
  54542. export class DotBlock extends NodeMaterialBlock {
  54543. /**
  54544. * Creates a new DotBlock
  54545. * @param name defines the block name
  54546. */
  54547. constructor(name: string);
  54548. /**
  54549. * Gets the current class name
  54550. * @returns the class name
  54551. */
  54552. getClassName(): string;
  54553. /**
  54554. * Gets the left operand input component
  54555. */
  54556. readonly left: NodeMaterialConnectionPoint;
  54557. /**
  54558. * Gets the right operand input component
  54559. */
  54560. readonly right: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Gets the output component
  54563. */
  54564. readonly output: NodeMaterialConnectionPoint;
  54565. protected _buildBlock(state: NodeMaterialBuildState): this;
  54566. }
  54567. }
  54568. declare module BABYLON {
  54569. /**
  54570. * Block used to remap a float from a range to a new one
  54571. */
  54572. export class RemapBlock extends NodeMaterialBlock {
  54573. /**
  54574. * Gets or sets the source range
  54575. */
  54576. sourceRange: Vector2;
  54577. /**
  54578. * Gets or sets the target range
  54579. */
  54580. targetRange: Vector2;
  54581. /**
  54582. * Creates a new RemapBlock
  54583. * @param name defines the block name
  54584. */
  54585. constructor(name: string);
  54586. /**
  54587. * Gets the current class name
  54588. * @returns the class name
  54589. */
  54590. getClassName(): string;
  54591. /**
  54592. * Gets the input component
  54593. */
  54594. readonly input: NodeMaterialConnectionPoint;
  54595. /**
  54596. * Gets the source min input component
  54597. */
  54598. readonly sourceMin: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the source max input component
  54601. */
  54602. readonly sourceMax: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the target min input component
  54605. */
  54606. readonly targetMin: NodeMaterialConnectionPoint;
  54607. /**
  54608. * Gets the target max input component
  54609. */
  54610. readonly targetMax: NodeMaterialConnectionPoint;
  54611. /**
  54612. * Gets the output component
  54613. */
  54614. readonly output: NodeMaterialConnectionPoint;
  54615. protected _buildBlock(state: NodeMaterialBuildState): this;
  54616. protected _dumpPropertiesCode(): string;
  54617. serialize(): any;
  54618. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54619. }
  54620. }
  54621. declare module BABYLON {
  54622. /**
  54623. * Block used to normalize a vector
  54624. */
  54625. export class NormalizeBlock extends NodeMaterialBlock {
  54626. /**
  54627. * Creates a new NormalizeBlock
  54628. * @param name defines the block name
  54629. */
  54630. constructor(name: string);
  54631. /**
  54632. * Gets the current class name
  54633. * @returns the class name
  54634. */
  54635. getClassName(): string;
  54636. /**
  54637. * Gets the input component
  54638. */
  54639. readonly input: NodeMaterialConnectionPoint;
  54640. /**
  54641. * Gets the output component
  54642. */
  54643. readonly output: NodeMaterialConnectionPoint;
  54644. protected _buildBlock(state: NodeMaterialBuildState): this;
  54645. }
  54646. }
  54647. declare module BABYLON {
  54648. /**
  54649. * Operations supported by the Trigonometry block
  54650. */
  54651. export enum TrigonometryBlockOperations {
  54652. /** Cos */
  54653. Cos = 0,
  54654. /** Sin */
  54655. Sin = 1,
  54656. /** Abs */
  54657. Abs = 2,
  54658. /** Exp */
  54659. Exp = 3,
  54660. /** Exp2 */
  54661. Exp2 = 4,
  54662. /** Round */
  54663. Round = 5,
  54664. /** Floor */
  54665. Floor = 6,
  54666. /** Ceiling */
  54667. Ceiling = 7,
  54668. /** Square root */
  54669. Sqrt = 8,
  54670. /** Log */
  54671. Log = 9,
  54672. /** Tangent */
  54673. Tan = 10,
  54674. /** Arc tangent */
  54675. ArcTan = 11,
  54676. /** Arc cosinus */
  54677. ArcCos = 12,
  54678. /** Arc sinus */
  54679. ArcSin = 13,
  54680. /** Fraction */
  54681. Fract = 14,
  54682. /** Sign */
  54683. Sign = 15,
  54684. /** To radians (from degrees) */
  54685. Radians = 16,
  54686. /** To degrees (from radians) */
  54687. Degrees = 17
  54688. }
  54689. /**
  54690. * Block used to apply trigonometry operation to floats
  54691. */
  54692. export class TrigonometryBlock extends NodeMaterialBlock {
  54693. /**
  54694. * Gets or sets the operation applied by the block
  54695. */
  54696. operation: TrigonometryBlockOperations;
  54697. /**
  54698. * Creates a new TrigonometryBlock
  54699. * @param name defines the block name
  54700. */
  54701. constructor(name: string);
  54702. /**
  54703. * Gets the current class name
  54704. * @returns the class name
  54705. */
  54706. getClassName(): string;
  54707. /**
  54708. * Gets the input component
  54709. */
  54710. readonly input: NodeMaterialConnectionPoint;
  54711. /**
  54712. * Gets the output component
  54713. */
  54714. readonly output: NodeMaterialConnectionPoint;
  54715. protected _buildBlock(state: NodeMaterialBuildState): this;
  54716. serialize(): any;
  54717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54718. }
  54719. }
  54720. declare module BABYLON {
  54721. /**
  54722. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54723. */
  54724. export class ColorMergerBlock extends NodeMaterialBlock {
  54725. /**
  54726. * Create a new ColorMergerBlock
  54727. * @param name defines the block name
  54728. */
  54729. constructor(name: string);
  54730. /**
  54731. * Gets the current class name
  54732. * @returns the class name
  54733. */
  54734. getClassName(): string;
  54735. /**
  54736. * Gets the r component (input)
  54737. */
  54738. readonly r: NodeMaterialConnectionPoint;
  54739. /**
  54740. * Gets the g component (input)
  54741. */
  54742. readonly g: NodeMaterialConnectionPoint;
  54743. /**
  54744. * Gets the b component (input)
  54745. */
  54746. readonly b: NodeMaterialConnectionPoint;
  54747. /**
  54748. * Gets the a component (input)
  54749. */
  54750. readonly a: NodeMaterialConnectionPoint;
  54751. /**
  54752. * Gets the rgba component (output)
  54753. */
  54754. readonly rgba: NodeMaterialConnectionPoint;
  54755. /**
  54756. * Gets the rgb component (output)
  54757. */
  54758. readonly rgb: NodeMaterialConnectionPoint;
  54759. protected _buildBlock(state: NodeMaterialBuildState): this;
  54760. }
  54761. }
  54762. declare module BABYLON {
  54763. /**
  54764. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54765. */
  54766. export class VectorMergerBlock extends NodeMaterialBlock {
  54767. /**
  54768. * Create a new VectorMergerBlock
  54769. * @param name defines the block name
  54770. */
  54771. constructor(name: string);
  54772. /**
  54773. * Gets the current class name
  54774. * @returns the class name
  54775. */
  54776. getClassName(): string;
  54777. /**
  54778. * Gets the x component (input)
  54779. */
  54780. readonly x: NodeMaterialConnectionPoint;
  54781. /**
  54782. * Gets the y component (input)
  54783. */
  54784. readonly y: NodeMaterialConnectionPoint;
  54785. /**
  54786. * Gets the z component (input)
  54787. */
  54788. readonly z: NodeMaterialConnectionPoint;
  54789. /**
  54790. * Gets the w component (input)
  54791. */
  54792. readonly w: NodeMaterialConnectionPoint;
  54793. /**
  54794. * Gets the xyzw component (output)
  54795. */
  54796. readonly xyzw: NodeMaterialConnectionPoint;
  54797. /**
  54798. * Gets the xyz component (output)
  54799. */
  54800. readonly xyz: NodeMaterialConnectionPoint;
  54801. /**
  54802. * Gets the xy component (output)
  54803. */
  54804. readonly xy: NodeMaterialConnectionPoint;
  54805. protected _buildBlock(state: NodeMaterialBuildState): this;
  54806. }
  54807. }
  54808. declare module BABYLON {
  54809. /**
  54810. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54811. */
  54812. export class ColorSplitterBlock extends NodeMaterialBlock {
  54813. /**
  54814. * Create a new ColorSplitterBlock
  54815. * @param name defines the block name
  54816. */
  54817. constructor(name: string);
  54818. /**
  54819. * Gets the current class name
  54820. * @returns the class name
  54821. */
  54822. getClassName(): string;
  54823. /**
  54824. * Gets the rgba component (input)
  54825. */
  54826. readonly rgba: NodeMaterialConnectionPoint;
  54827. /**
  54828. * Gets the rgb component (input)
  54829. */
  54830. readonly rgbIn: NodeMaterialConnectionPoint;
  54831. /**
  54832. * Gets the rgb component (output)
  54833. */
  54834. readonly rgbOut: NodeMaterialConnectionPoint;
  54835. /**
  54836. * Gets the r component (output)
  54837. */
  54838. readonly r: NodeMaterialConnectionPoint;
  54839. /**
  54840. * Gets the g component (output)
  54841. */
  54842. readonly g: NodeMaterialConnectionPoint;
  54843. /**
  54844. * Gets the b component (output)
  54845. */
  54846. readonly b: NodeMaterialConnectionPoint;
  54847. /**
  54848. * Gets the a component (output)
  54849. */
  54850. readonly a: NodeMaterialConnectionPoint;
  54851. protected _inputRename(name: string): string;
  54852. protected _outputRename(name: string): string;
  54853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54854. }
  54855. }
  54856. declare module BABYLON {
  54857. /**
  54858. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54859. */
  54860. export class VectorSplitterBlock extends NodeMaterialBlock {
  54861. /**
  54862. * Create a new VectorSplitterBlock
  54863. * @param name defines the block name
  54864. */
  54865. constructor(name: string);
  54866. /**
  54867. * Gets the current class name
  54868. * @returns the class name
  54869. */
  54870. getClassName(): string;
  54871. /**
  54872. * Gets the xyzw component (input)
  54873. */
  54874. readonly xyzw: NodeMaterialConnectionPoint;
  54875. /**
  54876. * Gets the xyz component (input)
  54877. */
  54878. readonly xyzIn: NodeMaterialConnectionPoint;
  54879. /**
  54880. * Gets the xy component (input)
  54881. */
  54882. readonly xyIn: NodeMaterialConnectionPoint;
  54883. /**
  54884. * Gets the xyz component (output)
  54885. */
  54886. readonly xyzOut: NodeMaterialConnectionPoint;
  54887. /**
  54888. * Gets the xy component (output)
  54889. */
  54890. readonly xyOut: NodeMaterialConnectionPoint;
  54891. /**
  54892. * Gets the x component (output)
  54893. */
  54894. readonly x: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the y component (output)
  54897. */
  54898. readonly y: NodeMaterialConnectionPoint;
  54899. /**
  54900. * Gets the z component (output)
  54901. */
  54902. readonly z: NodeMaterialConnectionPoint;
  54903. /**
  54904. * Gets the w component (output)
  54905. */
  54906. readonly w: NodeMaterialConnectionPoint;
  54907. protected _inputRename(name: string): string;
  54908. protected _outputRename(name: string): string;
  54909. protected _buildBlock(state: NodeMaterialBuildState): this;
  54910. }
  54911. }
  54912. declare module BABYLON {
  54913. /**
  54914. * Block used to lerp between 2 values
  54915. */
  54916. export class LerpBlock extends NodeMaterialBlock {
  54917. /**
  54918. * Creates a new LerpBlock
  54919. * @param name defines the block name
  54920. */
  54921. constructor(name: string);
  54922. /**
  54923. * Gets the current class name
  54924. * @returns the class name
  54925. */
  54926. getClassName(): string;
  54927. /**
  54928. * Gets the left operand input component
  54929. */
  54930. readonly left: NodeMaterialConnectionPoint;
  54931. /**
  54932. * Gets the right operand input component
  54933. */
  54934. readonly right: NodeMaterialConnectionPoint;
  54935. /**
  54936. * Gets the gradient operand input component
  54937. */
  54938. readonly gradient: NodeMaterialConnectionPoint;
  54939. /**
  54940. * Gets the output component
  54941. */
  54942. readonly output: NodeMaterialConnectionPoint;
  54943. protected _buildBlock(state: NodeMaterialBuildState): this;
  54944. }
  54945. }
  54946. declare module BABYLON {
  54947. /**
  54948. * Block used to divide 2 vectors
  54949. */
  54950. export class DivideBlock extends NodeMaterialBlock {
  54951. /**
  54952. * Creates a new DivideBlock
  54953. * @param name defines the block name
  54954. */
  54955. constructor(name: string);
  54956. /**
  54957. * Gets the current class name
  54958. * @returns the class name
  54959. */
  54960. getClassName(): string;
  54961. /**
  54962. * Gets the left operand input component
  54963. */
  54964. readonly left: NodeMaterialConnectionPoint;
  54965. /**
  54966. * Gets the right operand input component
  54967. */
  54968. readonly right: NodeMaterialConnectionPoint;
  54969. /**
  54970. * Gets the output component
  54971. */
  54972. readonly output: NodeMaterialConnectionPoint;
  54973. protected _buildBlock(state: NodeMaterialBuildState): this;
  54974. }
  54975. }
  54976. declare module BABYLON {
  54977. /**
  54978. * Block used to subtract 2 vectors
  54979. */
  54980. export class SubtractBlock extends NodeMaterialBlock {
  54981. /**
  54982. * Creates a new SubtractBlock
  54983. * @param name defines the block name
  54984. */
  54985. constructor(name: string);
  54986. /**
  54987. * Gets the current class name
  54988. * @returns the class name
  54989. */
  54990. getClassName(): string;
  54991. /**
  54992. * Gets the left operand input component
  54993. */
  54994. readonly left: NodeMaterialConnectionPoint;
  54995. /**
  54996. * Gets the right operand input component
  54997. */
  54998. readonly right: NodeMaterialConnectionPoint;
  54999. /**
  55000. * Gets the output component
  55001. */
  55002. readonly output: NodeMaterialConnectionPoint;
  55003. protected _buildBlock(state: NodeMaterialBuildState): this;
  55004. }
  55005. }
  55006. declare module BABYLON {
  55007. /**
  55008. * Block used to step a value
  55009. */
  55010. export class StepBlock extends NodeMaterialBlock {
  55011. /**
  55012. * Creates a new StepBlock
  55013. * @param name defines the block name
  55014. */
  55015. constructor(name: string);
  55016. /**
  55017. * Gets the current class name
  55018. * @returns the class name
  55019. */
  55020. getClassName(): string;
  55021. /**
  55022. * Gets the value operand input component
  55023. */
  55024. readonly value: NodeMaterialConnectionPoint;
  55025. /**
  55026. * Gets the edge operand input component
  55027. */
  55028. readonly edge: NodeMaterialConnectionPoint;
  55029. /**
  55030. * Gets the output component
  55031. */
  55032. readonly output: NodeMaterialConnectionPoint;
  55033. protected _buildBlock(state: NodeMaterialBuildState): this;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Block used to get the opposite (1 - x) of a value
  55039. */
  55040. export class OneMinusBlock extends NodeMaterialBlock {
  55041. /**
  55042. * Creates a new OneMinusBlock
  55043. * @param name defines the block name
  55044. */
  55045. constructor(name: string);
  55046. /**
  55047. * Gets the current class name
  55048. * @returns the class name
  55049. */
  55050. getClassName(): string;
  55051. /**
  55052. * Gets the input component
  55053. */
  55054. readonly input: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the output component
  55057. */
  55058. readonly output: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Block used to get the view direction
  55065. */
  55066. export class ViewDirectionBlock extends NodeMaterialBlock {
  55067. /**
  55068. * Creates a new ViewDirectionBlock
  55069. * @param name defines the block name
  55070. */
  55071. constructor(name: string);
  55072. /**
  55073. * Gets the current class name
  55074. * @returns the class name
  55075. */
  55076. getClassName(): string;
  55077. /**
  55078. * Gets the world position component
  55079. */
  55080. readonly worldPosition: NodeMaterialConnectionPoint;
  55081. /**
  55082. * Gets the camera position component
  55083. */
  55084. readonly cameraPosition: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the output component
  55087. */
  55088. readonly output: NodeMaterialConnectionPoint;
  55089. autoConfigure(material: NodeMaterial): void;
  55090. protected _buildBlock(state: NodeMaterialBuildState): this;
  55091. }
  55092. }
  55093. declare module BABYLON {
  55094. /**
  55095. * Block used to compute fresnel value
  55096. */
  55097. export class FresnelBlock extends NodeMaterialBlock {
  55098. /**
  55099. * Create a new FresnelBlock
  55100. * @param name defines the block name
  55101. */
  55102. constructor(name: string);
  55103. /**
  55104. * Gets the current class name
  55105. * @returns the class name
  55106. */
  55107. getClassName(): string;
  55108. /**
  55109. * Gets the world normal input component
  55110. */
  55111. readonly worldNormal: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the view direction input component
  55114. */
  55115. readonly viewDirection: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the bias input component
  55118. */
  55119. readonly bias: NodeMaterialConnectionPoint;
  55120. /**
  55121. * Gets the camera (or eye) position component
  55122. */
  55123. readonly power: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the fresnel output component
  55126. */
  55127. readonly fresnel: NodeMaterialConnectionPoint;
  55128. autoConfigure(material: NodeMaterial): void;
  55129. protected _buildBlock(state: NodeMaterialBuildState): this;
  55130. }
  55131. }
  55132. declare module BABYLON {
  55133. /**
  55134. * Block used to get the max of 2 values
  55135. */
  55136. export class MaxBlock extends NodeMaterialBlock {
  55137. /**
  55138. * Creates a new MaxBlock
  55139. * @param name defines the block name
  55140. */
  55141. constructor(name: string);
  55142. /**
  55143. * Gets the current class name
  55144. * @returns the class name
  55145. */
  55146. getClassName(): string;
  55147. /**
  55148. * Gets the left operand input component
  55149. */
  55150. readonly left: NodeMaterialConnectionPoint;
  55151. /**
  55152. * Gets the right operand input component
  55153. */
  55154. readonly right: NodeMaterialConnectionPoint;
  55155. /**
  55156. * Gets the output component
  55157. */
  55158. readonly output: NodeMaterialConnectionPoint;
  55159. protected _buildBlock(state: NodeMaterialBuildState): this;
  55160. }
  55161. }
  55162. declare module BABYLON {
  55163. /**
  55164. * Block used to get the min of 2 values
  55165. */
  55166. export class MinBlock extends NodeMaterialBlock {
  55167. /**
  55168. * Creates a new MinBlock
  55169. * @param name defines the block name
  55170. */
  55171. constructor(name: string);
  55172. /**
  55173. * Gets the current class name
  55174. * @returns the class name
  55175. */
  55176. getClassName(): string;
  55177. /**
  55178. * Gets the left operand input component
  55179. */
  55180. readonly left: NodeMaterialConnectionPoint;
  55181. /**
  55182. * Gets the right operand input component
  55183. */
  55184. readonly right: NodeMaterialConnectionPoint;
  55185. /**
  55186. * Gets the output component
  55187. */
  55188. readonly output: NodeMaterialConnectionPoint;
  55189. protected _buildBlock(state: NodeMaterialBuildState): this;
  55190. }
  55191. }
  55192. declare module BABYLON {
  55193. /**
  55194. * Block used to get the distance between 2 values
  55195. */
  55196. export class DistanceBlock extends NodeMaterialBlock {
  55197. /**
  55198. * Creates a new DistanceBlock
  55199. * @param name defines the block name
  55200. */
  55201. constructor(name: string);
  55202. /**
  55203. * Gets the current class name
  55204. * @returns the class name
  55205. */
  55206. getClassName(): string;
  55207. /**
  55208. * Gets the left operand input component
  55209. */
  55210. readonly left: NodeMaterialConnectionPoint;
  55211. /**
  55212. * Gets the right operand input component
  55213. */
  55214. readonly right: NodeMaterialConnectionPoint;
  55215. /**
  55216. * Gets the output component
  55217. */
  55218. readonly output: NodeMaterialConnectionPoint;
  55219. protected _buildBlock(state: NodeMaterialBuildState): this;
  55220. }
  55221. }
  55222. declare module BABYLON {
  55223. /**
  55224. * Block used to get the length of a vector
  55225. */
  55226. export class LengthBlock extends NodeMaterialBlock {
  55227. /**
  55228. * Creates a new LengthBlock
  55229. * @param name defines the block name
  55230. */
  55231. constructor(name: string);
  55232. /**
  55233. * Gets the current class name
  55234. * @returns the class name
  55235. */
  55236. getClassName(): string;
  55237. /**
  55238. * Gets the value input component
  55239. */
  55240. readonly value: NodeMaterialConnectionPoint;
  55241. /**
  55242. * Gets the output component
  55243. */
  55244. readonly output: NodeMaterialConnectionPoint;
  55245. protected _buildBlock(state: NodeMaterialBuildState): this;
  55246. }
  55247. }
  55248. declare module BABYLON {
  55249. /**
  55250. * Block used to get negative version of a value (i.e. x * -1)
  55251. */
  55252. export class NegateBlock extends NodeMaterialBlock {
  55253. /**
  55254. * Creates a new NegateBlock
  55255. * @param name defines the block name
  55256. */
  55257. constructor(name: string);
  55258. /**
  55259. * Gets the current class name
  55260. * @returns the class name
  55261. */
  55262. getClassName(): string;
  55263. /**
  55264. * Gets the value input component
  55265. */
  55266. readonly value: NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the output component
  55269. */
  55270. readonly output: NodeMaterialConnectionPoint;
  55271. protected _buildBlock(state: NodeMaterialBuildState): this;
  55272. }
  55273. }
  55274. declare module BABYLON {
  55275. /**
  55276. * Block used to get the value of the first parameter raised to the power of the second
  55277. */
  55278. export class PowBlock extends NodeMaterialBlock {
  55279. /**
  55280. * Creates a new PowBlock
  55281. * @param name defines the block name
  55282. */
  55283. constructor(name: string);
  55284. /**
  55285. * Gets the current class name
  55286. * @returns the class name
  55287. */
  55288. getClassName(): string;
  55289. /**
  55290. * Gets the value operand input component
  55291. */
  55292. readonly value: NodeMaterialConnectionPoint;
  55293. /**
  55294. * Gets the power operand input component
  55295. */
  55296. readonly power: NodeMaterialConnectionPoint;
  55297. /**
  55298. * Gets the output component
  55299. */
  55300. readonly output: NodeMaterialConnectionPoint;
  55301. protected _buildBlock(state: NodeMaterialBuildState): this;
  55302. }
  55303. }
  55304. declare module BABYLON {
  55305. /**
  55306. * Block used to get a random number
  55307. */
  55308. export class RandomNumberBlock extends NodeMaterialBlock {
  55309. /**
  55310. * Creates a new RandomNumberBlock
  55311. * @param name defines the block name
  55312. */
  55313. constructor(name: string);
  55314. /**
  55315. * Gets the current class name
  55316. * @returns the class name
  55317. */
  55318. getClassName(): string;
  55319. /**
  55320. * Gets the seed input component
  55321. */
  55322. readonly seed: NodeMaterialConnectionPoint;
  55323. /**
  55324. * Gets the output component
  55325. */
  55326. readonly output: NodeMaterialConnectionPoint;
  55327. protected _buildBlock(state: NodeMaterialBuildState): this;
  55328. }
  55329. }
  55330. declare module BABYLON {
  55331. /**
  55332. * Block used to compute arc tangent of 2 values
  55333. */
  55334. export class ArcTan2Block extends NodeMaterialBlock {
  55335. /**
  55336. * Creates a new ArcTan2Block
  55337. * @param name defines the block name
  55338. */
  55339. constructor(name: string);
  55340. /**
  55341. * Gets the current class name
  55342. * @returns the class name
  55343. */
  55344. getClassName(): string;
  55345. /**
  55346. * Gets the x operand input component
  55347. */
  55348. readonly x: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the y operand input component
  55351. */
  55352. readonly y: NodeMaterialConnectionPoint;
  55353. /**
  55354. * Gets the output component
  55355. */
  55356. readonly output: NodeMaterialConnectionPoint;
  55357. protected _buildBlock(state: NodeMaterialBuildState): this;
  55358. }
  55359. }
  55360. declare module BABYLON {
  55361. /**
  55362. * Block used to smooth step a value
  55363. */
  55364. export class SmoothStepBlock extends NodeMaterialBlock {
  55365. /**
  55366. * Creates a new SmoothStepBlock
  55367. * @param name defines the block name
  55368. */
  55369. constructor(name: string);
  55370. /**
  55371. * Gets the current class name
  55372. * @returns the class name
  55373. */
  55374. getClassName(): string;
  55375. /**
  55376. * Gets the value operand input component
  55377. */
  55378. readonly value: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the first edge operand input component
  55381. */
  55382. readonly edge0: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the second edge operand input component
  55385. */
  55386. readonly edge1: NodeMaterialConnectionPoint;
  55387. /**
  55388. * Gets the output component
  55389. */
  55390. readonly output: NodeMaterialConnectionPoint;
  55391. protected _buildBlock(state: NodeMaterialBuildState): this;
  55392. }
  55393. }
  55394. declare module BABYLON {
  55395. /**
  55396. * Block used to get the reciprocal (1 / x) of a value
  55397. */
  55398. export class ReciprocalBlock extends NodeMaterialBlock {
  55399. /**
  55400. * Creates a new ReciprocalBlock
  55401. * @param name defines the block name
  55402. */
  55403. constructor(name: string);
  55404. /**
  55405. * Gets the current class name
  55406. * @returns the class name
  55407. */
  55408. getClassName(): string;
  55409. /**
  55410. * Gets the input component
  55411. */
  55412. readonly input: NodeMaterialConnectionPoint;
  55413. /**
  55414. * Gets the output component
  55415. */
  55416. readonly output: NodeMaterialConnectionPoint;
  55417. protected _buildBlock(state: NodeMaterialBuildState): this;
  55418. }
  55419. }
  55420. declare module BABYLON {
  55421. /**
  55422. * Block used to replace a color by another one
  55423. */
  55424. export class ReplaceColorBlock extends NodeMaterialBlock {
  55425. /**
  55426. * Creates a new ReplaceColorBlock
  55427. * @param name defines the block name
  55428. */
  55429. constructor(name: string);
  55430. /**
  55431. * Gets the current class name
  55432. * @returns the class name
  55433. */
  55434. getClassName(): string;
  55435. /**
  55436. * Gets the value input component
  55437. */
  55438. readonly value: NodeMaterialConnectionPoint;
  55439. /**
  55440. * Gets the reference input component
  55441. */
  55442. readonly reference: NodeMaterialConnectionPoint;
  55443. /**
  55444. * Gets the distance input component
  55445. */
  55446. readonly distance: NodeMaterialConnectionPoint;
  55447. /**
  55448. * Gets the replacement input component
  55449. */
  55450. readonly replacement: NodeMaterialConnectionPoint;
  55451. /**
  55452. * Gets the output component
  55453. */
  55454. readonly output: NodeMaterialConnectionPoint;
  55455. protected _buildBlock(state: NodeMaterialBuildState): this;
  55456. }
  55457. }
  55458. declare module BABYLON {
  55459. /**
  55460. * Block used to posterize a value
  55461. * @see https://en.wikipedia.org/wiki/Posterization
  55462. */
  55463. export class PosterizeBlock extends NodeMaterialBlock {
  55464. /**
  55465. * Creates a new PosterizeBlock
  55466. * @param name defines the block name
  55467. */
  55468. constructor(name: string);
  55469. /**
  55470. * Gets the current class name
  55471. * @returns the class name
  55472. */
  55473. getClassName(): string;
  55474. /**
  55475. * Gets the value input component
  55476. */
  55477. readonly value: NodeMaterialConnectionPoint;
  55478. /**
  55479. * Gets the steps input component
  55480. */
  55481. readonly steps: NodeMaterialConnectionPoint;
  55482. /**
  55483. * Gets the output component
  55484. */
  55485. readonly output: NodeMaterialConnectionPoint;
  55486. protected _buildBlock(state: NodeMaterialBuildState): this;
  55487. }
  55488. }
  55489. declare module BABYLON {
  55490. /**
  55491. * Operations supported by the Wave block
  55492. */
  55493. export enum WaveBlockKind {
  55494. /** SawTooth */
  55495. SawTooth = 0,
  55496. /** Square */
  55497. Square = 1,
  55498. /** Triangle */
  55499. Triangle = 2
  55500. }
  55501. /**
  55502. * Block used to apply wave operation to floats
  55503. */
  55504. export class WaveBlock extends NodeMaterialBlock {
  55505. /**
  55506. * Gets or sets the kibnd of wave to be applied by the block
  55507. */
  55508. kind: WaveBlockKind;
  55509. /**
  55510. * Creates a new WaveBlock
  55511. * @param name defines the block name
  55512. */
  55513. constructor(name: string);
  55514. /**
  55515. * Gets the current class name
  55516. * @returns the class name
  55517. */
  55518. getClassName(): string;
  55519. /**
  55520. * Gets the input component
  55521. */
  55522. readonly input: NodeMaterialConnectionPoint;
  55523. /**
  55524. * Gets the output component
  55525. */
  55526. readonly output: NodeMaterialConnectionPoint;
  55527. protected _buildBlock(state: NodeMaterialBuildState): this;
  55528. serialize(): any;
  55529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Class used to store a color step for the GradientBlock
  55535. */
  55536. export class GradientBlockColorStep {
  55537. /**
  55538. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55539. */
  55540. step: number;
  55541. /**
  55542. * Gets or sets the color associated with this step
  55543. */
  55544. color: Color3;
  55545. /**
  55546. * Creates a new GradientBlockColorStep
  55547. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55548. * @param color defines the color associated with this step
  55549. */
  55550. constructor(
  55551. /**
  55552. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55553. */
  55554. step: number,
  55555. /**
  55556. * Gets or sets the color associated with this step
  55557. */
  55558. color: Color3);
  55559. }
  55560. /**
  55561. * Block used to return a color from a gradient based on an input value between 0 and 1
  55562. */
  55563. export class GradientBlock extends NodeMaterialBlock {
  55564. /**
  55565. * Gets or sets the list of color steps
  55566. */
  55567. colorSteps: GradientBlockColorStep[];
  55568. /**
  55569. * Creates a new GradientBlock
  55570. * @param name defines the block name
  55571. */
  55572. constructor(name: string);
  55573. /**
  55574. * Gets the current class name
  55575. * @returns the class name
  55576. */
  55577. getClassName(): string;
  55578. /**
  55579. * Gets the gradient input component
  55580. */
  55581. readonly gradient: NodeMaterialConnectionPoint;
  55582. /**
  55583. * Gets the output component
  55584. */
  55585. readonly output: NodeMaterialConnectionPoint;
  55586. private _writeColorConstant;
  55587. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55588. serialize(): any;
  55589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55590. protected _dumpPropertiesCode(): string;
  55591. }
  55592. }
  55593. declare module BABYLON {
  55594. /**
  55595. * Block used to normalize lerp between 2 values
  55596. */
  55597. export class NLerpBlock extends NodeMaterialBlock {
  55598. /**
  55599. * Creates a new NLerpBlock
  55600. * @param name defines the block name
  55601. */
  55602. constructor(name: string);
  55603. /**
  55604. * Gets the current class name
  55605. * @returns the class name
  55606. */
  55607. getClassName(): string;
  55608. /**
  55609. * Gets the left operand input component
  55610. */
  55611. readonly left: NodeMaterialConnectionPoint;
  55612. /**
  55613. * Gets the right operand input component
  55614. */
  55615. readonly right: NodeMaterialConnectionPoint;
  55616. /**
  55617. * Gets the gradient operand input component
  55618. */
  55619. readonly gradient: NodeMaterialConnectionPoint;
  55620. /**
  55621. * Gets the output component
  55622. */
  55623. readonly output: NodeMaterialConnectionPoint;
  55624. protected _buildBlock(state: NodeMaterialBuildState): this;
  55625. }
  55626. }
  55627. declare module BABYLON {
  55628. /**
  55629. * Effect Render Options
  55630. */
  55631. export interface IEffectRendererOptions {
  55632. /**
  55633. * Defines the vertices positions.
  55634. */
  55635. positions?: number[];
  55636. /**
  55637. * Defines the indices.
  55638. */
  55639. indices?: number[];
  55640. }
  55641. /**
  55642. * Helper class to render one or more effects
  55643. */
  55644. export class EffectRenderer {
  55645. private engine;
  55646. private static _DefaultOptions;
  55647. private _vertexBuffers;
  55648. private _indexBuffer;
  55649. private _ringBufferIndex;
  55650. private _ringScreenBuffer;
  55651. private _fullscreenViewport;
  55652. private _getNextFrameBuffer;
  55653. /**
  55654. * Creates an effect renderer
  55655. * @param engine the engine to use for rendering
  55656. * @param options defines the options of the effect renderer
  55657. */
  55658. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55659. /**
  55660. * Sets the current viewport in normalized coordinates 0-1
  55661. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55662. */
  55663. setViewport(viewport?: Viewport): void;
  55664. /**
  55665. * Binds the embedded attributes buffer to the effect.
  55666. * @param effect Defines the effect to bind the attributes for
  55667. */
  55668. bindBuffers(effect: Effect): void;
  55669. /**
  55670. * Sets the current effect wrapper to use during draw.
  55671. * The effect needs to be ready before calling this api.
  55672. * This also sets the default full screen position attribute.
  55673. * @param effectWrapper Defines the effect to draw with
  55674. */
  55675. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55676. /**
  55677. * Draws a full screen quad.
  55678. */
  55679. draw(): void;
  55680. /**
  55681. * renders one or more effects to a specified texture
  55682. * @param effectWrappers list of effects to renderer
  55683. * @param outputTexture texture to draw to, if null it will render to the screen
  55684. */
  55685. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55686. /**
  55687. * Disposes of the effect renderer
  55688. */
  55689. dispose(): void;
  55690. }
  55691. /**
  55692. * Options to create an EffectWrapper
  55693. */
  55694. interface EffectWrapperCreationOptions {
  55695. /**
  55696. * Engine to use to create the effect
  55697. */
  55698. engine: ThinEngine;
  55699. /**
  55700. * Fragment shader for the effect
  55701. */
  55702. fragmentShader: string;
  55703. /**
  55704. * Vertex shader for the effect
  55705. */
  55706. vertexShader?: string;
  55707. /**
  55708. * Attributes to use in the shader
  55709. */
  55710. attributeNames?: Array<string>;
  55711. /**
  55712. * Uniforms to use in the shader
  55713. */
  55714. uniformNames?: Array<string>;
  55715. /**
  55716. * Texture sampler names to use in the shader
  55717. */
  55718. samplerNames?: Array<string>;
  55719. /**
  55720. * The friendly name of the effect displayed in Spector.
  55721. */
  55722. name?: string;
  55723. }
  55724. /**
  55725. * Wraps an effect to be used for rendering
  55726. */
  55727. export class EffectWrapper {
  55728. /**
  55729. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55730. */
  55731. onApplyObservable: Observable<{}>;
  55732. /**
  55733. * The underlying effect
  55734. */
  55735. effect: Effect;
  55736. /**
  55737. * Creates an effect to be renderer
  55738. * @param creationOptions options to create the effect
  55739. */
  55740. constructor(creationOptions: EffectWrapperCreationOptions);
  55741. /**
  55742. * Disposes of the effect wrapper
  55743. */
  55744. dispose(): void;
  55745. }
  55746. }
  55747. declare module BABYLON {
  55748. /**
  55749. * Helper class to push actions to a pool of workers.
  55750. */
  55751. export class WorkerPool implements IDisposable {
  55752. private _workerInfos;
  55753. private _pendingActions;
  55754. /**
  55755. * Constructor
  55756. * @param workers Array of workers to use for actions
  55757. */
  55758. constructor(workers: Array<Worker>);
  55759. /**
  55760. * Terminates all workers and clears any pending actions.
  55761. */
  55762. dispose(): void;
  55763. /**
  55764. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55765. * pended until a worker has completed its action.
  55766. * @param action The action to perform. Call onComplete when the action is complete.
  55767. */
  55768. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55769. private _execute;
  55770. }
  55771. }
  55772. declare module BABYLON {
  55773. /**
  55774. * Configuration for Draco compression
  55775. */
  55776. export interface IDracoCompressionConfiguration {
  55777. /**
  55778. * Configuration for the decoder.
  55779. */
  55780. decoder: {
  55781. /**
  55782. * The url to the WebAssembly module.
  55783. */
  55784. wasmUrl?: string;
  55785. /**
  55786. * The url to the WebAssembly binary.
  55787. */
  55788. wasmBinaryUrl?: string;
  55789. /**
  55790. * The url to the fallback JavaScript module.
  55791. */
  55792. fallbackUrl?: string;
  55793. };
  55794. }
  55795. /**
  55796. * Draco compression (https://google.github.io/draco/)
  55797. *
  55798. * This class wraps the Draco module.
  55799. *
  55800. * **Encoder**
  55801. *
  55802. * The encoder is not currently implemented.
  55803. *
  55804. * **Decoder**
  55805. *
  55806. * 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.
  55807. *
  55808. * To update the configuration, use the following code:
  55809. * ```javascript
  55810. * DracoCompression.Configuration = {
  55811. * decoder: {
  55812. * wasmUrl: "<url to the WebAssembly library>",
  55813. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55814. * fallbackUrl: "<url to the fallback JavaScript library>",
  55815. * }
  55816. * };
  55817. * ```
  55818. *
  55819. * 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.
  55820. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55821. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55822. *
  55823. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55824. * ```javascript
  55825. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55826. * ```
  55827. *
  55828. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55829. */
  55830. export class DracoCompression implements IDisposable {
  55831. private _workerPoolPromise?;
  55832. private _decoderModulePromise?;
  55833. /**
  55834. * The configuration. Defaults to the following urls:
  55835. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55836. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55837. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55838. */
  55839. static Configuration: IDracoCompressionConfiguration;
  55840. /**
  55841. * Returns true if the decoder configuration is available.
  55842. */
  55843. static readonly DecoderAvailable: boolean;
  55844. /**
  55845. * Default number of workers to create when creating the draco compression object.
  55846. */
  55847. static DefaultNumWorkers: number;
  55848. private static GetDefaultNumWorkers;
  55849. private static _Default;
  55850. /**
  55851. * Default instance for the draco compression object.
  55852. */
  55853. static readonly Default: DracoCompression;
  55854. /**
  55855. * Constructor
  55856. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55857. */
  55858. constructor(numWorkers?: number);
  55859. /**
  55860. * Stop all async operations and release resources.
  55861. */
  55862. dispose(): void;
  55863. /**
  55864. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55865. * @returns a promise that resolves when ready
  55866. */
  55867. whenReadyAsync(): Promise<void>;
  55868. /**
  55869. * Decode Draco compressed mesh data to vertex data.
  55870. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55871. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55872. * @returns A promise that resolves with the decoded vertex data
  55873. */
  55874. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55875. [kind: string]: number;
  55876. }): Promise<VertexData>;
  55877. }
  55878. }
  55879. declare module BABYLON {
  55880. /**
  55881. * Class for building Constructive Solid Geometry
  55882. */
  55883. export class CSG {
  55884. private polygons;
  55885. /**
  55886. * The world matrix
  55887. */
  55888. matrix: Matrix;
  55889. /**
  55890. * Stores the position
  55891. */
  55892. position: Vector3;
  55893. /**
  55894. * Stores the rotation
  55895. */
  55896. rotation: Vector3;
  55897. /**
  55898. * Stores the rotation quaternion
  55899. */
  55900. rotationQuaternion: Nullable<Quaternion>;
  55901. /**
  55902. * Stores the scaling vector
  55903. */
  55904. scaling: Vector3;
  55905. /**
  55906. * Convert the Mesh to CSG
  55907. * @param mesh The Mesh to convert to CSG
  55908. * @returns A new CSG from the Mesh
  55909. */
  55910. static FromMesh(mesh: Mesh): CSG;
  55911. /**
  55912. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55913. * @param polygons Polygons used to construct a CSG solid
  55914. */
  55915. private static FromPolygons;
  55916. /**
  55917. * Clones, or makes a deep copy, of the CSG
  55918. * @returns A new CSG
  55919. */
  55920. clone(): CSG;
  55921. /**
  55922. * Unions this CSG with another CSG
  55923. * @param csg The CSG to union against this CSG
  55924. * @returns The unioned CSG
  55925. */
  55926. union(csg: CSG): CSG;
  55927. /**
  55928. * Unions this CSG with another CSG in place
  55929. * @param csg The CSG to union against this CSG
  55930. */
  55931. unionInPlace(csg: CSG): void;
  55932. /**
  55933. * Subtracts this CSG with another CSG
  55934. * @param csg The CSG to subtract against this CSG
  55935. * @returns A new CSG
  55936. */
  55937. subtract(csg: CSG): CSG;
  55938. /**
  55939. * Subtracts this CSG with another CSG in place
  55940. * @param csg The CSG to subtact against this CSG
  55941. */
  55942. subtractInPlace(csg: CSG): void;
  55943. /**
  55944. * Intersect this CSG with another CSG
  55945. * @param csg The CSG to intersect against this CSG
  55946. * @returns A new CSG
  55947. */
  55948. intersect(csg: CSG): CSG;
  55949. /**
  55950. * Intersects this CSG with another CSG in place
  55951. * @param csg The CSG to intersect against this CSG
  55952. */
  55953. intersectInPlace(csg: CSG): void;
  55954. /**
  55955. * Return a new CSG solid with solid and empty space switched. This solid is
  55956. * not modified.
  55957. * @returns A new CSG solid with solid and empty space switched
  55958. */
  55959. inverse(): CSG;
  55960. /**
  55961. * Inverses the CSG in place
  55962. */
  55963. inverseInPlace(): void;
  55964. /**
  55965. * This is used to keep meshes transformations so they can be restored
  55966. * when we build back a Babylon Mesh
  55967. * NB : All CSG operations are performed in world coordinates
  55968. * @param csg The CSG to copy the transform attributes from
  55969. * @returns This CSG
  55970. */
  55971. copyTransformAttributes(csg: CSG): CSG;
  55972. /**
  55973. * Build Raw mesh from CSG
  55974. * Coordinates here are in world space
  55975. * @param name The name of the mesh geometry
  55976. * @param scene The Scene
  55977. * @param keepSubMeshes Specifies if the submeshes should be kept
  55978. * @returns A new Mesh
  55979. */
  55980. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55981. /**
  55982. * Build Mesh from CSG taking material and transforms into account
  55983. * @param name The name of the Mesh
  55984. * @param material The material of the Mesh
  55985. * @param scene The Scene
  55986. * @param keepSubMeshes Specifies if submeshes should be kept
  55987. * @returns The new Mesh
  55988. */
  55989. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55990. }
  55991. }
  55992. declare module BABYLON {
  55993. /**
  55994. * Class used to create a trail following a mesh
  55995. */
  55996. export class TrailMesh extends Mesh {
  55997. private _generator;
  55998. private _autoStart;
  55999. private _running;
  56000. private _diameter;
  56001. private _length;
  56002. private _sectionPolygonPointsCount;
  56003. private _sectionVectors;
  56004. private _sectionNormalVectors;
  56005. private _beforeRenderObserver;
  56006. /**
  56007. * @constructor
  56008. * @param name The value used by scene.getMeshByName() to do a lookup.
  56009. * @param generator The mesh to generate a trail.
  56010. * @param scene The scene to add this mesh to.
  56011. * @param diameter Diameter of trailing mesh. Default is 1.
  56012. * @param length Length of trailing mesh. Default is 60.
  56013. * @param autoStart Automatically start trailing mesh. Default true.
  56014. */
  56015. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56016. /**
  56017. * "TrailMesh"
  56018. * @returns "TrailMesh"
  56019. */
  56020. getClassName(): string;
  56021. private _createMesh;
  56022. /**
  56023. * Start trailing mesh.
  56024. */
  56025. start(): void;
  56026. /**
  56027. * Stop trailing mesh.
  56028. */
  56029. stop(): void;
  56030. /**
  56031. * Update trailing mesh geometry.
  56032. */
  56033. update(): void;
  56034. /**
  56035. * Returns a new TrailMesh object.
  56036. * @param name is a string, the name given to the new mesh
  56037. * @param newGenerator use new generator object for cloned trail mesh
  56038. * @returns a new mesh
  56039. */
  56040. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56041. /**
  56042. * Serializes this trail mesh
  56043. * @param serializationObject object to write serialization to
  56044. */
  56045. serialize(serializationObject: any): void;
  56046. /**
  56047. * Parses a serialized trail mesh
  56048. * @param parsedMesh the serialized mesh
  56049. * @param scene the scene to create the trail mesh in
  56050. * @returns the created trail mesh
  56051. */
  56052. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * Class containing static functions to help procedurally build meshes
  56058. */
  56059. export class TiledBoxBuilder {
  56060. /**
  56061. * Creates a box mesh
  56062. * 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)
  56063. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56065. * * 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
  56066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56067. * @param name defines the name of the mesh
  56068. * @param options defines the options used to create the mesh
  56069. * @param scene defines the hosting scene
  56070. * @returns the box mesh
  56071. */
  56072. static CreateTiledBox(name: string, options: {
  56073. pattern?: number;
  56074. width?: number;
  56075. height?: number;
  56076. depth?: number;
  56077. tileSize?: number;
  56078. tileWidth?: number;
  56079. tileHeight?: number;
  56080. alignHorizontal?: number;
  56081. alignVertical?: number;
  56082. faceUV?: Vector4[];
  56083. faceColors?: Color4[];
  56084. sideOrientation?: number;
  56085. updatable?: boolean;
  56086. }, scene?: Nullable<Scene>): Mesh;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Class containing static functions to help procedurally build meshes
  56092. */
  56093. export class TorusKnotBuilder {
  56094. /**
  56095. * Creates a torus knot mesh
  56096. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56097. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56098. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56099. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56101. * * 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
  56102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56103. * @param name defines the name of the mesh
  56104. * @param options defines the options used to create the mesh
  56105. * @param scene defines the hosting scene
  56106. * @returns the torus knot mesh
  56107. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56108. */
  56109. static CreateTorusKnot(name: string, options: {
  56110. radius?: number;
  56111. tube?: number;
  56112. radialSegments?: number;
  56113. tubularSegments?: number;
  56114. p?: number;
  56115. q?: number;
  56116. updatable?: boolean;
  56117. sideOrientation?: number;
  56118. frontUVs?: Vector4;
  56119. backUVs?: Vector4;
  56120. }, scene: any): Mesh;
  56121. }
  56122. }
  56123. declare module BABYLON {
  56124. /**
  56125. * Polygon
  56126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56127. */
  56128. export class Polygon {
  56129. /**
  56130. * Creates a rectangle
  56131. * @param xmin bottom X coord
  56132. * @param ymin bottom Y coord
  56133. * @param xmax top X coord
  56134. * @param ymax top Y coord
  56135. * @returns points that make the resulting rectation
  56136. */
  56137. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56138. /**
  56139. * Creates a circle
  56140. * @param radius radius of circle
  56141. * @param cx scale in x
  56142. * @param cy scale in y
  56143. * @param numberOfSides number of sides that make up the circle
  56144. * @returns points that make the resulting circle
  56145. */
  56146. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56147. /**
  56148. * Creates a polygon from input string
  56149. * @param input Input polygon data
  56150. * @returns the parsed points
  56151. */
  56152. static Parse(input: string): Vector2[];
  56153. /**
  56154. * Starts building a polygon from x and y coordinates
  56155. * @param x x coordinate
  56156. * @param y y coordinate
  56157. * @returns the started path2
  56158. */
  56159. static StartingAt(x: number, y: number): Path2;
  56160. }
  56161. /**
  56162. * Builds a polygon
  56163. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56164. */
  56165. export class PolygonMeshBuilder {
  56166. private _points;
  56167. private _outlinepoints;
  56168. private _holes;
  56169. private _name;
  56170. private _scene;
  56171. private _epoints;
  56172. private _eholes;
  56173. private _addToepoint;
  56174. /**
  56175. * Babylon reference to the earcut plugin.
  56176. */
  56177. bjsEarcut: any;
  56178. /**
  56179. * Creates a PolygonMeshBuilder
  56180. * @param name name of the builder
  56181. * @param contours Path of the polygon
  56182. * @param scene scene to add to when creating the mesh
  56183. * @param earcutInjection can be used to inject your own earcut reference
  56184. */
  56185. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56186. /**
  56187. * Adds a whole within the polygon
  56188. * @param hole Array of points defining the hole
  56189. * @returns this
  56190. */
  56191. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56192. /**
  56193. * Creates the polygon
  56194. * @param updatable If the mesh should be updatable
  56195. * @param depth The depth of the mesh created
  56196. * @returns the created mesh
  56197. */
  56198. build(updatable?: boolean, depth?: number): Mesh;
  56199. /**
  56200. * Creates the polygon
  56201. * @param depth The depth of the mesh created
  56202. * @returns the created VertexData
  56203. */
  56204. buildVertexData(depth?: number): VertexData;
  56205. /**
  56206. * Adds a side to the polygon
  56207. * @param positions points that make the polygon
  56208. * @param normals normals of the polygon
  56209. * @param uvs uvs of the polygon
  56210. * @param indices indices of the polygon
  56211. * @param bounds bounds of the polygon
  56212. * @param points points of the polygon
  56213. * @param depth depth of the polygon
  56214. * @param flip flip of the polygon
  56215. */
  56216. private addSide;
  56217. }
  56218. }
  56219. declare module BABYLON {
  56220. /**
  56221. * Class containing static functions to help procedurally build meshes
  56222. */
  56223. export class PolygonBuilder {
  56224. /**
  56225. * Creates a polygon mesh
  56226. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56227. * * 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
  56228. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56230. * * 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)
  56231. * * Remember you can only change the shape positions, not their number when updating a polygon
  56232. * @param name defines the name of the mesh
  56233. * @param options defines the options used to create the mesh
  56234. * @param scene defines the hosting scene
  56235. * @param earcutInjection can be used to inject your own earcut reference
  56236. * @returns the polygon mesh
  56237. */
  56238. static CreatePolygon(name: string, options: {
  56239. shape: Vector3[];
  56240. holes?: Vector3[][];
  56241. depth?: number;
  56242. faceUV?: Vector4[];
  56243. faceColors?: Color4[];
  56244. updatable?: boolean;
  56245. sideOrientation?: number;
  56246. frontUVs?: Vector4;
  56247. backUVs?: Vector4;
  56248. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56249. /**
  56250. * Creates an extruded polygon mesh, with depth in the Y direction.
  56251. * * 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)
  56252. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56253. * @param name defines the name of the mesh
  56254. * @param options defines the options used to create the mesh
  56255. * @param scene defines the hosting scene
  56256. * @param earcutInjection can be used to inject your own earcut reference
  56257. * @returns the polygon mesh
  56258. */
  56259. static ExtrudePolygon(name: string, options: {
  56260. shape: Vector3[];
  56261. holes?: Vector3[][];
  56262. depth?: number;
  56263. faceUV?: Vector4[];
  56264. faceColors?: Color4[];
  56265. updatable?: boolean;
  56266. sideOrientation?: number;
  56267. frontUVs?: Vector4;
  56268. backUVs?: Vector4;
  56269. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56270. }
  56271. }
  56272. declare module BABYLON {
  56273. /**
  56274. * Class containing static functions to help procedurally build meshes
  56275. */
  56276. export class LatheBuilder {
  56277. /**
  56278. * Creates lathe mesh.
  56279. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56280. * * 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
  56281. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56282. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56283. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56284. * * 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
  56285. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56286. * * 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
  56287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56288. * * 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
  56289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56291. * @param name defines the name of the mesh
  56292. * @param options defines the options used to create the mesh
  56293. * @param scene defines the hosting scene
  56294. * @returns the lathe mesh
  56295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56296. */
  56297. static CreateLathe(name: string, options: {
  56298. shape: Vector3[];
  56299. radius?: number;
  56300. tessellation?: number;
  56301. clip?: number;
  56302. arc?: number;
  56303. closed?: boolean;
  56304. updatable?: boolean;
  56305. sideOrientation?: number;
  56306. frontUVs?: Vector4;
  56307. backUVs?: Vector4;
  56308. cap?: number;
  56309. invertUV?: boolean;
  56310. }, scene?: Nullable<Scene>): Mesh;
  56311. }
  56312. }
  56313. declare module BABYLON {
  56314. /**
  56315. * Class containing static functions to help procedurally build meshes
  56316. */
  56317. export class TiledPlaneBuilder {
  56318. /**
  56319. * Creates a tiled plane mesh
  56320. * * The parameter `pattern` will, depending on value, do nothing or
  56321. * * * flip (reflect about central vertical) alternate tiles across and up
  56322. * * * flip every tile on alternate rows
  56323. * * * rotate (180 degs) alternate tiles across and up
  56324. * * * rotate every tile on alternate rows
  56325. * * * flip and rotate alternate tiles across and up
  56326. * * * flip and rotate every tile on alternate rows
  56327. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56328. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56329. * * 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
  56330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56331. * * 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)
  56332. * * 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)
  56333. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56334. * @param name defines the name of the mesh
  56335. * @param options defines the options used to create the mesh
  56336. * @param scene defines the hosting scene
  56337. * @returns the box mesh
  56338. */
  56339. static CreateTiledPlane(name: string, options: {
  56340. pattern?: number;
  56341. tileSize?: number;
  56342. tileWidth?: number;
  56343. tileHeight?: number;
  56344. size?: number;
  56345. width?: number;
  56346. height?: number;
  56347. alignHorizontal?: number;
  56348. alignVertical?: number;
  56349. sideOrientation?: number;
  56350. frontUVs?: Vector4;
  56351. backUVs?: Vector4;
  56352. updatable?: boolean;
  56353. }, scene?: Nullable<Scene>): Mesh;
  56354. }
  56355. }
  56356. declare module BABYLON {
  56357. /**
  56358. * Class containing static functions to help procedurally build meshes
  56359. */
  56360. export class TubeBuilder {
  56361. /**
  56362. * Creates a tube mesh.
  56363. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56364. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56365. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56366. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56367. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56368. * * 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)
  56369. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56370. * * 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
  56371. * * 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
  56372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56373. * * 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
  56374. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56376. * @param name defines the name of the mesh
  56377. * @param options defines the options used to create the mesh
  56378. * @param scene defines the hosting scene
  56379. * @returns the tube mesh
  56380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56381. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56382. */
  56383. static CreateTube(name: string, options: {
  56384. path: Vector3[];
  56385. radius?: number;
  56386. tessellation?: number;
  56387. radiusFunction?: {
  56388. (i: number, distance: number): number;
  56389. };
  56390. cap?: number;
  56391. arc?: number;
  56392. updatable?: boolean;
  56393. sideOrientation?: number;
  56394. frontUVs?: Vector4;
  56395. backUVs?: Vector4;
  56396. instance?: Mesh;
  56397. invertUV?: boolean;
  56398. }, scene?: Nullable<Scene>): Mesh;
  56399. }
  56400. }
  56401. declare module BABYLON {
  56402. /**
  56403. * Class containing static functions to help procedurally build meshes
  56404. */
  56405. export class IcoSphereBuilder {
  56406. /**
  56407. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56408. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56409. * * 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`)
  56410. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56411. * * 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
  56412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56413. * * 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
  56414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56415. * @param name defines the name of the mesh
  56416. * @param options defines the options used to create the mesh
  56417. * @param scene defines the hosting scene
  56418. * @returns the icosahedron mesh
  56419. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56420. */
  56421. static CreateIcoSphere(name: string, options: {
  56422. radius?: number;
  56423. radiusX?: number;
  56424. radiusY?: number;
  56425. radiusZ?: number;
  56426. flat?: boolean;
  56427. subdivisions?: number;
  56428. sideOrientation?: number;
  56429. frontUVs?: Vector4;
  56430. backUVs?: Vector4;
  56431. updatable?: boolean;
  56432. }, scene?: Nullable<Scene>): Mesh;
  56433. }
  56434. }
  56435. declare module BABYLON {
  56436. /**
  56437. * Class containing static functions to help procedurally build meshes
  56438. */
  56439. export class DecalBuilder {
  56440. /**
  56441. * Creates a decal mesh.
  56442. * 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
  56443. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56444. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56445. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56446. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56447. * @param name defines the name of the mesh
  56448. * @param sourceMesh defines the mesh where the decal must be applied
  56449. * @param options defines the options used to create the mesh
  56450. * @param scene defines the hosting scene
  56451. * @returns the decal mesh
  56452. * @see https://doc.babylonjs.com/how_to/decals
  56453. */
  56454. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56455. position?: Vector3;
  56456. normal?: Vector3;
  56457. size?: Vector3;
  56458. angle?: number;
  56459. }): Mesh;
  56460. }
  56461. }
  56462. declare module BABYLON {
  56463. /**
  56464. * Class containing static functions to help procedurally build meshes
  56465. */
  56466. export class MeshBuilder {
  56467. /**
  56468. * Creates a box mesh
  56469. * * The parameter `size` sets the size (float) of each box side (default 1)
  56470. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56471. * * 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)
  56472. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56474. * * 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
  56475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56476. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56477. * @param name defines the name of the mesh
  56478. * @param options defines the options used to create the mesh
  56479. * @param scene defines the hosting scene
  56480. * @returns the box mesh
  56481. */
  56482. static CreateBox(name: string, options: {
  56483. size?: number;
  56484. width?: number;
  56485. height?: number;
  56486. depth?: number;
  56487. faceUV?: Vector4[];
  56488. faceColors?: Color4[];
  56489. sideOrientation?: number;
  56490. frontUVs?: Vector4;
  56491. backUVs?: Vector4;
  56492. updatable?: boolean;
  56493. }, scene?: Nullable<Scene>): Mesh;
  56494. /**
  56495. * Creates a tiled box mesh
  56496. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56498. * @param name defines the name of the mesh
  56499. * @param options defines the options used to create the mesh
  56500. * @param scene defines the hosting scene
  56501. * @returns the tiled box mesh
  56502. */
  56503. static CreateTiledBox(name: string, options: {
  56504. pattern?: number;
  56505. size?: number;
  56506. width?: number;
  56507. height?: number;
  56508. depth: number;
  56509. tileSize?: number;
  56510. tileWidth?: number;
  56511. tileHeight?: number;
  56512. faceUV?: Vector4[];
  56513. faceColors?: Color4[];
  56514. alignHorizontal?: number;
  56515. alignVertical?: number;
  56516. sideOrientation?: number;
  56517. updatable?: boolean;
  56518. }, scene?: Nullable<Scene>): Mesh;
  56519. /**
  56520. * Creates a sphere mesh
  56521. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56522. * * 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`)
  56523. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56524. * * 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
  56525. * * 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)
  56526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56527. * * 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
  56528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56529. * @param name defines the name of the mesh
  56530. * @param options defines the options used to create the mesh
  56531. * @param scene defines the hosting scene
  56532. * @returns the sphere mesh
  56533. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56534. */
  56535. static CreateSphere(name: string, options: {
  56536. segments?: number;
  56537. diameter?: number;
  56538. diameterX?: number;
  56539. diameterY?: number;
  56540. diameterZ?: number;
  56541. arc?: number;
  56542. slice?: number;
  56543. sideOrientation?: number;
  56544. frontUVs?: Vector4;
  56545. backUVs?: Vector4;
  56546. updatable?: boolean;
  56547. }, scene?: Nullable<Scene>): Mesh;
  56548. /**
  56549. * Creates a plane polygonal mesh. By default, this is a disc
  56550. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56551. * * 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
  56552. * * 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
  56553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56554. * * 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
  56555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56556. * @param name defines the name of the mesh
  56557. * @param options defines the options used to create the mesh
  56558. * @param scene defines the hosting scene
  56559. * @returns the plane polygonal mesh
  56560. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56561. */
  56562. static CreateDisc(name: string, options: {
  56563. radius?: number;
  56564. tessellation?: number;
  56565. arc?: number;
  56566. updatable?: boolean;
  56567. sideOrientation?: number;
  56568. frontUVs?: Vector4;
  56569. backUVs?: Vector4;
  56570. }, scene?: Nullable<Scene>): Mesh;
  56571. /**
  56572. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56573. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56574. * * 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`)
  56575. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56576. * * 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
  56577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56578. * * 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
  56579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56580. * @param name defines the name of the mesh
  56581. * @param options defines the options used to create the mesh
  56582. * @param scene defines the hosting scene
  56583. * @returns the icosahedron mesh
  56584. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56585. */
  56586. static CreateIcoSphere(name: string, options: {
  56587. radius?: number;
  56588. radiusX?: number;
  56589. radiusY?: number;
  56590. radiusZ?: number;
  56591. flat?: boolean;
  56592. subdivisions?: number;
  56593. sideOrientation?: number;
  56594. frontUVs?: Vector4;
  56595. backUVs?: Vector4;
  56596. updatable?: boolean;
  56597. }, scene?: Nullable<Scene>): Mesh;
  56598. /**
  56599. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56600. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56601. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56602. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56603. * * 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
  56604. * * 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
  56605. * * 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
  56606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56607. * * 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
  56608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56609. * * 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
  56610. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56611. * * 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
  56612. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56614. * @param name defines the name of the mesh
  56615. * @param options defines the options used to create the mesh
  56616. * @param scene defines the hosting scene
  56617. * @returns the ribbon mesh
  56618. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56620. */
  56621. static CreateRibbon(name: string, options: {
  56622. pathArray: Vector3[][];
  56623. closeArray?: boolean;
  56624. closePath?: boolean;
  56625. offset?: number;
  56626. updatable?: boolean;
  56627. sideOrientation?: number;
  56628. frontUVs?: Vector4;
  56629. backUVs?: Vector4;
  56630. instance?: Mesh;
  56631. invertUV?: boolean;
  56632. uvs?: Vector2[];
  56633. colors?: Color4[];
  56634. }, scene?: Nullable<Scene>): Mesh;
  56635. /**
  56636. * Creates a cylinder or a cone mesh
  56637. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56638. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56639. * * 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.
  56640. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56641. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56642. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56643. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56644. * * 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).
  56645. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56646. * * 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).
  56647. * * 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
  56648. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56649. * * 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
  56650. * * 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.
  56651. * * If `enclose` is false, a ring surface is one element.
  56652. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56653. * * 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
  56654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56655. * * 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
  56656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56657. * @param name defines the name of the mesh
  56658. * @param options defines the options used to create the mesh
  56659. * @param scene defines the hosting scene
  56660. * @returns the cylinder mesh
  56661. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56662. */
  56663. static CreateCylinder(name: string, options: {
  56664. height?: number;
  56665. diameterTop?: number;
  56666. diameterBottom?: number;
  56667. diameter?: number;
  56668. tessellation?: number;
  56669. subdivisions?: number;
  56670. arc?: number;
  56671. faceColors?: Color4[];
  56672. faceUV?: Vector4[];
  56673. updatable?: boolean;
  56674. hasRings?: boolean;
  56675. enclose?: boolean;
  56676. cap?: number;
  56677. sideOrientation?: number;
  56678. frontUVs?: Vector4;
  56679. backUVs?: Vector4;
  56680. }, scene?: Nullable<Scene>): Mesh;
  56681. /**
  56682. * Creates a torus mesh
  56683. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56684. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56685. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56687. * * 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
  56688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56689. * @param name defines the name of the mesh
  56690. * @param options defines the options used to create the mesh
  56691. * @param scene defines the hosting scene
  56692. * @returns the torus mesh
  56693. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56694. */
  56695. static CreateTorus(name: string, options: {
  56696. diameter?: number;
  56697. thickness?: number;
  56698. tessellation?: number;
  56699. updatable?: boolean;
  56700. sideOrientation?: number;
  56701. frontUVs?: Vector4;
  56702. backUVs?: Vector4;
  56703. }, scene?: Nullable<Scene>): Mesh;
  56704. /**
  56705. * Creates a torus knot mesh
  56706. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56707. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56708. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56709. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56711. * * 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
  56712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56713. * @param name defines the name of the mesh
  56714. * @param options defines the options used to create the mesh
  56715. * @param scene defines the hosting scene
  56716. * @returns the torus knot mesh
  56717. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56718. */
  56719. static CreateTorusKnot(name: string, options: {
  56720. radius?: number;
  56721. tube?: number;
  56722. radialSegments?: number;
  56723. tubularSegments?: number;
  56724. p?: number;
  56725. q?: number;
  56726. updatable?: boolean;
  56727. sideOrientation?: number;
  56728. frontUVs?: Vector4;
  56729. backUVs?: Vector4;
  56730. }, scene?: Nullable<Scene>): Mesh;
  56731. /**
  56732. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56733. * * 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
  56734. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56735. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56736. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56737. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56738. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56739. * * 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
  56740. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56743. * @param name defines the name of the new line system
  56744. * @param options defines the options used to create the line system
  56745. * @param scene defines the hosting scene
  56746. * @returns a new line system mesh
  56747. */
  56748. static CreateLineSystem(name: string, options: {
  56749. lines: Vector3[][];
  56750. updatable?: boolean;
  56751. instance?: Nullable<LinesMesh>;
  56752. colors?: Nullable<Color4[][]>;
  56753. useVertexAlpha?: boolean;
  56754. }, scene: Nullable<Scene>): LinesMesh;
  56755. /**
  56756. * Creates a line mesh
  56757. * 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
  56758. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56759. * * The parameter `points` is an array successive Vector3
  56760. * * 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
  56761. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56762. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56763. * * When updating an instance, remember that only point positions can change, not the number of points
  56764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56766. * @param name defines the name of the new line system
  56767. * @param options defines the options used to create the line system
  56768. * @param scene defines the hosting scene
  56769. * @returns a new line mesh
  56770. */
  56771. static CreateLines(name: string, options: {
  56772. points: Vector3[];
  56773. updatable?: boolean;
  56774. instance?: Nullable<LinesMesh>;
  56775. colors?: Color4[];
  56776. useVertexAlpha?: boolean;
  56777. }, scene?: Nullable<Scene>): LinesMesh;
  56778. /**
  56779. * Creates a dashed line mesh
  56780. * * 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
  56781. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56782. * * The parameter `points` is an array successive Vector3
  56783. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56784. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56785. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56786. * * 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
  56787. * * When updating an instance, remember that only point positions can change, not the number of points
  56788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56789. * @param name defines the name of the mesh
  56790. * @param options defines the options used to create the mesh
  56791. * @param scene defines the hosting scene
  56792. * @returns the dashed line mesh
  56793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56794. */
  56795. static CreateDashedLines(name: string, options: {
  56796. points: Vector3[];
  56797. dashSize?: number;
  56798. gapSize?: number;
  56799. dashNb?: number;
  56800. updatable?: boolean;
  56801. instance?: LinesMesh;
  56802. }, scene?: Nullable<Scene>): LinesMesh;
  56803. /**
  56804. * 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.
  56805. * * 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.
  56806. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56807. * * 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.
  56808. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56809. * * 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
  56810. * * 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
  56811. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56813. * * 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
  56814. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56816. * @param name defines the name of the mesh
  56817. * @param options defines the options used to create the mesh
  56818. * @param scene defines the hosting scene
  56819. * @returns the extruded shape mesh
  56820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56822. */
  56823. static ExtrudeShape(name: string, options: {
  56824. shape: Vector3[];
  56825. path: Vector3[];
  56826. scale?: number;
  56827. rotation?: number;
  56828. cap?: number;
  56829. updatable?: boolean;
  56830. sideOrientation?: number;
  56831. frontUVs?: Vector4;
  56832. backUVs?: Vector4;
  56833. instance?: Mesh;
  56834. invertUV?: boolean;
  56835. }, scene?: Nullable<Scene>): Mesh;
  56836. /**
  56837. * Creates an custom extruded shape mesh.
  56838. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56839. * * 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.
  56840. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56841. * * 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
  56842. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56843. * * 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
  56844. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56845. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56846. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56847. * * 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
  56848. * * 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
  56849. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56851. * * 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
  56852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56854. * @param name defines the name of the mesh
  56855. * @param options defines the options used to create the mesh
  56856. * @param scene defines the hosting scene
  56857. * @returns the custom extruded shape mesh
  56858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56861. */
  56862. static ExtrudeShapeCustom(name: string, options: {
  56863. shape: Vector3[];
  56864. path: Vector3[];
  56865. scaleFunction?: any;
  56866. rotationFunction?: any;
  56867. ribbonCloseArray?: boolean;
  56868. ribbonClosePath?: boolean;
  56869. cap?: number;
  56870. updatable?: boolean;
  56871. sideOrientation?: number;
  56872. frontUVs?: Vector4;
  56873. backUVs?: Vector4;
  56874. instance?: Mesh;
  56875. invertUV?: boolean;
  56876. }, scene?: Nullable<Scene>): Mesh;
  56877. /**
  56878. * Creates lathe mesh.
  56879. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56880. * * 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
  56881. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56882. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56883. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56884. * * 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
  56885. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56886. * * 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
  56887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56888. * * 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
  56889. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56891. * @param name defines the name of the mesh
  56892. * @param options defines the options used to create the mesh
  56893. * @param scene defines the hosting scene
  56894. * @returns the lathe mesh
  56895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56896. */
  56897. static CreateLathe(name: string, options: {
  56898. shape: Vector3[];
  56899. radius?: number;
  56900. tessellation?: number;
  56901. clip?: number;
  56902. arc?: number;
  56903. closed?: boolean;
  56904. updatable?: boolean;
  56905. sideOrientation?: number;
  56906. frontUVs?: Vector4;
  56907. backUVs?: Vector4;
  56908. cap?: number;
  56909. invertUV?: boolean;
  56910. }, scene?: Nullable<Scene>): Mesh;
  56911. /**
  56912. * Creates a tiled plane mesh
  56913. * * You can set a limited pattern arrangement with the tiles
  56914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56915. * * 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
  56916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56917. * @param name defines the name of the mesh
  56918. * @param options defines the options used to create the mesh
  56919. * @param scene defines the hosting scene
  56920. * @returns the plane mesh
  56921. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56922. */
  56923. static CreateTiledPlane(name: string, options: {
  56924. pattern?: number;
  56925. tileSize?: number;
  56926. tileWidth?: number;
  56927. tileHeight?: number;
  56928. size?: number;
  56929. width?: number;
  56930. height?: number;
  56931. alignHorizontal?: number;
  56932. alignVertical?: number;
  56933. sideOrientation?: number;
  56934. frontUVs?: Vector4;
  56935. backUVs?: Vector4;
  56936. updatable?: boolean;
  56937. }, scene?: Nullable<Scene>): Mesh;
  56938. /**
  56939. * Creates a plane mesh
  56940. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56941. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56942. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56944. * * 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
  56945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56946. * @param name defines the name of the mesh
  56947. * @param options defines the options used to create the mesh
  56948. * @param scene defines the hosting scene
  56949. * @returns the plane mesh
  56950. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56951. */
  56952. static CreatePlane(name: string, options: {
  56953. size?: number;
  56954. width?: number;
  56955. height?: number;
  56956. sideOrientation?: number;
  56957. frontUVs?: Vector4;
  56958. backUVs?: Vector4;
  56959. updatable?: boolean;
  56960. sourcePlane?: Plane;
  56961. }, scene?: Nullable<Scene>): Mesh;
  56962. /**
  56963. * Creates a ground mesh
  56964. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56965. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56967. * @param name defines the name of the mesh
  56968. * @param options defines the options used to create the mesh
  56969. * @param scene defines the hosting scene
  56970. * @returns the ground mesh
  56971. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56972. */
  56973. static CreateGround(name: string, options: {
  56974. width?: number;
  56975. height?: number;
  56976. subdivisions?: number;
  56977. subdivisionsX?: number;
  56978. subdivisionsY?: number;
  56979. updatable?: boolean;
  56980. }, scene?: Nullable<Scene>): Mesh;
  56981. /**
  56982. * Creates a tiled ground mesh
  56983. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56984. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56985. * * 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
  56986. * * 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
  56987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56988. * @param name defines the name of the mesh
  56989. * @param options defines the options used to create the mesh
  56990. * @param scene defines the hosting scene
  56991. * @returns the tiled ground mesh
  56992. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56993. */
  56994. static CreateTiledGround(name: string, options: {
  56995. xmin: number;
  56996. zmin: number;
  56997. xmax: number;
  56998. zmax: number;
  56999. subdivisions?: {
  57000. w: number;
  57001. h: number;
  57002. };
  57003. precision?: {
  57004. w: number;
  57005. h: number;
  57006. };
  57007. updatable?: boolean;
  57008. }, scene?: Nullable<Scene>): Mesh;
  57009. /**
  57010. * Creates a ground mesh from a height map
  57011. * * The parameter `url` sets the URL of the height map image resource.
  57012. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57013. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57014. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57015. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57016. * * 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.
  57017. * * 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).
  57018. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57020. * @param name defines the name of the mesh
  57021. * @param url defines the url to the height map
  57022. * @param options defines the options used to create the mesh
  57023. * @param scene defines the hosting scene
  57024. * @returns the ground mesh
  57025. * @see https://doc.babylonjs.com/babylon101/height_map
  57026. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57027. */
  57028. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57029. width?: number;
  57030. height?: number;
  57031. subdivisions?: number;
  57032. minHeight?: number;
  57033. maxHeight?: number;
  57034. colorFilter?: Color3;
  57035. alphaFilter?: number;
  57036. updatable?: boolean;
  57037. onReady?: (mesh: GroundMesh) => void;
  57038. }, scene?: Nullable<Scene>): GroundMesh;
  57039. /**
  57040. * Creates a polygon mesh
  57041. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57042. * * 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
  57043. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57045. * * 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)
  57046. * * Remember you can only change the shape positions, not their number when updating a polygon
  57047. * @param name defines the name of the mesh
  57048. * @param options defines the options used to create the mesh
  57049. * @param scene defines the hosting scene
  57050. * @param earcutInjection can be used to inject your own earcut reference
  57051. * @returns the polygon mesh
  57052. */
  57053. static CreatePolygon(name: string, options: {
  57054. shape: Vector3[];
  57055. holes?: Vector3[][];
  57056. depth?: number;
  57057. faceUV?: Vector4[];
  57058. faceColors?: Color4[];
  57059. updatable?: boolean;
  57060. sideOrientation?: number;
  57061. frontUVs?: Vector4;
  57062. backUVs?: Vector4;
  57063. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57064. /**
  57065. * Creates an extruded polygon mesh, with depth in the Y direction.
  57066. * * 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)
  57067. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57068. * @param name defines the name of the mesh
  57069. * @param options defines the options used to create the mesh
  57070. * @param scene defines the hosting scene
  57071. * @param earcutInjection can be used to inject your own earcut reference
  57072. * @returns the polygon mesh
  57073. */
  57074. static ExtrudePolygon(name: string, options: {
  57075. shape: Vector3[];
  57076. holes?: Vector3[][];
  57077. depth?: number;
  57078. faceUV?: Vector4[];
  57079. faceColors?: Color4[];
  57080. updatable?: boolean;
  57081. sideOrientation?: number;
  57082. frontUVs?: Vector4;
  57083. backUVs?: Vector4;
  57084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57085. /**
  57086. * Creates a tube mesh.
  57087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57092. * * 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)
  57093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57094. * * 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
  57095. * * 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
  57096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57097. * * 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
  57098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57100. * @param name defines the name of the mesh
  57101. * @param options defines the options used to create the mesh
  57102. * @param scene defines the hosting scene
  57103. * @returns the tube mesh
  57104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57106. */
  57107. static CreateTube(name: string, options: {
  57108. path: Vector3[];
  57109. radius?: number;
  57110. tessellation?: number;
  57111. radiusFunction?: {
  57112. (i: number, distance: number): number;
  57113. };
  57114. cap?: number;
  57115. arc?: number;
  57116. updatable?: boolean;
  57117. sideOrientation?: number;
  57118. frontUVs?: Vector4;
  57119. backUVs?: Vector4;
  57120. instance?: Mesh;
  57121. invertUV?: boolean;
  57122. }, scene?: Nullable<Scene>): Mesh;
  57123. /**
  57124. * Creates a polyhedron mesh
  57125. * * 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
  57126. * * The parameter `size` (positive float, default 1) sets the polygon size
  57127. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57128. * * 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`
  57129. * * 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
  57130. * * 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)`)
  57131. * * 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
  57132. * * 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
  57133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57134. * * 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
  57135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57136. * @param name defines the name of the mesh
  57137. * @param options defines the options used to create the mesh
  57138. * @param scene defines the hosting scene
  57139. * @returns the polyhedron mesh
  57140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57141. */
  57142. static CreatePolyhedron(name: string, options: {
  57143. type?: number;
  57144. size?: number;
  57145. sizeX?: number;
  57146. sizeY?: number;
  57147. sizeZ?: number;
  57148. custom?: any;
  57149. faceUV?: Vector4[];
  57150. faceColors?: Color4[];
  57151. flat?: boolean;
  57152. updatable?: boolean;
  57153. sideOrientation?: number;
  57154. frontUVs?: Vector4;
  57155. backUVs?: Vector4;
  57156. }, scene?: Nullable<Scene>): Mesh;
  57157. /**
  57158. * Creates a decal mesh.
  57159. * 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
  57160. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57161. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57162. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57163. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57164. * @param name defines the name of the mesh
  57165. * @param sourceMesh defines the mesh where the decal must be applied
  57166. * @param options defines the options used to create the mesh
  57167. * @param scene defines the hosting scene
  57168. * @returns the decal mesh
  57169. * @see https://doc.babylonjs.com/how_to/decals
  57170. */
  57171. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57172. position?: Vector3;
  57173. normal?: Vector3;
  57174. size?: Vector3;
  57175. angle?: number;
  57176. }): Mesh;
  57177. }
  57178. }
  57179. declare module BABYLON {
  57180. /**
  57181. * A simplifier interface for future simplification implementations
  57182. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57183. */
  57184. export interface ISimplifier {
  57185. /**
  57186. * Simplification of a given mesh according to the given settings.
  57187. * Since this requires computation, it is assumed that the function runs async.
  57188. * @param settings The settings of the simplification, including quality and distance
  57189. * @param successCallback A callback that will be called after the mesh was simplified.
  57190. * @param errorCallback in case of an error, this callback will be called. optional.
  57191. */
  57192. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57193. }
  57194. /**
  57195. * Expected simplification settings.
  57196. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57197. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57198. */
  57199. export interface ISimplificationSettings {
  57200. /**
  57201. * Gets or sets the expected quality
  57202. */
  57203. quality: number;
  57204. /**
  57205. * Gets or sets the distance when this optimized version should be used
  57206. */
  57207. distance: number;
  57208. /**
  57209. * Gets an already optimized mesh
  57210. */
  57211. optimizeMesh?: boolean;
  57212. }
  57213. /**
  57214. * Class used to specify simplification options
  57215. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57216. */
  57217. export class SimplificationSettings implements ISimplificationSettings {
  57218. /** expected quality */
  57219. quality: number;
  57220. /** distance when this optimized version should be used */
  57221. distance: number;
  57222. /** already optimized mesh */
  57223. optimizeMesh?: boolean | undefined;
  57224. /**
  57225. * Creates a SimplificationSettings
  57226. * @param quality expected quality
  57227. * @param distance distance when this optimized version should be used
  57228. * @param optimizeMesh already optimized mesh
  57229. */
  57230. constructor(
  57231. /** expected quality */
  57232. quality: number,
  57233. /** distance when this optimized version should be used */
  57234. distance: number,
  57235. /** already optimized mesh */
  57236. optimizeMesh?: boolean | undefined);
  57237. }
  57238. /**
  57239. * Interface used to define a simplification task
  57240. */
  57241. export interface ISimplificationTask {
  57242. /**
  57243. * Array of settings
  57244. */
  57245. settings: Array<ISimplificationSettings>;
  57246. /**
  57247. * Simplification type
  57248. */
  57249. simplificationType: SimplificationType;
  57250. /**
  57251. * Mesh to simplify
  57252. */
  57253. mesh: Mesh;
  57254. /**
  57255. * Callback called on success
  57256. */
  57257. successCallback?: () => void;
  57258. /**
  57259. * Defines if parallel processing can be used
  57260. */
  57261. parallelProcessing: boolean;
  57262. }
  57263. /**
  57264. * Queue used to order the simplification tasks
  57265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57266. */
  57267. export class SimplificationQueue {
  57268. private _simplificationArray;
  57269. /**
  57270. * Gets a boolean indicating that the process is still running
  57271. */
  57272. running: boolean;
  57273. /**
  57274. * Creates a new queue
  57275. */
  57276. constructor();
  57277. /**
  57278. * Adds a new simplification task
  57279. * @param task defines a task to add
  57280. */
  57281. addTask(task: ISimplificationTask): void;
  57282. /**
  57283. * Execute next task
  57284. */
  57285. executeNext(): void;
  57286. /**
  57287. * Execute a simplification task
  57288. * @param task defines the task to run
  57289. */
  57290. runSimplification(task: ISimplificationTask): void;
  57291. private getSimplifier;
  57292. }
  57293. /**
  57294. * The implemented types of simplification
  57295. * At the moment only Quadratic Error Decimation is implemented
  57296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57297. */
  57298. export enum SimplificationType {
  57299. /** Quadratic error decimation */
  57300. QUADRATIC = 0
  57301. }
  57302. }
  57303. declare module BABYLON {
  57304. interface Scene {
  57305. /** @hidden (Backing field) */
  57306. _simplificationQueue: SimplificationQueue;
  57307. /**
  57308. * Gets or sets the simplification queue attached to the scene
  57309. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57310. */
  57311. simplificationQueue: SimplificationQueue;
  57312. }
  57313. interface Mesh {
  57314. /**
  57315. * Simplify the mesh according to the given array of settings.
  57316. * Function will return immediately and will simplify async
  57317. * @param settings a collection of simplification settings
  57318. * @param parallelProcessing should all levels calculate parallel or one after the other
  57319. * @param simplificationType the type of simplification to run
  57320. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57321. * @returns the current mesh
  57322. */
  57323. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57324. }
  57325. /**
  57326. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57327. * created in a scene
  57328. */
  57329. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57330. /**
  57331. * The component name helpfull to identify the component in the list of scene components.
  57332. */
  57333. readonly name: string;
  57334. /**
  57335. * The scene the component belongs to.
  57336. */
  57337. scene: Scene;
  57338. /**
  57339. * Creates a new instance of the component for the given scene
  57340. * @param scene Defines the scene to register the component in
  57341. */
  57342. constructor(scene: Scene);
  57343. /**
  57344. * Registers the component in a given scene
  57345. */
  57346. register(): void;
  57347. /**
  57348. * Rebuilds the elements related to this component in case of
  57349. * context lost for instance.
  57350. */
  57351. rebuild(): void;
  57352. /**
  57353. * Disposes the component and the associated ressources
  57354. */
  57355. dispose(): void;
  57356. private _beforeCameraUpdate;
  57357. }
  57358. }
  57359. declare module BABYLON {
  57360. /**
  57361. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57362. */
  57363. export interface INavigationEnginePlugin {
  57364. /**
  57365. * plugin name
  57366. */
  57367. name: string;
  57368. /**
  57369. * Creates a navigation mesh
  57370. * @param meshes array of all the geometry used to compute the navigatio mesh
  57371. * @param parameters bunch of parameters used to filter geometry
  57372. */
  57373. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57374. /**
  57375. * Create a navigation mesh debug mesh
  57376. * @param scene is where the mesh will be added
  57377. * @returns debug display mesh
  57378. */
  57379. createDebugNavMesh(scene: Scene): Mesh;
  57380. /**
  57381. * Get a navigation mesh constrained position, closest to the parameter position
  57382. * @param position world position
  57383. * @returns the closest point to position constrained by the navigation mesh
  57384. */
  57385. getClosestPoint(position: Vector3): Vector3;
  57386. /**
  57387. * Get a navigation mesh constrained position, within a particular radius
  57388. * @param position world position
  57389. * @param maxRadius the maximum distance to the constrained world position
  57390. * @returns the closest point to position constrained by the navigation mesh
  57391. */
  57392. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57393. /**
  57394. * Compute the final position from a segment made of destination-position
  57395. * @param position world position
  57396. * @param destination world position
  57397. * @returns the resulting point along the navmesh
  57398. */
  57399. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57400. /**
  57401. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57402. * @param start world position
  57403. * @param end world position
  57404. * @returns array containing world position composing the path
  57405. */
  57406. computePath(start: Vector3, end: Vector3): Vector3[];
  57407. /**
  57408. * If this plugin is supported
  57409. * @returns true if plugin is supported
  57410. */
  57411. isSupported(): boolean;
  57412. /**
  57413. * Create a new Crowd so you can add agents
  57414. * @param maxAgents the maximum agent count in the crowd
  57415. * @param maxAgentRadius the maximum radius an agent can have
  57416. * @param scene to attach the crowd to
  57417. * @returns the crowd you can add agents to
  57418. */
  57419. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57420. /**
  57421. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57422. * The queries will try to find a solution within those bounds
  57423. * default is (1,1,1)
  57424. * @param extent x,y,z value that define the extent around the queries point of reference
  57425. */
  57426. setDefaultQueryExtent(extent: Vector3): void;
  57427. /**
  57428. * Get the Bounding box extent specified by setDefaultQueryExtent
  57429. * @returns the box extent values
  57430. */
  57431. getDefaultQueryExtent(): Vector3;
  57432. /**
  57433. * Release all resources
  57434. */
  57435. dispose(): void;
  57436. }
  57437. /**
  57438. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57439. */
  57440. export interface ICrowd {
  57441. /**
  57442. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57443. * You can attach anything to that node. The node position is updated in the scene update tick.
  57444. * @param pos world position that will be constrained by the navigation mesh
  57445. * @param parameters agent parameters
  57446. * @param transform hooked to the agent that will be update by the scene
  57447. * @returns agent index
  57448. */
  57449. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57450. /**
  57451. * Returns the agent position in world space
  57452. * @param index agent index returned by addAgent
  57453. * @returns world space position
  57454. */
  57455. getAgentPosition(index: number): Vector3;
  57456. /**
  57457. * Gets the agent velocity in world space
  57458. * @param index agent index returned by addAgent
  57459. * @returns world space velocity
  57460. */
  57461. getAgentVelocity(index: number): Vector3;
  57462. /**
  57463. * remove a particular agent previously created
  57464. * @param index agent index returned by addAgent
  57465. */
  57466. removeAgent(index: number): void;
  57467. /**
  57468. * get the list of all agents attached to this crowd
  57469. * @returns list of agent indices
  57470. */
  57471. getAgents(): number[];
  57472. /**
  57473. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57474. * @param deltaTime in seconds
  57475. */
  57476. update(deltaTime: number): void;
  57477. /**
  57478. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57479. * @param index agent index returned by addAgent
  57480. * @param destination targeted world position
  57481. */
  57482. agentGoto(index: number, destination: Vector3): void;
  57483. /**
  57484. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57485. * The queries will try to find a solution within those bounds
  57486. * default is (1,1,1)
  57487. * @param extent x,y,z value that define the extent around the queries point of reference
  57488. */
  57489. setDefaultQueryExtent(extent: Vector3): void;
  57490. /**
  57491. * Get the Bounding box extent specified by setDefaultQueryExtent
  57492. * @returns the box extent values
  57493. */
  57494. getDefaultQueryExtent(): Vector3;
  57495. /**
  57496. * Release all resources
  57497. */
  57498. dispose(): void;
  57499. }
  57500. /**
  57501. * Configures an agent
  57502. */
  57503. export interface IAgentParameters {
  57504. /**
  57505. * Agent radius. [Limit: >= 0]
  57506. */
  57507. radius: number;
  57508. /**
  57509. * Agent height. [Limit: > 0]
  57510. */
  57511. height: number;
  57512. /**
  57513. * Maximum allowed acceleration. [Limit: >= 0]
  57514. */
  57515. maxAcceleration: number;
  57516. /**
  57517. * Maximum allowed speed. [Limit: >= 0]
  57518. */
  57519. maxSpeed: number;
  57520. /**
  57521. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57522. */
  57523. collisionQueryRange: number;
  57524. /**
  57525. * The path visibility optimization range. [Limit: > 0]
  57526. */
  57527. pathOptimizationRange: number;
  57528. /**
  57529. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57530. */
  57531. separationWeight: number;
  57532. }
  57533. /**
  57534. * Configures the navigation mesh creation
  57535. */
  57536. export interface INavMeshParameters {
  57537. /**
  57538. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57539. */
  57540. cs: number;
  57541. /**
  57542. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57543. */
  57544. ch: number;
  57545. /**
  57546. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57547. */
  57548. walkableSlopeAngle: number;
  57549. /**
  57550. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57551. * be considered walkable. [Limit: >= 3] [Units: vx]
  57552. */
  57553. walkableHeight: number;
  57554. /**
  57555. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57556. */
  57557. walkableClimb: number;
  57558. /**
  57559. * The distance to erode/shrink the walkable area of the heightfield away from
  57560. * obstructions. [Limit: >=0] [Units: vx]
  57561. */
  57562. walkableRadius: number;
  57563. /**
  57564. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57565. */
  57566. maxEdgeLen: number;
  57567. /**
  57568. * The maximum distance a simplfied contour's border edges should deviate
  57569. * the original raw contour. [Limit: >=0] [Units: vx]
  57570. */
  57571. maxSimplificationError: number;
  57572. /**
  57573. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57574. */
  57575. minRegionArea: number;
  57576. /**
  57577. * Any regions with a span count smaller than this value will, if possible,
  57578. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57579. */
  57580. mergeRegionArea: number;
  57581. /**
  57582. * The maximum number of vertices allowed for polygons generated during the
  57583. * contour to polygon conversion process. [Limit: >= 3]
  57584. */
  57585. maxVertsPerPoly: number;
  57586. /**
  57587. * Sets the sampling distance to use when generating the detail mesh.
  57588. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57589. */
  57590. detailSampleDist: number;
  57591. /**
  57592. * The maximum distance the detail mesh surface should deviate from heightfield
  57593. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57594. */
  57595. detailSampleMaxError: number;
  57596. }
  57597. }
  57598. declare module BABYLON {
  57599. /**
  57600. * RecastJS navigation plugin
  57601. */
  57602. export class RecastJSPlugin implements INavigationEnginePlugin {
  57603. /**
  57604. * Reference to the Recast library
  57605. */
  57606. bjsRECAST: any;
  57607. /**
  57608. * plugin name
  57609. */
  57610. name: string;
  57611. /**
  57612. * the first navmesh created. We might extend this to support multiple navmeshes
  57613. */
  57614. navMesh: any;
  57615. /**
  57616. * Initializes the recastJS plugin
  57617. * @param recastInjection can be used to inject your own recast reference
  57618. */
  57619. constructor(recastInjection?: any);
  57620. /**
  57621. * Creates a navigation mesh
  57622. * @param meshes array of all the geometry used to compute the navigatio mesh
  57623. * @param parameters bunch of parameters used to filter geometry
  57624. */
  57625. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57626. /**
  57627. * Create a navigation mesh debug mesh
  57628. * @param scene is where the mesh will be added
  57629. * @returns debug display mesh
  57630. */
  57631. createDebugNavMesh(scene: Scene): Mesh;
  57632. /**
  57633. * Get a navigation mesh constrained position, closest to the parameter position
  57634. * @param position world position
  57635. * @returns the closest point to position constrained by the navigation mesh
  57636. */
  57637. getClosestPoint(position: Vector3): Vector3;
  57638. /**
  57639. * Get a navigation mesh constrained position, within a particular radius
  57640. * @param position world position
  57641. * @param maxRadius the maximum distance to the constrained world position
  57642. * @returns the closest point to position constrained by the navigation mesh
  57643. */
  57644. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57645. /**
  57646. * Compute the final position from a segment made of destination-position
  57647. * @param position world position
  57648. * @param destination world position
  57649. * @returns the resulting point along the navmesh
  57650. */
  57651. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57652. /**
  57653. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57654. * @param start world position
  57655. * @param end world position
  57656. * @returns array containing world position composing the path
  57657. */
  57658. computePath(start: Vector3, end: Vector3): Vector3[];
  57659. /**
  57660. * Create a new Crowd so you can add agents
  57661. * @param maxAgents the maximum agent count in the crowd
  57662. * @param maxAgentRadius the maximum radius an agent can have
  57663. * @param scene to attach the crowd to
  57664. * @returns the crowd you can add agents to
  57665. */
  57666. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57667. /**
  57668. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57669. * The queries will try to find a solution within those bounds
  57670. * default is (1,1,1)
  57671. * @param extent x,y,z value that define the extent around the queries point of reference
  57672. */
  57673. setDefaultQueryExtent(extent: Vector3): void;
  57674. /**
  57675. * Get the Bounding box extent specified by setDefaultQueryExtent
  57676. * @returns the box extent values
  57677. */
  57678. getDefaultQueryExtent(): Vector3;
  57679. /**
  57680. * Disposes
  57681. */
  57682. dispose(): void;
  57683. /**
  57684. * If this plugin is supported
  57685. * @returns true if plugin is supported
  57686. */
  57687. isSupported(): boolean;
  57688. }
  57689. /**
  57690. * Recast detour crowd implementation
  57691. */
  57692. export class RecastJSCrowd implements ICrowd {
  57693. /**
  57694. * Recast/detour plugin
  57695. */
  57696. bjsRECASTPlugin: RecastJSPlugin;
  57697. /**
  57698. * Link to the detour crowd
  57699. */
  57700. recastCrowd: any;
  57701. /**
  57702. * One transform per agent
  57703. */
  57704. transforms: TransformNode[];
  57705. /**
  57706. * All agents created
  57707. */
  57708. agents: number[];
  57709. /**
  57710. * Link to the scene is kept to unregister the crowd from the scene
  57711. */
  57712. private _scene;
  57713. /**
  57714. * Observer for crowd updates
  57715. */
  57716. private _onBeforeAnimationsObserver;
  57717. /**
  57718. * Constructor
  57719. * @param plugin recastJS plugin
  57720. * @param maxAgents the maximum agent count in the crowd
  57721. * @param maxAgentRadius the maximum radius an agent can have
  57722. * @param scene to attach the crowd to
  57723. * @returns the crowd you can add agents to
  57724. */
  57725. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57726. /**
  57727. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57728. * You can attach anything to that node. The node position is updated in the scene update tick.
  57729. * @param pos world position that will be constrained by the navigation mesh
  57730. * @param parameters agent parameters
  57731. * @param transform hooked to the agent that will be update by the scene
  57732. * @returns agent index
  57733. */
  57734. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57735. /**
  57736. * Returns the agent position in world space
  57737. * @param index agent index returned by addAgent
  57738. * @returns world space position
  57739. */
  57740. getAgentPosition(index: number): Vector3;
  57741. /**
  57742. * Returns the agent velocity in world space
  57743. * @param index agent index returned by addAgent
  57744. * @returns world space velocity
  57745. */
  57746. getAgentVelocity(index: number): Vector3;
  57747. /**
  57748. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57749. * @param index agent index returned by addAgent
  57750. * @param destination targeted world position
  57751. */
  57752. agentGoto(index: number, destination: Vector3): void;
  57753. /**
  57754. * remove a particular agent previously created
  57755. * @param index agent index returned by addAgent
  57756. */
  57757. removeAgent(index: number): void;
  57758. /**
  57759. * get the list of all agents attached to this crowd
  57760. * @returns list of agent indices
  57761. */
  57762. getAgents(): number[];
  57763. /**
  57764. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57765. * @param deltaTime in seconds
  57766. */
  57767. update(deltaTime: number): void;
  57768. /**
  57769. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57770. * The queries will try to find a solution within those bounds
  57771. * default is (1,1,1)
  57772. * @param extent x,y,z value that define the extent around the queries point of reference
  57773. */
  57774. setDefaultQueryExtent(extent: Vector3): void;
  57775. /**
  57776. * Get the Bounding box extent specified by setDefaultQueryExtent
  57777. * @returns the box extent values
  57778. */
  57779. getDefaultQueryExtent(): Vector3;
  57780. /**
  57781. * Release all resources
  57782. */
  57783. dispose(): void;
  57784. }
  57785. }
  57786. declare module BABYLON {
  57787. /**
  57788. * Class used to enable access to IndexedDB
  57789. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57790. */
  57791. export class Database implements IOfflineProvider {
  57792. private _callbackManifestChecked;
  57793. private _currentSceneUrl;
  57794. private _db;
  57795. private _enableSceneOffline;
  57796. private _enableTexturesOffline;
  57797. private _manifestVersionFound;
  57798. private _mustUpdateRessources;
  57799. private _hasReachedQuota;
  57800. private _isSupported;
  57801. private _idbFactory;
  57802. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57803. private static IsUASupportingBlobStorage;
  57804. /**
  57805. * Gets a boolean indicating if Database storate is enabled (off by default)
  57806. */
  57807. static IDBStorageEnabled: boolean;
  57808. /**
  57809. * Gets a boolean indicating if scene must be saved in the database
  57810. */
  57811. readonly enableSceneOffline: boolean;
  57812. /**
  57813. * Gets a boolean indicating if textures must be saved in the database
  57814. */
  57815. readonly enableTexturesOffline: boolean;
  57816. /**
  57817. * Creates a new Database
  57818. * @param urlToScene defines the url to load the scene
  57819. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57820. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57821. */
  57822. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57823. private static _ParseURL;
  57824. private static _ReturnFullUrlLocation;
  57825. private _checkManifestFile;
  57826. /**
  57827. * Open the database and make it available
  57828. * @param successCallback defines the callback to call on success
  57829. * @param errorCallback defines the callback to call on error
  57830. */
  57831. open(successCallback: () => void, errorCallback: () => void): void;
  57832. /**
  57833. * Loads an image from the database
  57834. * @param url defines the url to load from
  57835. * @param image defines the target DOM image
  57836. */
  57837. loadImage(url: string, image: HTMLImageElement): void;
  57838. private _loadImageFromDBAsync;
  57839. private _saveImageIntoDBAsync;
  57840. private _checkVersionFromDB;
  57841. private _loadVersionFromDBAsync;
  57842. private _saveVersionIntoDBAsync;
  57843. /**
  57844. * Loads a file from database
  57845. * @param url defines the URL to load from
  57846. * @param sceneLoaded defines a callback to call on success
  57847. * @param progressCallBack defines a callback to call when progress changed
  57848. * @param errorCallback defines a callback to call on error
  57849. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57850. */
  57851. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57852. private _loadFileAsync;
  57853. private _saveFileAsync;
  57854. /**
  57855. * Validates if xhr data is correct
  57856. * @param xhr defines the request to validate
  57857. * @param dataType defines the expected data type
  57858. * @returns true if data is correct
  57859. */
  57860. private static _ValidateXHRData;
  57861. }
  57862. }
  57863. declare module BABYLON {
  57864. /** @hidden */
  57865. export var gpuUpdateParticlesPixelShader: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module BABYLON {
  57871. /** @hidden */
  57872. export var gpuUpdateParticlesVertexShader: {
  57873. name: string;
  57874. shader: string;
  57875. };
  57876. }
  57877. declare module BABYLON {
  57878. /** @hidden */
  57879. export var clipPlaneFragmentDeclaration2: {
  57880. name: string;
  57881. shader: string;
  57882. };
  57883. }
  57884. declare module BABYLON {
  57885. /** @hidden */
  57886. export var gpuRenderParticlesPixelShader: {
  57887. name: string;
  57888. shader: string;
  57889. };
  57890. }
  57891. declare module BABYLON {
  57892. /** @hidden */
  57893. export var clipPlaneVertexDeclaration2: {
  57894. name: string;
  57895. shader: string;
  57896. };
  57897. }
  57898. declare module BABYLON {
  57899. /** @hidden */
  57900. export var gpuRenderParticlesVertexShader: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module BABYLON {
  57906. /**
  57907. * This represents a GPU particle system in Babylon
  57908. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57909. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57910. */
  57911. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57912. /**
  57913. * The layer mask we are rendering the particles through.
  57914. */
  57915. layerMask: number;
  57916. private _capacity;
  57917. private _activeCount;
  57918. private _currentActiveCount;
  57919. private _accumulatedCount;
  57920. private _renderEffect;
  57921. private _updateEffect;
  57922. private _buffer0;
  57923. private _buffer1;
  57924. private _spriteBuffer;
  57925. private _updateVAO;
  57926. private _renderVAO;
  57927. private _targetIndex;
  57928. private _sourceBuffer;
  57929. private _targetBuffer;
  57930. private _engine;
  57931. private _currentRenderId;
  57932. private _started;
  57933. private _stopped;
  57934. private _timeDelta;
  57935. private _randomTexture;
  57936. private _randomTexture2;
  57937. private _attributesStrideSize;
  57938. private _updateEffectOptions;
  57939. private _randomTextureSize;
  57940. private _actualFrame;
  57941. private readonly _rawTextureWidth;
  57942. /**
  57943. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57944. */
  57945. static readonly IsSupported: boolean;
  57946. /**
  57947. * An event triggered when the system is disposed.
  57948. */
  57949. onDisposeObservable: Observable<GPUParticleSystem>;
  57950. /**
  57951. * Gets the maximum number of particles active at the same time.
  57952. * @returns The max number of active particles.
  57953. */
  57954. getCapacity(): number;
  57955. /**
  57956. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57957. * to override the particles.
  57958. */
  57959. forceDepthWrite: boolean;
  57960. /**
  57961. * Gets or set the number of active particles
  57962. */
  57963. activeParticleCount: number;
  57964. private _preWarmDone;
  57965. /**
  57966. * Is this system ready to be used/rendered
  57967. * @return true if the system is ready
  57968. */
  57969. isReady(): boolean;
  57970. /**
  57971. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57972. * @returns True if it has been started, otherwise false.
  57973. */
  57974. isStarted(): boolean;
  57975. /**
  57976. * Starts the particle system and begins to emit
  57977. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57978. */
  57979. start(delay?: number): void;
  57980. /**
  57981. * Stops the particle system.
  57982. */
  57983. stop(): void;
  57984. /**
  57985. * Remove all active particles
  57986. */
  57987. reset(): void;
  57988. /**
  57989. * Returns the string "GPUParticleSystem"
  57990. * @returns a string containing the class name
  57991. */
  57992. getClassName(): string;
  57993. private _colorGradientsTexture;
  57994. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57995. /**
  57996. * Adds a new color gradient
  57997. * @param gradient defines the gradient to use (between 0 and 1)
  57998. * @param color1 defines the color to affect to the specified gradient
  57999. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58000. * @returns the current particle system
  58001. */
  58002. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58003. /**
  58004. * Remove a specific color gradient
  58005. * @param gradient defines the gradient to remove
  58006. * @returns the current particle system
  58007. */
  58008. removeColorGradient(gradient: number): GPUParticleSystem;
  58009. private _angularSpeedGradientsTexture;
  58010. private _sizeGradientsTexture;
  58011. private _velocityGradientsTexture;
  58012. private _limitVelocityGradientsTexture;
  58013. private _dragGradientsTexture;
  58014. private _addFactorGradient;
  58015. /**
  58016. * Adds a new size gradient
  58017. * @param gradient defines the gradient to use (between 0 and 1)
  58018. * @param factor defines the size factor to affect to the specified gradient
  58019. * @returns the current particle system
  58020. */
  58021. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58022. /**
  58023. * Remove a specific size gradient
  58024. * @param gradient defines the gradient to remove
  58025. * @returns the current particle system
  58026. */
  58027. removeSizeGradient(gradient: number): GPUParticleSystem;
  58028. /**
  58029. * Adds a new angular speed gradient
  58030. * @param gradient defines the gradient to use (between 0 and 1)
  58031. * @param factor defines the angular speed to affect to the specified gradient
  58032. * @returns the current particle system
  58033. */
  58034. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58035. /**
  58036. * Remove a specific angular speed gradient
  58037. * @param gradient defines the gradient to remove
  58038. * @returns the current particle system
  58039. */
  58040. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58041. /**
  58042. * Adds a new velocity gradient
  58043. * @param gradient defines the gradient to use (between 0 and 1)
  58044. * @param factor defines the velocity to affect to the specified gradient
  58045. * @returns the current particle system
  58046. */
  58047. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58048. /**
  58049. * Remove a specific velocity gradient
  58050. * @param gradient defines the gradient to remove
  58051. * @returns the current particle system
  58052. */
  58053. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58054. /**
  58055. * Adds a new limit velocity gradient
  58056. * @param gradient defines the gradient to use (between 0 and 1)
  58057. * @param factor defines the limit velocity value to affect to the specified gradient
  58058. * @returns the current particle system
  58059. */
  58060. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58061. /**
  58062. * Remove a specific limit velocity gradient
  58063. * @param gradient defines the gradient to remove
  58064. * @returns the current particle system
  58065. */
  58066. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58067. /**
  58068. * Adds a new drag gradient
  58069. * @param gradient defines the gradient to use (between 0 and 1)
  58070. * @param factor defines the drag value to affect to the specified gradient
  58071. * @returns the current particle system
  58072. */
  58073. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58074. /**
  58075. * Remove a specific drag gradient
  58076. * @param gradient defines the gradient to remove
  58077. * @returns the current particle system
  58078. */
  58079. removeDragGradient(gradient: number): GPUParticleSystem;
  58080. /**
  58081. * Not supported by GPUParticleSystem
  58082. * @param gradient defines the gradient to use (between 0 and 1)
  58083. * @param factor defines the emit rate value to affect to the specified gradient
  58084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58085. * @returns the current particle system
  58086. */
  58087. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58088. /**
  58089. * Not supported by GPUParticleSystem
  58090. * @param gradient defines the gradient to remove
  58091. * @returns the current particle system
  58092. */
  58093. removeEmitRateGradient(gradient: number): IParticleSystem;
  58094. /**
  58095. * Not supported by GPUParticleSystem
  58096. * @param gradient defines the gradient to use (between 0 and 1)
  58097. * @param factor defines the start size value to affect to the specified gradient
  58098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58099. * @returns the current particle system
  58100. */
  58101. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58102. /**
  58103. * Not supported by GPUParticleSystem
  58104. * @param gradient defines the gradient to remove
  58105. * @returns the current particle system
  58106. */
  58107. removeStartSizeGradient(gradient: number): IParticleSystem;
  58108. /**
  58109. * Not supported by GPUParticleSystem
  58110. * @param gradient defines the gradient to use (between 0 and 1)
  58111. * @param min defines the color remap minimal range
  58112. * @param max defines the color remap maximal range
  58113. * @returns the current particle system
  58114. */
  58115. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58116. /**
  58117. * Not supported by GPUParticleSystem
  58118. * @param gradient defines the gradient to remove
  58119. * @returns the current particle system
  58120. */
  58121. removeColorRemapGradient(): IParticleSystem;
  58122. /**
  58123. * Not supported by GPUParticleSystem
  58124. * @param gradient defines the gradient to use (between 0 and 1)
  58125. * @param min defines the alpha remap minimal range
  58126. * @param max defines the alpha remap maximal range
  58127. * @returns the current particle system
  58128. */
  58129. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58130. /**
  58131. * Not supported by GPUParticleSystem
  58132. * @param gradient defines the gradient to remove
  58133. * @returns the current particle system
  58134. */
  58135. removeAlphaRemapGradient(): IParticleSystem;
  58136. /**
  58137. * Not supported by GPUParticleSystem
  58138. * @param gradient defines the gradient to use (between 0 and 1)
  58139. * @param color defines the color to affect to the specified gradient
  58140. * @returns the current particle system
  58141. */
  58142. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58143. /**
  58144. * Not supported by GPUParticleSystem
  58145. * @param gradient defines the gradient to remove
  58146. * @returns the current particle system
  58147. */
  58148. removeRampGradient(): IParticleSystem;
  58149. /**
  58150. * Not supported by GPUParticleSystem
  58151. * @returns the list of ramp gradients
  58152. */
  58153. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58154. /**
  58155. * Not supported by GPUParticleSystem
  58156. * Gets or sets a boolean indicating that ramp gradients must be used
  58157. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58158. */
  58159. useRampGradients: boolean;
  58160. /**
  58161. * Not supported by GPUParticleSystem
  58162. * @param gradient defines the gradient to use (between 0 and 1)
  58163. * @param factor defines the life time factor to affect to the specified gradient
  58164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58165. * @returns the current particle system
  58166. */
  58167. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58168. /**
  58169. * Not supported by GPUParticleSystem
  58170. * @param gradient defines the gradient to remove
  58171. * @returns the current particle system
  58172. */
  58173. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58174. /**
  58175. * Instantiates a GPU particle system.
  58176. * 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.
  58177. * @param name The name of the particle system
  58178. * @param options The options used to create the system
  58179. * @param scene The scene the particle system belongs to
  58180. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58181. */
  58182. constructor(name: string, options: Partial<{
  58183. capacity: number;
  58184. randomTextureSize: number;
  58185. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58186. protected _reset(): void;
  58187. private _createUpdateVAO;
  58188. private _createRenderVAO;
  58189. private _initialize;
  58190. /** @hidden */
  58191. _recreateUpdateEffect(): void;
  58192. /** @hidden */
  58193. _recreateRenderEffect(): void;
  58194. /**
  58195. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58196. * @param preWarm defines if we are in the pre-warmimg phase
  58197. */
  58198. animate(preWarm?: boolean): void;
  58199. private _createFactorGradientTexture;
  58200. private _createSizeGradientTexture;
  58201. private _createAngularSpeedGradientTexture;
  58202. private _createVelocityGradientTexture;
  58203. private _createLimitVelocityGradientTexture;
  58204. private _createDragGradientTexture;
  58205. private _createColorGradientTexture;
  58206. /**
  58207. * Renders the particle system in its current state
  58208. * @param preWarm defines if the system should only update the particles but not render them
  58209. * @returns the current number of particles
  58210. */
  58211. render(preWarm?: boolean): number;
  58212. /**
  58213. * Rebuilds the particle system
  58214. */
  58215. rebuild(): void;
  58216. private _releaseBuffers;
  58217. private _releaseVAOs;
  58218. /**
  58219. * Disposes the particle system and free the associated resources
  58220. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58221. */
  58222. dispose(disposeTexture?: boolean): void;
  58223. /**
  58224. * Clones the particle system.
  58225. * @param name The name of the cloned object
  58226. * @param newEmitter The new emitter to use
  58227. * @returns the cloned particle system
  58228. */
  58229. clone(name: string, newEmitter: any): GPUParticleSystem;
  58230. /**
  58231. * Serializes the particle system to a JSON object.
  58232. * @returns the JSON object
  58233. */
  58234. serialize(): any;
  58235. /**
  58236. * Parses a JSON object to create a GPU particle system.
  58237. * @param parsedParticleSystem The JSON object to parse
  58238. * @param scene The scene to create the particle system in
  58239. * @param rootUrl The root url to use to load external dependencies like texture
  58240. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58241. * @returns the parsed GPU particle system
  58242. */
  58243. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58244. }
  58245. }
  58246. declare module BABYLON {
  58247. /**
  58248. * Represents a set of particle systems working together to create a specific effect
  58249. */
  58250. export class ParticleSystemSet implements IDisposable {
  58251. /**
  58252. * Gets or sets base Assets URL
  58253. */
  58254. static BaseAssetsUrl: string;
  58255. private _emitterCreationOptions;
  58256. private _emitterNode;
  58257. /**
  58258. * Gets the particle system list
  58259. */
  58260. systems: IParticleSystem[];
  58261. /**
  58262. * Gets the emitter node used with this set
  58263. */
  58264. readonly emitterNode: Nullable<TransformNode>;
  58265. /**
  58266. * Creates a new emitter mesh as a sphere
  58267. * @param options defines the options used to create the sphere
  58268. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58269. * @param scene defines the hosting scene
  58270. */
  58271. setEmitterAsSphere(options: {
  58272. diameter: number;
  58273. segments: number;
  58274. color: Color3;
  58275. }, renderingGroupId: number, scene: Scene): void;
  58276. /**
  58277. * Starts all particle systems of the set
  58278. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58279. */
  58280. start(emitter?: AbstractMesh): void;
  58281. /**
  58282. * Release all associated resources
  58283. */
  58284. dispose(): void;
  58285. /**
  58286. * Serialize the set into a JSON compatible object
  58287. * @returns a JSON compatible representation of the set
  58288. */
  58289. serialize(): any;
  58290. /**
  58291. * Parse a new ParticleSystemSet from a serialized source
  58292. * @param data defines a JSON compatible representation of the set
  58293. * @param scene defines the hosting scene
  58294. * @param gpu defines if we want GPU particles or CPU particles
  58295. * @returns a new ParticleSystemSet
  58296. */
  58297. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58298. }
  58299. }
  58300. declare module BABYLON {
  58301. /**
  58302. * This class is made for on one-liner static method to help creating particle system set.
  58303. */
  58304. export class ParticleHelper {
  58305. /**
  58306. * Gets or sets base Assets URL
  58307. */
  58308. static BaseAssetsUrl: string;
  58309. /**
  58310. * Create a default particle system that you can tweak
  58311. * @param emitter defines the emitter to use
  58312. * @param capacity defines the system capacity (default is 500 particles)
  58313. * @param scene defines the hosting scene
  58314. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58315. * @returns the new Particle system
  58316. */
  58317. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58318. /**
  58319. * This is the main static method (one-liner) of this helper to create different particle systems
  58320. * @param type This string represents the type to the particle system to create
  58321. * @param scene The scene where the particle system should live
  58322. * @param gpu If the system will use gpu
  58323. * @returns the ParticleSystemSet created
  58324. */
  58325. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58326. /**
  58327. * Static function used to export a particle system to a ParticleSystemSet variable.
  58328. * Please note that the emitter shape is not exported
  58329. * @param systems defines the particle systems to export
  58330. * @returns the created particle system set
  58331. */
  58332. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58333. }
  58334. }
  58335. declare module BABYLON {
  58336. interface Engine {
  58337. /**
  58338. * Create an effect to use with particle systems.
  58339. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58340. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58341. * @param uniformsNames defines a list of attribute names
  58342. * @param samplers defines an array of string used to represent textures
  58343. * @param defines defines the string containing the defines to use to compile the shaders
  58344. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58345. * @param onCompiled defines a function to call when the effect creation is successful
  58346. * @param onError defines a function to call when the effect creation has failed
  58347. * @returns the new Effect
  58348. */
  58349. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58350. }
  58351. interface Mesh {
  58352. /**
  58353. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58354. * @returns an array of IParticleSystem
  58355. */
  58356. getEmittedParticleSystems(): IParticleSystem[];
  58357. /**
  58358. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58359. * @returns an array of IParticleSystem
  58360. */
  58361. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58362. }
  58363. /**
  58364. * @hidden
  58365. */
  58366. export var _IDoNeedToBeInTheBuild: number;
  58367. }
  58368. declare module BABYLON {
  58369. /** Defines the 4 color options */
  58370. export enum PointColor {
  58371. /** color value */
  58372. Color = 2,
  58373. /** uv value */
  58374. UV = 1,
  58375. /** random value */
  58376. Random = 0,
  58377. /** stated value */
  58378. Stated = 3
  58379. }
  58380. /**
  58381. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58382. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  58383. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58384. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58385. *
  58386. * Full documentation here : TO BE ENTERED
  58387. */
  58388. export class PointsCloudSystem implements IDisposable {
  58389. /**
  58390. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58391. * Example : var p = SPS.particles[i];
  58392. */
  58393. particles: CloudPoint[];
  58394. /**
  58395. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58396. */
  58397. nbParticles: number;
  58398. /**
  58399. * This a counter for your own usage. It's not set by any SPS functions.
  58400. */
  58401. counter: number;
  58402. /**
  58403. * The PCS name. This name is also given to the underlying mesh.
  58404. */
  58405. name: string;
  58406. /**
  58407. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58408. */
  58409. mesh: Mesh;
  58410. /**
  58411. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58412. * Please read :
  58413. */
  58414. vars: any;
  58415. /**
  58416. * @hidden
  58417. */
  58418. _size: number;
  58419. private _scene;
  58420. private _promises;
  58421. private _positions;
  58422. private _indices;
  58423. private _normals;
  58424. private _colors;
  58425. private _uvs;
  58426. private _indices32;
  58427. private _positions32;
  58428. private _colors32;
  58429. private _uvs32;
  58430. private _updatable;
  58431. private _isVisibilityBoxLocked;
  58432. private _alwaysVisible;
  58433. private _groups;
  58434. private _groupCounter;
  58435. private _computeParticleColor;
  58436. private _computeParticleTexture;
  58437. private _computeParticleRotation;
  58438. private _computeBoundingBox;
  58439. private _isReady;
  58440. /**
  58441. * Creates a PCS (Points Cloud System) object
  58442. * @param name (String) is the PCS name, this will be the underlying mesh name
  58443. * @param pointSize (number) is the size for each point
  58444. * @param scene (Scene) is the scene in which the PCS is added
  58445. * @param options defines the options of the PCS e.g.
  58446. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58447. */
  58448. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58449. updatable?: boolean;
  58450. });
  58451. /**
  58452. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58453. * If no points were added to the PCS, the returned mesh is just a single point.
  58454. * @returns a promise for the created mesh
  58455. */
  58456. buildMeshAsync(): Promise<Mesh>;
  58457. /**
  58458. * @hidden
  58459. */
  58460. private _buildMesh;
  58461. private _addParticle;
  58462. private _randomUnitVector;
  58463. private _getColorIndicesForCoord;
  58464. private _setPointsColorOrUV;
  58465. private _colorFromTexture;
  58466. private _calculateDensity;
  58467. /**
  58468. * Adds points to the PCS in random positions within a unit sphere
  58469. * @param nb (positive integer) the number of particles to be created from this model
  58470. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58471. * @returns the number of groups in the system
  58472. */
  58473. addPoints(nb: number, pointFunction?: any): number;
  58474. /**
  58475. * Adds points to the PCS from the surface of the model shape
  58476. * @param mesh is any Mesh object that will be used as a surface model for the points
  58477. * @param nb (positive integer) the number of particles to be created from this model
  58478. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58479. * @param color (color3) to be used when colorWith is stated
  58480. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58481. * @returns the number of groups in the system
  58482. */
  58483. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58484. /**
  58485. * Adds points to the PCS inside the model shape
  58486. * @param mesh is any Mesh object that will be used as a surface model for the points
  58487. * @param nb (positive integer) the number of particles to be created from this model
  58488. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58489. * @param color (color4) to be used when colorWith is stated
  58490. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58491. * @returns the number of groups in the system
  58492. */
  58493. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58494. /**
  58495. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58496. * This method calls `updateParticle()` for each particle of the SPS.
  58497. * For an animated SPS, it is usually called within the render loop.
  58498. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58499. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58500. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58501. * @returns the PCS.
  58502. */
  58503. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58504. /**
  58505. * Disposes the PCS.
  58506. */
  58507. dispose(): void;
  58508. /**
  58509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58510. * doc :
  58511. * @returns the PCS.
  58512. */
  58513. refreshVisibleSize(): PointsCloudSystem;
  58514. /**
  58515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58516. * @param size the size (float) of the visibility box
  58517. * note : this doesn't lock the PCS mesh bounding box.
  58518. * doc :
  58519. */
  58520. setVisibilityBox(size: number): void;
  58521. /**
  58522. * Gets whether the PCS is always visible or not
  58523. * doc :
  58524. */
  58525. /**
  58526. * Sets the PCS as always visible or not
  58527. * doc :
  58528. */
  58529. isAlwaysVisible: boolean;
  58530. /**
  58531. * Tells to `setParticles()` to compute the particle rotations or not
  58532. * Default value : false. The PCS is faster when it's set to false
  58533. * Note : particle rotations are only applied to parent particles
  58534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58535. */
  58536. computeParticleRotation: boolean;
  58537. /**
  58538. * Tells to `setParticles()` to compute the particle colors or not.
  58539. * Default value : true. The PCS is faster when it's set to false.
  58540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58541. */
  58542. /**
  58543. * Gets if `setParticles()` computes the particle colors or not.
  58544. * Default value : false. The PCS is faster when it's set to false.
  58545. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58546. */
  58547. computeParticleColor: boolean;
  58548. /**
  58549. * Gets if `setParticles()` computes the particle textures or not.
  58550. * Default value : false. The PCS is faster when it's set to false.
  58551. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58552. */
  58553. computeParticleTexture: boolean;
  58554. /**
  58555. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58556. */
  58557. /**
  58558. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58559. */
  58560. computeBoundingBox: boolean;
  58561. /**
  58562. * This function does nothing. It may be overwritten to set all the particle first values.
  58563. * The PCS doesn't call this function, you may have to call it by your own.
  58564. * doc :
  58565. */
  58566. initParticles(): void;
  58567. /**
  58568. * This function does nothing. It may be overwritten to recycle a particle
  58569. * The PCS doesn't call this function, you can to call it
  58570. * doc :
  58571. * @param particle The particle to recycle
  58572. * @returns the recycled particle
  58573. */
  58574. recycleParticle(particle: CloudPoint): CloudPoint;
  58575. /**
  58576. * Updates a particle : this function should be overwritten by the user.
  58577. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58578. * doc :
  58579. * @example : just set a particle position or velocity and recycle conditions
  58580. * @param particle The particle to update
  58581. * @returns the updated particle
  58582. */
  58583. updateParticle(particle: CloudPoint): CloudPoint;
  58584. /**
  58585. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58586. * This does nothing and may be overwritten by the user.
  58587. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58588. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58589. * @param update the boolean update value actually passed to setParticles()
  58590. */
  58591. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58592. /**
  58593. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58594. * This will be passed three parameters.
  58595. * This does nothing and may be overwritten by the user.
  58596. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58597. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58598. * @param update the boolean update value actually passed to setParticles()
  58599. */
  58600. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58601. }
  58602. }
  58603. declare module BABYLON {
  58604. /**
  58605. * Represents one particle of a points cloud system.
  58606. */
  58607. export class CloudPoint {
  58608. /**
  58609. * particle global index
  58610. */
  58611. idx: number;
  58612. /**
  58613. * The color of the particle
  58614. */
  58615. color: Nullable<Color4>;
  58616. /**
  58617. * The world space position of the particle.
  58618. */
  58619. position: Vector3;
  58620. /**
  58621. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58622. */
  58623. rotation: Vector3;
  58624. /**
  58625. * The world space rotation quaternion of the particle.
  58626. */
  58627. rotationQuaternion: Nullable<Quaternion>;
  58628. /**
  58629. * The uv of the particle.
  58630. */
  58631. uv: Nullable<Vector2>;
  58632. /**
  58633. * The current speed of the particle.
  58634. */
  58635. velocity: Vector3;
  58636. /**
  58637. * The pivot point in the particle local space.
  58638. */
  58639. pivot: Vector3;
  58640. /**
  58641. * Must the particle be translated from its pivot point in its local space ?
  58642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58643. * Default : false
  58644. */
  58645. translateFromPivot: boolean;
  58646. /**
  58647. * Index of this particle in the global "positions" array (Internal use)
  58648. * @hidden
  58649. */
  58650. _pos: number;
  58651. /**
  58652. * @hidden Index of this particle in the global "indices" array (Internal use)
  58653. */
  58654. _ind: number;
  58655. /**
  58656. * Group this particle belongs to
  58657. */
  58658. _group: PointsGroup;
  58659. /**
  58660. * Group id of this particle
  58661. */
  58662. groupId: number;
  58663. /**
  58664. * Index of the particle in its group id (Internal use)
  58665. */
  58666. idxInGroup: number;
  58667. /**
  58668. * @hidden Particle BoundingInfo object (Internal use)
  58669. */
  58670. _boundingInfo: BoundingInfo;
  58671. /**
  58672. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58673. */
  58674. _pcs: PointsCloudSystem;
  58675. /**
  58676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58677. */
  58678. _stillInvisible: boolean;
  58679. /**
  58680. * @hidden Last computed particle rotation matrix
  58681. */
  58682. _rotationMatrix: number[];
  58683. /**
  58684. * Parent particle Id, if any.
  58685. * Default null.
  58686. */
  58687. parentId: Nullable<number>;
  58688. /**
  58689. * @hidden Internal global position in the PCS.
  58690. */
  58691. _globalPosition: Vector3;
  58692. /**
  58693. * Creates a Point Cloud object.
  58694. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58695. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58696. * @param group (PointsGroup) is the group the particle belongs to
  58697. * @param groupId (integer) is the group identifier in the PCS.
  58698. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58699. * @param pcs defines the PCS it is associated to
  58700. */
  58701. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58702. /**
  58703. * get point size
  58704. */
  58705. /**
  58706. * Set point size
  58707. */
  58708. size: Vector3;
  58709. /**
  58710. * Legacy support, changed quaternion to rotationQuaternion
  58711. */
  58712. /**
  58713. * Legacy support, changed quaternion to rotationQuaternion
  58714. */
  58715. quaternion: Nullable<Quaternion>;
  58716. /**
  58717. * Returns a boolean. True if the particle intersects a mesh, else false
  58718. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58719. * @param target is the object (point or mesh) what the intersection is computed against
  58720. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58721. * @returns true if it intersects
  58722. */
  58723. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58724. /**
  58725. * get the rotation matrix of the particle
  58726. * @hidden
  58727. */
  58728. getRotationMatrix(m: Matrix): void;
  58729. }
  58730. /**
  58731. * Represents a group of points in a points cloud system
  58732. * * PCS internal tool, don't use it manually.
  58733. */
  58734. export class PointsGroup {
  58735. /**
  58736. * The group id
  58737. * @hidden
  58738. */
  58739. groupID: number;
  58740. /**
  58741. * image data for group (internal use)
  58742. * @hidden
  58743. */
  58744. _groupImageData: Nullable<ArrayBufferView>;
  58745. /**
  58746. * Image Width (internal use)
  58747. * @hidden
  58748. */
  58749. _groupImgWidth: number;
  58750. /**
  58751. * Image Height (internal use)
  58752. * @hidden
  58753. */
  58754. _groupImgHeight: number;
  58755. /**
  58756. * Custom position function (internal use)
  58757. * @hidden
  58758. */
  58759. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58760. /**
  58761. * density per facet for surface points
  58762. * @hidden
  58763. */
  58764. _groupDensity: number[];
  58765. /**
  58766. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58767. * PCS internal tool, don't use it manually.
  58768. * @hidden
  58769. */
  58770. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58771. }
  58772. }
  58773. declare module BABYLON {
  58774. interface Scene {
  58775. /** @hidden (Backing field) */
  58776. _physicsEngine: Nullable<IPhysicsEngine>;
  58777. /**
  58778. * Gets the current physics engine
  58779. * @returns a IPhysicsEngine or null if none attached
  58780. */
  58781. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58782. /**
  58783. * Enables physics to the current scene
  58784. * @param gravity defines the scene's gravity for the physics engine
  58785. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58786. * @return a boolean indicating if the physics engine was initialized
  58787. */
  58788. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58789. /**
  58790. * Disables and disposes the physics engine associated with the scene
  58791. */
  58792. disablePhysicsEngine(): void;
  58793. /**
  58794. * Gets a boolean indicating if there is an active physics engine
  58795. * @returns a boolean indicating if there is an active physics engine
  58796. */
  58797. isPhysicsEnabled(): boolean;
  58798. /**
  58799. * Deletes a physics compound impostor
  58800. * @param compound defines the compound to delete
  58801. */
  58802. deleteCompoundImpostor(compound: any): void;
  58803. /**
  58804. * An event triggered when physic simulation is about to be run
  58805. */
  58806. onBeforePhysicsObservable: Observable<Scene>;
  58807. /**
  58808. * An event triggered when physic simulation has been done
  58809. */
  58810. onAfterPhysicsObservable: Observable<Scene>;
  58811. }
  58812. interface AbstractMesh {
  58813. /** @hidden */
  58814. _physicsImpostor: Nullable<PhysicsImpostor>;
  58815. /**
  58816. * Gets or sets impostor used for physic simulation
  58817. * @see http://doc.babylonjs.com/features/physics_engine
  58818. */
  58819. physicsImpostor: Nullable<PhysicsImpostor>;
  58820. /**
  58821. * Gets the current physics impostor
  58822. * @see http://doc.babylonjs.com/features/physics_engine
  58823. * @returns a physics impostor or null
  58824. */
  58825. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58826. /** Apply a physic impulse to the mesh
  58827. * @param force defines the force to apply
  58828. * @param contactPoint defines where to apply the force
  58829. * @returns the current mesh
  58830. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58831. */
  58832. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58833. /**
  58834. * Creates a physic joint between two meshes
  58835. * @param otherMesh defines the other mesh to use
  58836. * @param pivot1 defines the pivot to use on this mesh
  58837. * @param pivot2 defines the pivot to use on the other mesh
  58838. * @param options defines additional options (can be plugin dependent)
  58839. * @returns the current mesh
  58840. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58841. */
  58842. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58843. /** @hidden */
  58844. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58845. }
  58846. /**
  58847. * Defines the physics engine scene component responsible to manage a physics engine
  58848. */
  58849. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58850. /**
  58851. * The component name helpful to identify the component in the list of scene components.
  58852. */
  58853. readonly name: string;
  58854. /**
  58855. * The scene the component belongs to.
  58856. */
  58857. scene: Scene;
  58858. /**
  58859. * Creates a new instance of the component for the given scene
  58860. * @param scene Defines the scene to register the component in
  58861. */
  58862. constructor(scene: Scene);
  58863. /**
  58864. * Registers the component in a given scene
  58865. */
  58866. register(): void;
  58867. /**
  58868. * Rebuilds the elements related to this component in case of
  58869. * context lost for instance.
  58870. */
  58871. rebuild(): void;
  58872. /**
  58873. * Disposes the component and the associated ressources
  58874. */
  58875. dispose(): void;
  58876. }
  58877. }
  58878. declare module BABYLON {
  58879. /**
  58880. * A helper for physics simulations
  58881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58882. */
  58883. export class PhysicsHelper {
  58884. private _scene;
  58885. private _physicsEngine;
  58886. /**
  58887. * Initializes the Physics helper
  58888. * @param scene Babylon.js scene
  58889. */
  58890. constructor(scene: Scene);
  58891. /**
  58892. * Applies a radial explosion impulse
  58893. * @param origin the origin of the explosion
  58894. * @param radiusOrEventOptions the radius or the options of radial explosion
  58895. * @param strength the explosion strength
  58896. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58897. * @returns A physics radial explosion event, or null
  58898. */
  58899. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58900. /**
  58901. * Applies a radial explosion force
  58902. * @param origin the origin of the explosion
  58903. * @param radiusOrEventOptions the radius or the options of radial explosion
  58904. * @param strength the explosion strength
  58905. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58906. * @returns A physics radial explosion event, or null
  58907. */
  58908. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58909. /**
  58910. * Creates a gravitational field
  58911. * @param origin the origin of the explosion
  58912. * @param radiusOrEventOptions the radius or the options of radial explosion
  58913. * @param strength the explosion strength
  58914. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58915. * @returns A physics gravitational field event, or null
  58916. */
  58917. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58918. /**
  58919. * Creates a physics updraft event
  58920. * @param origin the origin of the updraft
  58921. * @param radiusOrEventOptions the radius or the options of the updraft
  58922. * @param strength the strength of the updraft
  58923. * @param height the height of the updraft
  58924. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58925. * @returns A physics updraft event, or null
  58926. */
  58927. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58928. /**
  58929. * Creates a physics vortex event
  58930. * @param origin the of the vortex
  58931. * @param radiusOrEventOptions the radius or the options of the vortex
  58932. * @param strength the strength of the vortex
  58933. * @param height the height of the vortex
  58934. * @returns a Physics vortex event, or null
  58935. * A physics vortex event or null
  58936. */
  58937. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58938. }
  58939. /**
  58940. * Represents a physics radial explosion event
  58941. */
  58942. class PhysicsRadialExplosionEvent {
  58943. private _scene;
  58944. private _options;
  58945. private _sphere;
  58946. private _dataFetched;
  58947. /**
  58948. * Initializes a radial explosioin event
  58949. * @param _scene BabylonJS scene
  58950. * @param _options The options for the vortex event
  58951. */
  58952. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58953. /**
  58954. * Returns the data related to the radial explosion event (sphere).
  58955. * @returns The radial explosion event data
  58956. */
  58957. getData(): PhysicsRadialExplosionEventData;
  58958. /**
  58959. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58960. * @param impostor A physics imposter
  58961. * @param origin the origin of the explosion
  58962. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58963. */
  58964. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58965. /**
  58966. * Triggers affecterd impostors callbacks
  58967. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58968. */
  58969. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58970. /**
  58971. * Disposes the sphere.
  58972. * @param force Specifies if the sphere should be disposed by force
  58973. */
  58974. dispose(force?: boolean): void;
  58975. /*** Helpers ***/
  58976. private _prepareSphere;
  58977. private _intersectsWithSphere;
  58978. }
  58979. /**
  58980. * Represents a gravitational field event
  58981. */
  58982. class PhysicsGravitationalFieldEvent {
  58983. private _physicsHelper;
  58984. private _scene;
  58985. private _origin;
  58986. private _options;
  58987. private _tickCallback;
  58988. private _sphere;
  58989. private _dataFetched;
  58990. /**
  58991. * Initializes the physics gravitational field event
  58992. * @param _physicsHelper A physics helper
  58993. * @param _scene BabylonJS scene
  58994. * @param _origin The origin position of the gravitational field event
  58995. * @param _options The options for the vortex event
  58996. */
  58997. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58998. /**
  58999. * Returns the data related to the gravitational field event (sphere).
  59000. * @returns A gravitational field event
  59001. */
  59002. getData(): PhysicsGravitationalFieldEventData;
  59003. /**
  59004. * Enables the gravitational field.
  59005. */
  59006. enable(): void;
  59007. /**
  59008. * Disables the gravitational field.
  59009. */
  59010. disable(): void;
  59011. /**
  59012. * Disposes the sphere.
  59013. * @param force The force to dispose from the gravitational field event
  59014. */
  59015. dispose(force?: boolean): void;
  59016. private _tick;
  59017. }
  59018. /**
  59019. * Represents a physics updraft event
  59020. */
  59021. class PhysicsUpdraftEvent {
  59022. private _scene;
  59023. private _origin;
  59024. private _options;
  59025. private _physicsEngine;
  59026. private _originTop;
  59027. private _originDirection;
  59028. private _tickCallback;
  59029. private _cylinder;
  59030. private _cylinderPosition;
  59031. private _dataFetched;
  59032. /**
  59033. * Initializes the physics updraft event
  59034. * @param _scene BabylonJS scene
  59035. * @param _origin The origin position of the updraft
  59036. * @param _options The options for the updraft event
  59037. */
  59038. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59039. /**
  59040. * Returns the data related to the updraft event (cylinder).
  59041. * @returns A physics updraft event
  59042. */
  59043. getData(): PhysicsUpdraftEventData;
  59044. /**
  59045. * Enables the updraft.
  59046. */
  59047. enable(): void;
  59048. /**
  59049. * Disables the updraft.
  59050. */
  59051. disable(): void;
  59052. /**
  59053. * Disposes the cylinder.
  59054. * @param force Specifies if the updraft should be disposed by force
  59055. */
  59056. dispose(force?: boolean): void;
  59057. private getImpostorHitData;
  59058. private _tick;
  59059. /*** Helpers ***/
  59060. private _prepareCylinder;
  59061. private _intersectsWithCylinder;
  59062. }
  59063. /**
  59064. * Represents a physics vortex event
  59065. */
  59066. class PhysicsVortexEvent {
  59067. private _scene;
  59068. private _origin;
  59069. private _options;
  59070. private _physicsEngine;
  59071. private _originTop;
  59072. private _tickCallback;
  59073. private _cylinder;
  59074. private _cylinderPosition;
  59075. private _dataFetched;
  59076. /**
  59077. * Initializes the physics vortex event
  59078. * @param _scene The BabylonJS scene
  59079. * @param _origin The origin position of the vortex
  59080. * @param _options The options for the vortex event
  59081. */
  59082. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59083. /**
  59084. * Returns the data related to the vortex event (cylinder).
  59085. * @returns The physics vortex event data
  59086. */
  59087. getData(): PhysicsVortexEventData;
  59088. /**
  59089. * Enables the vortex.
  59090. */
  59091. enable(): void;
  59092. /**
  59093. * Disables the cortex.
  59094. */
  59095. disable(): void;
  59096. /**
  59097. * Disposes the sphere.
  59098. * @param force
  59099. */
  59100. dispose(force?: boolean): void;
  59101. private getImpostorHitData;
  59102. private _tick;
  59103. /*** Helpers ***/
  59104. private _prepareCylinder;
  59105. private _intersectsWithCylinder;
  59106. }
  59107. /**
  59108. * Options fot the radial explosion event
  59109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59110. */
  59111. export class PhysicsRadialExplosionEventOptions {
  59112. /**
  59113. * The radius of the sphere for the radial explosion.
  59114. */
  59115. radius: number;
  59116. /**
  59117. * The strenth of the explosion.
  59118. */
  59119. strength: number;
  59120. /**
  59121. * The strenght of the force in correspondence to the distance of the affected object
  59122. */
  59123. falloff: PhysicsRadialImpulseFalloff;
  59124. /**
  59125. * Sphere options for the radial explosion.
  59126. */
  59127. sphere: {
  59128. segments: number;
  59129. diameter: number;
  59130. };
  59131. /**
  59132. * Sphere options for the radial explosion.
  59133. */
  59134. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59135. }
  59136. /**
  59137. * Options fot the updraft event
  59138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59139. */
  59140. export class PhysicsUpdraftEventOptions {
  59141. /**
  59142. * The radius of the cylinder for the vortex
  59143. */
  59144. radius: number;
  59145. /**
  59146. * The strenth of the updraft.
  59147. */
  59148. strength: number;
  59149. /**
  59150. * The height of the cylinder for the updraft.
  59151. */
  59152. height: number;
  59153. /**
  59154. * The mode for the the updraft.
  59155. */
  59156. updraftMode: PhysicsUpdraftMode;
  59157. }
  59158. /**
  59159. * Options fot the vortex event
  59160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59161. */
  59162. export class PhysicsVortexEventOptions {
  59163. /**
  59164. * The radius of the cylinder for the vortex
  59165. */
  59166. radius: number;
  59167. /**
  59168. * The strenth of the vortex.
  59169. */
  59170. strength: number;
  59171. /**
  59172. * The height of the cylinder for the vortex.
  59173. */
  59174. height: number;
  59175. /**
  59176. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59177. */
  59178. centripetalForceThreshold: number;
  59179. /**
  59180. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59181. */
  59182. centripetalForceMultiplier: number;
  59183. /**
  59184. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59185. */
  59186. centrifugalForceMultiplier: number;
  59187. /**
  59188. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59189. */
  59190. updraftForceMultiplier: number;
  59191. }
  59192. /**
  59193. * The strenght of the force in correspondence to the distance of the affected object
  59194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59195. */
  59196. export enum PhysicsRadialImpulseFalloff {
  59197. /** Defines that impulse is constant in strength across it's whole radius */
  59198. Constant = 0,
  59199. /** Defines that impulse gets weaker if it's further from the origin */
  59200. Linear = 1
  59201. }
  59202. /**
  59203. * The strength of the force in correspondence to the distance of the affected object
  59204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59205. */
  59206. export enum PhysicsUpdraftMode {
  59207. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59208. Center = 0,
  59209. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59210. Perpendicular = 1
  59211. }
  59212. /**
  59213. * Interface for a physics hit data
  59214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59215. */
  59216. export interface PhysicsHitData {
  59217. /**
  59218. * The force applied at the contact point
  59219. */
  59220. force: Vector3;
  59221. /**
  59222. * The contact point
  59223. */
  59224. contactPoint: Vector3;
  59225. /**
  59226. * The distance from the origin to the contact point
  59227. */
  59228. distanceFromOrigin: number;
  59229. }
  59230. /**
  59231. * Interface for radial explosion event data
  59232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59233. */
  59234. export interface PhysicsRadialExplosionEventData {
  59235. /**
  59236. * A sphere used for the radial explosion event
  59237. */
  59238. sphere: Mesh;
  59239. }
  59240. /**
  59241. * Interface for gravitational field event data
  59242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59243. */
  59244. export interface PhysicsGravitationalFieldEventData {
  59245. /**
  59246. * A sphere mesh used for the gravitational field event
  59247. */
  59248. sphere: Mesh;
  59249. }
  59250. /**
  59251. * Interface for updraft event data
  59252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59253. */
  59254. export interface PhysicsUpdraftEventData {
  59255. /**
  59256. * A cylinder used for the updraft event
  59257. */
  59258. cylinder: Mesh;
  59259. }
  59260. /**
  59261. * Interface for vortex event data
  59262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59263. */
  59264. export interface PhysicsVortexEventData {
  59265. /**
  59266. * A cylinder used for the vortex event
  59267. */
  59268. cylinder: Mesh;
  59269. }
  59270. /**
  59271. * Interface for an affected physics impostor
  59272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59273. */
  59274. export interface PhysicsAffectedImpostorWithData {
  59275. /**
  59276. * The impostor affected by the effect
  59277. */
  59278. impostor: PhysicsImpostor;
  59279. /**
  59280. * The data about the hit/horce from the explosion
  59281. */
  59282. hitData: PhysicsHitData;
  59283. }
  59284. }
  59285. declare module BABYLON {
  59286. /** @hidden */
  59287. export var blackAndWhitePixelShader: {
  59288. name: string;
  59289. shader: string;
  59290. };
  59291. }
  59292. declare module BABYLON {
  59293. /**
  59294. * Post process used to render in black and white
  59295. */
  59296. export class BlackAndWhitePostProcess extends PostProcess {
  59297. /**
  59298. * Linear about to convert he result to black and white (default: 1)
  59299. */
  59300. degree: number;
  59301. /**
  59302. * Creates a black and white post process
  59303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59304. * @param name The name of the effect.
  59305. * @param options The required width/height ratio to downsize to before computing the render pass.
  59306. * @param camera The camera to apply the render pass to.
  59307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59308. * @param engine The engine which the post process will be applied. (default: current engine)
  59309. * @param reusable If the post process can be reused on the same frame. (default: false)
  59310. */
  59311. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59312. }
  59313. }
  59314. declare module BABYLON {
  59315. /**
  59316. * This represents a set of one or more post processes in Babylon.
  59317. * A post process can be used to apply a shader to a texture after it is rendered.
  59318. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59319. */
  59320. export class PostProcessRenderEffect {
  59321. private _postProcesses;
  59322. private _getPostProcesses;
  59323. private _singleInstance;
  59324. private _cameras;
  59325. private _indicesForCamera;
  59326. /**
  59327. * Name of the effect
  59328. * @hidden
  59329. */
  59330. _name: string;
  59331. /**
  59332. * Instantiates a post process render effect.
  59333. * A post process can be used to apply a shader to a texture after it is rendered.
  59334. * @param engine The engine the effect is tied to
  59335. * @param name The name of the effect
  59336. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59337. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59338. */
  59339. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59340. /**
  59341. * Checks if all the post processes in the effect are supported.
  59342. */
  59343. readonly isSupported: boolean;
  59344. /**
  59345. * Updates the current state of the effect
  59346. * @hidden
  59347. */
  59348. _update(): void;
  59349. /**
  59350. * Attaches the effect on cameras
  59351. * @param cameras The camera to attach to.
  59352. * @hidden
  59353. */
  59354. _attachCameras(cameras: Camera): void;
  59355. /**
  59356. * Attaches the effect on cameras
  59357. * @param cameras The camera to attach to.
  59358. * @hidden
  59359. */
  59360. _attachCameras(cameras: Camera[]): void;
  59361. /**
  59362. * Detaches the effect on cameras
  59363. * @param cameras The camera to detatch from.
  59364. * @hidden
  59365. */
  59366. _detachCameras(cameras: Camera): void;
  59367. /**
  59368. * Detatches the effect on cameras
  59369. * @param cameras The camera to detatch from.
  59370. * @hidden
  59371. */
  59372. _detachCameras(cameras: Camera[]): void;
  59373. /**
  59374. * Enables the effect on given cameras
  59375. * @param cameras The camera to enable.
  59376. * @hidden
  59377. */
  59378. _enable(cameras: Camera): void;
  59379. /**
  59380. * Enables the effect on given cameras
  59381. * @param cameras The camera to enable.
  59382. * @hidden
  59383. */
  59384. _enable(cameras: Nullable<Camera[]>): void;
  59385. /**
  59386. * Disables the effect on the given cameras
  59387. * @param cameras The camera to disable.
  59388. * @hidden
  59389. */
  59390. _disable(cameras: Camera): void;
  59391. /**
  59392. * Disables the effect on the given cameras
  59393. * @param cameras The camera to disable.
  59394. * @hidden
  59395. */
  59396. _disable(cameras: Nullable<Camera[]>): void;
  59397. /**
  59398. * Gets a list of the post processes contained in the effect.
  59399. * @param camera The camera to get the post processes on.
  59400. * @returns The list of the post processes in the effect.
  59401. */
  59402. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /** @hidden */
  59407. export var extractHighlightsPixelShader: {
  59408. name: string;
  59409. shader: string;
  59410. };
  59411. }
  59412. declare module BABYLON {
  59413. /**
  59414. * 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.
  59415. */
  59416. export class ExtractHighlightsPostProcess extends PostProcess {
  59417. /**
  59418. * The luminance threshold, pixels below this value will be set to black.
  59419. */
  59420. threshold: number;
  59421. /** @hidden */
  59422. _exposure: number;
  59423. /**
  59424. * Post process which has the input texture to be used when performing highlight extraction
  59425. * @hidden
  59426. */
  59427. _inputPostProcess: Nullable<PostProcess>;
  59428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59429. }
  59430. }
  59431. declare module BABYLON {
  59432. /** @hidden */
  59433. export var bloomMergePixelShader: {
  59434. name: string;
  59435. shader: string;
  59436. };
  59437. }
  59438. declare module BABYLON {
  59439. /**
  59440. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59441. */
  59442. export class BloomMergePostProcess extends PostProcess {
  59443. /** Weight of the bloom to be added to the original input. */
  59444. weight: number;
  59445. /**
  59446. * Creates a new instance of @see BloomMergePostProcess
  59447. * @param name The name of the effect.
  59448. * @param originalFromInput Post process which's input will be used for the merge.
  59449. * @param blurred Blurred highlights post process which's output will be used.
  59450. * @param weight Weight of the bloom to be added to the original input.
  59451. * @param options The required width/height ratio to downsize to before computing the render pass.
  59452. * @param camera The camera to apply the render pass to.
  59453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59454. * @param engine The engine which the post process will be applied. (default: current engine)
  59455. * @param reusable If the post process can be reused on the same frame. (default: false)
  59456. * @param textureType Type of textures used when performing the post process. (default: 0)
  59457. * @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)
  59458. */
  59459. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59460. /** Weight of the bloom to be added to the original input. */
  59461. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59462. }
  59463. }
  59464. declare module BABYLON {
  59465. /**
  59466. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59467. */
  59468. export class BloomEffect extends PostProcessRenderEffect {
  59469. private bloomScale;
  59470. /**
  59471. * @hidden Internal
  59472. */
  59473. _effects: Array<PostProcess>;
  59474. /**
  59475. * @hidden Internal
  59476. */
  59477. _downscale: ExtractHighlightsPostProcess;
  59478. private _blurX;
  59479. private _blurY;
  59480. private _merge;
  59481. /**
  59482. * The luminance threshold to find bright areas of the image to bloom.
  59483. */
  59484. threshold: number;
  59485. /**
  59486. * The strength of the bloom.
  59487. */
  59488. weight: number;
  59489. /**
  59490. * Specifies the size of the bloom blur kernel, relative to the final output size
  59491. */
  59492. kernel: number;
  59493. /**
  59494. * Creates a new instance of @see BloomEffect
  59495. * @param scene The scene the effect belongs to.
  59496. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59497. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59498. * @param bloomWeight The the strength of bloom.
  59499. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59500. * @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)
  59501. */
  59502. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59503. /**
  59504. * Disposes each of the internal effects for a given camera.
  59505. * @param camera The camera to dispose the effect on.
  59506. */
  59507. disposeEffects(camera: Camera): void;
  59508. /**
  59509. * @hidden Internal
  59510. */
  59511. _updateEffects(): void;
  59512. /**
  59513. * Internal
  59514. * @returns if all the contained post processes are ready.
  59515. * @hidden
  59516. */
  59517. _isReady(): boolean;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. /** @hidden */
  59522. export var chromaticAberrationPixelShader: {
  59523. name: string;
  59524. shader: string;
  59525. };
  59526. }
  59527. declare module BABYLON {
  59528. /**
  59529. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59530. */
  59531. export class ChromaticAberrationPostProcess extends PostProcess {
  59532. /**
  59533. * The amount of seperation of rgb channels (default: 30)
  59534. */
  59535. aberrationAmount: number;
  59536. /**
  59537. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59538. */
  59539. radialIntensity: number;
  59540. /**
  59541. * 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))
  59542. */
  59543. direction: Vector2;
  59544. /**
  59545. * 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))
  59546. */
  59547. centerPosition: Vector2;
  59548. /**
  59549. * Creates a new instance ChromaticAberrationPostProcess
  59550. * @param name The name of the effect.
  59551. * @param screenWidth The width of the screen to apply the effect on.
  59552. * @param screenHeight The height of the screen to apply the effect on.
  59553. * @param options The required width/height ratio to downsize to before computing the render pass.
  59554. * @param camera The camera to apply the render pass to.
  59555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59556. * @param engine The engine which the post process will be applied. (default: current engine)
  59557. * @param reusable If the post process can be reused on the same frame. (default: false)
  59558. * @param textureType Type of textures used when performing the post process. (default: 0)
  59559. * @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)
  59560. */
  59561. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59562. }
  59563. }
  59564. declare module BABYLON {
  59565. /** @hidden */
  59566. export var circleOfConfusionPixelShader: {
  59567. name: string;
  59568. shader: string;
  59569. };
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59574. */
  59575. export class CircleOfConfusionPostProcess extends PostProcess {
  59576. /**
  59577. * 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.
  59578. */
  59579. lensSize: number;
  59580. /**
  59581. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59582. */
  59583. fStop: number;
  59584. /**
  59585. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59586. */
  59587. focusDistance: number;
  59588. /**
  59589. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59590. */
  59591. focalLength: number;
  59592. private _depthTexture;
  59593. /**
  59594. * Creates a new instance CircleOfConfusionPostProcess
  59595. * @param name The name of the effect.
  59596. * @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.
  59597. * @param options The required width/height ratio to downsize to before computing the render pass.
  59598. * @param camera The camera to apply the render pass to.
  59599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59600. * @param engine The engine which the post process will be applied. (default: current engine)
  59601. * @param reusable If the post process can be reused on the same frame. (default: false)
  59602. * @param textureType Type of textures used when performing the post process. (default: 0)
  59603. * @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)
  59604. */
  59605. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59606. /**
  59607. * 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.
  59608. */
  59609. depthTexture: RenderTargetTexture;
  59610. }
  59611. }
  59612. declare module BABYLON {
  59613. /** @hidden */
  59614. export var colorCorrectionPixelShader: {
  59615. name: string;
  59616. shader: string;
  59617. };
  59618. }
  59619. declare module BABYLON {
  59620. /**
  59621. *
  59622. * This post-process allows the modification of rendered colors by using
  59623. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59624. *
  59625. * The object needs to be provided an url to a texture containing the color
  59626. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59627. * Use an image editing software to tweak the LUT to match your needs.
  59628. *
  59629. * For an example of a color LUT, see here:
  59630. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59631. * For explanations on color grading, see here:
  59632. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59633. *
  59634. */
  59635. export class ColorCorrectionPostProcess extends PostProcess {
  59636. private _colorTableTexture;
  59637. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59638. }
  59639. }
  59640. declare module BABYLON {
  59641. /** @hidden */
  59642. export var convolutionPixelShader: {
  59643. name: string;
  59644. shader: string;
  59645. };
  59646. }
  59647. declare module BABYLON {
  59648. /**
  59649. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59650. * input texture to perform effects such as edge detection or sharpening
  59651. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59652. */
  59653. export class ConvolutionPostProcess extends PostProcess {
  59654. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59655. kernel: number[];
  59656. /**
  59657. * Creates a new instance ConvolutionPostProcess
  59658. * @param name The name of the effect.
  59659. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59660. * @param options The required width/height ratio to downsize to before computing the render pass.
  59661. * @param camera The camera to apply the render pass to.
  59662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59663. * @param engine The engine which the post process will be applied. (default: current engine)
  59664. * @param reusable If the post process can be reused on the same frame. (default: false)
  59665. * @param textureType Type of textures used when performing the post process. (default: 0)
  59666. */
  59667. constructor(name: string,
  59668. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59669. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59670. /**
  59671. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59672. */
  59673. static EdgeDetect0Kernel: number[];
  59674. /**
  59675. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59676. */
  59677. static EdgeDetect1Kernel: number[];
  59678. /**
  59679. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59680. */
  59681. static EdgeDetect2Kernel: number[];
  59682. /**
  59683. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59684. */
  59685. static SharpenKernel: number[];
  59686. /**
  59687. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59688. */
  59689. static EmbossKernel: number[];
  59690. /**
  59691. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59692. */
  59693. static GaussianKernel: number[];
  59694. }
  59695. }
  59696. declare module BABYLON {
  59697. /**
  59698. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59699. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59700. * based on samples that have a large difference in distance than the center pixel.
  59701. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59702. */
  59703. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59704. direction: Vector2;
  59705. /**
  59706. * Creates a new instance CircleOfConfusionPostProcess
  59707. * @param name The name of the effect.
  59708. * @param scene The scene the effect belongs to.
  59709. * @param direction The direction the blur should be applied.
  59710. * @param kernel The size of the kernel used to blur.
  59711. * @param options The required width/height ratio to downsize to before computing the render pass.
  59712. * @param camera The camera to apply the render pass to.
  59713. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59714. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59716. * @param engine The engine which the post process will be applied. (default: current engine)
  59717. * @param reusable If the post process can be reused on the same frame. (default: false)
  59718. * @param textureType Type of textures used when performing the post process. (default: 0)
  59719. * @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)
  59720. */
  59721. 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);
  59722. }
  59723. }
  59724. declare module BABYLON {
  59725. /** @hidden */
  59726. export var depthOfFieldMergePixelShader: {
  59727. name: string;
  59728. shader: string;
  59729. };
  59730. }
  59731. declare module BABYLON {
  59732. /**
  59733. * Options to be set when merging outputs from the default pipeline.
  59734. */
  59735. export class DepthOfFieldMergePostProcessOptions {
  59736. /**
  59737. * The original image to merge on top of
  59738. */
  59739. originalFromInput: PostProcess;
  59740. /**
  59741. * Parameters to perform the merge of the depth of field effect
  59742. */
  59743. depthOfField?: {
  59744. circleOfConfusion: PostProcess;
  59745. blurSteps: Array<PostProcess>;
  59746. };
  59747. /**
  59748. * Parameters to perform the merge of bloom effect
  59749. */
  59750. bloom?: {
  59751. blurred: PostProcess;
  59752. weight: number;
  59753. };
  59754. }
  59755. /**
  59756. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59757. */
  59758. export class DepthOfFieldMergePostProcess extends PostProcess {
  59759. private blurSteps;
  59760. /**
  59761. * Creates a new instance of DepthOfFieldMergePostProcess
  59762. * @param name The name of the effect.
  59763. * @param originalFromInput Post process which's input will be used for the merge.
  59764. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59765. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59766. * @param options The required width/height ratio to downsize to before computing the render pass.
  59767. * @param camera The camera to apply the render pass to.
  59768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59769. * @param engine The engine which the post process will be applied. (default: current engine)
  59770. * @param reusable If the post process can be reused on the same frame. (default: false)
  59771. * @param textureType Type of textures used when performing the post process. (default: 0)
  59772. * @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)
  59773. */
  59774. 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);
  59775. /**
  59776. * Updates the effect with the current post process compile time values and recompiles the shader.
  59777. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59778. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59779. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59780. * @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
  59781. * @param onCompiled Called when the shader has been compiled.
  59782. * @param onError Called if there is an error when compiling a shader.
  59783. */
  59784. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59785. }
  59786. }
  59787. declare module BABYLON {
  59788. /**
  59789. * Specifies the level of max blur that should be applied when using the depth of field effect
  59790. */
  59791. export enum DepthOfFieldEffectBlurLevel {
  59792. /**
  59793. * Subtle blur
  59794. */
  59795. Low = 0,
  59796. /**
  59797. * Medium blur
  59798. */
  59799. Medium = 1,
  59800. /**
  59801. * Large blur
  59802. */
  59803. High = 2
  59804. }
  59805. /**
  59806. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59807. */
  59808. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59809. private _circleOfConfusion;
  59810. /**
  59811. * @hidden Internal, blurs from high to low
  59812. */
  59813. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59814. private _depthOfFieldBlurY;
  59815. private _dofMerge;
  59816. /**
  59817. * @hidden Internal post processes in depth of field effect
  59818. */
  59819. _effects: Array<PostProcess>;
  59820. /**
  59821. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59822. */
  59823. focalLength: number;
  59824. /**
  59825. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59826. */
  59827. fStop: number;
  59828. /**
  59829. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59830. */
  59831. focusDistance: number;
  59832. /**
  59833. * 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.
  59834. */
  59835. lensSize: number;
  59836. /**
  59837. * Creates a new instance DepthOfFieldEffect
  59838. * @param scene The scene the effect belongs to.
  59839. * @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.
  59840. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59841. * @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)
  59842. */
  59843. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59844. /**
  59845. * Get the current class name of the current effet
  59846. * @returns "DepthOfFieldEffect"
  59847. */
  59848. getClassName(): string;
  59849. /**
  59850. * 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.
  59851. */
  59852. depthTexture: RenderTargetTexture;
  59853. /**
  59854. * Disposes each of the internal effects for a given camera.
  59855. * @param camera The camera to dispose the effect on.
  59856. */
  59857. disposeEffects(camera: Camera): void;
  59858. /**
  59859. * @hidden Internal
  59860. */
  59861. _updateEffects(): void;
  59862. /**
  59863. * Internal
  59864. * @returns if all the contained post processes are ready.
  59865. * @hidden
  59866. */
  59867. _isReady(): boolean;
  59868. }
  59869. }
  59870. declare module BABYLON {
  59871. /** @hidden */
  59872. export var displayPassPixelShader: {
  59873. name: string;
  59874. shader: string;
  59875. };
  59876. }
  59877. declare module BABYLON {
  59878. /**
  59879. * DisplayPassPostProcess which produces an output the same as it's input
  59880. */
  59881. export class DisplayPassPostProcess extends PostProcess {
  59882. /**
  59883. * Creates the DisplayPassPostProcess
  59884. * @param name The name of the effect.
  59885. * @param options The required width/height ratio to downsize to before computing the render pass.
  59886. * @param camera The camera to apply the render pass to.
  59887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59888. * @param engine The engine which the post process will be applied. (default: current engine)
  59889. * @param reusable If the post process can be reused on the same frame. (default: false)
  59890. */
  59891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59892. }
  59893. }
  59894. declare module BABYLON {
  59895. /** @hidden */
  59896. export var filterPixelShader: {
  59897. name: string;
  59898. shader: string;
  59899. };
  59900. }
  59901. declare module BABYLON {
  59902. /**
  59903. * Applies a kernel filter to the image
  59904. */
  59905. export class FilterPostProcess extends PostProcess {
  59906. /** The matrix to be applied to the image */
  59907. kernelMatrix: Matrix;
  59908. /**
  59909. *
  59910. * @param name The name of the effect.
  59911. * @param kernelMatrix The matrix to be applied to the image
  59912. * @param options The required width/height ratio to downsize to before computing the render pass.
  59913. * @param camera The camera to apply the render pass to.
  59914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59915. * @param engine The engine which the post process will be applied. (default: current engine)
  59916. * @param reusable If the post process can be reused on the same frame. (default: false)
  59917. */
  59918. constructor(name: string,
  59919. /** The matrix to be applied to the image */
  59920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59921. }
  59922. }
  59923. declare module BABYLON {
  59924. /** @hidden */
  59925. export var fxaaPixelShader: {
  59926. name: string;
  59927. shader: string;
  59928. };
  59929. }
  59930. declare module BABYLON {
  59931. /** @hidden */
  59932. export var fxaaVertexShader: {
  59933. name: string;
  59934. shader: string;
  59935. };
  59936. }
  59937. declare module BABYLON {
  59938. /**
  59939. * Fxaa post process
  59940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59941. */
  59942. export class FxaaPostProcess extends PostProcess {
  59943. /** @hidden */
  59944. texelWidth: number;
  59945. /** @hidden */
  59946. texelHeight: number;
  59947. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59948. private _getDefines;
  59949. }
  59950. }
  59951. declare module BABYLON {
  59952. /** @hidden */
  59953. export var grainPixelShader: {
  59954. name: string;
  59955. shader: string;
  59956. };
  59957. }
  59958. declare module BABYLON {
  59959. /**
  59960. * The GrainPostProcess adds noise to the image at mid luminance levels
  59961. */
  59962. export class GrainPostProcess extends PostProcess {
  59963. /**
  59964. * The intensity of the grain added (default: 30)
  59965. */
  59966. intensity: number;
  59967. /**
  59968. * If the grain should be randomized on every frame
  59969. */
  59970. animated: boolean;
  59971. /**
  59972. * Creates a new instance of @see GrainPostProcess
  59973. * @param name The name of the effect.
  59974. * @param options The required width/height ratio to downsize to before computing the render pass.
  59975. * @param camera The camera to apply the render pass to.
  59976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59977. * @param engine The engine which the post process will be applied. (default: current engine)
  59978. * @param reusable If the post process can be reused on the same frame. (default: false)
  59979. * @param textureType Type of textures used when performing the post process. (default: 0)
  59980. * @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)
  59981. */
  59982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59983. }
  59984. }
  59985. declare module BABYLON {
  59986. /** @hidden */
  59987. export var highlightsPixelShader: {
  59988. name: string;
  59989. shader: string;
  59990. };
  59991. }
  59992. declare module BABYLON {
  59993. /**
  59994. * Extracts highlights from the image
  59995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59996. */
  59997. export class HighlightsPostProcess extends PostProcess {
  59998. /**
  59999. * Extracts highlights from the image
  60000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60001. * @param name The name of the effect.
  60002. * @param options The required width/height ratio to downsize to before computing the render pass.
  60003. * @param camera The camera to apply the render pass to.
  60004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60005. * @param engine The engine which the post process will be applied. (default: current engine)
  60006. * @param reusable If the post process can be reused on the same frame. (default: false)
  60007. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60008. */
  60009. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60010. }
  60011. }
  60012. declare module BABYLON {
  60013. /** @hidden */
  60014. export var mrtFragmentDeclaration: {
  60015. name: string;
  60016. shader: string;
  60017. };
  60018. }
  60019. declare module BABYLON {
  60020. /** @hidden */
  60021. export var geometryPixelShader: {
  60022. name: string;
  60023. shader: string;
  60024. };
  60025. }
  60026. declare module BABYLON {
  60027. /** @hidden */
  60028. export var geometryVertexShader: {
  60029. name: string;
  60030. shader: string;
  60031. };
  60032. }
  60033. declare module BABYLON {
  60034. /** @hidden */
  60035. interface ISavedTransformationMatrix {
  60036. world: Matrix;
  60037. viewProjection: Matrix;
  60038. }
  60039. /**
  60040. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60041. */
  60042. export class GeometryBufferRenderer {
  60043. /**
  60044. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60045. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60046. */
  60047. static readonly POSITION_TEXTURE_TYPE: number;
  60048. /**
  60049. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60050. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60051. */
  60052. static readonly VELOCITY_TEXTURE_TYPE: number;
  60053. /**
  60054. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60055. * in order to compute objects velocities when enableVelocity is set to "true"
  60056. * @hidden
  60057. */
  60058. _previousTransformationMatrices: {
  60059. [index: number]: ISavedTransformationMatrix;
  60060. };
  60061. /**
  60062. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60063. * in order to compute objects velocities when enableVelocity is set to "true"
  60064. * @hidden
  60065. */
  60066. _previousBonesTransformationMatrices: {
  60067. [index: number]: Float32Array;
  60068. };
  60069. /**
  60070. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60071. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60072. */
  60073. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60074. private _scene;
  60075. private _multiRenderTarget;
  60076. private _ratio;
  60077. private _enablePosition;
  60078. private _enableVelocity;
  60079. private _positionIndex;
  60080. private _velocityIndex;
  60081. protected _effect: Effect;
  60082. protected _cachedDefines: string;
  60083. /**
  60084. * Set the render list (meshes to be rendered) used in the G buffer.
  60085. */
  60086. renderList: Mesh[];
  60087. /**
  60088. * Gets wether or not G buffer are supported by the running hardware.
  60089. * This requires draw buffer supports
  60090. */
  60091. readonly isSupported: boolean;
  60092. /**
  60093. * Returns the index of the given texture type in the G-Buffer textures array
  60094. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60095. * @returns the index of the given texture type in the G-Buffer textures array
  60096. */
  60097. getTextureIndex(textureType: number): number;
  60098. /**
  60099. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60100. */
  60101. /**
  60102. * Sets whether or not objects positions are enabled for the G buffer.
  60103. */
  60104. enablePosition: boolean;
  60105. /**
  60106. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60107. */
  60108. /**
  60109. * Sets wether or not objects velocities are enabled for the G buffer.
  60110. */
  60111. enableVelocity: boolean;
  60112. /**
  60113. * Gets the scene associated with the buffer.
  60114. */
  60115. readonly scene: Scene;
  60116. /**
  60117. * Gets the ratio used by the buffer during its creation.
  60118. * How big is the buffer related to the main canvas.
  60119. */
  60120. readonly ratio: number;
  60121. /** @hidden */
  60122. static _SceneComponentInitialization: (scene: Scene) => void;
  60123. /**
  60124. * Creates a new G Buffer for the scene
  60125. * @param scene The scene the buffer belongs to
  60126. * @param ratio How big is the buffer related to the main canvas.
  60127. */
  60128. constructor(scene: Scene, ratio?: number);
  60129. /**
  60130. * Checks wether everything is ready to render a submesh to the G buffer.
  60131. * @param subMesh the submesh to check readiness for
  60132. * @param useInstances is the mesh drawn using instance or not
  60133. * @returns true if ready otherwise false
  60134. */
  60135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60136. /**
  60137. * Gets the current underlying G Buffer.
  60138. * @returns the buffer
  60139. */
  60140. getGBuffer(): MultiRenderTarget;
  60141. /**
  60142. * Gets the number of samples used to render the buffer (anti aliasing).
  60143. */
  60144. /**
  60145. * Sets the number of samples used to render the buffer (anti aliasing).
  60146. */
  60147. samples: number;
  60148. /**
  60149. * Disposes the renderer and frees up associated resources.
  60150. */
  60151. dispose(): void;
  60152. protected _createRenderTargets(): void;
  60153. private _copyBonesTransformationMatrices;
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. interface Scene {
  60158. /** @hidden (Backing field) */
  60159. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60160. /**
  60161. * Gets or Sets the current geometry buffer associated to the scene.
  60162. */
  60163. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60164. /**
  60165. * Enables a GeometryBufferRender and associates it with the scene
  60166. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60167. * @returns the GeometryBufferRenderer
  60168. */
  60169. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60170. /**
  60171. * Disables the GeometryBufferRender associated with the scene
  60172. */
  60173. disableGeometryBufferRenderer(): void;
  60174. }
  60175. /**
  60176. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60177. * in several rendering techniques.
  60178. */
  60179. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60180. /**
  60181. * The component name helpful to identify the component in the list of scene components.
  60182. */
  60183. readonly name: string;
  60184. /**
  60185. * The scene the component belongs to.
  60186. */
  60187. scene: Scene;
  60188. /**
  60189. * Creates a new instance of the component for the given scene
  60190. * @param scene Defines the scene to register the component in
  60191. */
  60192. constructor(scene: Scene);
  60193. /**
  60194. * Registers the component in a given scene
  60195. */
  60196. register(): void;
  60197. /**
  60198. * Rebuilds the elements related to this component in case of
  60199. * context lost for instance.
  60200. */
  60201. rebuild(): void;
  60202. /**
  60203. * Disposes the component and the associated ressources
  60204. */
  60205. dispose(): void;
  60206. private _gatherRenderTargets;
  60207. }
  60208. }
  60209. declare module BABYLON {
  60210. /** @hidden */
  60211. export var motionBlurPixelShader: {
  60212. name: string;
  60213. shader: string;
  60214. };
  60215. }
  60216. declare module BABYLON {
  60217. /**
  60218. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60219. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60220. * As an example, all you have to do is to create the post-process:
  60221. * var mb = new BABYLON.MotionBlurPostProcess(
  60222. * 'mb', // The name of the effect.
  60223. * scene, // The scene containing the objects to blur according to their velocity.
  60224. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60225. * camera // The camera to apply the render pass to.
  60226. * );
  60227. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60228. */
  60229. export class MotionBlurPostProcess extends PostProcess {
  60230. /**
  60231. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60232. */
  60233. motionStrength: number;
  60234. /**
  60235. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60236. */
  60237. /**
  60238. * Sets the number of iterations to be used for motion blur quality
  60239. */
  60240. motionBlurSamples: number;
  60241. private _motionBlurSamples;
  60242. private _geometryBufferRenderer;
  60243. /**
  60244. * Creates a new instance MotionBlurPostProcess
  60245. * @param name The name of the effect.
  60246. * @param scene The scene containing the objects to blur according to their velocity.
  60247. * @param options The required width/height ratio to downsize to before computing the render pass.
  60248. * @param camera The camera to apply the render pass to.
  60249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60250. * @param engine The engine which the post process will be applied. (default: current engine)
  60251. * @param reusable If the post process can be reused on the same frame. (default: false)
  60252. * @param textureType Type of textures used when performing the post process. (default: 0)
  60253. * @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)
  60254. */
  60255. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60256. /**
  60257. * Excludes the given skinned mesh from computing bones velocities.
  60258. * 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.
  60259. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60260. */
  60261. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60262. /**
  60263. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60264. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60265. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60266. */
  60267. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60268. /**
  60269. * Disposes the post process.
  60270. * @param camera The camera to dispose the post process on.
  60271. */
  60272. dispose(camera?: Camera): void;
  60273. }
  60274. }
  60275. declare module BABYLON {
  60276. /** @hidden */
  60277. export var refractionPixelShader: {
  60278. name: string;
  60279. shader: string;
  60280. };
  60281. }
  60282. declare module BABYLON {
  60283. /**
  60284. * Post process which applies a refractin texture
  60285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60286. */
  60287. export class RefractionPostProcess extends PostProcess {
  60288. /** the base color of the refraction (used to taint the rendering) */
  60289. color: Color3;
  60290. /** simulated refraction depth */
  60291. depth: number;
  60292. /** the coefficient of the base color (0 to remove base color tainting) */
  60293. colorLevel: number;
  60294. private _refTexture;
  60295. private _ownRefractionTexture;
  60296. /**
  60297. * Gets or sets the refraction texture
  60298. * Please note that you are responsible for disposing the texture if you set it manually
  60299. */
  60300. refractionTexture: Texture;
  60301. /**
  60302. * Initializes the RefractionPostProcess
  60303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60304. * @param name The name of the effect.
  60305. * @param refractionTextureUrl Url of the refraction texture to use
  60306. * @param color the base color of the refraction (used to taint the rendering)
  60307. * @param depth simulated refraction depth
  60308. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60309. * @param camera The camera to apply the render pass to.
  60310. * @param options The required width/height ratio to downsize to before computing the render pass.
  60311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60312. * @param engine The engine which the post process will be applied. (default: current engine)
  60313. * @param reusable If the post process can be reused on the same frame. (default: false)
  60314. */
  60315. constructor(name: string, refractionTextureUrl: string,
  60316. /** the base color of the refraction (used to taint the rendering) */
  60317. color: Color3,
  60318. /** simulated refraction depth */
  60319. depth: number,
  60320. /** the coefficient of the base color (0 to remove base color tainting) */
  60321. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60322. /**
  60323. * Disposes of the post process
  60324. * @param camera Camera to dispose post process on
  60325. */
  60326. dispose(camera: Camera): void;
  60327. }
  60328. }
  60329. declare module BABYLON {
  60330. /** @hidden */
  60331. export var sharpenPixelShader: {
  60332. name: string;
  60333. shader: string;
  60334. };
  60335. }
  60336. declare module BABYLON {
  60337. /**
  60338. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60339. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60340. */
  60341. export class SharpenPostProcess extends PostProcess {
  60342. /**
  60343. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60344. */
  60345. colorAmount: number;
  60346. /**
  60347. * How much sharpness should be applied (default: 0.3)
  60348. */
  60349. edgeAmount: number;
  60350. /**
  60351. * Creates a new instance ConvolutionPostProcess
  60352. * @param name The name of the effect.
  60353. * @param options The required width/height ratio to downsize to before computing the render pass.
  60354. * @param camera The camera to apply the render pass to.
  60355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60356. * @param engine The engine which the post process will be applied. (default: current engine)
  60357. * @param reusable If the post process can be reused on the same frame. (default: false)
  60358. * @param textureType Type of textures used when performing the post process. (default: 0)
  60359. * @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)
  60360. */
  60361. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /**
  60366. * PostProcessRenderPipeline
  60367. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60368. */
  60369. export class PostProcessRenderPipeline {
  60370. private engine;
  60371. private _renderEffects;
  60372. private _renderEffectsForIsolatedPass;
  60373. /**
  60374. * List of inspectable custom properties (used by the Inspector)
  60375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60376. */
  60377. inspectableCustomProperties: IInspectable[];
  60378. /**
  60379. * @hidden
  60380. */
  60381. protected _cameras: Camera[];
  60382. /** @hidden */
  60383. _name: string;
  60384. /**
  60385. * Gets pipeline name
  60386. */
  60387. readonly name: string;
  60388. /**
  60389. * Initializes a PostProcessRenderPipeline
  60390. * @param engine engine to add the pipeline to
  60391. * @param name name of the pipeline
  60392. */
  60393. constructor(engine: Engine, name: string);
  60394. /**
  60395. * Gets the class name
  60396. * @returns "PostProcessRenderPipeline"
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * If all the render effects in the pipeline are supported
  60401. */
  60402. readonly isSupported: boolean;
  60403. /**
  60404. * Adds an effect to the pipeline
  60405. * @param renderEffect the effect to add
  60406. */
  60407. addEffect(renderEffect: PostProcessRenderEffect): void;
  60408. /** @hidden */
  60409. _rebuild(): void;
  60410. /** @hidden */
  60411. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60412. /** @hidden */
  60413. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60414. /** @hidden */
  60415. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60416. /** @hidden */
  60417. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60418. /** @hidden */
  60419. _attachCameras(cameras: Camera, unique: boolean): void;
  60420. /** @hidden */
  60421. _attachCameras(cameras: Camera[], unique: boolean): void;
  60422. /** @hidden */
  60423. _detachCameras(cameras: Camera): void;
  60424. /** @hidden */
  60425. _detachCameras(cameras: Nullable<Camera[]>): void;
  60426. /** @hidden */
  60427. _update(): void;
  60428. /** @hidden */
  60429. _reset(): void;
  60430. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60431. /**
  60432. * Disposes of the pipeline
  60433. */
  60434. dispose(): void;
  60435. }
  60436. }
  60437. declare module BABYLON {
  60438. /**
  60439. * PostProcessRenderPipelineManager class
  60440. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60441. */
  60442. export class PostProcessRenderPipelineManager {
  60443. private _renderPipelines;
  60444. /**
  60445. * Initializes a PostProcessRenderPipelineManager
  60446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60447. */
  60448. constructor();
  60449. /**
  60450. * Gets the list of supported render pipelines
  60451. */
  60452. readonly supportedPipelines: PostProcessRenderPipeline[];
  60453. /**
  60454. * Adds a pipeline to the manager
  60455. * @param renderPipeline The pipeline to add
  60456. */
  60457. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60458. /**
  60459. * Attaches a camera to the pipeline
  60460. * @param renderPipelineName The name of the pipeline to attach to
  60461. * @param cameras the camera to attach
  60462. * @param unique if the camera can be attached multiple times to the pipeline
  60463. */
  60464. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60465. /**
  60466. * Detaches a camera from the pipeline
  60467. * @param renderPipelineName The name of the pipeline to detach from
  60468. * @param cameras the camera to detach
  60469. */
  60470. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60471. /**
  60472. * Enables an effect by name on a pipeline
  60473. * @param renderPipelineName the name of the pipeline to enable the effect in
  60474. * @param renderEffectName the name of the effect to enable
  60475. * @param cameras the cameras that the effect should be enabled on
  60476. */
  60477. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60478. /**
  60479. * Disables an effect by name on a pipeline
  60480. * @param renderPipelineName the name of the pipeline to disable the effect in
  60481. * @param renderEffectName the name of the effect to disable
  60482. * @param cameras the cameras that the effect should be disabled on
  60483. */
  60484. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60485. /**
  60486. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60487. */
  60488. update(): void;
  60489. /** @hidden */
  60490. _rebuild(): void;
  60491. /**
  60492. * Disposes of the manager and pipelines
  60493. */
  60494. dispose(): void;
  60495. }
  60496. }
  60497. declare module BABYLON {
  60498. interface Scene {
  60499. /** @hidden (Backing field) */
  60500. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60501. /**
  60502. * Gets the postprocess render pipeline manager
  60503. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60504. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60505. */
  60506. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60507. }
  60508. /**
  60509. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60510. */
  60511. export class PostProcessRenderPipelineManagerSceneComponent 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. }
  60540. }
  60541. declare module BABYLON {
  60542. /**
  60543. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60544. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60545. */
  60546. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60547. private _scene;
  60548. private _camerasToBeAttached;
  60549. /**
  60550. * ID of the sharpen post process,
  60551. */
  60552. private readonly SharpenPostProcessId;
  60553. /**
  60554. * @ignore
  60555. * ID of the image processing post process;
  60556. */
  60557. readonly ImageProcessingPostProcessId: string;
  60558. /**
  60559. * @ignore
  60560. * ID of the Fast Approximate Anti-Aliasing post process;
  60561. */
  60562. readonly FxaaPostProcessId: string;
  60563. /**
  60564. * ID of the chromatic aberration post process,
  60565. */
  60566. private readonly ChromaticAberrationPostProcessId;
  60567. /**
  60568. * ID of the grain post process
  60569. */
  60570. private readonly GrainPostProcessId;
  60571. /**
  60572. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60573. */
  60574. sharpen: SharpenPostProcess;
  60575. private _sharpenEffect;
  60576. private bloom;
  60577. /**
  60578. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60579. */
  60580. depthOfField: DepthOfFieldEffect;
  60581. /**
  60582. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60583. */
  60584. fxaa: FxaaPostProcess;
  60585. /**
  60586. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60587. */
  60588. imageProcessing: ImageProcessingPostProcess;
  60589. /**
  60590. * Chromatic aberration post process which will shift rgb colors in the image
  60591. */
  60592. chromaticAberration: ChromaticAberrationPostProcess;
  60593. private _chromaticAberrationEffect;
  60594. /**
  60595. * Grain post process which add noise to the image
  60596. */
  60597. grain: GrainPostProcess;
  60598. private _grainEffect;
  60599. /**
  60600. * Glow post process which adds a glow to emissive areas of the image
  60601. */
  60602. private _glowLayer;
  60603. /**
  60604. * Animations which can be used to tweak settings over a period of time
  60605. */
  60606. animations: Animation[];
  60607. private _imageProcessingConfigurationObserver;
  60608. private _sharpenEnabled;
  60609. private _bloomEnabled;
  60610. private _depthOfFieldEnabled;
  60611. private _depthOfFieldBlurLevel;
  60612. private _fxaaEnabled;
  60613. private _imageProcessingEnabled;
  60614. private _defaultPipelineTextureType;
  60615. private _bloomScale;
  60616. private _chromaticAberrationEnabled;
  60617. private _grainEnabled;
  60618. private _buildAllowed;
  60619. /**
  60620. * Gets active scene
  60621. */
  60622. readonly scene: Scene;
  60623. /**
  60624. * Enable or disable the sharpen process from the pipeline
  60625. */
  60626. sharpenEnabled: boolean;
  60627. private _resizeObserver;
  60628. private _hardwareScaleLevel;
  60629. private _bloomKernel;
  60630. /**
  60631. * Specifies the size of the bloom blur kernel, relative to the final output size
  60632. */
  60633. bloomKernel: number;
  60634. /**
  60635. * Specifies the weight of the bloom in the final rendering
  60636. */
  60637. private _bloomWeight;
  60638. /**
  60639. * Specifies the luma threshold for the area that will be blurred by the bloom
  60640. */
  60641. private _bloomThreshold;
  60642. private _hdr;
  60643. /**
  60644. * The strength of the bloom.
  60645. */
  60646. bloomWeight: number;
  60647. /**
  60648. * The strength of the bloom.
  60649. */
  60650. bloomThreshold: number;
  60651. /**
  60652. * The scale of the bloom, lower value will provide better performance.
  60653. */
  60654. bloomScale: number;
  60655. /**
  60656. * Enable or disable the bloom from the pipeline
  60657. */
  60658. bloomEnabled: boolean;
  60659. private _rebuildBloom;
  60660. /**
  60661. * If the depth of field is enabled.
  60662. */
  60663. depthOfFieldEnabled: boolean;
  60664. /**
  60665. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60666. */
  60667. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60668. /**
  60669. * If the anti aliasing is enabled.
  60670. */
  60671. fxaaEnabled: boolean;
  60672. private _samples;
  60673. /**
  60674. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60675. */
  60676. samples: number;
  60677. /**
  60678. * If image processing is enabled.
  60679. */
  60680. imageProcessingEnabled: boolean;
  60681. /**
  60682. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60683. */
  60684. glowLayerEnabled: boolean;
  60685. /**
  60686. * Gets the glow layer (or null if not defined)
  60687. */
  60688. readonly glowLayer: Nullable<GlowLayer>;
  60689. /**
  60690. * Enable or disable the chromaticAberration process from the pipeline
  60691. */
  60692. chromaticAberrationEnabled: boolean;
  60693. /**
  60694. * Enable or disable the grain process from the pipeline
  60695. */
  60696. grainEnabled: boolean;
  60697. /**
  60698. * @constructor
  60699. * @param name - The rendering pipeline name (default: "")
  60700. * @param hdr - If high dynamic range textures should be used (default: true)
  60701. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60702. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60703. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60704. */
  60705. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60706. /**
  60707. * Get the class name
  60708. * @returns "DefaultRenderingPipeline"
  60709. */
  60710. getClassName(): string;
  60711. /**
  60712. * Force the compilation of the entire pipeline.
  60713. */
  60714. prepare(): void;
  60715. private _hasCleared;
  60716. private _prevPostProcess;
  60717. private _prevPrevPostProcess;
  60718. private _setAutoClearAndTextureSharing;
  60719. private _depthOfFieldSceneObserver;
  60720. private _buildPipeline;
  60721. private _disposePostProcesses;
  60722. /**
  60723. * Adds a camera to the pipeline
  60724. * @param camera the camera to be added
  60725. */
  60726. addCamera(camera: Camera): void;
  60727. /**
  60728. * Removes a camera from the pipeline
  60729. * @param camera the camera to remove
  60730. */
  60731. removeCamera(camera: Camera): void;
  60732. /**
  60733. * Dispose of the pipeline and stop all post processes
  60734. */
  60735. dispose(): void;
  60736. /**
  60737. * Serialize the rendering pipeline (Used when exporting)
  60738. * @returns the serialized object
  60739. */
  60740. serialize(): any;
  60741. /**
  60742. * Parse the serialized pipeline
  60743. * @param source Source pipeline.
  60744. * @param scene The scene to load the pipeline to.
  60745. * @param rootUrl The URL of the serialized pipeline.
  60746. * @returns An instantiated pipeline from the serialized object.
  60747. */
  60748. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /** @hidden */
  60753. export var lensHighlightsPixelShader: {
  60754. name: string;
  60755. shader: string;
  60756. };
  60757. }
  60758. declare module BABYLON {
  60759. /** @hidden */
  60760. export var depthOfFieldPixelShader: {
  60761. name: string;
  60762. shader: string;
  60763. };
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * BABYLON.JS Chromatic Aberration GLSL Shader
  60768. * Author: Olivier Guyot
  60769. * Separates very slightly R, G and B colors on the edges of the screen
  60770. * Inspired by Francois Tarlier & Martins Upitis
  60771. */
  60772. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60773. /**
  60774. * @ignore
  60775. * The chromatic aberration PostProcess id in the pipeline
  60776. */
  60777. LensChromaticAberrationEffect: string;
  60778. /**
  60779. * @ignore
  60780. * The highlights enhancing PostProcess id in the pipeline
  60781. */
  60782. HighlightsEnhancingEffect: string;
  60783. /**
  60784. * @ignore
  60785. * The depth-of-field PostProcess id in the pipeline
  60786. */
  60787. LensDepthOfFieldEffect: string;
  60788. private _scene;
  60789. private _depthTexture;
  60790. private _grainTexture;
  60791. private _chromaticAberrationPostProcess;
  60792. private _highlightsPostProcess;
  60793. private _depthOfFieldPostProcess;
  60794. private _edgeBlur;
  60795. private _grainAmount;
  60796. private _chromaticAberration;
  60797. private _distortion;
  60798. private _highlightsGain;
  60799. private _highlightsThreshold;
  60800. private _dofDistance;
  60801. private _dofAperture;
  60802. private _dofDarken;
  60803. private _dofPentagon;
  60804. private _blurNoise;
  60805. /**
  60806. * @constructor
  60807. *
  60808. * Effect parameters are as follow:
  60809. * {
  60810. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60811. * edge_blur: number; // from 0 to x (1 for realism)
  60812. * distortion: number; // from 0 to x (1 for realism)
  60813. * grain_amount: number; // from 0 to 1
  60814. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60815. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60816. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60817. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60818. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60819. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60820. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60821. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60822. * }
  60823. * Note: if an effect parameter is unset, effect is disabled
  60824. *
  60825. * @param name The rendering pipeline name
  60826. * @param parameters - An object containing all parameters (see above)
  60827. * @param scene The scene linked to this pipeline
  60828. * @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)
  60829. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60830. */
  60831. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60832. /**
  60833. * Get the class name
  60834. * @returns "LensRenderingPipeline"
  60835. */
  60836. getClassName(): string;
  60837. /**
  60838. * Gets associated scene
  60839. */
  60840. readonly scene: Scene;
  60841. /**
  60842. * Gets or sets the edge blur
  60843. */
  60844. edgeBlur: number;
  60845. /**
  60846. * Gets or sets the grain amount
  60847. */
  60848. grainAmount: number;
  60849. /**
  60850. * Gets or sets the chromatic aberration amount
  60851. */
  60852. chromaticAberration: number;
  60853. /**
  60854. * Gets or sets the depth of field aperture
  60855. */
  60856. dofAperture: number;
  60857. /**
  60858. * Gets or sets the edge distortion
  60859. */
  60860. edgeDistortion: number;
  60861. /**
  60862. * Gets or sets the depth of field distortion
  60863. */
  60864. dofDistortion: number;
  60865. /**
  60866. * Gets or sets the darken out of focus amount
  60867. */
  60868. darkenOutOfFocus: number;
  60869. /**
  60870. * Gets or sets a boolean indicating if blur noise is enabled
  60871. */
  60872. blurNoise: boolean;
  60873. /**
  60874. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60875. */
  60876. pentagonBokeh: boolean;
  60877. /**
  60878. * Gets or sets the highlight grain amount
  60879. */
  60880. highlightsGain: number;
  60881. /**
  60882. * Gets or sets the highlight threshold
  60883. */
  60884. highlightsThreshold: number;
  60885. /**
  60886. * Sets the amount of blur at the edges
  60887. * @param amount blur amount
  60888. */
  60889. setEdgeBlur(amount: number): void;
  60890. /**
  60891. * Sets edge blur to 0
  60892. */
  60893. disableEdgeBlur(): void;
  60894. /**
  60895. * Sets the amout of grain
  60896. * @param amount Amount of grain
  60897. */
  60898. setGrainAmount(amount: number): void;
  60899. /**
  60900. * Set grain amount to 0
  60901. */
  60902. disableGrain(): void;
  60903. /**
  60904. * Sets the chromatic aberration amount
  60905. * @param amount amount of chromatic aberration
  60906. */
  60907. setChromaticAberration(amount: number): void;
  60908. /**
  60909. * Sets chromatic aberration amount to 0
  60910. */
  60911. disableChromaticAberration(): void;
  60912. /**
  60913. * Sets the EdgeDistortion amount
  60914. * @param amount amount of EdgeDistortion
  60915. */
  60916. setEdgeDistortion(amount: number): void;
  60917. /**
  60918. * Sets edge distortion to 0
  60919. */
  60920. disableEdgeDistortion(): void;
  60921. /**
  60922. * Sets the FocusDistance amount
  60923. * @param amount amount of FocusDistance
  60924. */
  60925. setFocusDistance(amount: number): void;
  60926. /**
  60927. * Disables depth of field
  60928. */
  60929. disableDepthOfField(): void;
  60930. /**
  60931. * Sets the Aperture amount
  60932. * @param amount amount of Aperture
  60933. */
  60934. setAperture(amount: number): void;
  60935. /**
  60936. * Sets the DarkenOutOfFocus amount
  60937. * @param amount amount of DarkenOutOfFocus
  60938. */
  60939. setDarkenOutOfFocus(amount: number): void;
  60940. private _pentagonBokehIsEnabled;
  60941. /**
  60942. * Creates a pentagon bokeh effect
  60943. */
  60944. enablePentagonBokeh(): void;
  60945. /**
  60946. * Disables the pentagon bokeh effect
  60947. */
  60948. disablePentagonBokeh(): void;
  60949. /**
  60950. * Enables noise blur
  60951. */
  60952. enableNoiseBlur(): void;
  60953. /**
  60954. * Disables noise blur
  60955. */
  60956. disableNoiseBlur(): void;
  60957. /**
  60958. * Sets the HighlightsGain amount
  60959. * @param amount amount of HighlightsGain
  60960. */
  60961. setHighlightsGain(amount: number): void;
  60962. /**
  60963. * Sets the HighlightsThreshold amount
  60964. * @param amount amount of HighlightsThreshold
  60965. */
  60966. setHighlightsThreshold(amount: number): void;
  60967. /**
  60968. * Disables highlights
  60969. */
  60970. disableHighlights(): void;
  60971. /**
  60972. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60973. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60974. */
  60975. dispose(disableDepthRender?: boolean): void;
  60976. private _createChromaticAberrationPostProcess;
  60977. private _createHighlightsPostProcess;
  60978. private _createDepthOfFieldPostProcess;
  60979. private _createGrainTexture;
  60980. }
  60981. }
  60982. declare module BABYLON {
  60983. /** @hidden */
  60984. export var ssao2PixelShader: {
  60985. name: string;
  60986. shader: string;
  60987. };
  60988. }
  60989. declare module BABYLON {
  60990. /** @hidden */
  60991. export var ssaoCombinePixelShader: {
  60992. name: string;
  60993. shader: string;
  60994. };
  60995. }
  60996. declare module BABYLON {
  60997. /**
  60998. * Render pipeline to produce ssao effect
  60999. */
  61000. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61001. /**
  61002. * @ignore
  61003. * The PassPostProcess id in the pipeline that contains the original scene color
  61004. */
  61005. SSAOOriginalSceneColorEffect: string;
  61006. /**
  61007. * @ignore
  61008. * The SSAO PostProcess id in the pipeline
  61009. */
  61010. SSAORenderEffect: string;
  61011. /**
  61012. * @ignore
  61013. * The horizontal blur PostProcess id in the pipeline
  61014. */
  61015. SSAOBlurHRenderEffect: string;
  61016. /**
  61017. * @ignore
  61018. * The vertical blur PostProcess id in the pipeline
  61019. */
  61020. SSAOBlurVRenderEffect: string;
  61021. /**
  61022. * @ignore
  61023. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61024. */
  61025. SSAOCombineRenderEffect: string;
  61026. /**
  61027. * The output strength of the SSAO post-process. Default value is 1.0.
  61028. */
  61029. totalStrength: number;
  61030. /**
  61031. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61032. */
  61033. maxZ: number;
  61034. /**
  61035. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61036. */
  61037. minZAspect: number;
  61038. private _samples;
  61039. /**
  61040. * Number of samples used for the SSAO calculations. Default value is 8
  61041. */
  61042. samples: number;
  61043. private _textureSamples;
  61044. /**
  61045. * Number of samples to use for antialiasing
  61046. */
  61047. textureSamples: number;
  61048. /**
  61049. * Ratio object used for SSAO ratio and blur ratio
  61050. */
  61051. private _ratio;
  61052. /**
  61053. * Dynamically generated sphere sampler.
  61054. */
  61055. private _sampleSphere;
  61056. /**
  61057. * Blur filter offsets
  61058. */
  61059. private _samplerOffsets;
  61060. private _expensiveBlur;
  61061. /**
  61062. * If bilateral blur should be used
  61063. */
  61064. expensiveBlur: boolean;
  61065. /**
  61066. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61067. */
  61068. radius: number;
  61069. /**
  61070. * The base color of the SSAO post-process
  61071. * The final result is "base + ssao" between [0, 1]
  61072. */
  61073. base: number;
  61074. /**
  61075. * Support test.
  61076. */
  61077. static readonly IsSupported: boolean;
  61078. private _scene;
  61079. private _depthTexture;
  61080. private _normalTexture;
  61081. private _randomTexture;
  61082. private _originalColorPostProcess;
  61083. private _ssaoPostProcess;
  61084. private _blurHPostProcess;
  61085. private _blurVPostProcess;
  61086. private _ssaoCombinePostProcess;
  61087. private _firstUpdate;
  61088. /**
  61089. * Gets active scene
  61090. */
  61091. readonly scene: Scene;
  61092. /**
  61093. * @constructor
  61094. * @param name The rendering pipeline name
  61095. * @param scene The scene linked to this pipeline
  61096. * @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 }
  61097. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61098. */
  61099. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61100. /**
  61101. * Get the class name
  61102. * @returns "SSAO2RenderingPipeline"
  61103. */
  61104. getClassName(): string;
  61105. /**
  61106. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61107. */
  61108. dispose(disableGeometryBufferRenderer?: boolean): void;
  61109. private _createBlurPostProcess;
  61110. /** @hidden */
  61111. _rebuild(): void;
  61112. private _bits;
  61113. private _radicalInverse_VdC;
  61114. private _hammersley;
  61115. private _hemisphereSample_uniform;
  61116. private _generateHemisphere;
  61117. private _createSSAOPostProcess;
  61118. private _createSSAOCombinePostProcess;
  61119. private _createRandomTexture;
  61120. /**
  61121. * Serialize the rendering pipeline (Used when exporting)
  61122. * @returns the serialized object
  61123. */
  61124. serialize(): any;
  61125. /**
  61126. * Parse the serialized pipeline
  61127. * @param source Source pipeline.
  61128. * @param scene The scene to load the pipeline to.
  61129. * @param rootUrl The URL of the serialized pipeline.
  61130. * @returns An instantiated pipeline from the serialized object.
  61131. */
  61132. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61133. }
  61134. }
  61135. declare module BABYLON {
  61136. /** @hidden */
  61137. export var ssaoPixelShader: {
  61138. name: string;
  61139. shader: string;
  61140. };
  61141. }
  61142. declare module BABYLON {
  61143. /**
  61144. * Render pipeline to produce ssao effect
  61145. */
  61146. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61147. /**
  61148. * @ignore
  61149. * The PassPostProcess id in the pipeline that contains the original scene color
  61150. */
  61151. SSAOOriginalSceneColorEffect: string;
  61152. /**
  61153. * @ignore
  61154. * The SSAO PostProcess id in the pipeline
  61155. */
  61156. SSAORenderEffect: string;
  61157. /**
  61158. * @ignore
  61159. * The horizontal blur PostProcess id in the pipeline
  61160. */
  61161. SSAOBlurHRenderEffect: string;
  61162. /**
  61163. * @ignore
  61164. * The vertical blur PostProcess id in the pipeline
  61165. */
  61166. SSAOBlurVRenderEffect: string;
  61167. /**
  61168. * @ignore
  61169. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61170. */
  61171. SSAOCombineRenderEffect: string;
  61172. /**
  61173. * The output strength of the SSAO post-process. Default value is 1.0.
  61174. */
  61175. totalStrength: number;
  61176. /**
  61177. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61178. */
  61179. radius: number;
  61180. /**
  61181. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61182. * Must not be equal to fallOff and superior to fallOff.
  61183. * Default value is 0.0075
  61184. */
  61185. area: number;
  61186. /**
  61187. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61188. * Must not be equal to area and inferior to area.
  61189. * Default value is 0.000001
  61190. */
  61191. fallOff: number;
  61192. /**
  61193. * The base color of the SSAO post-process
  61194. * The final result is "base + ssao" between [0, 1]
  61195. */
  61196. base: number;
  61197. private _scene;
  61198. private _depthTexture;
  61199. private _randomTexture;
  61200. private _originalColorPostProcess;
  61201. private _ssaoPostProcess;
  61202. private _blurHPostProcess;
  61203. private _blurVPostProcess;
  61204. private _ssaoCombinePostProcess;
  61205. private _firstUpdate;
  61206. /**
  61207. * Gets active scene
  61208. */
  61209. readonly scene: Scene;
  61210. /**
  61211. * @constructor
  61212. * @param name - The rendering pipeline name
  61213. * @param scene - The scene linked to this pipeline
  61214. * @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 }
  61215. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61216. */
  61217. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61218. /**
  61219. * Get the class name
  61220. * @returns "SSAORenderingPipeline"
  61221. */
  61222. getClassName(): string;
  61223. /**
  61224. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61225. */
  61226. dispose(disableDepthRender?: boolean): void;
  61227. private _createBlurPostProcess;
  61228. /** @hidden */
  61229. _rebuild(): void;
  61230. private _createSSAOPostProcess;
  61231. private _createSSAOCombinePostProcess;
  61232. private _createRandomTexture;
  61233. }
  61234. }
  61235. declare module BABYLON {
  61236. /** @hidden */
  61237. export var standardPixelShader: {
  61238. name: string;
  61239. shader: string;
  61240. };
  61241. }
  61242. declare module BABYLON {
  61243. /**
  61244. * Standard rendering pipeline
  61245. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61246. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61247. */
  61248. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61249. /**
  61250. * Public members
  61251. */
  61252. /**
  61253. * Post-process which contains the original scene color before the pipeline applies all the effects
  61254. */
  61255. originalPostProcess: Nullable<PostProcess>;
  61256. /**
  61257. * Post-process used to down scale an image x4
  61258. */
  61259. downSampleX4PostProcess: Nullable<PostProcess>;
  61260. /**
  61261. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61262. */
  61263. brightPassPostProcess: Nullable<PostProcess>;
  61264. /**
  61265. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61266. */
  61267. blurHPostProcesses: PostProcess[];
  61268. /**
  61269. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61270. */
  61271. blurVPostProcesses: PostProcess[];
  61272. /**
  61273. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61274. */
  61275. textureAdderPostProcess: Nullable<PostProcess>;
  61276. /**
  61277. * Post-process used to create volumetric lighting effect
  61278. */
  61279. volumetricLightPostProcess: Nullable<PostProcess>;
  61280. /**
  61281. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61282. */
  61283. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61284. /**
  61285. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61286. */
  61287. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61288. /**
  61289. * Post-process used to merge the volumetric light effect and the real scene color
  61290. */
  61291. volumetricLightMergePostProces: Nullable<PostProcess>;
  61292. /**
  61293. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61294. */
  61295. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61296. /**
  61297. * Base post-process used to calculate the average luminance of the final image for HDR
  61298. */
  61299. luminancePostProcess: Nullable<PostProcess>;
  61300. /**
  61301. * Post-processes used to create down sample post-processes in order to get
  61302. * the average luminance of the final image for HDR
  61303. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61304. */
  61305. luminanceDownSamplePostProcesses: PostProcess[];
  61306. /**
  61307. * Post-process used to create a HDR effect (light adaptation)
  61308. */
  61309. hdrPostProcess: Nullable<PostProcess>;
  61310. /**
  61311. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61312. */
  61313. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61314. /**
  61315. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61316. */
  61317. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61318. /**
  61319. * Post-process used to merge the final HDR post-process and the real scene color
  61320. */
  61321. hdrFinalPostProcess: Nullable<PostProcess>;
  61322. /**
  61323. * Post-process used to create a lens flare effect
  61324. */
  61325. lensFlarePostProcess: Nullable<PostProcess>;
  61326. /**
  61327. * Post-process that merges the result of the lens flare post-process and the real scene color
  61328. */
  61329. lensFlareComposePostProcess: Nullable<PostProcess>;
  61330. /**
  61331. * Post-process used to create a motion blur effect
  61332. */
  61333. motionBlurPostProcess: Nullable<PostProcess>;
  61334. /**
  61335. * Post-process used to create a depth of field effect
  61336. */
  61337. depthOfFieldPostProcess: Nullable<PostProcess>;
  61338. /**
  61339. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61340. */
  61341. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61342. /**
  61343. * Represents the brightness threshold in order to configure the illuminated surfaces
  61344. */
  61345. brightThreshold: number;
  61346. /**
  61347. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61348. */
  61349. blurWidth: number;
  61350. /**
  61351. * Sets if the blur for highlighted surfaces must be only horizontal
  61352. */
  61353. horizontalBlur: boolean;
  61354. /**
  61355. * Gets the overall exposure used by the pipeline
  61356. */
  61357. /**
  61358. * Sets the overall exposure used by the pipeline
  61359. */
  61360. exposure: number;
  61361. /**
  61362. * Texture used typically to simulate "dirty" on camera lens
  61363. */
  61364. lensTexture: Nullable<Texture>;
  61365. /**
  61366. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61367. */
  61368. volumetricLightCoefficient: number;
  61369. /**
  61370. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61371. */
  61372. volumetricLightPower: number;
  61373. /**
  61374. * Used the set the blur intensity to smooth the volumetric lights
  61375. */
  61376. volumetricLightBlurScale: number;
  61377. /**
  61378. * Light (spot or directional) used to generate the volumetric lights rays
  61379. * The source light must have a shadow generate so the pipeline can get its
  61380. * depth map
  61381. */
  61382. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61383. /**
  61384. * For eye adaptation, represents the minimum luminance the eye can see
  61385. */
  61386. hdrMinimumLuminance: number;
  61387. /**
  61388. * For eye adaptation, represents the decrease luminance speed
  61389. */
  61390. hdrDecreaseRate: number;
  61391. /**
  61392. * For eye adaptation, represents the increase luminance speed
  61393. */
  61394. hdrIncreaseRate: number;
  61395. /**
  61396. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61397. */
  61398. /**
  61399. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61400. */
  61401. hdrAutoExposure: boolean;
  61402. /**
  61403. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61404. */
  61405. lensColorTexture: Nullable<Texture>;
  61406. /**
  61407. * The overall strengh for the lens flare effect
  61408. */
  61409. lensFlareStrength: number;
  61410. /**
  61411. * Dispersion coefficient for lens flare ghosts
  61412. */
  61413. lensFlareGhostDispersal: number;
  61414. /**
  61415. * Main lens flare halo width
  61416. */
  61417. lensFlareHaloWidth: number;
  61418. /**
  61419. * Based on the lens distortion effect, defines how much the lens flare result
  61420. * is distorted
  61421. */
  61422. lensFlareDistortionStrength: number;
  61423. /**
  61424. * Configures the blur intensity used for for lens flare (halo)
  61425. */
  61426. lensFlareBlurWidth: number;
  61427. /**
  61428. * Lens star texture must be used to simulate rays on the flares and is available
  61429. * in the documentation
  61430. */
  61431. lensStarTexture: Nullable<Texture>;
  61432. /**
  61433. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61434. * flare effect by taking account of the dirt texture
  61435. */
  61436. lensFlareDirtTexture: Nullable<Texture>;
  61437. /**
  61438. * Represents the focal length for the depth of field effect
  61439. */
  61440. depthOfFieldDistance: number;
  61441. /**
  61442. * Represents the blur intensity for the blurred part of the depth of field effect
  61443. */
  61444. depthOfFieldBlurWidth: number;
  61445. /**
  61446. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61447. */
  61448. /**
  61449. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61450. */
  61451. motionStrength: number;
  61452. /**
  61453. * Gets wether or not the motion blur post-process is object based or screen based.
  61454. */
  61455. /**
  61456. * Sets wether or not the motion blur post-process should be object based or screen based
  61457. */
  61458. objectBasedMotionBlur: boolean;
  61459. /**
  61460. * List of animations for the pipeline (IAnimatable implementation)
  61461. */
  61462. animations: Animation[];
  61463. /**
  61464. * Private members
  61465. */
  61466. private _scene;
  61467. private _currentDepthOfFieldSource;
  61468. private _basePostProcess;
  61469. private _fixedExposure;
  61470. private _currentExposure;
  61471. private _hdrAutoExposure;
  61472. private _hdrCurrentLuminance;
  61473. private _motionStrength;
  61474. private _isObjectBasedMotionBlur;
  61475. private _floatTextureType;
  61476. private _camerasToBeAttached;
  61477. private _ratio;
  61478. private _bloomEnabled;
  61479. private _depthOfFieldEnabled;
  61480. private _vlsEnabled;
  61481. private _lensFlareEnabled;
  61482. private _hdrEnabled;
  61483. private _motionBlurEnabled;
  61484. private _fxaaEnabled;
  61485. private _motionBlurSamples;
  61486. private _volumetricLightStepsCount;
  61487. private _samples;
  61488. /**
  61489. * @ignore
  61490. * Specifies if the bloom pipeline is enabled
  61491. */
  61492. BloomEnabled: boolean;
  61493. /**
  61494. * @ignore
  61495. * Specifies if the depth of field pipeline is enabed
  61496. */
  61497. DepthOfFieldEnabled: boolean;
  61498. /**
  61499. * @ignore
  61500. * Specifies if the lens flare pipeline is enabed
  61501. */
  61502. LensFlareEnabled: boolean;
  61503. /**
  61504. * @ignore
  61505. * Specifies if the HDR pipeline is enabled
  61506. */
  61507. HDREnabled: boolean;
  61508. /**
  61509. * @ignore
  61510. * Specifies if the volumetric lights scattering effect is enabled
  61511. */
  61512. VLSEnabled: boolean;
  61513. /**
  61514. * @ignore
  61515. * Specifies if the motion blur effect is enabled
  61516. */
  61517. MotionBlurEnabled: boolean;
  61518. /**
  61519. * Specifies if anti-aliasing is enabled
  61520. */
  61521. fxaaEnabled: boolean;
  61522. /**
  61523. * Specifies the number of steps used to calculate the volumetric lights
  61524. * Typically in interval [50, 200]
  61525. */
  61526. volumetricLightStepsCount: number;
  61527. /**
  61528. * Specifies the number of samples used for the motion blur effect
  61529. * Typically in interval [16, 64]
  61530. */
  61531. motionBlurSamples: number;
  61532. /**
  61533. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61534. */
  61535. samples: number;
  61536. /**
  61537. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61538. * @constructor
  61539. * @param name The rendering pipeline name
  61540. * @param scene The scene linked to this pipeline
  61541. * @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)
  61542. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61543. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61544. */
  61545. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61546. private _buildPipeline;
  61547. private _createDownSampleX4PostProcess;
  61548. private _createBrightPassPostProcess;
  61549. private _createBlurPostProcesses;
  61550. private _createTextureAdderPostProcess;
  61551. private _createVolumetricLightPostProcess;
  61552. private _createLuminancePostProcesses;
  61553. private _createHdrPostProcess;
  61554. private _createLensFlarePostProcess;
  61555. private _createDepthOfFieldPostProcess;
  61556. private _createMotionBlurPostProcess;
  61557. private _getDepthTexture;
  61558. private _disposePostProcesses;
  61559. /**
  61560. * Dispose of the pipeline and stop all post processes
  61561. */
  61562. dispose(): void;
  61563. /**
  61564. * Serialize the rendering pipeline (Used when exporting)
  61565. * @returns the serialized object
  61566. */
  61567. serialize(): any;
  61568. /**
  61569. * Parse the serialized pipeline
  61570. * @param source Source pipeline.
  61571. * @param scene The scene to load the pipeline to.
  61572. * @param rootUrl The URL of the serialized pipeline.
  61573. * @returns An instantiated pipeline from the serialized object.
  61574. */
  61575. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61576. /**
  61577. * Luminance steps
  61578. */
  61579. static LuminanceSteps: number;
  61580. }
  61581. }
  61582. declare module BABYLON {
  61583. /** @hidden */
  61584. export var tonemapPixelShader: {
  61585. name: string;
  61586. shader: string;
  61587. };
  61588. }
  61589. declare module BABYLON {
  61590. /** Defines operator used for tonemapping */
  61591. export enum TonemappingOperator {
  61592. /** Hable */
  61593. Hable = 0,
  61594. /** Reinhard */
  61595. Reinhard = 1,
  61596. /** HejiDawson */
  61597. HejiDawson = 2,
  61598. /** Photographic */
  61599. Photographic = 3
  61600. }
  61601. /**
  61602. * Defines a post process to apply tone mapping
  61603. */
  61604. export class TonemapPostProcess extends PostProcess {
  61605. private _operator;
  61606. /** Defines the required exposure adjustement */
  61607. exposureAdjustment: number;
  61608. /**
  61609. * Creates a new TonemapPostProcess
  61610. * @param name defines the name of the postprocess
  61611. * @param _operator defines the operator to use
  61612. * @param exposureAdjustment defines the required exposure adjustement
  61613. * @param camera defines the camera to use (can be null)
  61614. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61615. * @param engine defines the hosting engine (can be ignore if camera is set)
  61616. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61617. */
  61618. constructor(name: string, _operator: TonemappingOperator,
  61619. /** Defines the required exposure adjustement */
  61620. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /** @hidden */
  61625. export var depthVertexShader: {
  61626. name: string;
  61627. shader: string;
  61628. };
  61629. }
  61630. declare module BABYLON {
  61631. /** @hidden */
  61632. export var volumetricLightScatteringPixelShader: {
  61633. name: string;
  61634. shader: string;
  61635. };
  61636. }
  61637. declare module BABYLON {
  61638. /** @hidden */
  61639. export var volumetricLightScatteringPassVertexShader: {
  61640. name: string;
  61641. shader: string;
  61642. };
  61643. }
  61644. declare module BABYLON {
  61645. /** @hidden */
  61646. export var volumetricLightScatteringPassPixelShader: {
  61647. name: string;
  61648. shader: string;
  61649. };
  61650. }
  61651. declare module BABYLON {
  61652. /**
  61653. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61654. */
  61655. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61656. private _volumetricLightScatteringPass;
  61657. private _volumetricLightScatteringRTT;
  61658. private _viewPort;
  61659. private _screenCoordinates;
  61660. private _cachedDefines;
  61661. /**
  61662. * If not undefined, the mesh position is computed from the attached node position
  61663. */
  61664. attachedNode: {
  61665. position: Vector3;
  61666. };
  61667. /**
  61668. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61669. */
  61670. customMeshPosition: Vector3;
  61671. /**
  61672. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61673. */
  61674. useCustomMeshPosition: boolean;
  61675. /**
  61676. * If the post-process should inverse the light scattering direction
  61677. */
  61678. invert: boolean;
  61679. /**
  61680. * The internal mesh used by the post-process
  61681. */
  61682. mesh: Mesh;
  61683. /**
  61684. * @hidden
  61685. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61686. */
  61687. useDiffuseColor: boolean;
  61688. /**
  61689. * Array containing the excluded meshes not rendered in the internal pass
  61690. */
  61691. excludedMeshes: AbstractMesh[];
  61692. /**
  61693. * Controls the overall intensity of the post-process
  61694. */
  61695. exposure: number;
  61696. /**
  61697. * Dissipates each sample's contribution in range [0, 1]
  61698. */
  61699. decay: number;
  61700. /**
  61701. * Controls the overall intensity of each sample
  61702. */
  61703. weight: number;
  61704. /**
  61705. * Controls the density of each sample
  61706. */
  61707. density: number;
  61708. /**
  61709. * @constructor
  61710. * @param name The post-process name
  61711. * @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)
  61712. * @param camera The camera that the post-process will be attached to
  61713. * @param mesh The mesh used to create the light scattering
  61714. * @param samples The post-process quality, default 100
  61715. * @param samplingModeThe post-process filtering mode
  61716. * @param engine The babylon engine
  61717. * @param reusable If the post-process is reusable
  61718. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61719. */
  61720. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61721. /**
  61722. * Returns the string "VolumetricLightScatteringPostProcess"
  61723. * @returns "VolumetricLightScatteringPostProcess"
  61724. */
  61725. getClassName(): string;
  61726. private _isReady;
  61727. /**
  61728. * Sets the new light position for light scattering effect
  61729. * @param position The new custom light position
  61730. */
  61731. setCustomMeshPosition(position: Vector3): void;
  61732. /**
  61733. * Returns the light position for light scattering effect
  61734. * @return Vector3 The custom light position
  61735. */
  61736. getCustomMeshPosition(): Vector3;
  61737. /**
  61738. * Disposes the internal assets and detaches the post-process from the camera
  61739. */
  61740. dispose(camera: Camera): void;
  61741. /**
  61742. * Returns the render target texture used by the post-process
  61743. * @return the render target texture used by the post-process
  61744. */
  61745. getPass(): RenderTargetTexture;
  61746. private _meshExcluded;
  61747. private _createPass;
  61748. private _updateMeshScreenCoordinates;
  61749. /**
  61750. * Creates a default mesh for the Volumeric Light Scattering post-process
  61751. * @param name The mesh name
  61752. * @param scene The scene where to create the mesh
  61753. * @return the default mesh
  61754. */
  61755. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61756. }
  61757. }
  61758. declare module BABYLON {
  61759. interface Scene {
  61760. /** @hidden (Backing field) */
  61761. _boundingBoxRenderer: BoundingBoxRenderer;
  61762. /** @hidden (Backing field) */
  61763. _forceShowBoundingBoxes: boolean;
  61764. /**
  61765. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61766. */
  61767. forceShowBoundingBoxes: boolean;
  61768. /**
  61769. * Gets the bounding box renderer associated with the scene
  61770. * @returns a BoundingBoxRenderer
  61771. */
  61772. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61773. }
  61774. interface AbstractMesh {
  61775. /** @hidden (Backing field) */
  61776. _showBoundingBox: boolean;
  61777. /**
  61778. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61779. */
  61780. showBoundingBox: boolean;
  61781. }
  61782. /**
  61783. * Component responsible of rendering the bounding box of the meshes in a scene.
  61784. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61785. */
  61786. export class BoundingBoxRenderer implements ISceneComponent {
  61787. /**
  61788. * The component name helpfull to identify the component in the list of scene components.
  61789. */
  61790. readonly name: string;
  61791. /**
  61792. * The scene the component belongs to.
  61793. */
  61794. scene: Scene;
  61795. /**
  61796. * Color of the bounding box lines placed in front of an object
  61797. */
  61798. frontColor: Color3;
  61799. /**
  61800. * Color of the bounding box lines placed behind an object
  61801. */
  61802. backColor: Color3;
  61803. /**
  61804. * Defines if the renderer should show the back lines or not
  61805. */
  61806. showBackLines: boolean;
  61807. /**
  61808. * @hidden
  61809. */
  61810. renderList: SmartArray<BoundingBox>;
  61811. private _colorShader;
  61812. private _vertexBuffers;
  61813. private _indexBuffer;
  61814. private _fillIndexBuffer;
  61815. private _fillIndexData;
  61816. /**
  61817. * Instantiates a new bounding box renderer in a scene.
  61818. * @param scene the scene the renderer renders in
  61819. */
  61820. constructor(scene: Scene);
  61821. /**
  61822. * Registers the component in a given scene
  61823. */
  61824. register(): void;
  61825. private _evaluateSubMesh;
  61826. private _activeMesh;
  61827. private _prepareRessources;
  61828. private _createIndexBuffer;
  61829. /**
  61830. * Rebuilds the elements related to this component in case of
  61831. * context lost for instance.
  61832. */
  61833. rebuild(): void;
  61834. /**
  61835. * @hidden
  61836. */
  61837. reset(): void;
  61838. /**
  61839. * Render the bounding boxes of a specific rendering group
  61840. * @param renderingGroupId defines the rendering group to render
  61841. */
  61842. render(renderingGroupId: number): void;
  61843. /**
  61844. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61845. * @param mesh Define the mesh to render the occlusion bounding box for
  61846. */
  61847. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61848. /**
  61849. * Dispose and release the resources attached to this renderer.
  61850. */
  61851. dispose(): void;
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /** @hidden */
  61856. export var depthPixelShader: {
  61857. name: string;
  61858. shader: string;
  61859. };
  61860. }
  61861. declare module BABYLON {
  61862. /**
  61863. * This represents a depth renderer in Babylon.
  61864. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61865. */
  61866. export class DepthRenderer {
  61867. private _scene;
  61868. private _depthMap;
  61869. private _effect;
  61870. private readonly _storeNonLinearDepth;
  61871. private readonly _clearColor;
  61872. /** Get if the depth renderer is using packed depth or not */
  61873. readonly isPacked: boolean;
  61874. private _cachedDefines;
  61875. private _camera;
  61876. /**
  61877. * Specifiess that the depth renderer will only be used within
  61878. * the camera it is created for.
  61879. * This can help forcing its rendering during the camera processing.
  61880. */
  61881. useOnlyInActiveCamera: boolean;
  61882. /** @hidden */
  61883. static _SceneComponentInitialization: (scene: Scene) => void;
  61884. /**
  61885. * Instantiates a depth renderer
  61886. * @param scene The scene the renderer belongs to
  61887. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61888. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61889. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61890. */
  61891. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61892. /**
  61893. * Creates the depth rendering effect and checks if the effect is ready.
  61894. * @param subMesh The submesh to be used to render the depth map of
  61895. * @param useInstances If multiple world instances should be used
  61896. * @returns if the depth renderer is ready to render the depth map
  61897. */
  61898. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61899. /**
  61900. * Gets the texture which the depth map will be written to.
  61901. * @returns The depth map texture
  61902. */
  61903. getDepthMap(): RenderTargetTexture;
  61904. /**
  61905. * Disposes of the depth renderer.
  61906. */
  61907. dispose(): void;
  61908. }
  61909. }
  61910. declare module BABYLON {
  61911. interface Scene {
  61912. /** @hidden (Backing field) */
  61913. _depthRenderer: {
  61914. [id: string]: DepthRenderer;
  61915. };
  61916. /**
  61917. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61918. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61919. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61920. * @returns the created depth renderer
  61921. */
  61922. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61923. /**
  61924. * Disables a depth renderer for a given camera
  61925. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61926. */
  61927. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61928. }
  61929. /**
  61930. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61931. * in several rendering techniques.
  61932. */
  61933. export class DepthRendererSceneComponent implements ISceneComponent {
  61934. /**
  61935. * The component name helpfull to identify the component in the list of scene components.
  61936. */
  61937. readonly name: string;
  61938. /**
  61939. * The scene the component belongs to.
  61940. */
  61941. scene: Scene;
  61942. /**
  61943. * Creates a new instance of the component for the given scene
  61944. * @param scene Defines the scene to register the component in
  61945. */
  61946. constructor(scene: Scene);
  61947. /**
  61948. * Registers the component in a given scene
  61949. */
  61950. register(): void;
  61951. /**
  61952. * Rebuilds the elements related to this component in case of
  61953. * context lost for instance.
  61954. */
  61955. rebuild(): void;
  61956. /**
  61957. * Disposes the component and the associated ressources
  61958. */
  61959. dispose(): void;
  61960. private _gatherRenderTargets;
  61961. private _gatherActiveCameraRenderTargets;
  61962. }
  61963. }
  61964. declare module BABYLON {
  61965. /** @hidden */
  61966. export var outlinePixelShader: {
  61967. name: string;
  61968. shader: string;
  61969. };
  61970. }
  61971. declare module BABYLON {
  61972. /** @hidden */
  61973. export var outlineVertexShader: {
  61974. name: string;
  61975. shader: string;
  61976. };
  61977. }
  61978. declare module BABYLON {
  61979. interface Scene {
  61980. /** @hidden */
  61981. _outlineRenderer: OutlineRenderer;
  61982. /**
  61983. * Gets the outline renderer associated with the scene
  61984. * @returns a OutlineRenderer
  61985. */
  61986. getOutlineRenderer(): OutlineRenderer;
  61987. }
  61988. interface AbstractMesh {
  61989. /** @hidden (Backing field) */
  61990. _renderOutline: boolean;
  61991. /**
  61992. * Gets or sets a boolean indicating if the outline must be rendered as well
  61993. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61994. */
  61995. renderOutline: boolean;
  61996. /** @hidden (Backing field) */
  61997. _renderOverlay: boolean;
  61998. /**
  61999. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62000. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62001. */
  62002. renderOverlay: boolean;
  62003. }
  62004. /**
  62005. * This class is responsible to draw bothe outline/overlay of meshes.
  62006. * It should not be used directly but through the available method on mesh.
  62007. */
  62008. export class OutlineRenderer implements ISceneComponent {
  62009. /**
  62010. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62011. */
  62012. private static _StencilReference;
  62013. /**
  62014. * The name of the component. Each component must have a unique name.
  62015. */
  62016. name: string;
  62017. /**
  62018. * The scene the component belongs to.
  62019. */
  62020. scene: Scene;
  62021. /**
  62022. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62023. */
  62024. zOffset: number;
  62025. private _engine;
  62026. private _effect;
  62027. private _cachedDefines;
  62028. private _savedDepthWrite;
  62029. /**
  62030. * Instantiates a new outline renderer. (There could be only one per scene).
  62031. * @param scene Defines the scene it belongs to
  62032. */
  62033. constructor(scene: Scene);
  62034. /**
  62035. * Register the component to one instance of a scene.
  62036. */
  62037. register(): void;
  62038. /**
  62039. * Rebuilds the elements related to this component in case of
  62040. * context lost for instance.
  62041. */
  62042. rebuild(): void;
  62043. /**
  62044. * Disposes the component and the associated ressources.
  62045. */
  62046. dispose(): void;
  62047. /**
  62048. * Renders the outline in the canvas.
  62049. * @param subMesh Defines the sumesh to render
  62050. * @param batch Defines the batch of meshes in case of instances
  62051. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62052. */
  62053. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62054. /**
  62055. * Returns whether or not the outline renderer is ready for a given submesh.
  62056. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62057. * @param subMesh Defines the submesh to check readyness for
  62058. * @param useInstances Defines wheter wee are trying to render instances or not
  62059. * @returns true if ready otherwise false
  62060. */
  62061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62062. private _beforeRenderingMesh;
  62063. private _afterRenderingMesh;
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /**
  62068. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62069. * @see http://doc.babylonjs.com/babylon101/sprites
  62070. */
  62071. export class SpritePackedManager extends SpriteManager {
  62072. /** defines the packed manager's name */
  62073. name: string;
  62074. /**
  62075. * Creates a new sprite manager from a packed sprite sheet
  62076. * @param name defines the manager's name
  62077. * @param imgUrl defines the sprite sheet url
  62078. * @param capacity defines the maximum allowed number of sprites
  62079. * @param scene defines the hosting scene
  62080. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62081. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62082. * @param samplingMode defines the smapling mode to use with spritesheet
  62083. * @param fromPacked set to true; do not alter
  62084. */
  62085. constructor(
  62086. /** defines the packed manager's name */
  62087. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62088. }
  62089. }
  62090. declare module BABYLON {
  62091. /**
  62092. * Defines the list of states available for a task inside a AssetsManager
  62093. */
  62094. export enum AssetTaskState {
  62095. /**
  62096. * Initialization
  62097. */
  62098. INIT = 0,
  62099. /**
  62100. * Running
  62101. */
  62102. RUNNING = 1,
  62103. /**
  62104. * Done
  62105. */
  62106. DONE = 2,
  62107. /**
  62108. * Error
  62109. */
  62110. ERROR = 3
  62111. }
  62112. /**
  62113. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62114. */
  62115. export abstract class AbstractAssetTask {
  62116. /**
  62117. * Task name
  62118. */ name: string;
  62119. /**
  62120. * Callback called when the task is successful
  62121. */
  62122. onSuccess: (task: any) => void;
  62123. /**
  62124. * Callback called when the task is not successful
  62125. */
  62126. onError: (task: any, message?: string, exception?: any) => void;
  62127. /**
  62128. * Creates a new AssetsManager
  62129. * @param name defines the name of the task
  62130. */
  62131. constructor(
  62132. /**
  62133. * Task name
  62134. */ name: string);
  62135. private _isCompleted;
  62136. private _taskState;
  62137. private _errorObject;
  62138. /**
  62139. * Get if the task is completed
  62140. */
  62141. readonly isCompleted: boolean;
  62142. /**
  62143. * Gets the current state of the task
  62144. */
  62145. readonly taskState: AssetTaskState;
  62146. /**
  62147. * Gets the current error object (if task is in error)
  62148. */
  62149. readonly errorObject: {
  62150. message?: string;
  62151. exception?: any;
  62152. };
  62153. /**
  62154. * Internal only
  62155. * @hidden
  62156. */
  62157. _setErrorObject(message?: string, exception?: any): void;
  62158. /**
  62159. * Execute the current task
  62160. * @param scene defines the scene where you want your assets to be loaded
  62161. * @param onSuccess is a callback called when the task is successfully executed
  62162. * @param onError is a callback called if an error occurs
  62163. */
  62164. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62165. /**
  62166. * Execute the current task
  62167. * @param scene defines the scene where you want your assets to be loaded
  62168. * @param onSuccess is a callback called when the task is successfully executed
  62169. * @param onError is a callback called if an error occurs
  62170. */
  62171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62172. /**
  62173. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62174. * This can be used with failed tasks that have the reason for failure fixed.
  62175. */
  62176. reset(): void;
  62177. private onErrorCallback;
  62178. private onDoneCallback;
  62179. }
  62180. /**
  62181. * Define the interface used by progress events raised during assets loading
  62182. */
  62183. export interface IAssetsProgressEvent {
  62184. /**
  62185. * Defines the number of remaining tasks to process
  62186. */
  62187. remainingCount: number;
  62188. /**
  62189. * Defines the total number of tasks
  62190. */
  62191. totalCount: number;
  62192. /**
  62193. * Defines the task that was just processed
  62194. */
  62195. task: AbstractAssetTask;
  62196. }
  62197. /**
  62198. * Class used to share progress information about assets loading
  62199. */
  62200. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62201. /**
  62202. * Defines the number of remaining tasks to process
  62203. */
  62204. remainingCount: number;
  62205. /**
  62206. * Defines the total number of tasks
  62207. */
  62208. totalCount: number;
  62209. /**
  62210. * Defines the task that was just processed
  62211. */
  62212. task: AbstractAssetTask;
  62213. /**
  62214. * Creates a AssetsProgressEvent
  62215. * @param remainingCount defines the number of remaining tasks to process
  62216. * @param totalCount defines the total number of tasks
  62217. * @param task defines the task that was just processed
  62218. */
  62219. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62220. }
  62221. /**
  62222. * Define a task used by AssetsManager to load meshes
  62223. */
  62224. export class MeshAssetTask extends AbstractAssetTask {
  62225. /**
  62226. * Defines the name of the task
  62227. */
  62228. name: string;
  62229. /**
  62230. * Defines the list of mesh's names you want to load
  62231. */
  62232. meshesNames: any;
  62233. /**
  62234. * Defines the root url to use as a base to load your meshes and associated resources
  62235. */
  62236. rootUrl: string;
  62237. /**
  62238. * Defines the filename of the scene to load from
  62239. */
  62240. sceneFilename: string;
  62241. /**
  62242. * Gets the list of loaded meshes
  62243. */
  62244. loadedMeshes: Array<AbstractMesh>;
  62245. /**
  62246. * Gets the list of loaded particle systems
  62247. */
  62248. loadedParticleSystems: Array<IParticleSystem>;
  62249. /**
  62250. * Gets the list of loaded skeletons
  62251. */
  62252. loadedSkeletons: Array<Skeleton>;
  62253. /**
  62254. * Gets the list of loaded animation groups
  62255. */
  62256. loadedAnimationGroups: Array<AnimationGroup>;
  62257. /**
  62258. * Callback called when the task is successful
  62259. */
  62260. onSuccess: (task: MeshAssetTask) => void;
  62261. /**
  62262. * Callback called when the task is successful
  62263. */
  62264. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62265. /**
  62266. * Creates a new MeshAssetTask
  62267. * @param name defines the name of the task
  62268. * @param meshesNames defines the list of mesh's names you want to load
  62269. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62270. * @param sceneFilename defines the filename of the scene to load from
  62271. */
  62272. constructor(
  62273. /**
  62274. * Defines the name of the task
  62275. */
  62276. name: string,
  62277. /**
  62278. * Defines the list of mesh's names you want to load
  62279. */
  62280. meshesNames: any,
  62281. /**
  62282. * Defines the root url to use as a base to load your meshes and associated resources
  62283. */
  62284. rootUrl: string,
  62285. /**
  62286. * Defines the filename of the scene to load from
  62287. */
  62288. sceneFilename: string);
  62289. /**
  62290. * Execute the current task
  62291. * @param scene defines the scene where you want your assets to be loaded
  62292. * @param onSuccess is a callback called when the task is successfully executed
  62293. * @param onError is a callback called if an error occurs
  62294. */
  62295. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62296. }
  62297. /**
  62298. * Define a task used by AssetsManager to load text content
  62299. */
  62300. export class TextFileAssetTask extends AbstractAssetTask {
  62301. /**
  62302. * Defines the name of the task
  62303. */
  62304. name: string;
  62305. /**
  62306. * Defines the location of the file to load
  62307. */
  62308. url: string;
  62309. /**
  62310. * Gets the loaded text string
  62311. */
  62312. text: string;
  62313. /**
  62314. * Callback called when the task is successful
  62315. */
  62316. onSuccess: (task: TextFileAssetTask) => void;
  62317. /**
  62318. * Callback called when the task is successful
  62319. */
  62320. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62321. /**
  62322. * Creates a new TextFileAssetTask object
  62323. * @param name defines the name of the task
  62324. * @param url defines the location of the file to load
  62325. */
  62326. constructor(
  62327. /**
  62328. * Defines the name of the task
  62329. */
  62330. name: string,
  62331. /**
  62332. * Defines the location of the file to load
  62333. */
  62334. url: string);
  62335. /**
  62336. * Execute the current task
  62337. * @param scene defines the scene where you want your assets to be loaded
  62338. * @param onSuccess is a callback called when the task is successfully executed
  62339. * @param onError is a callback called if an error occurs
  62340. */
  62341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62342. }
  62343. /**
  62344. * Define a task used by AssetsManager to load binary data
  62345. */
  62346. export class BinaryFileAssetTask extends AbstractAssetTask {
  62347. /**
  62348. * Defines the name of the task
  62349. */
  62350. name: string;
  62351. /**
  62352. * Defines the location of the file to load
  62353. */
  62354. url: string;
  62355. /**
  62356. * Gets the lodaded data (as an array buffer)
  62357. */
  62358. data: ArrayBuffer;
  62359. /**
  62360. * Callback called when the task is successful
  62361. */
  62362. onSuccess: (task: BinaryFileAssetTask) => void;
  62363. /**
  62364. * Callback called when the task is successful
  62365. */
  62366. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62367. /**
  62368. * Creates a new BinaryFileAssetTask object
  62369. * @param name defines the name of the new task
  62370. * @param url defines the location of the file to load
  62371. */
  62372. constructor(
  62373. /**
  62374. * Defines the name of the task
  62375. */
  62376. name: string,
  62377. /**
  62378. * Defines the location of the file to load
  62379. */
  62380. url: string);
  62381. /**
  62382. * Execute the current task
  62383. * @param scene defines the scene where you want your assets to be loaded
  62384. * @param onSuccess is a callback called when the task is successfully executed
  62385. * @param onError is a callback called if an error occurs
  62386. */
  62387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62388. }
  62389. /**
  62390. * Define a task used by AssetsManager to load images
  62391. */
  62392. export class ImageAssetTask extends AbstractAssetTask {
  62393. /**
  62394. * Defines the name of the task
  62395. */
  62396. name: string;
  62397. /**
  62398. * Defines the location of the image to load
  62399. */
  62400. url: string;
  62401. /**
  62402. * Gets the loaded images
  62403. */
  62404. image: HTMLImageElement;
  62405. /**
  62406. * Callback called when the task is successful
  62407. */
  62408. onSuccess: (task: ImageAssetTask) => void;
  62409. /**
  62410. * Callback called when the task is successful
  62411. */
  62412. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62413. /**
  62414. * Creates a new ImageAssetTask
  62415. * @param name defines the name of the task
  62416. * @param url defines the location of the image to load
  62417. */
  62418. constructor(
  62419. /**
  62420. * Defines the name of the task
  62421. */
  62422. name: string,
  62423. /**
  62424. * Defines the location of the image to load
  62425. */
  62426. url: string);
  62427. /**
  62428. * Execute the current task
  62429. * @param scene defines the scene where you want your assets to be loaded
  62430. * @param onSuccess is a callback called when the task is successfully executed
  62431. * @param onError is a callback called if an error occurs
  62432. */
  62433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62434. }
  62435. /**
  62436. * Defines the interface used by texture loading tasks
  62437. */
  62438. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62439. /**
  62440. * Gets the loaded texture
  62441. */
  62442. texture: TEX;
  62443. }
  62444. /**
  62445. * Define a task used by AssetsManager to load 2D textures
  62446. */
  62447. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62448. /**
  62449. * Defines the name of the task
  62450. */
  62451. name: string;
  62452. /**
  62453. * Defines the location of the file to load
  62454. */
  62455. url: string;
  62456. /**
  62457. * Defines if mipmap should not be generated (default is false)
  62458. */
  62459. noMipmap?: boolean | undefined;
  62460. /**
  62461. * Defines if texture must be inverted on Y axis (default is false)
  62462. */
  62463. invertY?: boolean | undefined;
  62464. /**
  62465. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62466. */
  62467. samplingMode: number;
  62468. /**
  62469. * Gets the loaded texture
  62470. */
  62471. texture: Texture;
  62472. /**
  62473. * Callback called when the task is successful
  62474. */
  62475. onSuccess: (task: TextureAssetTask) => void;
  62476. /**
  62477. * Callback called when the task is successful
  62478. */
  62479. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62480. /**
  62481. * Creates a new TextureAssetTask object
  62482. * @param name defines the name of the task
  62483. * @param url defines the location of the file to load
  62484. * @param noMipmap defines if mipmap should not be generated (default is false)
  62485. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62486. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62487. */
  62488. constructor(
  62489. /**
  62490. * Defines the name of the task
  62491. */
  62492. name: string,
  62493. /**
  62494. * Defines the location of the file to load
  62495. */
  62496. url: string,
  62497. /**
  62498. * Defines if mipmap should not be generated (default is false)
  62499. */
  62500. noMipmap?: boolean | undefined,
  62501. /**
  62502. * Defines if texture must be inverted on Y axis (default is false)
  62503. */
  62504. invertY?: boolean | undefined,
  62505. /**
  62506. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62507. */
  62508. samplingMode?: number);
  62509. /**
  62510. * Execute the current task
  62511. * @param scene defines the scene where you want your assets to be loaded
  62512. * @param onSuccess is a callback called when the task is successfully executed
  62513. * @param onError is a callback called if an error occurs
  62514. */
  62515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62516. }
  62517. /**
  62518. * Define a task used by AssetsManager to load cube textures
  62519. */
  62520. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62521. /**
  62522. * Defines the name of the task
  62523. */
  62524. name: string;
  62525. /**
  62526. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62527. */
  62528. url: string;
  62529. /**
  62530. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62531. */
  62532. extensions?: string[] | undefined;
  62533. /**
  62534. * Defines if mipmaps should not be generated (default is false)
  62535. */
  62536. noMipmap?: boolean | undefined;
  62537. /**
  62538. * Defines the explicit list of files (undefined by default)
  62539. */
  62540. files?: string[] | undefined;
  62541. /**
  62542. * Gets the loaded texture
  62543. */
  62544. texture: CubeTexture;
  62545. /**
  62546. * Callback called when the task is successful
  62547. */
  62548. onSuccess: (task: CubeTextureAssetTask) => void;
  62549. /**
  62550. * Callback called when the task is successful
  62551. */
  62552. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62553. /**
  62554. * Creates a new CubeTextureAssetTask
  62555. * @param name defines the name of the task
  62556. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62557. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62558. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62559. * @param files defines the explicit list of files (undefined by default)
  62560. */
  62561. constructor(
  62562. /**
  62563. * Defines the name of the task
  62564. */
  62565. name: string,
  62566. /**
  62567. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62568. */
  62569. url: string,
  62570. /**
  62571. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62572. */
  62573. extensions?: string[] | undefined,
  62574. /**
  62575. * Defines if mipmaps should not be generated (default is false)
  62576. */
  62577. noMipmap?: boolean | undefined,
  62578. /**
  62579. * Defines the explicit list of files (undefined by default)
  62580. */
  62581. files?: string[] | undefined);
  62582. /**
  62583. * Execute the current task
  62584. * @param scene defines the scene where you want your assets to be loaded
  62585. * @param onSuccess is a callback called when the task is successfully executed
  62586. * @param onError is a callback called if an error occurs
  62587. */
  62588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62589. }
  62590. /**
  62591. * Define a task used by AssetsManager to load HDR cube textures
  62592. */
  62593. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62594. /**
  62595. * Defines the name of the task
  62596. */
  62597. name: string;
  62598. /**
  62599. * Defines the location of the file to load
  62600. */
  62601. url: string;
  62602. /**
  62603. * Defines the desired size (the more it increases the longer the generation will be)
  62604. */
  62605. size: number;
  62606. /**
  62607. * Defines if mipmaps should not be generated (default is false)
  62608. */
  62609. noMipmap: boolean;
  62610. /**
  62611. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62612. */
  62613. generateHarmonics: boolean;
  62614. /**
  62615. * 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)
  62616. */
  62617. gammaSpace: boolean;
  62618. /**
  62619. * Internal Use Only
  62620. */
  62621. reserved: boolean;
  62622. /**
  62623. * Gets the loaded texture
  62624. */
  62625. texture: HDRCubeTexture;
  62626. /**
  62627. * Callback called when the task is successful
  62628. */
  62629. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62630. /**
  62631. * Callback called when the task is successful
  62632. */
  62633. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62634. /**
  62635. * Creates a new HDRCubeTextureAssetTask object
  62636. * @param name defines the name of the task
  62637. * @param url defines the location of the file to load
  62638. * @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.
  62639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62640. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62641. * @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)
  62642. * @param reserved Internal use only
  62643. */
  62644. constructor(
  62645. /**
  62646. * Defines the name of the task
  62647. */
  62648. name: string,
  62649. /**
  62650. * Defines the location of the file to load
  62651. */
  62652. url: string,
  62653. /**
  62654. * Defines the desired size (the more it increases the longer the generation will be)
  62655. */
  62656. size: number,
  62657. /**
  62658. * Defines if mipmaps should not be generated (default is false)
  62659. */
  62660. noMipmap?: boolean,
  62661. /**
  62662. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62663. */
  62664. generateHarmonics?: boolean,
  62665. /**
  62666. * 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)
  62667. */
  62668. gammaSpace?: boolean,
  62669. /**
  62670. * Internal Use Only
  62671. */
  62672. reserved?: boolean);
  62673. /**
  62674. * Execute the current task
  62675. * @param scene defines the scene where you want your assets to be loaded
  62676. * @param onSuccess is a callback called when the task is successfully executed
  62677. * @param onError is a callback called if an error occurs
  62678. */
  62679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62680. }
  62681. /**
  62682. * Define a task used by AssetsManager to load Equirectangular cube textures
  62683. */
  62684. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62685. /**
  62686. * Defines the name of the task
  62687. */
  62688. name: string;
  62689. /**
  62690. * Defines the location of the file to load
  62691. */
  62692. url: string;
  62693. /**
  62694. * Defines the desired size (the more it increases the longer the generation will be)
  62695. */
  62696. size: number;
  62697. /**
  62698. * Defines if mipmaps should not be generated (default is false)
  62699. */
  62700. noMipmap: boolean;
  62701. /**
  62702. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62703. * but the standard material would require them in Gamma space) (default is true)
  62704. */
  62705. gammaSpace: boolean;
  62706. /**
  62707. * Gets the loaded texture
  62708. */
  62709. texture: EquiRectangularCubeTexture;
  62710. /**
  62711. * Callback called when the task is successful
  62712. */
  62713. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62714. /**
  62715. * Callback called when the task is successful
  62716. */
  62717. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62718. /**
  62719. * Creates a new EquiRectangularCubeTextureAssetTask object
  62720. * @param name defines the name of the task
  62721. * @param url defines the location of the file to load
  62722. * @param size defines the desired size (the more it increases the longer the generation will be)
  62723. * If the size is omitted this implies you are using a preprocessed cubemap.
  62724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62725. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62726. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62727. * (default is true)
  62728. */
  62729. constructor(
  62730. /**
  62731. * Defines the name of the task
  62732. */
  62733. name: string,
  62734. /**
  62735. * Defines the location of the file to load
  62736. */
  62737. url: string,
  62738. /**
  62739. * Defines the desired size (the more it increases the longer the generation will be)
  62740. */
  62741. size: number,
  62742. /**
  62743. * Defines if mipmaps should not be generated (default is false)
  62744. */
  62745. noMipmap?: boolean,
  62746. /**
  62747. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62748. * but the standard material would require them in Gamma space) (default is true)
  62749. */
  62750. gammaSpace?: boolean);
  62751. /**
  62752. * Execute the current task
  62753. * @param scene defines the scene where you want your assets to be loaded
  62754. * @param onSuccess is a callback called when the task is successfully executed
  62755. * @param onError is a callback called if an error occurs
  62756. */
  62757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62758. }
  62759. /**
  62760. * This class can be used to easily import assets into a scene
  62761. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62762. */
  62763. export class AssetsManager {
  62764. private _scene;
  62765. private _isLoading;
  62766. protected _tasks: AbstractAssetTask[];
  62767. protected _waitingTasksCount: number;
  62768. protected _totalTasksCount: number;
  62769. /**
  62770. * Callback called when all tasks are processed
  62771. */
  62772. onFinish: (tasks: AbstractAssetTask[]) => void;
  62773. /**
  62774. * Callback called when a task is successful
  62775. */
  62776. onTaskSuccess: (task: AbstractAssetTask) => void;
  62777. /**
  62778. * Callback called when a task had an error
  62779. */
  62780. onTaskError: (task: AbstractAssetTask) => void;
  62781. /**
  62782. * Callback called when a task is done (whatever the result is)
  62783. */
  62784. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62785. /**
  62786. * Observable called when all tasks are processed
  62787. */
  62788. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62789. /**
  62790. * Observable called when a task had an error
  62791. */
  62792. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62793. /**
  62794. * Observable called when all tasks were executed
  62795. */
  62796. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62797. /**
  62798. * Observable called when a task is done (whatever the result is)
  62799. */
  62800. onProgressObservable: Observable<IAssetsProgressEvent>;
  62801. /**
  62802. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62803. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62804. */
  62805. useDefaultLoadingScreen: boolean;
  62806. /**
  62807. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62808. * when all assets have been downloaded.
  62809. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62810. */
  62811. autoHideLoadingUI: boolean;
  62812. /**
  62813. * Creates a new AssetsManager
  62814. * @param scene defines the scene to work on
  62815. */
  62816. constructor(scene: Scene);
  62817. /**
  62818. * Add a MeshAssetTask to the list of active tasks
  62819. * @param taskName defines the name of the new task
  62820. * @param meshesNames defines the name of meshes to load
  62821. * @param rootUrl defines the root url to use to locate files
  62822. * @param sceneFilename defines the filename of the scene file
  62823. * @returns a new MeshAssetTask object
  62824. */
  62825. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62826. /**
  62827. * Add a TextFileAssetTask to the list of active tasks
  62828. * @param taskName defines the name of the new task
  62829. * @param url defines the url of the file to load
  62830. * @returns a new TextFileAssetTask object
  62831. */
  62832. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62833. /**
  62834. * Add a BinaryFileAssetTask to the list of active tasks
  62835. * @param taskName defines the name of the new task
  62836. * @param url defines the url of the file to load
  62837. * @returns a new BinaryFileAssetTask object
  62838. */
  62839. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62840. /**
  62841. * Add a ImageAssetTask to the list of active tasks
  62842. * @param taskName defines the name of the new task
  62843. * @param url defines the url of the file to load
  62844. * @returns a new ImageAssetTask object
  62845. */
  62846. addImageTask(taskName: string, url: string): ImageAssetTask;
  62847. /**
  62848. * Add a TextureAssetTask to the list of active tasks
  62849. * @param taskName defines the name of the new task
  62850. * @param url defines the url of the file to load
  62851. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62852. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62853. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62854. * @returns a new TextureAssetTask object
  62855. */
  62856. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62857. /**
  62858. * Add a CubeTextureAssetTask to the list of active tasks
  62859. * @param taskName defines the name of the new task
  62860. * @param url defines the url of the file to load
  62861. * @param extensions defines the extension to use to load the cube map (can be null)
  62862. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62863. * @param files defines the list of files to load (can be null)
  62864. * @returns a new CubeTextureAssetTask object
  62865. */
  62866. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62867. /**
  62868. *
  62869. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62870. * @param taskName defines the name of the new task
  62871. * @param url defines the url of the file to load
  62872. * @param size defines the size you want for the cubemap (can be null)
  62873. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62874. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62875. * @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)
  62876. * @param reserved Internal use only
  62877. * @returns a new HDRCubeTextureAssetTask object
  62878. */
  62879. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62880. /**
  62881. *
  62882. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62883. * @param taskName defines the name of the new task
  62884. * @param url defines the url of the file to load
  62885. * @param size defines the size you want for the cubemap (can be null)
  62886. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62887. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62888. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62889. * @returns a new EquiRectangularCubeTextureAssetTask object
  62890. */
  62891. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62892. /**
  62893. * Remove a task from the assets manager.
  62894. * @param task the task to remove
  62895. */
  62896. removeTask(task: AbstractAssetTask): void;
  62897. private _decreaseWaitingTasksCount;
  62898. private _runTask;
  62899. /**
  62900. * Reset the AssetsManager and remove all tasks
  62901. * @return the current instance of the AssetsManager
  62902. */
  62903. reset(): AssetsManager;
  62904. /**
  62905. * Start the loading process
  62906. * @return the current instance of the AssetsManager
  62907. */
  62908. load(): AssetsManager;
  62909. /**
  62910. * Start the loading process as an async operation
  62911. * @return a promise returning the list of failed tasks
  62912. */
  62913. loadAsync(): Promise<void>;
  62914. }
  62915. }
  62916. declare module BABYLON {
  62917. /**
  62918. * Wrapper class for promise with external resolve and reject.
  62919. */
  62920. export class Deferred<T> {
  62921. /**
  62922. * The promise associated with this deferred object.
  62923. */
  62924. readonly promise: Promise<T>;
  62925. private _resolve;
  62926. private _reject;
  62927. /**
  62928. * The resolve method of the promise associated with this deferred object.
  62929. */
  62930. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62931. /**
  62932. * The reject method of the promise associated with this deferred object.
  62933. */
  62934. readonly reject: (reason?: any) => void;
  62935. /**
  62936. * Constructor for this deferred object.
  62937. */
  62938. constructor();
  62939. }
  62940. }
  62941. declare module BABYLON {
  62942. /**
  62943. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62944. */
  62945. export class MeshExploder {
  62946. private _centerMesh;
  62947. private _meshes;
  62948. private _meshesOrigins;
  62949. private _toCenterVectors;
  62950. private _scaledDirection;
  62951. private _newPosition;
  62952. private _centerPosition;
  62953. /**
  62954. * Explodes meshes from a center mesh.
  62955. * @param meshes The meshes to explode.
  62956. * @param centerMesh The mesh to be center of explosion.
  62957. */
  62958. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62959. private _setCenterMesh;
  62960. /**
  62961. * Get class name
  62962. * @returns "MeshExploder"
  62963. */
  62964. getClassName(): string;
  62965. /**
  62966. * "Exploded meshes"
  62967. * @returns Array of meshes with the centerMesh at index 0.
  62968. */
  62969. getMeshes(): Array<Mesh>;
  62970. /**
  62971. * Explodes meshes giving a specific direction
  62972. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62973. */
  62974. explode(direction?: number): void;
  62975. }
  62976. }
  62977. declare module BABYLON {
  62978. /**
  62979. * Class used to help managing file picking and drag'n'drop
  62980. */
  62981. export class FilesInput {
  62982. /**
  62983. * List of files ready to be loaded
  62984. */
  62985. static readonly FilesToLoad: {
  62986. [key: string]: File;
  62987. };
  62988. /**
  62989. * Callback called when a file is processed
  62990. */
  62991. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62992. private _engine;
  62993. private _currentScene;
  62994. private _sceneLoadedCallback;
  62995. private _progressCallback;
  62996. private _additionalRenderLoopLogicCallback;
  62997. private _textureLoadingCallback;
  62998. private _startingProcessingFilesCallback;
  62999. private _onReloadCallback;
  63000. private _errorCallback;
  63001. private _elementToMonitor;
  63002. private _sceneFileToLoad;
  63003. private _filesToLoad;
  63004. /**
  63005. * Creates a new FilesInput
  63006. * @param engine defines the rendering engine
  63007. * @param scene defines the hosting scene
  63008. * @param sceneLoadedCallback callback called when scene is loaded
  63009. * @param progressCallback callback called to track progress
  63010. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63011. * @param textureLoadingCallback callback called when a texture is loading
  63012. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63013. * @param onReloadCallback callback called when a reload is requested
  63014. * @param errorCallback callback call if an error occurs
  63015. */
  63016. 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);
  63017. private _dragEnterHandler;
  63018. private _dragOverHandler;
  63019. private _dropHandler;
  63020. /**
  63021. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63022. * @param elementToMonitor defines the DOM element to track
  63023. */
  63024. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63025. /**
  63026. * Release all associated resources
  63027. */
  63028. dispose(): void;
  63029. private renderFunction;
  63030. private drag;
  63031. private drop;
  63032. private _traverseFolder;
  63033. private _processFiles;
  63034. /**
  63035. * Load files from a drop event
  63036. * @param event defines the drop event to use as source
  63037. */
  63038. loadFiles(event: any): void;
  63039. private _processReload;
  63040. /**
  63041. * Reload the current scene from the loaded files
  63042. */
  63043. reload(): void;
  63044. }
  63045. }
  63046. declare module BABYLON {
  63047. /**
  63048. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63050. */
  63051. export class SceneOptimization {
  63052. /**
  63053. * Defines the priority of this optimization (0 by default which means first in the list)
  63054. */
  63055. priority: number;
  63056. /**
  63057. * Gets a string describing the action executed by the current optimization
  63058. * @returns description string
  63059. */
  63060. getDescription(): string;
  63061. /**
  63062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63063. * @param scene defines the current scene where to apply this optimization
  63064. * @param optimizer defines the current optimizer
  63065. * @returns true if everything that can be done was applied
  63066. */
  63067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63068. /**
  63069. * Creates the SceneOptimization object
  63070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63071. * @param desc defines the description associated with the optimization
  63072. */
  63073. constructor(
  63074. /**
  63075. * Defines the priority of this optimization (0 by default which means first in the list)
  63076. */
  63077. priority?: number);
  63078. }
  63079. /**
  63080. * Defines an optimization used to reduce the size of render target textures
  63081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63082. */
  63083. export class TextureOptimization extends SceneOptimization {
  63084. /**
  63085. * Defines the priority of this optimization (0 by default which means first in the list)
  63086. */
  63087. priority: number;
  63088. /**
  63089. * 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
  63090. */
  63091. maximumSize: number;
  63092. /**
  63093. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63094. */
  63095. step: number;
  63096. /**
  63097. * Gets a string describing the action executed by the current optimization
  63098. * @returns description string
  63099. */
  63100. getDescription(): string;
  63101. /**
  63102. * Creates the TextureOptimization object
  63103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63104. * @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
  63105. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63106. */
  63107. constructor(
  63108. /**
  63109. * Defines the priority of this optimization (0 by default which means first in the list)
  63110. */
  63111. priority?: number,
  63112. /**
  63113. * 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
  63114. */
  63115. maximumSize?: number,
  63116. /**
  63117. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63118. */
  63119. step?: number);
  63120. /**
  63121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63122. * @param scene defines the current scene where to apply this optimization
  63123. * @param optimizer defines the current optimizer
  63124. * @returns true if everything that can be done was applied
  63125. */
  63126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63127. }
  63128. /**
  63129. * Defines an optimization used to increase or decrease the rendering resolution
  63130. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63131. */
  63132. export class HardwareScalingOptimization extends SceneOptimization {
  63133. /**
  63134. * Defines the priority of this optimization (0 by default which means first in the list)
  63135. */
  63136. priority: number;
  63137. /**
  63138. * Defines the maximum scale to use (2 by default)
  63139. */
  63140. maximumScale: number;
  63141. /**
  63142. * Defines the step to use between two passes (0.5 by default)
  63143. */
  63144. step: number;
  63145. private _currentScale;
  63146. private _directionOffset;
  63147. /**
  63148. * Gets a string describing the action executed by the current optimization
  63149. * @return description string
  63150. */
  63151. getDescription(): string;
  63152. /**
  63153. * Creates the HardwareScalingOptimization object
  63154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63155. * @param maximumScale defines the maximum scale to use (2 by default)
  63156. * @param step defines the step to use between two passes (0.5 by default)
  63157. */
  63158. constructor(
  63159. /**
  63160. * Defines the priority of this optimization (0 by default which means first in the list)
  63161. */
  63162. priority?: number,
  63163. /**
  63164. * Defines the maximum scale to use (2 by default)
  63165. */
  63166. maximumScale?: number,
  63167. /**
  63168. * Defines the step to use between two passes (0.5 by default)
  63169. */
  63170. step?: number);
  63171. /**
  63172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63173. * @param scene defines the current scene where to apply this optimization
  63174. * @param optimizer defines the current optimizer
  63175. * @returns true if everything that can be done was applied
  63176. */
  63177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63178. }
  63179. /**
  63180. * Defines an optimization used to remove shadows
  63181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63182. */
  63183. export class ShadowsOptimization extends SceneOptimization {
  63184. /**
  63185. * Gets a string describing the action executed by the current optimization
  63186. * @return description string
  63187. */
  63188. getDescription(): string;
  63189. /**
  63190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63191. * @param scene defines the current scene where to apply this optimization
  63192. * @param optimizer defines the current optimizer
  63193. * @returns true if everything that can be done was applied
  63194. */
  63195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63196. }
  63197. /**
  63198. * Defines an optimization used to turn post-processes off
  63199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63200. */
  63201. export class PostProcessesOptimization extends SceneOptimization {
  63202. /**
  63203. * Gets a string describing the action executed by the current optimization
  63204. * @return description string
  63205. */
  63206. getDescription(): string;
  63207. /**
  63208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63209. * @param scene defines the current scene where to apply this optimization
  63210. * @param optimizer defines the current optimizer
  63211. * @returns true if everything that can be done was applied
  63212. */
  63213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63214. }
  63215. /**
  63216. * Defines an optimization used to turn lens flares off
  63217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63218. */
  63219. export class LensFlaresOptimization extends SceneOptimization {
  63220. /**
  63221. * Gets a string describing the action executed by the current optimization
  63222. * @return description string
  63223. */
  63224. getDescription(): string;
  63225. /**
  63226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63227. * @param scene defines the current scene where to apply this optimization
  63228. * @param optimizer defines the current optimizer
  63229. * @returns true if everything that can be done was applied
  63230. */
  63231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63232. }
  63233. /**
  63234. * Defines an optimization based on user defined callback.
  63235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63236. */
  63237. export class CustomOptimization extends SceneOptimization {
  63238. /**
  63239. * Callback called to apply the custom optimization.
  63240. */
  63241. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63242. /**
  63243. * Callback called to get custom description
  63244. */
  63245. onGetDescription: () => string;
  63246. /**
  63247. * Gets a string describing the action executed by the current optimization
  63248. * @returns description string
  63249. */
  63250. getDescription(): string;
  63251. /**
  63252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63253. * @param scene defines the current scene where to apply this optimization
  63254. * @param optimizer defines the current optimizer
  63255. * @returns true if everything that can be done was applied
  63256. */
  63257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63258. }
  63259. /**
  63260. * Defines an optimization used to turn particles off
  63261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63262. */
  63263. export class ParticlesOptimization extends SceneOptimization {
  63264. /**
  63265. * Gets a string describing the action executed by the current optimization
  63266. * @return description string
  63267. */
  63268. getDescription(): string;
  63269. /**
  63270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63271. * @param scene defines the current scene where to apply this optimization
  63272. * @param optimizer defines the current optimizer
  63273. * @returns true if everything that can be done was applied
  63274. */
  63275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63276. }
  63277. /**
  63278. * Defines an optimization used to turn render targets off
  63279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63280. */
  63281. export class RenderTargetsOptimization extends SceneOptimization {
  63282. /**
  63283. * Gets a string describing the action executed by the current optimization
  63284. * @return description string
  63285. */
  63286. getDescription(): string;
  63287. /**
  63288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63289. * @param scene defines the current scene where to apply this optimization
  63290. * @param optimizer defines the current optimizer
  63291. * @returns true if everything that can be done was applied
  63292. */
  63293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63294. }
  63295. /**
  63296. * Defines an optimization used to merge meshes with compatible materials
  63297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63298. */
  63299. export class MergeMeshesOptimization extends SceneOptimization {
  63300. private static _UpdateSelectionTree;
  63301. /**
  63302. * Gets or sets a boolean which defines if optimization octree has to be updated
  63303. */
  63304. /**
  63305. * Gets or sets a boolean which defines if optimization octree has to be updated
  63306. */
  63307. static UpdateSelectionTree: boolean;
  63308. /**
  63309. * Gets a string describing the action executed by the current optimization
  63310. * @return description string
  63311. */
  63312. getDescription(): string;
  63313. private _canBeMerged;
  63314. /**
  63315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63316. * @param scene defines the current scene where to apply this optimization
  63317. * @param optimizer defines the current optimizer
  63318. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63319. * @returns true if everything that can be done was applied
  63320. */
  63321. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63322. }
  63323. /**
  63324. * Defines a list of options used by SceneOptimizer
  63325. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63326. */
  63327. export class SceneOptimizerOptions {
  63328. /**
  63329. * Defines the target frame rate to reach (60 by default)
  63330. */
  63331. targetFrameRate: number;
  63332. /**
  63333. * Defines the interval between two checkes (2000ms by default)
  63334. */
  63335. trackerDuration: number;
  63336. /**
  63337. * Gets the list of optimizations to apply
  63338. */
  63339. optimizations: SceneOptimization[];
  63340. /**
  63341. * Creates a new list of options used by SceneOptimizer
  63342. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63343. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63344. */
  63345. constructor(
  63346. /**
  63347. * Defines the target frame rate to reach (60 by default)
  63348. */
  63349. targetFrameRate?: number,
  63350. /**
  63351. * Defines the interval between two checkes (2000ms by default)
  63352. */
  63353. trackerDuration?: number);
  63354. /**
  63355. * Add a new optimization
  63356. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63357. * @returns the current SceneOptimizerOptions
  63358. */
  63359. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63360. /**
  63361. * Add a new custom optimization
  63362. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63363. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63364. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63365. * @returns the current SceneOptimizerOptions
  63366. */
  63367. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63368. /**
  63369. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63370. * @param targetFrameRate defines the target frame rate (60 by default)
  63371. * @returns a SceneOptimizerOptions object
  63372. */
  63373. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63374. /**
  63375. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63376. * @param targetFrameRate defines the target frame rate (60 by default)
  63377. * @returns a SceneOptimizerOptions object
  63378. */
  63379. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63380. /**
  63381. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63382. * @param targetFrameRate defines the target frame rate (60 by default)
  63383. * @returns a SceneOptimizerOptions object
  63384. */
  63385. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63386. }
  63387. /**
  63388. * Class used to run optimizations in order to reach a target frame rate
  63389. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63390. */
  63391. export class SceneOptimizer implements IDisposable {
  63392. private _isRunning;
  63393. private _options;
  63394. private _scene;
  63395. private _currentPriorityLevel;
  63396. private _targetFrameRate;
  63397. private _trackerDuration;
  63398. private _currentFrameRate;
  63399. private _sceneDisposeObserver;
  63400. private _improvementMode;
  63401. /**
  63402. * Defines an observable called when the optimizer reaches the target frame rate
  63403. */
  63404. onSuccessObservable: Observable<SceneOptimizer>;
  63405. /**
  63406. * Defines an observable called when the optimizer enables an optimization
  63407. */
  63408. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63409. /**
  63410. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63411. */
  63412. onFailureObservable: Observable<SceneOptimizer>;
  63413. /**
  63414. * Gets a boolean indicating if the optimizer is in improvement mode
  63415. */
  63416. readonly isInImprovementMode: boolean;
  63417. /**
  63418. * Gets the current priority level (0 at start)
  63419. */
  63420. readonly currentPriorityLevel: number;
  63421. /**
  63422. * Gets the current frame rate checked by the SceneOptimizer
  63423. */
  63424. readonly currentFrameRate: number;
  63425. /**
  63426. * Gets or sets the current target frame rate (60 by default)
  63427. */
  63428. /**
  63429. * Gets or sets the current target frame rate (60 by default)
  63430. */
  63431. targetFrameRate: number;
  63432. /**
  63433. * Gets or sets the current interval between two checks (every 2000ms by default)
  63434. */
  63435. /**
  63436. * Gets or sets the current interval between two checks (every 2000ms by default)
  63437. */
  63438. trackerDuration: number;
  63439. /**
  63440. * Gets the list of active optimizations
  63441. */
  63442. readonly optimizations: SceneOptimization[];
  63443. /**
  63444. * Creates a new SceneOptimizer
  63445. * @param scene defines the scene to work on
  63446. * @param options defines the options to use with the SceneOptimizer
  63447. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63448. * @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)
  63449. */
  63450. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63451. /**
  63452. * Stops the current optimizer
  63453. */
  63454. stop(): void;
  63455. /**
  63456. * Reset the optimizer to initial step (current priority level = 0)
  63457. */
  63458. reset(): void;
  63459. /**
  63460. * Start the optimizer. By default it will try to reach a specific framerate
  63461. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63462. */
  63463. start(): void;
  63464. private _checkCurrentState;
  63465. /**
  63466. * Release all resources
  63467. */
  63468. dispose(): void;
  63469. /**
  63470. * Helper function to create a SceneOptimizer with one single line of code
  63471. * @param scene defines the scene to work on
  63472. * @param options defines the options to use with the SceneOptimizer
  63473. * @param onSuccess defines a callback to call on success
  63474. * @param onFailure defines a callback to call on failure
  63475. * @returns the new SceneOptimizer object
  63476. */
  63477. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63478. }
  63479. }
  63480. declare module BABYLON {
  63481. /**
  63482. * Class used to serialize a scene into a string
  63483. */
  63484. export class SceneSerializer {
  63485. /**
  63486. * Clear cache used by a previous serialization
  63487. */
  63488. static ClearCache(): void;
  63489. /**
  63490. * Serialize a scene into a JSON compatible object
  63491. * @param scene defines the scene to serialize
  63492. * @returns a JSON compatible object
  63493. */
  63494. static Serialize(scene: Scene): any;
  63495. /**
  63496. * Serialize a mesh into a JSON compatible object
  63497. * @param toSerialize defines the mesh to serialize
  63498. * @param withParents defines if parents must be serialized as well
  63499. * @param withChildren defines if children must be serialized as well
  63500. * @returns a JSON compatible object
  63501. */
  63502. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63503. }
  63504. }
  63505. declare module BABYLON {
  63506. /**
  63507. * Class used to host texture specific utilities
  63508. */
  63509. export class TextureTools {
  63510. /**
  63511. * Uses the GPU to create a copy texture rescaled at a given size
  63512. * @param texture Texture to copy from
  63513. * @param width defines the desired width
  63514. * @param height defines the desired height
  63515. * @param useBilinearMode defines if bilinear mode has to be used
  63516. * @return the generated texture
  63517. */
  63518. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * This represents the different options available for the video capture.
  63524. */
  63525. export interface VideoRecorderOptions {
  63526. /** Defines the mime type of the video. */
  63527. mimeType: string;
  63528. /** Defines the FPS the video should be recorded at. */
  63529. fps: number;
  63530. /** Defines the chunk size for the recording data. */
  63531. recordChunckSize: number;
  63532. /** The audio tracks to attach to the recording. */
  63533. audioTracks?: MediaStreamTrack[];
  63534. }
  63535. /**
  63536. * This can help with recording videos from BabylonJS.
  63537. * This is based on the available WebRTC functionalities of the browser.
  63538. *
  63539. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63540. */
  63541. export class VideoRecorder {
  63542. private static readonly _defaultOptions;
  63543. /**
  63544. * Returns whether or not the VideoRecorder is available in your browser.
  63545. * @param engine Defines the Babylon Engine.
  63546. * @returns true if supported otherwise false.
  63547. */
  63548. static IsSupported(engine: Engine): boolean;
  63549. private readonly _options;
  63550. private _canvas;
  63551. private _mediaRecorder;
  63552. private _recordedChunks;
  63553. private _fileName;
  63554. private _resolve;
  63555. private _reject;
  63556. /**
  63557. * True when a recording is already in progress.
  63558. */
  63559. readonly isRecording: boolean;
  63560. /**
  63561. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63562. * @param engine Defines the BabylonJS Engine you wish to record.
  63563. * @param options Defines options that can be used to customize the capture.
  63564. */
  63565. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63566. /**
  63567. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63568. */
  63569. stopRecording(): void;
  63570. /**
  63571. * Starts recording the canvas for a max duration specified in parameters.
  63572. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63573. * If null no automatic download will start and you can rely on the promise to get the data back.
  63574. * @param maxDuration Defines the maximum recording time in seconds.
  63575. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63576. * @return A promise callback at the end of the recording with the video data in Blob.
  63577. */
  63578. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63579. /**
  63580. * Releases internal resources used during the recording.
  63581. */
  63582. dispose(): void;
  63583. private _handleDataAvailable;
  63584. private _handleError;
  63585. private _handleStop;
  63586. }
  63587. }
  63588. declare module BABYLON {
  63589. /**
  63590. * Class containing a set of static utilities functions for screenshots
  63591. */
  63592. export class ScreenshotTools {
  63593. /**
  63594. * Captures a screenshot of the current rendering
  63595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63596. * @param engine defines the rendering engine
  63597. * @param camera defines the source camera
  63598. * @param size This parameter can be set to a single number or to an object with the
  63599. * following (optional) properties: precision, width, height. If a single number is passed,
  63600. * it will be used for both width and height. If an object is passed, the screenshot size
  63601. * will be derived from the parameters. The precision property is a multiplier allowing
  63602. * rendering at a higher or lower resolution
  63603. * @param successCallback defines the callback receives a single parameter which contains the
  63604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63605. * src parameter of an <img> to display it
  63606. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63607. * Check your browser for supported MIME types
  63608. */
  63609. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63610. /**
  63611. * Captures a screenshot of the current rendering
  63612. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63613. * @param engine defines the rendering engine
  63614. * @param camera defines the source camera
  63615. * @param size This parameter can be set to a single number or to an object with the
  63616. * following (optional) properties: precision, width, height. If a single number is passed,
  63617. * it will be used for both width and height. If an object is passed, the screenshot size
  63618. * will be derived from the parameters. The precision property is a multiplier allowing
  63619. * rendering at a higher or lower resolution
  63620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63621. * Check your browser for supported MIME types
  63622. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63623. * to the src parameter of an <img> to display it
  63624. */
  63625. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63626. /**
  63627. * Generates an image screenshot from the specified camera.
  63628. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63629. * @param engine The engine to use for rendering
  63630. * @param camera The camera to use for rendering
  63631. * @param size This parameter can be set to a single number or to an object with the
  63632. * following (optional) properties: precision, width, height. If a single number is passed,
  63633. * it will be used for both width and height. If an object is passed, the screenshot size
  63634. * will be derived from the parameters. The precision property is a multiplier allowing
  63635. * rendering at a higher or lower resolution
  63636. * @param successCallback The callback receives a single parameter which contains the
  63637. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63638. * src parameter of an <img> to display it
  63639. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63640. * Check your browser for supported MIME types
  63641. * @param samples Texture samples (default: 1)
  63642. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63643. * @param fileName A name for for the downloaded file.
  63644. */
  63645. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63646. /**
  63647. * Generates an image screenshot from the specified camera.
  63648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63649. * @param engine The engine to use for rendering
  63650. * @param camera The camera to use for rendering
  63651. * @param size This parameter can be set to a single number or to an object with the
  63652. * following (optional) properties: precision, width, height. If a single number is passed,
  63653. * it will be used for both width and height. If an object is passed, the screenshot size
  63654. * will be derived from the parameters. The precision property is a multiplier allowing
  63655. * rendering at a higher or lower resolution
  63656. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63657. * Check your browser for supported MIME types
  63658. * @param samples Texture samples (default: 1)
  63659. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63660. * @param fileName A name for for the downloaded file.
  63661. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63662. * to the src parameter of an <img> to display it
  63663. */
  63664. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63665. /**
  63666. * Gets height and width for screenshot size
  63667. * @private
  63668. */
  63669. private static _getScreenshotSize;
  63670. }
  63671. }
  63672. declare module BABYLON {
  63673. /**
  63674. * A cursor which tracks a point on a path
  63675. */
  63676. export class PathCursor {
  63677. private path;
  63678. /**
  63679. * Stores path cursor callbacks for when an onchange event is triggered
  63680. */
  63681. private _onchange;
  63682. /**
  63683. * The value of the path cursor
  63684. */
  63685. value: number;
  63686. /**
  63687. * The animation array of the path cursor
  63688. */
  63689. animations: Animation[];
  63690. /**
  63691. * Initializes the path cursor
  63692. * @param path The path to track
  63693. */
  63694. constructor(path: Path2);
  63695. /**
  63696. * Gets the cursor point on the path
  63697. * @returns A point on the path cursor at the cursor location
  63698. */
  63699. getPoint(): Vector3;
  63700. /**
  63701. * Moves the cursor ahead by the step amount
  63702. * @param step The amount to move the cursor forward
  63703. * @returns This path cursor
  63704. */
  63705. moveAhead(step?: number): PathCursor;
  63706. /**
  63707. * Moves the cursor behind by the step amount
  63708. * @param step The amount to move the cursor back
  63709. * @returns This path cursor
  63710. */
  63711. moveBack(step?: number): PathCursor;
  63712. /**
  63713. * Moves the cursor by the step amount
  63714. * If the step amount is greater than one, an exception is thrown
  63715. * @param step The amount to move the cursor
  63716. * @returns This path cursor
  63717. */
  63718. move(step: number): PathCursor;
  63719. /**
  63720. * Ensures that the value is limited between zero and one
  63721. * @returns This path cursor
  63722. */
  63723. private ensureLimits;
  63724. /**
  63725. * Runs onchange callbacks on change (used by the animation engine)
  63726. * @returns This path cursor
  63727. */
  63728. private raiseOnChange;
  63729. /**
  63730. * Executes a function on change
  63731. * @param f A path cursor onchange callback
  63732. * @returns This path cursor
  63733. */
  63734. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63735. }
  63736. }
  63737. declare module BABYLON {
  63738. /** @hidden */
  63739. export var blurPixelShader: {
  63740. name: string;
  63741. shader: string;
  63742. };
  63743. }
  63744. declare module BABYLON {
  63745. /** @hidden */
  63746. export var pointCloudVertexDeclaration: {
  63747. name: string;
  63748. shader: string;
  63749. };
  63750. }
  63751. // Mixins
  63752. interface Window {
  63753. mozIndexedDB: IDBFactory;
  63754. webkitIndexedDB: IDBFactory;
  63755. msIndexedDB: IDBFactory;
  63756. webkitURL: typeof URL;
  63757. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63758. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63759. WebGLRenderingContext: WebGLRenderingContext;
  63760. MSGesture: MSGesture;
  63761. CANNON: any;
  63762. AudioContext: AudioContext;
  63763. webkitAudioContext: AudioContext;
  63764. PointerEvent: any;
  63765. Math: Math;
  63766. Uint8Array: Uint8ArrayConstructor;
  63767. Float32Array: Float32ArrayConstructor;
  63768. mozURL: typeof URL;
  63769. msURL: typeof URL;
  63770. VRFrameData: any; // WebVR, from specs 1.1
  63771. DracoDecoderModule: any;
  63772. setImmediate(handler: (...args: any[]) => void): number;
  63773. }
  63774. interface HTMLCanvasElement {
  63775. requestPointerLock(): void;
  63776. msRequestPointerLock?(): void;
  63777. mozRequestPointerLock?(): void;
  63778. webkitRequestPointerLock?(): void;
  63779. /** Track wether a record is in progress */
  63780. isRecording: boolean;
  63781. /** Capture Stream method defined by some browsers */
  63782. captureStream(fps?: number): MediaStream;
  63783. }
  63784. interface CanvasRenderingContext2D {
  63785. msImageSmoothingEnabled: boolean;
  63786. }
  63787. interface MouseEvent {
  63788. mozMovementX: number;
  63789. mozMovementY: number;
  63790. webkitMovementX: number;
  63791. webkitMovementY: number;
  63792. msMovementX: number;
  63793. msMovementY: number;
  63794. }
  63795. interface Navigator {
  63796. mozGetVRDevices: (any: any) => any;
  63797. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63798. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63799. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63800. webkitGetGamepads(): Gamepad[];
  63801. msGetGamepads(): Gamepad[];
  63802. webkitGamepads(): Gamepad[];
  63803. }
  63804. interface HTMLVideoElement {
  63805. mozSrcObject: any;
  63806. }
  63807. interface Math {
  63808. fround(x: number): number;
  63809. imul(a: number, b: number): number;
  63810. }
  63811. interface WebGLRenderingContext {
  63812. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63813. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63814. vertexAttribDivisor(index: number, divisor: number): void;
  63815. createVertexArray(): any;
  63816. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63817. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63818. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63819. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63820. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63821. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63822. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63823. // Queries
  63824. createQuery(): WebGLQuery;
  63825. deleteQuery(query: WebGLQuery): void;
  63826. beginQuery(target: number, query: WebGLQuery): void;
  63827. endQuery(target: number): void;
  63828. getQueryParameter(query: WebGLQuery, pname: number): any;
  63829. getQuery(target: number, pname: number): any;
  63830. MAX_SAMPLES: number;
  63831. RGBA8: number;
  63832. READ_FRAMEBUFFER: number;
  63833. DRAW_FRAMEBUFFER: number;
  63834. UNIFORM_BUFFER: number;
  63835. HALF_FLOAT_OES: number;
  63836. RGBA16F: number;
  63837. RGBA32F: number;
  63838. R32F: number;
  63839. RG32F: number;
  63840. RGB32F: number;
  63841. R16F: number;
  63842. RG16F: number;
  63843. RGB16F: number;
  63844. RED: number;
  63845. RG: number;
  63846. R8: number;
  63847. RG8: number;
  63848. UNSIGNED_INT_24_8: number;
  63849. DEPTH24_STENCIL8: number;
  63850. MIN: number;
  63851. MAX: number;
  63852. /* Multiple Render Targets */
  63853. drawBuffers(buffers: number[]): void;
  63854. readBuffer(src: number): void;
  63855. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63856. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63857. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63858. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63859. // Occlusion Query
  63860. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63861. ANY_SAMPLES_PASSED: number;
  63862. QUERY_RESULT_AVAILABLE: number;
  63863. QUERY_RESULT: number;
  63864. }
  63865. interface WebGLProgram {
  63866. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63867. }
  63868. interface EXT_disjoint_timer_query {
  63869. QUERY_COUNTER_BITS_EXT: number;
  63870. TIME_ELAPSED_EXT: number;
  63871. TIMESTAMP_EXT: number;
  63872. GPU_DISJOINT_EXT: number;
  63873. QUERY_RESULT_EXT: number;
  63874. QUERY_RESULT_AVAILABLE_EXT: number;
  63875. queryCounterEXT(query: WebGLQuery, target: number): void;
  63876. createQueryEXT(): WebGLQuery;
  63877. beginQueryEXT(target: number, query: WebGLQuery): void;
  63878. endQueryEXT(target: number): void;
  63879. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63880. deleteQueryEXT(query: WebGLQuery): void;
  63881. }
  63882. interface WebGLUniformLocation {
  63883. _currentState: any;
  63884. }
  63885. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63886. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63887. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63888. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63889. interface WebGLRenderingContext {
  63890. readonly RASTERIZER_DISCARD: number;
  63891. readonly DEPTH_COMPONENT24: number;
  63892. readonly TEXTURE_3D: number;
  63893. readonly TEXTURE_2D_ARRAY: number;
  63894. readonly TEXTURE_COMPARE_FUNC: number;
  63895. readonly TEXTURE_COMPARE_MODE: number;
  63896. readonly COMPARE_REF_TO_TEXTURE: number;
  63897. readonly TEXTURE_WRAP_R: number;
  63898. readonly HALF_FLOAT: number;
  63899. readonly RGB8: number;
  63900. readonly RED_INTEGER: number;
  63901. readonly RG_INTEGER: number;
  63902. readonly RGB_INTEGER: number;
  63903. readonly RGBA_INTEGER: number;
  63904. readonly R8_SNORM: number;
  63905. readonly RG8_SNORM: number;
  63906. readonly RGB8_SNORM: number;
  63907. readonly RGBA8_SNORM: number;
  63908. readonly R8I: number;
  63909. readonly RG8I: number;
  63910. readonly RGB8I: number;
  63911. readonly RGBA8I: number;
  63912. readonly R8UI: number;
  63913. readonly RG8UI: number;
  63914. readonly RGB8UI: number;
  63915. readonly RGBA8UI: number;
  63916. readonly R16I: number;
  63917. readonly RG16I: number;
  63918. readonly RGB16I: number;
  63919. readonly RGBA16I: number;
  63920. readonly R16UI: number;
  63921. readonly RG16UI: number;
  63922. readonly RGB16UI: number;
  63923. readonly RGBA16UI: number;
  63924. readonly R32I: number;
  63925. readonly RG32I: number;
  63926. readonly RGB32I: number;
  63927. readonly RGBA32I: number;
  63928. readonly R32UI: number;
  63929. readonly RG32UI: number;
  63930. readonly RGB32UI: number;
  63931. readonly RGBA32UI: number;
  63932. readonly RGB10_A2UI: number;
  63933. readonly R11F_G11F_B10F: number;
  63934. readonly RGB9_E5: number;
  63935. readonly RGB10_A2: number;
  63936. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63937. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63938. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63939. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63940. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63941. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63942. 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;
  63943. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63944. readonly TRANSFORM_FEEDBACK: number;
  63945. readonly INTERLEAVED_ATTRIBS: number;
  63946. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63947. createTransformFeedback(): WebGLTransformFeedback;
  63948. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63949. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63950. beginTransformFeedback(primitiveMode: number): void;
  63951. endTransformFeedback(): void;
  63952. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63953. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63954. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63955. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63956. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63957. }
  63958. interface ImageBitmap {
  63959. readonly width: number;
  63960. readonly height: number;
  63961. close(): void;
  63962. }
  63963. interface WebGLQuery extends WebGLObject {
  63964. }
  63965. declare var WebGLQuery: {
  63966. prototype: WebGLQuery;
  63967. new(): WebGLQuery;
  63968. };
  63969. interface WebGLSampler extends WebGLObject {
  63970. }
  63971. declare var WebGLSampler: {
  63972. prototype: WebGLSampler;
  63973. new(): WebGLSampler;
  63974. };
  63975. interface WebGLSync extends WebGLObject {
  63976. }
  63977. declare var WebGLSync: {
  63978. prototype: WebGLSync;
  63979. new(): WebGLSync;
  63980. };
  63981. interface WebGLTransformFeedback extends WebGLObject {
  63982. }
  63983. declare var WebGLTransformFeedback: {
  63984. prototype: WebGLTransformFeedback;
  63985. new(): WebGLTransformFeedback;
  63986. };
  63987. interface WebGLVertexArrayObject extends WebGLObject {
  63988. }
  63989. declare var WebGLVertexArrayObject: {
  63990. prototype: WebGLVertexArrayObject;
  63991. new(): WebGLVertexArrayObject;
  63992. };
  63993. // Type definitions for WebVR API
  63994. // Project: https://w3c.github.io/webvr/
  63995. // Definitions by: six a <https://github.com/lostfictions>
  63996. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63997. interface VRDisplay extends EventTarget {
  63998. /**
  63999. * Dictionary of capabilities describing the VRDisplay.
  64000. */
  64001. readonly capabilities: VRDisplayCapabilities;
  64002. /**
  64003. * z-depth defining the far plane of the eye view frustum
  64004. * enables mapping of values in the render target depth
  64005. * attachment to scene coordinates. Initially set to 10000.0.
  64006. */
  64007. depthFar: number;
  64008. /**
  64009. * z-depth defining the near plane of the eye view frustum
  64010. * enables mapping of values in the render target depth
  64011. * attachment to scene coordinates. Initially set to 0.01.
  64012. */
  64013. depthNear: number;
  64014. /**
  64015. * An identifier for this distinct VRDisplay. Used as an
  64016. * association point in the Gamepad API.
  64017. */
  64018. readonly displayId: number;
  64019. /**
  64020. * A display name, a user-readable name identifying it.
  64021. */
  64022. readonly displayName: string;
  64023. readonly isConnected: boolean;
  64024. readonly isPresenting: boolean;
  64025. /**
  64026. * If this VRDisplay supports room-scale experiences, the optional
  64027. * stage attribute contains details on the room-scale parameters.
  64028. */
  64029. readonly stageParameters: VRStageParameters | null;
  64030. /**
  64031. * Passing the value returned by `requestAnimationFrame` to
  64032. * `cancelAnimationFrame` will unregister the callback.
  64033. * @param handle Define the hanle of the request to cancel
  64034. */
  64035. cancelAnimationFrame(handle: number): void;
  64036. /**
  64037. * Stops presenting to the VRDisplay.
  64038. * @returns a promise to know when it stopped
  64039. */
  64040. exitPresent(): Promise<void>;
  64041. /**
  64042. * Return the current VREyeParameters for the given eye.
  64043. * @param whichEye Define the eye we want the parameter for
  64044. * @returns the eye parameters
  64045. */
  64046. getEyeParameters(whichEye: string): VREyeParameters;
  64047. /**
  64048. * Populates the passed VRFrameData with the information required to render
  64049. * the current frame.
  64050. * @param frameData Define the data structure to populate
  64051. * @returns true if ok otherwise false
  64052. */
  64053. getFrameData(frameData: VRFrameData): boolean;
  64054. /**
  64055. * Get the layers currently being presented.
  64056. * @returns the list of VR layers
  64057. */
  64058. getLayers(): VRLayer[];
  64059. /**
  64060. * Return a VRPose containing the future predicted pose of the VRDisplay
  64061. * when the current frame will be presented. The value returned will not
  64062. * change until JavaScript has returned control to the browser.
  64063. *
  64064. * The VRPose will contain the position, orientation, velocity,
  64065. * and acceleration of each of these properties.
  64066. * @returns the pose object
  64067. */
  64068. getPose(): VRPose;
  64069. /**
  64070. * Return the current instantaneous pose of the VRDisplay, with no
  64071. * prediction applied.
  64072. * @returns the current instantaneous pose
  64073. */
  64074. getImmediatePose(): VRPose;
  64075. /**
  64076. * The callback passed to `requestAnimationFrame` will be called
  64077. * any time a new frame should be rendered. When the VRDisplay is
  64078. * presenting the callback will be called at the native refresh
  64079. * rate of the HMD. When not presenting this function acts
  64080. * identically to how window.requestAnimationFrame acts. Content should
  64081. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64082. * asynchronously from other displays and at differing refresh rates.
  64083. * @param callback Define the eaction to run next frame
  64084. * @returns the request handle it
  64085. */
  64086. requestAnimationFrame(callback: FrameRequestCallback): number;
  64087. /**
  64088. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64089. * Repeat calls while already presenting will update the VRLayers being displayed.
  64090. * @param layers Define the list of layer to present
  64091. * @returns a promise to know when the request has been fulfilled
  64092. */
  64093. requestPresent(layers: VRLayer[]): Promise<void>;
  64094. /**
  64095. * Reset the pose for this display, treating its current position and
  64096. * orientation as the "origin/zero" values. VRPose.position,
  64097. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64098. * updated when calling resetPose(). This should be called in only
  64099. * sitting-space experiences.
  64100. */
  64101. resetPose(): void;
  64102. /**
  64103. * The VRLayer provided to the VRDisplay will be captured and presented
  64104. * in the HMD. Calling this function has the same effect on the source
  64105. * canvas as any other operation that uses its source image, and canvases
  64106. * created without preserveDrawingBuffer set to true will be cleared.
  64107. * @param pose Define the pose to submit
  64108. */
  64109. submitFrame(pose?: VRPose): void;
  64110. }
  64111. declare var VRDisplay: {
  64112. prototype: VRDisplay;
  64113. new(): VRDisplay;
  64114. };
  64115. interface VRLayer {
  64116. leftBounds?: number[] | Float32Array | null;
  64117. rightBounds?: number[] | Float32Array | null;
  64118. source?: HTMLCanvasElement | null;
  64119. }
  64120. interface VRDisplayCapabilities {
  64121. readonly canPresent: boolean;
  64122. readonly hasExternalDisplay: boolean;
  64123. readonly hasOrientation: boolean;
  64124. readonly hasPosition: boolean;
  64125. readonly maxLayers: number;
  64126. }
  64127. interface VREyeParameters {
  64128. /** @deprecated */
  64129. readonly fieldOfView: VRFieldOfView;
  64130. readonly offset: Float32Array;
  64131. readonly renderHeight: number;
  64132. readonly renderWidth: number;
  64133. }
  64134. interface VRFieldOfView {
  64135. readonly downDegrees: number;
  64136. readonly leftDegrees: number;
  64137. readonly rightDegrees: number;
  64138. readonly upDegrees: number;
  64139. }
  64140. interface VRFrameData {
  64141. readonly leftProjectionMatrix: Float32Array;
  64142. readonly leftViewMatrix: Float32Array;
  64143. readonly pose: VRPose;
  64144. readonly rightProjectionMatrix: Float32Array;
  64145. readonly rightViewMatrix: Float32Array;
  64146. readonly timestamp: number;
  64147. }
  64148. interface VRPose {
  64149. readonly angularAcceleration: Float32Array | null;
  64150. readonly angularVelocity: Float32Array | null;
  64151. readonly linearAcceleration: Float32Array | null;
  64152. readonly linearVelocity: Float32Array | null;
  64153. readonly orientation: Float32Array | null;
  64154. readonly position: Float32Array | null;
  64155. readonly timestamp: number;
  64156. }
  64157. interface VRStageParameters {
  64158. sittingToStandingTransform?: Float32Array;
  64159. sizeX?: number;
  64160. sizeY?: number;
  64161. }
  64162. interface Navigator {
  64163. getVRDisplays(): Promise<VRDisplay[]>;
  64164. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64165. }
  64166. interface Window {
  64167. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64168. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64169. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64170. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64171. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64172. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64173. }
  64174. interface Gamepad {
  64175. readonly displayId: number;
  64176. }
  64177. type XRSessionMode =
  64178. | "inline"
  64179. | "immersive-vr"
  64180. | "immersive-ar";
  64181. type XRReferenceSpaceType =
  64182. | "viewer"
  64183. | "local"
  64184. | "local-floor"
  64185. | "bounded-floor"
  64186. | "unbounded";
  64187. type XREnvironmentBlendMode =
  64188. | "opaque"
  64189. | "additive"
  64190. | "alpha-blend";
  64191. type XRVisibilityState =
  64192. | "visible"
  64193. | "visible-blurred"
  64194. | "hidden";
  64195. type XRHandedness =
  64196. | "none"
  64197. | "left"
  64198. | "right";
  64199. type XRTargetRayMode =
  64200. | "gaze"
  64201. | "tracked-pointer"
  64202. | "screen";
  64203. type XREye =
  64204. | "none"
  64205. | "left"
  64206. | "right";
  64207. interface XRSpace extends EventTarget {
  64208. }
  64209. interface XRRenderState {
  64210. depthNear?: number;
  64211. depthFar?: number;
  64212. inlineVerticalFieldOfView?: number;
  64213. baseLayer?: XRWebGLLayer;
  64214. }
  64215. interface XRInputSource {
  64216. handedness: XRHandedness;
  64217. targetRayMode: XRTargetRayMode;
  64218. targetRaySpace: XRSpace;
  64219. gripSpace: XRSpace | undefined;
  64220. gamepad: Gamepad | undefined;
  64221. profiles: Array<string>;
  64222. }
  64223. interface XRSession {
  64224. addEventListener: Function;
  64225. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64226. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64227. requestAnimationFrame: Function;
  64228. end(): Promise<void>;
  64229. renderState: XRRenderState;
  64230. inputSources: Array<XRInputSource>;
  64231. }
  64232. interface XRReferenceSpace extends XRSpace {
  64233. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64234. onreset: any;
  64235. }
  64236. interface XRFrame {
  64237. session: XRSession;
  64238. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64239. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64240. }
  64241. interface XRViewerPose extends XRPose {
  64242. views: Array<XRView>;
  64243. }
  64244. interface XRPose {
  64245. transform: XRRigidTransform;
  64246. emulatedPosition: boolean;
  64247. }
  64248. declare var XRWebGLLayer: {
  64249. prototype: XRWebGLLayer;
  64250. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64251. };
  64252. interface XRWebGLLayer {
  64253. framebuffer: WebGLFramebuffer;
  64254. framebufferWidth: number;
  64255. framebufferHeight: number;
  64256. getViewport: Function;
  64257. }
  64258. interface XRRigidTransform {
  64259. position: DOMPointReadOnly;
  64260. orientation: DOMPointReadOnly;
  64261. matrix: Float32Array;
  64262. inverse: XRRigidTransform;
  64263. }
  64264. interface XRView {
  64265. eye: XREye;
  64266. projectionMatrix: Float32Array;
  64267. transform: XRRigidTransform;
  64268. }
  64269. interface XRInputSourceChangeEvent {
  64270. session: XRSession;
  64271. removed: Array<XRInputSource>;
  64272. added: Array<XRInputSource>;
  64273. }
  64274. /**
  64275. * @ignore
  64276. */
  64277. declare module BABYLON.GLTF2.Exporter {
  64278. }
  64279. /**
  64280. * @ignore
  64281. */
  64282. declare module BABYLON.GLTF1 {
  64283. }
  64284. declare module BABYLON.GUI {
  64285. /**
  64286. * Class used to specific a value and its associated unit
  64287. */
  64288. export class ValueAndUnit {
  64289. /** defines the unit to store */
  64290. unit: number;
  64291. /** defines a boolean indicating if the value can be negative */
  64292. negativeValueAllowed: boolean;
  64293. private _value;
  64294. private _originalUnit;
  64295. /**
  64296. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64297. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64298. */
  64299. ignoreAdaptiveScaling: boolean;
  64300. /**
  64301. * Creates a new ValueAndUnit
  64302. * @param value defines the value to store
  64303. * @param unit defines the unit to store
  64304. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64305. */
  64306. constructor(value: number,
  64307. /** defines the unit to store */
  64308. unit?: number,
  64309. /** defines a boolean indicating if the value can be negative */
  64310. negativeValueAllowed?: boolean);
  64311. /** Gets a boolean indicating if the value is a percentage */
  64312. readonly isPercentage: boolean;
  64313. /** Gets a boolean indicating if the value is store as pixel */
  64314. readonly isPixel: boolean;
  64315. /** Gets direct internal value */
  64316. readonly internalValue: number;
  64317. /**
  64318. * Gets value as pixel
  64319. * @param host defines the root host
  64320. * @param refValue defines the reference value for percentages
  64321. * @returns the value as pixel
  64322. */
  64323. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64324. /**
  64325. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64326. * @param value defines the value to store
  64327. * @param unit defines the unit to store
  64328. * @returns the current ValueAndUnit
  64329. */
  64330. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64331. /**
  64332. * Gets the value accordingly to its unit
  64333. * @param host defines the root host
  64334. * @returns the value
  64335. */
  64336. getValue(host: AdvancedDynamicTexture): number;
  64337. /**
  64338. * Gets a string representation of the value
  64339. * @param host defines the root host
  64340. * @param decimals defines an optional number of decimals to display
  64341. * @returns a string
  64342. */
  64343. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64344. /**
  64345. * Store a value parsed from a string
  64346. * @param source defines the source string
  64347. * @returns true if the value was successfully parsed
  64348. */
  64349. fromString(source: string | number): boolean;
  64350. private static _Regex;
  64351. private static _UNITMODE_PERCENTAGE;
  64352. private static _UNITMODE_PIXEL;
  64353. /** UNITMODE_PERCENTAGE */
  64354. static readonly UNITMODE_PERCENTAGE: number;
  64355. /** UNITMODE_PIXEL */
  64356. static readonly UNITMODE_PIXEL: number;
  64357. }
  64358. }
  64359. declare module BABYLON.GUI {
  64360. /**
  64361. * Define a style used by control to automatically setup properties based on a template.
  64362. * Only support font related properties so far
  64363. */
  64364. export class Style implements BABYLON.IDisposable {
  64365. private _fontFamily;
  64366. private _fontStyle;
  64367. private _fontWeight;
  64368. /** @hidden */
  64369. _host: AdvancedDynamicTexture;
  64370. /** @hidden */
  64371. _fontSize: ValueAndUnit;
  64372. /**
  64373. * BABYLON.Observable raised when the style values are changed
  64374. */
  64375. onChangedObservable: BABYLON.Observable<Style>;
  64376. /**
  64377. * Creates a new style object
  64378. * @param host defines the AdvancedDynamicTexture which hosts this style
  64379. */
  64380. constructor(host: AdvancedDynamicTexture);
  64381. /**
  64382. * Gets or sets the font size
  64383. */
  64384. fontSize: string | number;
  64385. /**
  64386. * Gets or sets the font family
  64387. */
  64388. fontFamily: string;
  64389. /**
  64390. * Gets or sets the font style
  64391. */
  64392. fontStyle: string;
  64393. /** Gets or sets font weight */
  64394. fontWeight: string;
  64395. /** Dispose all associated resources */
  64396. dispose(): void;
  64397. }
  64398. }
  64399. declare module BABYLON.GUI {
  64400. /**
  64401. * Class used to transport BABYLON.Vector2 information for pointer events
  64402. */
  64403. export class Vector2WithInfo extends BABYLON.Vector2 {
  64404. /** defines the current mouse button index */
  64405. buttonIndex: number;
  64406. /**
  64407. * Creates a new Vector2WithInfo
  64408. * @param source defines the vector2 data to transport
  64409. * @param buttonIndex defines the current mouse button index
  64410. */
  64411. constructor(source: BABYLON.Vector2,
  64412. /** defines the current mouse button index */
  64413. buttonIndex?: number);
  64414. }
  64415. /** Class used to provide 2D matrix features */
  64416. export class Matrix2D {
  64417. /** Gets the internal array of 6 floats used to store matrix data */
  64418. m: Float32Array;
  64419. /**
  64420. * Creates a new matrix
  64421. * @param m00 defines value for (0, 0)
  64422. * @param m01 defines value for (0, 1)
  64423. * @param m10 defines value for (1, 0)
  64424. * @param m11 defines value for (1, 1)
  64425. * @param m20 defines value for (2, 0)
  64426. * @param m21 defines value for (2, 1)
  64427. */
  64428. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64429. /**
  64430. * Fills the matrix from direct values
  64431. * @param m00 defines value for (0, 0)
  64432. * @param m01 defines value for (0, 1)
  64433. * @param m10 defines value for (1, 0)
  64434. * @param m11 defines value for (1, 1)
  64435. * @param m20 defines value for (2, 0)
  64436. * @param m21 defines value for (2, 1)
  64437. * @returns the current modified matrix
  64438. */
  64439. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64440. /**
  64441. * Gets matrix determinant
  64442. * @returns the determinant
  64443. */
  64444. determinant(): number;
  64445. /**
  64446. * Inverses the matrix and stores it in a target matrix
  64447. * @param result defines the target matrix
  64448. * @returns the current matrix
  64449. */
  64450. invertToRef(result: Matrix2D): Matrix2D;
  64451. /**
  64452. * Multiplies the current matrix with another one
  64453. * @param other defines the second operand
  64454. * @param result defines the target matrix
  64455. * @returns the current matrix
  64456. */
  64457. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64458. /**
  64459. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64460. * @param x defines the x coordinate to transform
  64461. * @param y defines the x coordinate to transform
  64462. * @param result defines the target vector2
  64463. * @returns the current matrix
  64464. */
  64465. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64466. /**
  64467. * Creates an identity matrix
  64468. * @returns a new matrix
  64469. */
  64470. static Identity(): Matrix2D;
  64471. /**
  64472. * Creates a translation matrix and stores it in a target matrix
  64473. * @param x defines the x coordinate of the translation
  64474. * @param y defines the y coordinate of the translation
  64475. * @param result defines the target matrix
  64476. */
  64477. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64478. /**
  64479. * Creates a scaling matrix and stores it in a target matrix
  64480. * @param x defines the x coordinate of the scaling
  64481. * @param y defines the y coordinate of the scaling
  64482. * @param result defines the target matrix
  64483. */
  64484. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64485. /**
  64486. * Creates a rotation matrix and stores it in a target matrix
  64487. * @param angle defines the rotation angle
  64488. * @param result defines the target matrix
  64489. */
  64490. static RotationToRef(angle: number, result: Matrix2D): void;
  64491. private static _TempPreTranslationMatrix;
  64492. private static _TempPostTranslationMatrix;
  64493. private static _TempRotationMatrix;
  64494. private static _TempScalingMatrix;
  64495. private static _TempCompose0;
  64496. private static _TempCompose1;
  64497. private static _TempCompose2;
  64498. /**
  64499. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64500. * @param tx defines the x coordinate of the translation
  64501. * @param ty defines the y coordinate of the translation
  64502. * @param angle defines the rotation angle
  64503. * @param scaleX defines the x coordinate of the scaling
  64504. * @param scaleY defines the y coordinate of the scaling
  64505. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64506. * @param result defines the target matrix
  64507. */
  64508. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64509. }
  64510. }
  64511. declare module BABYLON.GUI {
  64512. /**
  64513. * Class used to store 2D control sizes
  64514. */
  64515. export class Measure {
  64516. /** defines left coordinate */
  64517. left: number;
  64518. /** defines top coordinate */
  64519. top: number;
  64520. /** defines width dimension */
  64521. width: number;
  64522. /** defines height dimension */
  64523. height: number;
  64524. /**
  64525. * Creates a new measure
  64526. * @param left defines left coordinate
  64527. * @param top defines top coordinate
  64528. * @param width defines width dimension
  64529. * @param height defines height dimension
  64530. */
  64531. constructor(
  64532. /** defines left coordinate */
  64533. left: number,
  64534. /** defines top coordinate */
  64535. top: number,
  64536. /** defines width dimension */
  64537. width: number,
  64538. /** defines height dimension */
  64539. height: number);
  64540. /**
  64541. * Copy from another measure
  64542. * @param other defines the other measure to copy from
  64543. */
  64544. copyFrom(other: Measure): void;
  64545. /**
  64546. * Copy from a group of 4 floats
  64547. * @param left defines left coordinate
  64548. * @param top defines top coordinate
  64549. * @param width defines width dimension
  64550. * @param height defines height dimension
  64551. */
  64552. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64553. /**
  64554. * Computes the axis aligned bounding box measure for two given measures
  64555. * @param a Input measure
  64556. * @param b Input measure
  64557. * @param result the resulting bounding measure
  64558. */
  64559. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64560. /**
  64561. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64562. * @param transform the matrix to transform the measure before computing the AABB
  64563. * @param result the resulting AABB
  64564. */
  64565. transformToRef(transform: Matrix2D, result: Measure): void;
  64566. /**
  64567. * Check equality between this measure and another one
  64568. * @param other defines the other measures
  64569. * @returns true if both measures are equals
  64570. */
  64571. isEqualsTo(other: Measure): boolean;
  64572. /**
  64573. * Creates an empty measure
  64574. * @returns a new measure
  64575. */
  64576. static Empty(): Measure;
  64577. }
  64578. }
  64579. declare module BABYLON.GUI {
  64580. /**
  64581. * Interface used to define a control that can receive focus
  64582. */
  64583. export interface IFocusableControl {
  64584. /**
  64585. * Function called when the control receives the focus
  64586. */
  64587. onFocus(): void;
  64588. /**
  64589. * Function called when the control loses the focus
  64590. */
  64591. onBlur(): void;
  64592. /**
  64593. * Function called to let the control handle keyboard events
  64594. * @param evt defines the current keyboard event
  64595. */
  64596. processKeyboard(evt: KeyboardEvent): void;
  64597. /**
  64598. * Function called to get the list of controls that should not steal the focus from this control
  64599. * @returns an array of controls
  64600. */
  64601. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64602. }
  64603. /**
  64604. * Class used to create texture to support 2D GUI elements
  64605. * @see http://doc.babylonjs.com/how_to/gui
  64606. */
  64607. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64608. private _isDirty;
  64609. private _renderObserver;
  64610. private _resizeObserver;
  64611. private _preKeyboardObserver;
  64612. private _pointerMoveObserver;
  64613. private _pointerObserver;
  64614. private _canvasPointerOutObserver;
  64615. private _background;
  64616. /** @hidden */
  64617. _rootContainer: Container;
  64618. /** @hidden */
  64619. _lastPickedControl: Control;
  64620. /** @hidden */
  64621. _lastControlOver: {
  64622. [pointerId: number]: Control;
  64623. };
  64624. /** @hidden */
  64625. _lastControlDown: {
  64626. [pointerId: number]: Control;
  64627. };
  64628. /** @hidden */
  64629. _capturingControl: {
  64630. [pointerId: number]: Control;
  64631. };
  64632. /** @hidden */
  64633. _shouldBlockPointer: boolean;
  64634. /** @hidden */
  64635. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64636. /** @hidden */
  64637. _linkedControls: Control[];
  64638. private _isFullscreen;
  64639. private _fullscreenViewport;
  64640. private _idealWidth;
  64641. private _idealHeight;
  64642. private _useSmallestIdeal;
  64643. private _renderAtIdealSize;
  64644. private _focusedControl;
  64645. private _blockNextFocusCheck;
  64646. private _renderScale;
  64647. private _rootCanvas;
  64648. private _cursorChanged;
  64649. /**
  64650. * Define type to string to ensure compatibility across browsers
  64651. * Safari doesn't support DataTransfer constructor
  64652. */
  64653. private _clipboardData;
  64654. /**
  64655. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64656. */
  64657. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64658. /**
  64659. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64660. */
  64661. onControlPickedObservable: BABYLON.Observable<Control>;
  64662. /**
  64663. * BABYLON.Observable event triggered before layout is evaluated
  64664. */
  64665. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64666. /**
  64667. * BABYLON.Observable event triggered after the layout was evaluated
  64668. */
  64669. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64670. /**
  64671. * BABYLON.Observable event triggered before the texture is rendered
  64672. */
  64673. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64674. /**
  64675. * BABYLON.Observable event triggered after the texture was rendered
  64676. */
  64677. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64678. /**
  64679. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64680. */
  64681. premulAlpha: boolean;
  64682. /**
  64683. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64684. * Useful when you want more antialiasing
  64685. */
  64686. renderScale: number;
  64687. /** Gets or sets the background color */
  64688. background: string;
  64689. /**
  64690. * Gets or sets the ideal width used to design controls.
  64691. * The GUI will then rescale everything accordingly
  64692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64693. */
  64694. idealWidth: number;
  64695. /**
  64696. * Gets or sets the ideal height used to design controls.
  64697. * The GUI will then rescale everything accordingly
  64698. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64699. */
  64700. idealHeight: number;
  64701. /**
  64702. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64703. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64704. */
  64705. useSmallestIdeal: boolean;
  64706. /**
  64707. * Gets or sets a boolean indicating if adaptive scaling must be used
  64708. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64709. */
  64710. renderAtIdealSize: boolean;
  64711. /**
  64712. * Gets the underlying layer used to render the texture when in fullscreen mode
  64713. */
  64714. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64715. /**
  64716. * Gets the root container control
  64717. */
  64718. readonly rootContainer: Container;
  64719. /**
  64720. * Returns an array containing the root container.
  64721. * This is mostly used to let the Inspector introspects the ADT
  64722. * @returns an array containing the rootContainer
  64723. */
  64724. getChildren(): Array<Container>;
  64725. /**
  64726. * Will return all controls that are inside this texture
  64727. * @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
  64728. * @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
  64729. * @return all child controls
  64730. */
  64731. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64732. /**
  64733. * Gets or sets the current focused control
  64734. */
  64735. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64736. /**
  64737. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64738. */
  64739. isForeground: boolean;
  64740. /**
  64741. * Gets or set information about clipboardData
  64742. */
  64743. clipboardData: string;
  64744. /**
  64745. * Creates a new AdvancedDynamicTexture
  64746. * @param name defines the name of the texture
  64747. * @param width defines the width of the texture
  64748. * @param height defines the height of the texture
  64749. * @param scene defines the hosting scene
  64750. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64751. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64752. */
  64753. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64754. /**
  64755. * Get the current class name of the texture useful for serialization or dynamic coding.
  64756. * @returns "AdvancedDynamicTexture"
  64757. */
  64758. getClassName(): string;
  64759. /**
  64760. * Function used to execute a function on all controls
  64761. * @param func defines the function to execute
  64762. * @param container defines the container where controls belong. If null the root container will be used
  64763. */
  64764. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64765. private _useInvalidateRectOptimization;
  64766. /**
  64767. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64768. */
  64769. useInvalidateRectOptimization: boolean;
  64770. private _invalidatedRectangle;
  64771. /**
  64772. * Invalidates a rectangle area on the gui texture
  64773. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64774. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64775. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64776. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64777. */
  64778. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64779. /**
  64780. * Marks the texture as dirty forcing a complete update
  64781. */
  64782. markAsDirty(): void;
  64783. /**
  64784. * Helper function used to create a new style
  64785. * @returns a new style
  64786. * @see http://doc.babylonjs.com/how_to/gui#styles
  64787. */
  64788. createStyle(): Style;
  64789. /**
  64790. * Adds a new control to the root container
  64791. * @param control defines the control to add
  64792. * @returns the current texture
  64793. */
  64794. addControl(control: Control): AdvancedDynamicTexture;
  64795. /**
  64796. * Removes a control from the root container
  64797. * @param control defines the control to remove
  64798. * @returns the current texture
  64799. */
  64800. removeControl(control: Control): AdvancedDynamicTexture;
  64801. /**
  64802. * Release all resources
  64803. */
  64804. dispose(): void;
  64805. private _onResize;
  64806. /** @hidden */
  64807. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64808. /**
  64809. * Get screen coordinates for a vector3
  64810. * @param position defines the position to project
  64811. * @param worldMatrix defines the world matrix to use
  64812. * @returns the projected position
  64813. */
  64814. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64815. private _checkUpdate;
  64816. private _clearMeasure;
  64817. private _render;
  64818. /** @hidden */
  64819. _changeCursor(cursor: string): void;
  64820. /** @hidden */
  64821. _registerLastControlDown(control: Control, pointerId: number): void;
  64822. private _doPicking;
  64823. /** @hidden */
  64824. _cleanControlAfterRemovalFromList(list: {
  64825. [pointerId: number]: Control;
  64826. }, control: Control): void;
  64827. /** @hidden */
  64828. _cleanControlAfterRemoval(control: Control): void;
  64829. /** Attach to all scene events required to support pointer events */
  64830. attach(): void;
  64831. /** @hidden */
  64832. private onClipboardCopy;
  64833. /** @hidden */
  64834. private onClipboardCut;
  64835. /** @hidden */
  64836. private onClipboardPaste;
  64837. /**
  64838. * Register the clipboard Events onto the canvas
  64839. */
  64840. registerClipboardEvents(): void;
  64841. /**
  64842. * Unregister the clipboard Events from the canvas
  64843. */
  64844. unRegisterClipboardEvents(): void;
  64845. /**
  64846. * Connect the texture to a hosting mesh to enable interactions
  64847. * @param mesh defines the mesh to attach to
  64848. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64849. */
  64850. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64851. /**
  64852. * Move the focus to a specific control
  64853. * @param control defines the control which will receive the focus
  64854. */
  64855. moveFocusToControl(control: IFocusableControl): void;
  64856. private _manageFocus;
  64857. private _attachToOnPointerOut;
  64858. /**
  64859. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64860. * @param mesh defines the mesh which will receive the texture
  64861. * @param width defines the texture width (1024 by default)
  64862. * @param height defines the texture height (1024 by default)
  64863. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64864. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64865. * @returns a new AdvancedDynamicTexture
  64866. */
  64867. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64868. /**
  64869. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64870. * In this mode the texture will rely on a layer for its rendering.
  64871. * This allows it to be treated like any other layer.
  64872. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64873. * LayerMask is set through advancedTexture.layer.layerMask
  64874. * @param name defines name for the texture
  64875. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64876. * @param scene defines the hsoting scene
  64877. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64878. * @returns a new AdvancedDynamicTexture
  64879. */
  64880. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64881. }
  64882. }
  64883. declare module BABYLON.GUI {
  64884. /**
  64885. * Root class used for all 2D controls
  64886. * @see http://doc.babylonjs.com/how_to/gui#controls
  64887. */
  64888. export class Control {
  64889. /** defines the name of the control */
  64890. name?: string | undefined;
  64891. /**
  64892. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64893. */
  64894. static AllowAlphaInheritance: boolean;
  64895. private _alpha;
  64896. private _alphaSet;
  64897. private _zIndex;
  64898. /** @hidden */
  64899. _host: AdvancedDynamicTexture;
  64900. /** Gets or sets the control parent */
  64901. parent: BABYLON.Nullable<Container>;
  64902. /** @hidden */
  64903. _currentMeasure: Measure;
  64904. private _fontFamily;
  64905. private _fontStyle;
  64906. private _fontWeight;
  64907. private _fontSize;
  64908. private _font;
  64909. /** @hidden */
  64910. _width: ValueAndUnit;
  64911. /** @hidden */
  64912. _height: ValueAndUnit;
  64913. /** @hidden */
  64914. protected _fontOffset: {
  64915. ascent: number;
  64916. height: number;
  64917. descent: number;
  64918. };
  64919. private _color;
  64920. private _style;
  64921. private _styleObserver;
  64922. /** @hidden */
  64923. protected _horizontalAlignment: number;
  64924. /** @hidden */
  64925. protected _verticalAlignment: number;
  64926. /** @hidden */
  64927. protected _isDirty: boolean;
  64928. /** @hidden */
  64929. protected _wasDirty: boolean;
  64930. /** @hidden */
  64931. _tempParentMeasure: Measure;
  64932. /** @hidden */
  64933. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64934. /** @hidden */
  64935. protected _cachedParentMeasure: Measure;
  64936. private _paddingLeft;
  64937. private _paddingRight;
  64938. private _paddingTop;
  64939. private _paddingBottom;
  64940. /** @hidden */
  64941. _left: ValueAndUnit;
  64942. /** @hidden */
  64943. _top: ValueAndUnit;
  64944. private _scaleX;
  64945. private _scaleY;
  64946. private _rotation;
  64947. private _transformCenterX;
  64948. private _transformCenterY;
  64949. /** @hidden */
  64950. _transformMatrix: Matrix2D;
  64951. /** @hidden */
  64952. protected _invertTransformMatrix: Matrix2D;
  64953. /** @hidden */
  64954. protected _transformedPosition: BABYLON.Vector2;
  64955. private _isMatrixDirty;
  64956. private _cachedOffsetX;
  64957. private _cachedOffsetY;
  64958. private _isVisible;
  64959. private _isHighlighted;
  64960. /** @hidden */
  64961. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64962. private _fontSet;
  64963. private _dummyVector2;
  64964. private _downCount;
  64965. private _enterCount;
  64966. private _doNotRender;
  64967. private _downPointerIds;
  64968. protected _isEnabled: boolean;
  64969. protected _disabledColor: string;
  64970. /** @hidden */
  64971. protected _rebuildLayout: boolean;
  64972. /** @hidden */
  64973. _isClipped: boolean;
  64974. /** @hidden */
  64975. _tag: any;
  64976. /**
  64977. * 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
  64978. */
  64979. uniqueId: number;
  64980. /**
  64981. * Gets or sets an object used to store user defined information for the node
  64982. */
  64983. metadata: any;
  64984. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64985. isHitTestVisible: boolean;
  64986. /** Gets or sets a boolean indicating if the control can block pointer events */
  64987. isPointerBlocker: boolean;
  64988. /** Gets or sets a boolean indicating if the control can be focusable */
  64989. isFocusInvisible: boolean;
  64990. /**
  64991. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64992. * 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
  64993. */
  64994. clipChildren: boolean;
  64995. /**
  64996. * Gets or sets a boolean indicating that control content must be clipped
  64997. * 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
  64998. */
  64999. clipContent: boolean;
  65000. /**
  65001. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65002. */
  65003. useBitmapCache: boolean;
  65004. private _cacheData;
  65005. private _shadowOffsetX;
  65006. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65007. shadowOffsetX: number;
  65008. private _shadowOffsetY;
  65009. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65010. shadowOffsetY: number;
  65011. private _shadowBlur;
  65012. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65013. shadowBlur: number;
  65014. private _shadowColor;
  65015. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65016. shadowColor: string;
  65017. /** Gets or sets the cursor to use when the control is hovered */
  65018. hoverCursor: string;
  65019. /** @hidden */
  65020. protected _linkOffsetX: ValueAndUnit;
  65021. /** @hidden */
  65022. protected _linkOffsetY: ValueAndUnit;
  65023. /** Gets the control type name */
  65024. readonly typeName: string;
  65025. /**
  65026. * Get the current class name of the control.
  65027. * @returns current class name
  65028. */
  65029. getClassName(): string;
  65030. /**
  65031. * An event triggered when the pointer move over the control.
  65032. */
  65033. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65034. /**
  65035. * An event triggered when the pointer move out of the control.
  65036. */
  65037. onPointerOutObservable: BABYLON.Observable<Control>;
  65038. /**
  65039. * An event triggered when the pointer taps the control
  65040. */
  65041. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65042. /**
  65043. * An event triggered when pointer up
  65044. */
  65045. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65046. /**
  65047. * An event triggered when a control is clicked on
  65048. */
  65049. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65050. /**
  65051. * An event triggered when pointer enters the control
  65052. */
  65053. onPointerEnterObservable: BABYLON.Observable<Control>;
  65054. /**
  65055. * An event triggered when the control is marked as dirty
  65056. */
  65057. onDirtyObservable: BABYLON.Observable<Control>;
  65058. /**
  65059. * An event triggered before drawing the control
  65060. */
  65061. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65062. /**
  65063. * An event triggered after the control was drawn
  65064. */
  65065. onAfterDrawObservable: BABYLON.Observable<Control>;
  65066. /**
  65067. * Get the hosting AdvancedDynamicTexture
  65068. */
  65069. readonly host: AdvancedDynamicTexture;
  65070. /** Gets or set information about font offsets (used to render and align text) */
  65071. fontOffset: {
  65072. ascent: number;
  65073. height: number;
  65074. descent: number;
  65075. };
  65076. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65077. alpha: number;
  65078. /**
  65079. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65080. */
  65081. isHighlighted: boolean;
  65082. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65083. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65084. */
  65085. scaleX: number;
  65086. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65087. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65088. */
  65089. scaleY: number;
  65090. /** Gets or sets the rotation angle (0 by default)
  65091. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65092. */
  65093. rotation: number;
  65094. /** Gets or sets the transformation center on Y axis (0 by default)
  65095. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65096. */
  65097. transformCenterY: number;
  65098. /** Gets or sets the transformation center on X axis (0 by default)
  65099. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65100. */
  65101. transformCenterX: number;
  65102. /**
  65103. * Gets or sets the horizontal alignment
  65104. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65105. */
  65106. horizontalAlignment: number;
  65107. /**
  65108. * Gets or sets the vertical alignment
  65109. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65110. */
  65111. verticalAlignment: number;
  65112. /**
  65113. * Gets or sets control width
  65114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65115. */
  65116. width: string | number;
  65117. /**
  65118. * Gets or sets the control width in pixel
  65119. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65120. */
  65121. widthInPixels: number;
  65122. /**
  65123. * Gets or sets control height
  65124. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65125. */
  65126. height: string | number;
  65127. /**
  65128. * Gets or sets control height in pixel
  65129. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65130. */
  65131. heightInPixels: number;
  65132. /** Gets or set font family */
  65133. fontFamily: string;
  65134. /** Gets or sets font style */
  65135. fontStyle: string;
  65136. /** Gets or sets font weight */
  65137. fontWeight: string;
  65138. /**
  65139. * Gets or sets style
  65140. * @see http://doc.babylonjs.com/how_to/gui#styles
  65141. */
  65142. style: BABYLON.Nullable<Style>;
  65143. /** @hidden */
  65144. readonly _isFontSizeInPercentage: boolean;
  65145. /** Gets or sets font size in pixels */
  65146. fontSizeInPixels: number;
  65147. /** Gets or sets font size */
  65148. fontSize: string | number;
  65149. /** Gets or sets foreground color */
  65150. color: string;
  65151. /** Gets or sets z index which is used to reorder controls on the z axis */
  65152. zIndex: number;
  65153. /** Gets or sets a boolean indicating if the control can be rendered */
  65154. notRenderable: boolean;
  65155. /** Gets or sets a boolean indicating if the control is visible */
  65156. isVisible: boolean;
  65157. /** Gets a boolean indicating that the control needs to update its rendering */
  65158. readonly isDirty: boolean;
  65159. /**
  65160. * Gets the current linked mesh (or null if none)
  65161. */
  65162. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65163. /**
  65164. * Gets or sets a value indicating the padding to use on the left of the control
  65165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65166. */
  65167. paddingLeft: string | number;
  65168. /**
  65169. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65170. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65171. */
  65172. paddingLeftInPixels: number;
  65173. /**
  65174. * Gets or sets a value indicating the padding to use on the right of the control
  65175. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65176. */
  65177. paddingRight: string | number;
  65178. /**
  65179. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65181. */
  65182. paddingRightInPixels: number;
  65183. /**
  65184. * Gets or sets a value indicating the padding to use on the top of the control
  65185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65186. */
  65187. paddingTop: string | number;
  65188. /**
  65189. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65191. */
  65192. paddingTopInPixels: number;
  65193. /**
  65194. * Gets or sets a value indicating the padding to use on the bottom of the control
  65195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65196. */
  65197. paddingBottom: string | number;
  65198. /**
  65199. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65200. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65201. */
  65202. paddingBottomInPixels: number;
  65203. /**
  65204. * Gets or sets a value indicating the left coordinate of the control
  65205. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65206. */
  65207. left: string | number;
  65208. /**
  65209. * Gets or sets a value indicating the left coordinate in pixels of the control
  65210. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65211. */
  65212. leftInPixels: number;
  65213. /**
  65214. * Gets or sets a value indicating the top coordinate of the control
  65215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65216. */
  65217. top: string | number;
  65218. /**
  65219. * Gets or sets a value indicating the top coordinate in pixels of the control
  65220. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65221. */
  65222. topInPixels: number;
  65223. /**
  65224. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65225. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65226. */
  65227. linkOffsetX: string | number;
  65228. /**
  65229. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65230. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65231. */
  65232. linkOffsetXInPixels: number;
  65233. /**
  65234. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65235. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65236. */
  65237. linkOffsetY: string | number;
  65238. /**
  65239. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65240. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65241. */
  65242. linkOffsetYInPixels: number;
  65243. /** Gets the center coordinate on X axis */
  65244. readonly centerX: number;
  65245. /** Gets the center coordinate on Y axis */
  65246. readonly centerY: number;
  65247. /** Gets or sets if control is Enabled*/
  65248. isEnabled: boolean;
  65249. /** Gets or sets background color of control if it's disabled*/
  65250. disabledColor: string;
  65251. /**
  65252. * Creates a new control
  65253. * @param name defines the name of the control
  65254. */
  65255. constructor(
  65256. /** defines the name of the control */
  65257. name?: string | undefined);
  65258. /** @hidden */
  65259. protected _getTypeName(): string;
  65260. /**
  65261. * Gets the first ascendant in the hierarchy of the given type
  65262. * @param className defines the required type
  65263. * @returns the ascendant or null if not found
  65264. */
  65265. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65266. /** @hidden */
  65267. _resetFontCache(): void;
  65268. /**
  65269. * Determines if a container is an ascendant of the current control
  65270. * @param container defines the container to look for
  65271. * @returns true if the container is one of the ascendant of the control
  65272. */
  65273. isAscendant(container: Control): boolean;
  65274. /**
  65275. * Gets coordinates in local control space
  65276. * @param globalCoordinates defines the coordinates to transform
  65277. * @returns the new coordinates in local space
  65278. */
  65279. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65280. /**
  65281. * Gets coordinates in local control space
  65282. * @param globalCoordinates defines the coordinates to transform
  65283. * @param result defines the target vector2 where to store the result
  65284. * @returns the current control
  65285. */
  65286. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65287. /**
  65288. * Gets coordinates in parent local control space
  65289. * @param globalCoordinates defines the coordinates to transform
  65290. * @returns the new coordinates in parent local space
  65291. */
  65292. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65293. /**
  65294. * Move the current control to a vector3 position projected onto the screen.
  65295. * @param position defines the target position
  65296. * @param scene defines the hosting scene
  65297. */
  65298. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65299. /** @hidden */
  65300. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65301. /**
  65302. * Will return all controls that have this control as ascendant
  65303. * @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
  65304. * @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
  65305. * @return all child controls
  65306. */
  65307. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65308. /**
  65309. * Link current control with a target mesh
  65310. * @param mesh defines the mesh to link with
  65311. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65312. */
  65313. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65314. /** @hidden */
  65315. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65316. /** @hidden */
  65317. _offsetLeft(offset: number): void;
  65318. /** @hidden */
  65319. _offsetTop(offset: number): void;
  65320. /** @hidden */
  65321. _markMatrixAsDirty(): void;
  65322. /** @hidden */
  65323. _flagDescendantsAsMatrixDirty(): void;
  65324. /** @hidden */
  65325. _intersectsRect(rect: Measure): boolean;
  65326. /** @hidden */
  65327. protected invalidateRect(): void;
  65328. /** @hidden */
  65329. _markAsDirty(force?: boolean): void;
  65330. /** @hidden */
  65331. _markAllAsDirty(): void;
  65332. /** @hidden */
  65333. _link(host: AdvancedDynamicTexture): void;
  65334. /** @hidden */
  65335. protected _transform(context?: CanvasRenderingContext2D): void;
  65336. /** @hidden */
  65337. _renderHighlight(context: CanvasRenderingContext2D): void;
  65338. /** @hidden */
  65339. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65340. /** @hidden */
  65341. protected _applyStates(context: CanvasRenderingContext2D): void;
  65342. /** @hidden */
  65343. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65344. /** @hidden */
  65345. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65346. protected _evaluateClippingState(parentMeasure: Measure): void;
  65347. /** @hidden */
  65348. _measure(): void;
  65349. /** @hidden */
  65350. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65351. /** @hidden */
  65352. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65353. /** @hidden */
  65354. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65355. /** @hidden */
  65356. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65357. private static _ClipMeasure;
  65358. private _tmpMeasureA;
  65359. private _clip;
  65360. /** @hidden */
  65361. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65362. /** @hidden */
  65363. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65364. /**
  65365. * Tests if a given coordinates belong to the current control
  65366. * @param x defines x coordinate to test
  65367. * @param y defines y coordinate to test
  65368. * @returns true if the coordinates are inside the control
  65369. */
  65370. contains(x: number, y: number): boolean;
  65371. /** @hidden */
  65372. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65373. /** @hidden */
  65374. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65375. /** @hidden */
  65376. _onPointerEnter(target: Control): boolean;
  65377. /** @hidden */
  65378. _onPointerOut(target: Control, force?: boolean): void;
  65379. /** @hidden */
  65380. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65381. /** @hidden */
  65382. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65383. /** @hidden */
  65384. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65385. /** @hidden */
  65386. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65387. private _prepareFont;
  65388. /** Releases associated resources */
  65389. dispose(): void;
  65390. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65391. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65392. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65393. private static _VERTICAL_ALIGNMENT_TOP;
  65394. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65395. private static _VERTICAL_ALIGNMENT_CENTER;
  65396. /** HORIZONTAL_ALIGNMENT_LEFT */
  65397. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65398. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65399. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65400. /** HORIZONTAL_ALIGNMENT_CENTER */
  65401. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65402. /** VERTICAL_ALIGNMENT_TOP */
  65403. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65404. /** VERTICAL_ALIGNMENT_BOTTOM */
  65405. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65406. /** VERTICAL_ALIGNMENT_CENTER */
  65407. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65408. private static _FontHeightSizes;
  65409. /** @hidden */
  65410. static _GetFontOffset(font: string): {
  65411. ascent: number;
  65412. height: number;
  65413. descent: number;
  65414. };
  65415. /**
  65416. * Creates a stack panel that can be used to render headers
  65417. * @param control defines the control to associate with the header
  65418. * @param text defines the text of the header
  65419. * @param size defines the size of the header
  65420. * @param options defines options used to configure the header
  65421. * @returns a new StackPanel
  65422. * @ignore
  65423. * @hidden
  65424. */
  65425. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65426. isHorizontal: boolean;
  65427. controlFirst: boolean;
  65428. }) => any;
  65429. /** @hidden */
  65430. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65431. }
  65432. }
  65433. declare module BABYLON.GUI {
  65434. /**
  65435. * Root class for 2D containers
  65436. * @see http://doc.babylonjs.com/how_to/gui#containers
  65437. */
  65438. export class Container extends Control {
  65439. name?: string | undefined;
  65440. /** @hidden */
  65441. protected _children: Control[];
  65442. /** @hidden */
  65443. protected _measureForChildren: Measure;
  65444. /** @hidden */
  65445. protected _background: string;
  65446. /** @hidden */
  65447. protected _adaptWidthToChildren: boolean;
  65448. /** @hidden */
  65449. protected _adaptHeightToChildren: boolean;
  65450. /**
  65451. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65452. */
  65453. logLayoutCycleErrors: boolean;
  65454. /**
  65455. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65456. */
  65457. maxLayoutCycle: number;
  65458. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65459. adaptHeightToChildren: boolean;
  65460. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65461. adaptWidthToChildren: boolean;
  65462. /** Gets or sets background color */
  65463. background: string;
  65464. /** Gets the list of children */
  65465. readonly children: Control[];
  65466. /**
  65467. * Creates a new Container
  65468. * @param name defines the name of the container
  65469. */
  65470. constructor(name?: string | undefined);
  65471. protected _getTypeName(): string;
  65472. _flagDescendantsAsMatrixDirty(): void;
  65473. /**
  65474. * Gets a child using its name
  65475. * @param name defines the child name to look for
  65476. * @returns the child control if found
  65477. */
  65478. getChildByName(name: string): BABYLON.Nullable<Control>;
  65479. /**
  65480. * Gets a child using its type and its name
  65481. * @param name defines the child name to look for
  65482. * @param type defines the child type to look for
  65483. * @returns the child control if found
  65484. */
  65485. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65486. /**
  65487. * Search for a specific control in children
  65488. * @param control defines the control to look for
  65489. * @returns true if the control is in child list
  65490. */
  65491. containsControl(control: Control): boolean;
  65492. /**
  65493. * Adds a new control to the current container
  65494. * @param control defines the control to add
  65495. * @returns the current container
  65496. */
  65497. addControl(control: BABYLON.Nullable<Control>): Container;
  65498. /**
  65499. * Removes all controls from the current container
  65500. * @returns the current container
  65501. */
  65502. clearControls(): Container;
  65503. /**
  65504. * Removes a control from the current container
  65505. * @param control defines the control to remove
  65506. * @returns the current container
  65507. */
  65508. removeControl(control: Control): Container;
  65509. /** @hidden */
  65510. _reOrderControl(control: Control): void;
  65511. /** @hidden */
  65512. _offsetLeft(offset: number): void;
  65513. /** @hidden */
  65514. _offsetTop(offset: number): void;
  65515. /** @hidden */
  65516. _markAllAsDirty(): void;
  65517. /** @hidden */
  65518. protected _localDraw(context: CanvasRenderingContext2D): void;
  65519. /** @hidden */
  65520. _link(host: AdvancedDynamicTexture): void;
  65521. /** @hidden */
  65522. protected _beforeLayout(): void;
  65523. /** @hidden */
  65524. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65525. /** @hidden */
  65526. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65527. protected _postMeasure(): void;
  65528. /** @hidden */
  65529. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65530. /** @hidden */
  65531. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65532. /** @hidden */
  65533. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65534. /** @hidden */
  65535. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65536. /** Releases associated resources */
  65537. dispose(): void;
  65538. }
  65539. }
  65540. declare module BABYLON.GUI {
  65541. /** Class used to create rectangle container */
  65542. export class Rectangle extends Container {
  65543. name?: string | undefined;
  65544. private _thickness;
  65545. private _cornerRadius;
  65546. /** Gets or sets border thickness */
  65547. thickness: number;
  65548. /** Gets or sets the corner radius angle */
  65549. cornerRadius: number;
  65550. /**
  65551. * Creates a new Rectangle
  65552. * @param name defines the control name
  65553. */
  65554. constructor(name?: string | undefined);
  65555. protected _getTypeName(): string;
  65556. protected _localDraw(context: CanvasRenderingContext2D): void;
  65557. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65558. private _drawRoundedRect;
  65559. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65560. }
  65561. }
  65562. declare module BABYLON.GUI {
  65563. /**
  65564. * Enum that determines the text-wrapping mode to use.
  65565. */
  65566. export enum TextWrapping {
  65567. /**
  65568. * Clip the text when it's larger than Control.width; this is the default mode.
  65569. */
  65570. Clip = 0,
  65571. /**
  65572. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65573. */
  65574. WordWrap = 1,
  65575. /**
  65576. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65577. */
  65578. Ellipsis = 2
  65579. }
  65580. /**
  65581. * Class used to create text block control
  65582. */
  65583. export class TextBlock extends Control {
  65584. /**
  65585. * Defines the name of the control
  65586. */
  65587. name?: string | undefined;
  65588. private _text;
  65589. private _textWrapping;
  65590. private _textHorizontalAlignment;
  65591. private _textVerticalAlignment;
  65592. private _lines;
  65593. private _resizeToFit;
  65594. private _lineSpacing;
  65595. private _outlineWidth;
  65596. private _outlineColor;
  65597. /**
  65598. * An event triggered after the text is changed
  65599. */
  65600. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65601. /**
  65602. * An event triggered after the text was broken up into lines
  65603. */
  65604. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65605. /**
  65606. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65607. */
  65608. readonly lines: any[];
  65609. /**
  65610. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65611. */
  65612. /**
  65613. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65614. */
  65615. resizeToFit: boolean;
  65616. /**
  65617. * Gets or sets a boolean indicating if text must be wrapped
  65618. */
  65619. /**
  65620. * Gets or sets a boolean indicating if text must be wrapped
  65621. */
  65622. textWrapping: TextWrapping | boolean;
  65623. /**
  65624. * Gets or sets text to display
  65625. */
  65626. /**
  65627. * Gets or sets text to display
  65628. */
  65629. text: string;
  65630. /**
  65631. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65632. */
  65633. /**
  65634. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65635. */
  65636. textHorizontalAlignment: number;
  65637. /**
  65638. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65639. */
  65640. /**
  65641. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65642. */
  65643. textVerticalAlignment: number;
  65644. /**
  65645. * Gets or sets line spacing value
  65646. */
  65647. /**
  65648. * Gets or sets line spacing value
  65649. */
  65650. lineSpacing: string | number;
  65651. /**
  65652. * Gets or sets outlineWidth of the text to display
  65653. */
  65654. /**
  65655. * Gets or sets outlineWidth of the text to display
  65656. */
  65657. outlineWidth: number;
  65658. /**
  65659. * Gets or sets outlineColor of the text to display
  65660. */
  65661. /**
  65662. * Gets or sets outlineColor of the text to display
  65663. */
  65664. outlineColor: string;
  65665. /**
  65666. * Creates a new TextBlock object
  65667. * @param name defines the name of the control
  65668. * @param text defines the text to display (emptry string by default)
  65669. */
  65670. constructor(
  65671. /**
  65672. * Defines the name of the control
  65673. */
  65674. name?: string | undefined, text?: string);
  65675. protected _getTypeName(): string;
  65676. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65677. private _drawText;
  65678. /** @hidden */
  65679. _draw(context: CanvasRenderingContext2D): void;
  65680. protected _applyStates(context: CanvasRenderingContext2D): void;
  65681. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65682. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65683. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65684. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65685. protected _renderLines(context: CanvasRenderingContext2D): void;
  65686. /**
  65687. * Given a width constraint applied on the text block, find the expected height
  65688. * @returns expected height
  65689. */
  65690. computeExpectedHeight(): number;
  65691. dispose(): void;
  65692. }
  65693. }
  65694. declare module BABYLON.GUI {
  65695. /**
  65696. * Class used to create 2D images
  65697. */
  65698. export class Image extends Control {
  65699. name?: string | undefined;
  65700. private static _WorkingCanvas;
  65701. private _domImage;
  65702. private _imageWidth;
  65703. private _imageHeight;
  65704. private _loaded;
  65705. private _stretch;
  65706. private _source;
  65707. private _autoScale;
  65708. private _sourceLeft;
  65709. private _sourceTop;
  65710. private _sourceWidth;
  65711. private _sourceHeight;
  65712. private _cellWidth;
  65713. private _cellHeight;
  65714. private _cellId;
  65715. private _populateNinePatchSlicesFromImage;
  65716. private _sliceLeft;
  65717. private _sliceRight;
  65718. private _sliceTop;
  65719. private _sliceBottom;
  65720. private _detectPointerOnOpaqueOnly;
  65721. /**
  65722. * BABYLON.Observable notified when the content is loaded
  65723. */
  65724. onImageLoadedObservable: BABYLON.Observable<Image>;
  65725. /**
  65726. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65727. */
  65728. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65729. /**
  65730. * Gets a boolean indicating that the content is loaded
  65731. */
  65732. readonly isLoaded: boolean;
  65733. /**
  65734. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65735. */
  65736. populateNinePatchSlicesFromImage: boolean;
  65737. /**
  65738. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65739. * Beware using this as this will comsume more memory as the image has to be stored twice
  65740. */
  65741. detectPointerOnOpaqueOnly: boolean;
  65742. /**
  65743. * Gets or sets the left value for slicing (9-patch)
  65744. */
  65745. sliceLeft: number;
  65746. /**
  65747. * Gets or sets the right value for slicing (9-patch)
  65748. */
  65749. sliceRight: number;
  65750. /**
  65751. * Gets or sets the top value for slicing (9-patch)
  65752. */
  65753. sliceTop: number;
  65754. /**
  65755. * Gets or sets the bottom value for slicing (9-patch)
  65756. */
  65757. sliceBottom: number;
  65758. /**
  65759. * Gets or sets the left coordinate in the source image
  65760. */
  65761. sourceLeft: number;
  65762. /**
  65763. * Gets or sets the top coordinate in the source image
  65764. */
  65765. sourceTop: number;
  65766. /**
  65767. * Gets or sets the width to capture in the source image
  65768. */
  65769. sourceWidth: number;
  65770. /**
  65771. * Gets or sets the height to capture in the source image
  65772. */
  65773. sourceHeight: number;
  65774. /**
  65775. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65776. * @see http://doc.babylonjs.com/how_to/gui#image
  65777. */
  65778. autoScale: boolean;
  65779. /** Gets or sets the streching mode used by the image */
  65780. stretch: number;
  65781. /**
  65782. * Gets or sets the internal DOM image used to render the control
  65783. */
  65784. domImage: HTMLImageElement;
  65785. private _onImageLoaded;
  65786. private _extractNinePatchSliceDataFromImage;
  65787. /**
  65788. * Gets or sets image source url
  65789. */
  65790. source: BABYLON.Nullable<string>;
  65791. /**
  65792. * Checks for svg document with icon id present
  65793. */
  65794. private _svgCheck;
  65795. /**
  65796. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65797. * given external svg file and icon id
  65798. */
  65799. private _getSVGAttribs;
  65800. /**
  65801. * Gets or sets the cell width to use when animation sheet is enabled
  65802. * @see http://doc.babylonjs.com/how_to/gui#image
  65803. */
  65804. cellWidth: number;
  65805. /**
  65806. * Gets or sets the cell height to use when animation sheet is enabled
  65807. * @see http://doc.babylonjs.com/how_to/gui#image
  65808. */
  65809. cellHeight: number;
  65810. /**
  65811. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65812. * @see http://doc.babylonjs.com/how_to/gui#image
  65813. */
  65814. cellId: number;
  65815. /**
  65816. * Creates a new Image
  65817. * @param name defines the control name
  65818. * @param url defines the image url
  65819. */
  65820. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65821. /**
  65822. * Tests if a given coordinates belong to the current control
  65823. * @param x defines x coordinate to test
  65824. * @param y defines y coordinate to test
  65825. * @returns true if the coordinates are inside the control
  65826. */
  65827. contains(x: number, y: number): boolean;
  65828. protected _getTypeName(): string;
  65829. /** Force the control to synchronize with its content */
  65830. synchronizeSizeWithContent(): void;
  65831. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65832. private _prepareWorkingCanvasForOpaqueDetection;
  65833. private _drawImage;
  65834. _draw(context: CanvasRenderingContext2D): void;
  65835. private _renderCornerPatch;
  65836. private _renderNinePatch;
  65837. dispose(): void;
  65838. /** STRETCH_NONE */
  65839. static readonly STRETCH_NONE: number;
  65840. /** STRETCH_FILL */
  65841. static readonly STRETCH_FILL: number;
  65842. /** STRETCH_UNIFORM */
  65843. static readonly STRETCH_UNIFORM: number;
  65844. /** STRETCH_EXTEND */
  65845. static readonly STRETCH_EXTEND: number;
  65846. /** NINE_PATCH */
  65847. static readonly STRETCH_NINE_PATCH: number;
  65848. }
  65849. }
  65850. declare module BABYLON.GUI {
  65851. /**
  65852. * Class used to create 2D buttons
  65853. */
  65854. export class Button extends Rectangle {
  65855. name?: string | undefined;
  65856. /**
  65857. * Function called to generate a pointer enter animation
  65858. */
  65859. pointerEnterAnimation: () => void;
  65860. /**
  65861. * Function called to generate a pointer out animation
  65862. */
  65863. pointerOutAnimation: () => void;
  65864. /**
  65865. * Function called to generate a pointer down animation
  65866. */
  65867. pointerDownAnimation: () => void;
  65868. /**
  65869. * Function called to generate a pointer up animation
  65870. */
  65871. pointerUpAnimation: () => void;
  65872. /**
  65873. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65874. */
  65875. delegatePickingToChildren: boolean;
  65876. private _image;
  65877. /**
  65878. * Returns the image part of the button (if any)
  65879. */
  65880. readonly image: BABYLON.Nullable<Image>;
  65881. private _textBlock;
  65882. /**
  65883. * Returns the image part of the button (if any)
  65884. */
  65885. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65886. /**
  65887. * Creates a new Button
  65888. * @param name defines the name of the button
  65889. */
  65890. constructor(name?: string | undefined);
  65891. protected _getTypeName(): string;
  65892. /** @hidden */
  65893. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65894. /** @hidden */
  65895. _onPointerEnter(target: Control): boolean;
  65896. /** @hidden */
  65897. _onPointerOut(target: Control, force?: boolean): void;
  65898. /** @hidden */
  65899. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65900. /** @hidden */
  65901. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65902. /**
  65903. * Creates a new button made with an image and a text
  65904. * @param name defines the name of the button
  65905. * @param text defines the text of the button
  65906. * @param imageUrl defines the url of the image
  65907. * @returns a new Button
  65908. */
  65909. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65910. /**
  65911. * Creates a new button made with an image
  65912. * @param name defines the name of the button
  65913. * @param imageUrl defines the url of the image
  65914. * @returns a new Button
  65915. */
  65916. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65917. /**
  65918. * Creates a new button made with a text
  65919. * @param name defines the name of the button
  65920. * @param text defines the text of the button
  65921. * @returns a new Button
  65922. */
  65923. static CreateSimpleButton(name: string, text: string): Button;
  65924. /**
  65925. * Creates a new button made with an image and a centered text
  65926. * @param name defines the name of the button
  65927. * @param text defines the text of the button
  65928. * @param imageUrl defines the url of the image
  65929. * @returns a new Button
  65930. */
  65931. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65932. }
  65933. }
  65934. declare module BABYLON.GUI {
  65935. /**
  65936. * Class used to create a 2D stack panel container
  65937. */
  65938. export class StackPanel extends Container {
  65939. name?: string | undefined;
  65940. private _isVertical;
  65941. private _manualWidth;
  65942. private _manualHeight;
  65943. private _doNotTrackManualChanges;
  65944. /**
  65945. * Gets or sets a boolean indicating that layou warnings should be ignored
  65946. */
  65947. ignoreLayoutWarnings: boolean;
  65948. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65949. isVertical: boolean;
  65950. /**
  65951. * Gets or sets panel width.
  65952. * This value should not be set when in horizontal mode as it will be computed automatically
  65953. */
  65954. width: string | number;
  65955. /**
  65956. * Gets or sets panel height.
  65957. * This value should not be set when in vertical mode as it will be computed automatically
  65958. */
  65959. height: string | number;
  65960. /**
  65961. * Creates a new StackPanel
  65962. * @param name defines control name
  65963. */
  65964. constructor(name?: string | undefined);
  65965. protected _getTypeName(): string;
  65966. /** @hidden */
  65967. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65968. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65969. protected _postMeasure(): void;
  65970. }
  65971. }
  65972. declare module BABYLON.GUI {
  65973. /**
  65974. * Class used to represent a 2D checkbox
  65975. */
  65976. export class Checkbox extends Control {
  65977. name?: string | undefined;
  65978. private _isChecked;
  65979. private _background;
  65980. private _checkSizeRatio;
  65981. private _thickness;
  65982. /** Gets or sets border thickness */
  65983. thickness: number;
  65984. /**
  65985. * BABYLON.Observable raised when isChecked property changes
  65986. */
  65987. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65988. /** Gets or sets a value indicating the ratio between overall size and check size */
  65989. checkSizeRatio: number;
  65990. /** Gets or sets background color */
  65991. background: string;
  65992. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65993. isChecked: boolean;
  65994. /**
  65995. * Creates a new CheckBox
  65996. * @param name defines the control name
  65997. */
  65998. constructor(name?: string | undefined);
  65999. protected _getTypeName(): string;
  66000. /** @hidden */
  66001. _draw(context: CanvasRenderingContext2D): void;
  66002. /** @hidden */
  66003. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66004. /**
  66005. * Utility function to easily create a checkbox with a header
  66006. * @param title defines the label to use for the header
  66007. * @param onValueChanged defines the callback to call when value changes
  66008. * @returns a StackPanel containing the checkbox and a textBlock
  66009. */
  66010. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66011. }
  66012. }
  66013. declare module BABYLON.GUI {
  66014. /**
  66015. * Class used to store key control properties
  66016. */
  66017. export class KeyPropertySet {
  66018. /** Width */
  66019. width?: string;
  66020. /** Height */
  66021. height?: string;
  66022. /** Left padding */
  66023. paddingLeft?: string;
  66024. /** Right padding */
  66025. paddingRight?: string;
  66026. /** Top padding */
  66027. paddingTop?: string;
  66028. /** Bottom padding */
  66029. paddingBottom?: string;
  66030. /** Foreground color */
  66031. color?: string;
  66032. /** Background color */
  66033. background?: string;
  66034. }
  66035. /**
  66036. * Class used to create virtual keyboard
  66037. */
  66038. export class VirtualKeyboard extends StackPanel {
  66039. /** BABYLON.Observable raised when a key is pressed */
  66040. onKeyPressObservable: BABYLON.Observable<string>;
  66041. /** Gets or sets default key button width */
  66042. defaultButtonWidth: string;
  66043. /** Gets or sets default key button height */
  66044. defaultButtonHeight: string;
  66045. /** Gets or sets default key button left padding */
  66046. defaultButtonPaddingLeft: string;
  66047. /** Gets or sets default key button right padding */
  66048. defaultButtonPaddingRight: string;
  66049. /** Gets or sets default key button top padding */
  66050. defaultButtonPaddingTop: string;
  66051. /** Gets or sets default key button bottom padding */
  66052. defaultButtonPaddingBottom: string;
  66053. /** Gets or sets default key button foreground color */
  66054. defaultButtonColor: string;
  66055. /** Gets or sets default key button background color */
  66056. defaultButtonBackground: string;
  66057. /** Gets or sets shift button foreground color */
  66058. shiftButtonColor: string;
  66059. /** Gets or sets shift button thickness*/
  66060. selectedShiftThickness: number;
  66061. /** Gets shift key state */
  66062. shiftState: number;
  66063. protected _getTypeName(): string;
  66064. private _createKey;
  66065. /**
  66066. * Adds a new row of keys
  66067. * @param keys defines the list of keys to add
  66068. * @param propertySets defines the associated property sets
  66069. */
  66070. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66071. /**
  66072. * Set the shift key to a specific state
  66073. * @param shiftState defines the new shift state
  66074. */
  66075. applyShiftState(shiftState: number): void;
  66076. private _currentlyConnectedInputText;
  66077. private _connectedInputTexts;
  66078. private _onKeyPressObserver;
  66079. /** Gets the input text control currently attached to the keyboard */
  66080. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66081. /**
  66082. * Connects the keyboard with an input text control
  66083. *
  66084. * @param input defines the target control
  66085. */
  66086. connect(input: InputText): void;
  66087. /**
  66088. * Disconnects the keyboard from connected InputText controls
  66089. *
  66090. * @param input optionally defines a target control, otherwise all are disconnected
  66091. */
  66092. disconnect(input?: InputText): void;
  66093. private _removeConnectedInputObservables;
  66094. /**
  66095. * Release all resources
  66096. */
  66097. dispose(): void;
  66098. /**
  66099. * Creates a new keyboard using a default layout
  66100. *
  66101. * @param name defines control name
  66102. * @returns a new VirtualKeyboard
  66103. */
  66104. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66105. }
  66106. }
  66107. declare module BABYLON.GUI {
  66108. /**
  66109. * Class used to create input text control
  66110. */
  66111. export class InputText extends Control implements IFocusableControl {
  66112. name?: string | undefined;
  66113. private _text;
  66114. private _placeholderText;
  66115. private _background;
  66116. private _focusedBackground;
  66117. private _focusedColor;
  66118. private _placeholderColor;
  66119. private _thickness;
  66120. private _margin;
  66121. private _autoStretchWidth;
  66122. private _maxWidth;
  66123. private _isFocused;
  66124. private _blinkTimeout;
  66125. private _blinkIsEven;
  66126. private _cursorOffset;
  66127. private _scrollLeft;
  66128. private _textWidth;
  66129. private _clickedCoordinate;
  66130. private _deadKey;
  66131. private _addKey;
  66132. private _currentKey;
  66133. private _isTextHighlightOn;
  66134. private _textHighlightColor;
  66135. private _highligherOpacity;
  66136. private _highlightedText;
  66137. private _startHighlightIndex;
  66138. private _endHighlightIndex;
  66139. private _cursorIndex;
  66140. private _onFocusSelectAll;
  66141. private _isPointerDown;
  66142. private _onClipboardObserver;
  66143. private _onPointerDblTapObserver;
  66144. /** @hidden */
  66145. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66146. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66147. promptMessage: string;
  66148. /** Force disable prompt on mobile device */
  66149. disableMobilePrompt: boolean;
  66150. /** BABYLON.Observable raised when the text changes */
  66151. onTextChangedObservable: BABYLON.Observable<InputText>;
  66152. /** BABYLON.Observable raised just before an entered character is to be added */
  66153. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66154. /** BABYLON.Observable raised when the control gets the focus */
  66155. onFocusObservable: BABYLON.Observable<InputText>;
  66156. /** BABYLON.Observable raised when the control loses the focus */
  66157. onBlurObservable: BABYLON.Observable<InputText>;
  66158. /**Observable raised when the text is highlighted */
  66159. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66160. /**Observable raised when copy event is triggered */
  66161. onTextCopyObservable: BABYLON.Observable<InputText>;
  66162. /** BABYLON.Observable raised when cut event is triggered */
  66163. onTextCutObservable: BABYLON.Observable<InputText>;
  66164. /** BABYLON.Observable raised when paste event is triggered */
  66165. onTextPasteObservable: BABYLON.Observable<InputText>;
  66166. /** BABYLON.Observable raised when a key event was processed */
  66167. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66168. /** Gets or sets the maximum width allowed by the control */
  66169. maxWidth: string | number;
  66170. /** Gets the maximum width allowed by the control in pixels */
  66171. readonly maxWidthInPixels: number;
  66172. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66173. highligherOpacity: number;
  66174. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66175. onFocusSelectAll: boolean;
  66176. /** Gets or sets the text hightlight color */
  66177. textHighlightColor: string;
  66178. /** Gets or sets control margin */
  66179. margin: string;
  66180. /** Gets control margin in pixels */
  66181. readonly marginInPixels: number;
  66182. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66183. autoStretchWidth: boolean;
  66184. /** Gets or sets border thickness */
  66185. thickness: number;
  66186. /** Gets or sets the background color when focused */
  66187. focusedBackground: string;
  66188. /** Gets or sets the background color when focused */
  66189. focusedColor: string;
  66190. /** Gets or sets the background color */
  66191. background: string;
  66192. /** Gets or sets the placeholder color */
  66193. placeholderColor: string;
  66194. /** Gets or sets the text displayed when the control is empty */
  66195. placeholderText: string;
  66196. /** Gets or sets the dead key flag */
  66197. deadKey: boolean;
  66198. /** Gets or sets the highlight text */
  66199. highlightedText: string;
  66200. /** Gets or sets if the current key should be added */
  66201. addKey: boolean;
  66202. /** Gets or sets the value of the current key being entered */
  66203. currentKey: string;
  66204. /** Gets or sets the text displayed in the control */
  66205. text: string;
  66206. /** Gets or sets control width */
  66207. width: string | number;
  66208. /**
  66209. * Creates a new InputText
  66210. * @param name defines the control name
  66211. * @param text defines the text of the control
  66212. */
  66213. constructor(name?: string | undefined, text?: string);
  66214. /** @hidden */
  66215. onBlur(): void;
  66216. /** @hidden */
  66217. onFocus(): void;
  66218. protected _getTypeName(): string;
  66219. /**
  66220. * Function called to get the list of controls that should not steal the focus from this control
  66221. * @returns an array of controls
  66222. */
  66223. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66224. /** @hidden */
  66225. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66226. /** @hidden */
  66227. private _updateValueFromCursorIndex;
  66228. /** @hidden */
  66229. private _processDblClick;
  66230. /** @hidden */
  66231. private _selectAllText;
  66232. /**
  66233. * Handles the keyboard event
  66234. * @param evt Defines the KeyboardEvent
  66235. */
  66236. processKeyboard(evt: KeyboardEvent): void;
  66237. /** @hidden */
  66238. private _onCopyText;
  66239. /** @hidden */
  66240. private _onCutText;
  66241. /** @hidden */
  66242. private _onPasteText;
  66243. _draw(context: CanvasRenderingContext2D): void;
  66244. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66245. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66246. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66247. protected _beforeRenderText(text: string): string;
  66248. dispose(): void;
  66249. }
  66250. }
  66251. declare module BABYLON.GUI {
  66252. /**
  66253. * Class used to create a 2D grid container
  66254. */
  66255. export class Grid extends Container {
  66256. name?: string | undefined;
  66257. private _rowDefinitions;
  66258. private _columnDefinitions;
  66259. private _cells;
  66260. private _childControls;
  66261. /**
  66262. * Gets the number of columns
  66263. */
  66264. readonly columnCount: number;
  66265. /**
  66266. * Gets the number of rows
  66267. */
  66268. readonly rowCount: number;
  66269. /** Gets the list of children */
  66270. readonly children: Control[];
  66271. /** Gets the list of cells (e.g. the containers) */
  66272. readonly cells: {
  66273. [key: string]: Container;
  66274. };
  66275. /**
  66276. * Gets the definition of a specific row
  66277. * @param index defines the index of the row
  66278. * @returns the row definition
  66279. */
  66280. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66281. /**
  66282. * Gets the definition of a specific column
  66283. * @param index defines the index of the column
  66284. * @returns the column definition
  66285. */
  66286. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66287. /**
  66288. * Adds a new row to the grid
  66289. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66290. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66291. * @returns the current grid
  66292. */
  66293. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66294. /**
  66295. * Adds a new column to the grid
  66296. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66297. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66298. * @returns the current grid
  66299. */
  66300. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66301. /**
  66302. * Update a row definition
  66303. * @param index defines the index of the row to update
  66304. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66305. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66306. * @returns the current grid
  66307. */
  66308. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66309. /**
  66310. * Update a column definition
  66311. * @param index defines the index of the column to update
  66312. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66313. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66314. * @returns the current grid
  66315. */
  66316. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66317. /**
  66318. * Gets the list of children stored in a specific cell
  66319. * @param row defines the row to check
  66320. * @param column defines the column to check
  66321. * @returns the list of controls
  66322. */
  66323. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66324. /**
  66325. * Gets a string representing the child cell info (row x column)
  66326. * @param child defines the control to get info from
  66327. * @returns a string containing the child cell info (row x column)
  66328. */
  66329. getChildCellInfo(child: Control): string;
  66330. private _removeCell;
  66331. private _offsetCell;
  66332. /**
  66333. * Remove a column definition at specified index
  66334. * @param index defines the index of the column to remove
  66335. * @returns the current grid
  66336. */
  66337. removeColumnDefinition(index: number): Grid;
  66338. /**
  66339. * Remove a row definition at specified index
  66340. * @param index defines the index of the row to remove
  66341. * @returns the current grid
  66342. */
  66343. removeRowDefinition(index: number): Grid;
  66344. /**
  66345. * Adds a new control to the current grid
  66346. * @param control defines the control to add
  66347. * @param row defines the row where to add the control (0 by default)
  66348. * @param column defines the column where to add the control (0 by default)
  66349. * @returns the current grid
  66350. */
  66351. addControl(control: Control, row?: number, column?: number): Grid;
  66352. /**
  66353. * Removes a control from the current container
  66354. * @param control defines the control to remove
  66355. * @returns the current container
  66356. */
  66357. removeControl(control: Control): Container;
  66358. /**
  66359. * Creates a new Grid
  66360. * @param name defines control name
  66361. */
  66362. constructor(name?: string | undefined);
  66363. protected _getTypeName(): string;
  66364. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66365. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66366. _flagDescendantsAsMatrixDirty(): void;
  66367. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66368. /** Releases associated resources */
  66369. dispose(): void;
  66370. }
  66371. }
  66372. declare module BABYLON.GUI {
  66373. /** Class used to create color pickers */
  66374. export class ColorPicker extends Control {
  66375. name?: string | undefined;
  66376. private static _Epsilon;
  66377. private _colorWheelCanvas;
  66378. private _value;
  66379. private _tmpColor;
  66380. private _pointerStartedOnSquare;
  66381. private _pointerStartedOnWheel;
  66382. private _squareLeft;
  66383. private _squareTop;
  66384. private _squareSize;
  66385. private _h;
  66386. private _s;
  66387. private _v;
  66388. private _lastPointerDownID;
  66389. /**
  66390. * BABYLON.Observable raised when the value changes
  66391. */
  66392. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66393. /** Gets or sets the color of the color picker */
  66394. value: BABYLON.Color3;
  66395. /**
  66396. * Gets or sets control width
  66397. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66398. */
  66399. width: string | number;
  66400. /**
  66401. * Gets or sets control height
  66402. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66403. */
  66404. /** Gets or sets control height */
  66405. height: string | number;
  66406. /** Gets or sets control size */
  66407. size: string | number;
  66408. /**
  66409. * Creates a new ColorPicker
  66410. * @param name defines the control name
  66411. */
  66412. constructor(name?: string | undefined);
  66413. protected _getTypeName(): string;
  66414. /** @hidden */
  66415. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66416. private _updateSquareProps;
  66417. private _drawGradientSquare;
  66418. private _drawCircle;
  66419. private _createColorWheelCanvas;
  66420. /** @hidden */
  66421. _draw(context: CanvasRenderingContext2D): void;
  66422. private _pointerIsDown;
  66423. private _updateValueFromPointer;
  66424. private _isPointOnSquare;
  66425. private _isPointOnWheel;
  66426. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66427. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66428. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66429. /**
  66430. * This function expands the color picker by creating a color picker dialog with manual
  66431. * color value input and the ability to save colors into an array to be used later in
  66432. * subsequent launches of the dialogue.
  66433. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66434. * @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.
  66435. * @returns picked color as a hex string and the saved colors array as hex strings.
  66436. */
  66437. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66438. pickerWidth?: string;
  66439. pickerHeight?: string;
  66440. headerHeight?: string;
  66441. lastColor?: string;
  66442. swatchLimit?: number;
  66443. numSwatchesPerLine?: number;
  66444. savedColors?: Array<string>;
  66445. }): Promise<{
  66446. savedColors?: string[];
  66447. pickedColor: string;
  66448. }>;
  66449. }
  66450. }
  66451. declare module BABYLON.GUI {
  66452. /** Class used to create 2D ellipse containers */
  66453. export class Ellipse extends Container {
  66454. name?: string | undefined;
  66455. private _thickness;
  66456. /** Gets or sets border thickness */
  66457. thickness: number;
  66458. /**
  66459. * Creates a new Ellipse
  66460. * @param name defines the control name
  66461. */
  66462. constructor(name?: string | undefined);
  66463. protected _getTypeName(): string;
  66464. protected _localDraw(context: CanvasRenderingContext2D): void;
  66465. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66466. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66467. }
  66468. }
  66469. declare module BABYLON.GUI {
  66470. /**
  66471. * Class used to create a password control
  66472. */
  66473. export class InputPassword extends InputText {
  66474. protected _beforeRenderText(text: string): string;
  66475. }
  66476. }
  66477. declare module BABYLON.GUI {
  66478. /** Class used to render 2D lines */
  66479. export class Line extends Control {
  66480. name?: string | undefined;
  66481. private _lineWidth;
  66482. private _x1;
  66483. private _y1;
  66484. private _x2;
  66485. private _y2;
  66486. private _dash;
  66487. private _connectedControl;
  66488. private _connectedControlDirtyObserver;
  66489. /** Gets or sets the dash pattern */
  66490. dash: Array<number>;
  66491. /** Gets or sets the control connected with the line end */
  66492. connectedControl: Control;
  66493. /** Gets or sets start coordinates on X axis */
  66494. x1: string | number;
  66495. /** Gets or sets start coordinates on Y axis */
  66496. y1: string | number;
  66497. /** Gets or sets end coordinates on X axis */
  66498. x2: string | number;
  66499. /** Gets or sets end coordinates on Y axis */
  66500. y2: string | number;
  66501. /** Gets or sets line width */
  66502. lineWidth: number;
  66503. /** Gets or sets horizontal alignment */
  66504. horizontalAlignment: number;
  66505. /** Gets or sets vertical alignment */
  66506. verticalAlignment: number;
  66507. private readonly _effectiveX2;
  66508. private readonly _effectiveY2;
  66509. /**
  66510. * Creates a new Line
  66511. * @param name defines the control name
  66512. */
  66513. constructor(name?: string | undefined);
  66514. protected _getTypeName(): string;
  66515. _draw(context: CanvasRenderingContext2D): void;
  66516. _measure(): void;
  66517. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66518. /**
  66519. * Move one end of the line given 3D cartesian coordinates.
  66520. * @param position Targeted world position
  66521. * @param scene BABYLON.Scene
  66522. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66523. */
  66524. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66525. /**
  66526. * Move one end of the line to a position in screen absolute space.
  66527. * @param projectedPosition Position in screen absolute space (X, Y)
  66528. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66529. */
  66530. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66531. }
  66532. }
  66533. declare module BABYLON.GUI {
  66534. /**
  66535. * Class used to store a point for a MultiLine object.
  66536. * The point can be pure 2D coordinates, a mesh or a control
  66537. */
  66538. export class MultiLinePoint {
  66539. private _multiLine;
  66540. private _x;
  66541. private _y;
  66542. private _control;
  66543. private _mesh;
  66544. private _controlObserver;
  66545. private _meshObserver;
  66546. /** @hidden */
  66547. _point: BABYLON.Vector2;
  66548. /**
  66549. * Creates a new MultiLinePoint
  66550. * @param multiLine defines the source MultiLine object
  66551. */
  66552. constructor(multiLine: MultiLine);
  66553. /** Gets or sets x coordinate */
  66554. x: string | number;
  66555. /** Gets or sets y coordinate */
  66556. y: string | number;
  66557. /** Gets or sets the control associated with this point */
  66558. control: BABYLON.Nullable<Control>;
  66559. /** Gets or sets the mesh associated with this point */
  66560. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66561. /** Resets links */
  66562. resetLinks(): void;
  66563. /**
  66564. * Gets a translation vector
  66565. * @returns the translation vector
  66566. */
  66567. translate(): BABYLON.Vector2;
  66568. private _translatePoint;
  66569. /** Release associated resources */
  66570. dispose(): void;
  66571. }
  66572. }
  66573. declare module BABYLON.GUI {
  66574. /**
  66575. * Class used to create multi line control
  66576. */
  66577. export class MultiLine extends Control {
  66578. name?: string | undefined;
  66579. private _lineWidth;
  66580. private _dash;
  66581. private _points;
  66582. private _minX;
  66583. private _minY;
  66584. private _maxX;
  66585. private _maxY;
  66586. /**
  66587. * Creates a new MultiLine
  66588. * @param name defines the control name
  66589. */
  66590. constructor(name?: string | undefined);
  66591. /** Gets or sets dash pattern */
  66592. dash: Array<number>;
  66593. /**
  66594. * Gets point stored at specified index
  66595. * @param index defines the index to look for
  66596. * @returns the requested point if found
  66597. */
  66598. getAt(index: number): MultiLinePoint;
  66599. /** Function called when a point is updated */
  66600. onPointUpdate: () => void;
  66601. /**
  66602. * Adds new points to the point collection
  66603. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66604. * @returns the list of created MultiLinePoint
  66605. */
  66606. add(...items: (AbstractMesh | Control | {
  66607. x: string | number;
  66608. y: string | number;
  66609. })[]): MultiLinePoint[];
  66610. /**
  66611. * Adds a new point to the point collection
  66612. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66613. * @returns the created MultiLinePoint
  66614. */
  66615. push(item?: (AbstractMesh | Control | {
  66616. x: string | number;
  66617. y: string | number;
  66618. })): MultiLinePoint;
  66619. /**
  66620. * Remove a specific value or point from the active point collection
  66621. * @param value defines the value or point to remove
  66622. */
  66623. remove(value: number | MultiLinePoint): void;
  66624. /**
  66625. * Resets this object to initial state (no point)
  66626. */
  66627. reset(): void;
  66628. /**
  66629. * Resets all links
  66630. */
  66631. resetLinks(): void;
  66632. /** Gets or sets line width */
  66633. lineWidth: number;
  66634. horizontalAlignment: number;
  66635. verticalAlignment: number;
  66636. protected _getTypeName(): string;
  66637. _draw(context: CanvasRenderingContext2D): void;
  66638. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66639. _measure(): void;
  66640. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66641. dispose(): void;
  66642. }
  66643. }
  66644. declare module BABYLON.GUI {
  66645. /**
  66646. * Class used to create radio button controls
  66647. */
  66648. export class RadioButton extends Control {
  66649. name?: string | undefined;
  66650. private _isChecked;
  66651. private _background;
  66652. private _checkSizeRatio;
  66653. private _thickness;
  66654. /** Gets or sets border thickness */
  66655. thickness: number;
  66656. /** Gets or sets group name */
  66657. group: string;
  66658. /** BABYLON.Observable raised when isChecked is changed */
  66659. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66660. /** Gets or sets a value indicating the ratio between overall size and check size */
  66661. checkSizeRatio: number;
  66662. /** Gets or sets background color */
  66663. background: string;
  66664. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66665. isChecked: boolean;
  66666. /**
  66667. * Creates a new RadioButton
  66668. * @param name defines the control name
  66669. */
  66670. constructor(name?: string | undefined);
  66671. protected _getTypeName(): string;
  66672. _draw(context: CanvasRenderingContext2D): void;
  66673. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66674. /**
  66675. * Utility function to easily create a radio button with a header
  66676. * @param title defines the label to use for the header
  66677. * @param group defines the group to use for the radio button
  66678. * @param isChecked defines the initial state of the radio button
  66679. * @param onValueChanged defines the callback to call when value changes
  66680. * @returns a StackPanel containing the radio button and a textBlock
  66681. */
  66682. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66683. }
  66684. }
  66685. declare module BABYLON.GUI {
  66686. /**
  66687. * Class used to create slider controls
  66688. */
  66689. export class BaseSlider extends Control {
  66690. name?: string | undefined;
  66691. protected _thumbWidth: ValueAndUnit;
  66692. private _minimum;
  66693. private _maximum;
  66694. private _value;
  66695. private _isVertical;
  66696. protected _barOffset: ValueAndUnit;
  66697. private _isThumbClamped;
  66698. protected _displayThumb: boolean;
  66699. private _step;
  66700. private _lastPointerDownID;
  66701. protected _effectiveBarOffset: number;
  66702. protected _renderLeft: number;
  66703. protected _renderTop: number;
  66704. protected _renderWidth: number;
  66705. protected _renderHeight: number;
  66706. protected _backgroundBoxLength: number;
  66707. protected _backgroundBoxThickness: number;
  66708. protected _effectiveThumbThickness: number;
  66709. /** BABYLON.Observable raised when the sldier value changes */
  66710. onValueChangedObservable: BABYLON.Observable<number>;
  66711. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66712. displayThumb: boolean;
  66713. /** Gets or sets a step to apply to values (0 by default) */
  66714. step: number;
  66715. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66716. barOffset: string | number;
  66717. /** Gets main bar offset in pixels*/
  66718. readonly barOffsetInPixels: number;
  66719. /** Gets or sets thumb width */
  66720. thumbWidth: string | number;
  66721. /** Gets thumb width in pixels */
  66722. readonly thumbWidthInPixels: number;
  66723. /** Gets or sets minimum value */
  66724. minimum: number;
  66725. /** Gets or sets maximum value */
  66726. maximum: number;
  66727. /** Gets or sets current value */
  66728. value: number;
  66729. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66730. isVertical: boolean;
  66731. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66732. isThumbClamped: boolean;
  66733. /**
  66734. * Creates a new BaseSlider
  66735. * @param name defines the control name
  66736. */
  66737. constructor(name?: string | undefined);
  66738. protected _getTypeName(): string;
  66739. protected _getThumbPosition(): number;
  66740. protected _getThumbThickness(type: string): number;
  66741. protected _prepareRenderingData(type: string): void;
  66742. private _pointerIsDown;
  66743. /** @hidden */
  66744. protected _updateValueFromPointer(x: number, y: number): void;
  66745. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66746. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66747. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66748. }
  66749. }
  66750. declare module BABYLON.GUI {
  66751. /**
  66752. * Class used to create slider controls
  66753. */
  66754. export class Slider extends BaseSlider {
  66755. name?: string | undefined;
  66756. private _background;
  66757. private _borderColor;
  66758. private _isThumbCircle;
  66759. protected _displayValueBar: boolean;
  66760. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66761. displayValueBar: boolean;
  66762. /** Gets or sets border color */
  66763. borderColor: string;
  66764. /** Gets or sets background color */
  66765. background: string;
  66766. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66767. isThumbCircle: boolean;
  66768. /**
  66769. * Creates a new Slider
  66770. * @param name defines the control name
  66771. */
  66772. constructor(name?: string | undefined);
  66773. protected _getTypeName(): string;
  66774. _draw(context: CanvasRenderingContext2D): void;
  66775. }
  66776. }
  66777. declare module BABYLON.GUI {
  66778. /** Class used to create a RadioGroup
  66779. * which contains groups of radio buttons
  66780. */
  66781. export class SelectorGroup {
  66782. /** name of SelectorGroup */
  66783. name: string;
  66784. private _groupPanel;
  66785. private _selectors;
  66786. private _groupHeader;
  66787. /**
  66788. * Creates a new SelectorGroup
  66789. * @param name of group, used as a group heading
  66790. */
  66791. constructor(
  66792. /** name of SelectorGroup */
  66793. name: string);
  66794. /** Gets the groupPanel of the SelectorGroup */
  66795. readonly groupPanel: StackPanel;
  66796. /** Gets the selectors array */
  66797. readonly selectors: StackPanel[];
  66798. /** Gets and sets the group header */
  66799. header: string;
  66800. /** @hidden */
  66801. private _addGroupHeader;
  66802. /** @hidden*/
  66803. _getSelector(selectorNb: number): StackPanel | undefined;
  66804. /** Removes the selector at the given position
  66805. * @param selectorNb the position of the selector within the group
  66806. */
  66807. removeSelector(selectorNb: number): void;
  66808. }
  66809. /** Class used to create a CheckboxGroup
  66810. * which contains groups of checkbox buttons
  66811. */
  66812. export class CheckboxGroup extends SelectorGroup {
  66813. /** Adds a checkbox as a control
  66814. * @param text is the label for the selector
  66815. * @param func is the function called when the Selector is checked
  66816. * @param checked is true when Selector is checked
  66817. */
  66818. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66819. /** @hidden */
  66820. _setSelectorLabel(selectorNb: number, label: string): void;
  66821. /** @hidden */
  66822. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66823. /** @hidden */
  66824. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66825. /** @hidden */
  66826. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66827. }
  66828. /** Class used to create a RadioGroup
  66829. * which contains groups of radio buttons
  66830. */
  66831. export class RadioGroup extends SelectorGroup {
  66832. private _selectNb;
  66833. /** Adds a radio button as a control
  66834. * @param label is the label for the selector
  66835. * @param func is the function called when the Selector is checked
  66836. * @param checked is true when Selector is checked
  66837. */
  66838. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66839. /** @hidden */
  66840. _setSelectorLabel(selectorNb: number, label: string): void;
  66841. /** @hidden */
  66842. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66843. /** @hidden */
  66844. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66845. /** @hidden */
  66846. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66847. }
  66848. /** Class used to create a SliderGroup
  66849. * which contains groups of slider buttons
  66850. */
  66851. export class SliderGroup extends SelectorGroup {
  66852. /**
  66853. * Adds a slider to the SelectorGroup
  66854. * @param label is the label for the SliderBar
  66855. * @param func is the function called when the Slider moves
  66856. * @param unit is a string describing the units used, eg degrees or metres
  66857. * @param min is the minimum value for the Slider
  66858. * @param max is the maximum value for the Slider
  66859. * @param value is the start value for the Slider between min and max
  66860. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66861. */
  66862. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66863. /** @hidden */
  66864. _setSelectorLabel(selectorNb: number, label: string): void;
  66865. /** @hidden */
  66866. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66867. /** @hidden */
  66868. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66869. /** @hidden */
  66870. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66871. }
  66872. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66873. * @see http://doc.babylonjs.com/how_to/selector
  66874. */
  66875. export class SelectionPanel extends Rectangle {
  66876. /** name of SelectionPanel */
  66877. name: string;
  66878. /** an array of SelectionGroups */
  66879. groups: SelectorGroup[];
  66880. private _panel;
  66881. private _buttonColor;
  66882. private _buttonBackground;
  66883. private _headerColor;
  66884. private _barColor;
  66885. private _barHeight;
  66886. private _spacerHeight;
  66887. private _labelColor;
  66888. private _groups;
  66889. private _bars;
  66890. /**
  66891. * Creates a new SelectionPanel
  66892. * @param name of SelectionPanel
  66893. * @param groups is an array of SelectionGroups
  66894. */
  66895. constructor(
  66896. /** name of SelectionPanel */
  66897. name: string,
  66898. /** an array of SelectionGroups */
  66899. groups?: SelectorGroup[]);
  66900. protected _getTypeName(): string;
  66901. /** Gets or sets the headerColor */
  66902. headerColor: string;
  66903. private _setHeaderColor;
  66904. /** Gets or sets the button color */
  66905. buttonColor: string;
  66906. private _setbuttonColor;
  66907. /** Gets or sets the label color */
  66908. labelColor: string;
  66909. private _setLabelColor;
  66910. /** Gets or sets the button background */
  66911. buttonBackground: string;
  66912. private _setButtonBackground;
  66913. /** Gets or sets the color of separator bar */
  66914. barColor: string;
  66915. private _setBarColor;
  66916. /** Gets or sets the height of separator bar */
  66917. barHeight: string;
  66918. private _setBarHeight;
  66919. /** Gets or sets the height of spacers*/
  66920. spacerHeight: string;
  66921. private _setSpacerHeight;
  66922. /** Adds a bar between groups */
  66923. private _addSpacer;
  66924. /** Add a group to the selection panel
  66925. * @param group is the selector group to add
  66926. */
  66927. addGroup(group: SelectorGroup): void;
  66928. /** Remove the group from the given position
  66929. * @param groupNb is the position of the group in the list
  66930. */
  66931. removeGroup(groupNb: number): void;
  66932. /** Change a group header label
  66933. * @param label is the new group header label
  66934. * @param groupNb is the number of the group to relabel
  66935. * */
  66936. setHeaderName(label: string, groupNb: number): void;
  66937. /** Change selector label to the one given
  66938. * @param label is the new selector label
  66939. * @param groupNb is the number of the groupcontaining the selector
  66940. * @param selectorNb is the number of the selector within a group to relabel
  66941. * */
  66942. relabel(label: string, groupNb: number, selectorNb: number): void;
  66943. /** For a given group position remove the selector at the given position
  66944. * @param groupNb is the number of the group to remove the selector from
  66945. * @param selectorNb is the number of the selector within the group
  66946. */
  66947. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66948. /** For a given group position of correct type add a checkbox button
  66949. * @param groupNb is the number of the group to remove the selector from
  66950. * @param label is the label for the selector
  66951. * @param func is the function called when the Selector is checked
  66952. * @param checked is true when Selector is checked
  66953. */
  66954. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66955. /** For a given group position of correct type add a radio button
  66956. * @param groupNb is the number of the group to remove the selector from
  66957. * @param label is the label for the selector
  66958. * @param func is the function called when the Selector is checked
  66959. * @param checked is true when Selector is checked
  66960. */
  66961. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66962. /**
  66963. * For a given slider group add a slider
  66964. * @param groupNb is the number of the group to add the slider to
  66965. * @param label is the label for the Slider
  66966. * @param func is the function called when the Slider moves
  66967. * @param unit is a string describing the units used, eg degrees or metres
  66968. * @param min is the minimum value for the Slider
  66969. * @param max is the maximum value for the Slider
  66970. * @param value is the start value for the Slider between min and max
  66971. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66972. */
  66973. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66974. }
  66975. }
  66976. declare module BABYLON.GUI {
  66977. /**
  66978. * Class used to hold a the container for ScrollViewer
  66979. * @hidden
  66980. */
  66981. export class _ScrollViewerWindow extends Container {
  66982. parentClientWidth: number;
  66983. parentClientHeight: number;
  66984. /**
  66985. * Creates a new ScrollViewerWindow
  66986. * @param name of ScrollViewerWindow
  66987. */
  66988. constructor(name?: string);
  66989. protected _getTypeName(): string;
  66990. /** @hidden */
  66991. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66992. protected _postMeasure(): void;
  66993. }
  66994. }
  66995. declare module BABYLON.GUI {
  66996. /**
  66997. * Class used to create slider controls
  66998. */
  66999. export class ScrollBar extends BaseSlider {
  67000. name?: string | undefined;
  67001. private _background;
  67002. private _borderColor;
  67003. private _thumbMeasure;
  67004. /** Gets or sets border color */
  67005. borderColor: string;
  67006. /** Gets or sets background color */
  67007. background: string;
  67008. /**
  67009. * Creates a new Slider
  67010. * @param name defines the control name
  67011. */
  67012. constructor(name?: string | undefined);
  67013. protected _getTypeName(): string;
  67014. protected _getThumbThickness(): number;
  67015. _draw(context: CanvasRenderingContext2D): void;
  67016. private _first;
  67017. private _originX;
  67018. private _originY;
  67019. /** @hidden */
  67020. protected _updateValueFromPointer(x: number, y: number): void;
  67021. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67022. }
  67023. }
  67024. declare module BABYLON.GUI {
  67025. /**
  67026. * Class used to hold a viewer window and sliders in a grid
  67027. */
  67028. export class ScrollViewer extends Rectangle {
  67029. private _grid;
  67030. private _horizontalBarSpace;
  67031. private _verticalBarSpace;
  67032. private _dragSpace;
  67033. private _horizontalBar;
  67034. private _verticalBar;
  67035. private _barColor;
  67036. private _barBackground;
  67037. private _barSize;
  67038. private _endLeft;
  67039. private _endTop;
  67040. private _window;
  67041. private _pointerIsOver;
  67042. private _wheelPrecision;
  67043. private _onPointerObserver;
  67044. private _clientWidth;
  67045. private _clientHeight;
  67046. /**
  67047. * Gets the horizontal scrollbar
  67048. */
  67049. readonly horizontalBar: ScrollBar;
  67050. /**
  67051. * Gets the vertical scrollbar
  67052. */
  67053. readonly verticalBar: ScrollBar;
  67054. /**
  67055. * Adds a new control to the current container
  67056. * @param control defines the control to add
  67057. * @returns the current container
  67058. */
  67059. addControl(control: BABYLON.Nullable<Control>): Container;
  67060. /**
  67061. * Removes a control from the current container
  67062. * @param control defines the control to remove
  67063. * @returns the current container
  67064. */
  67065. removeControl(control: Control): Container;
  67066. /** Gets the list of children */
  67067. readonly children: Control[];
  67068. _flagDescendantsAsMatrixDirty(): void;
  67069. /**
  67070. * Creates a new ScrollViewer
  67071. * @param name of ScrollViewer
  67072. */
  67073. constructor(name?: string);
  67074. /** Reset the scroll viewer window to initial size */
  67075. resetWindow(): void;
  67076. protected _getTypeName(): string;
  67077. private _buildClientSizes;
  67078. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67079. protected _postMeasure(): void;
  67080. /**
  67081. * Gets or sets the mouse wheel precision
  67082. * from 0 to 1 with a default value of 0.05
  67083. * */
  67084. wheelPrecision: number;
  67085. /** Gets or sets the bar color */
  67086. barColor: string;
  67087. /** Gets or sets the size of the bar */
  67088. barSize: number;
  67089. /** Gets or sets the bar background */
  67090. barBackground: string;
  67091. /** @hidden */
  67092. private _updateScroller;
  67093. _link(host: AdvancedDynamicTexture): void;
  67094. /** @hidden */
  67095. private _attachWheel;
  67096. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67097. /** Releases associated resources */
  67098. dispose(): void;
  67099. }
  67100. }
  67101. declare module BABYLON.GUI {
  67102. /** Class used to render a grid */
  67103. export class DisplayGrid extends Control {
  67104. name?: string | undefined;
  67105. private _cellWidth;
  67106. private _cellHeight;
  67107. private _minorLineTickness;
  67108. private _minorLineColor;
  67109. private _majorLineTickness;
  67110. private _majorLineColor;
  67111. private _majorLineFrequency;
  67112. private _background;
  67113. private _displayMajorLines;
  67114. private _displayMinorLines;
  67115. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67116. displayMinorLines: boolean;
  67117. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67118. displayMajorLines: boolean;
  67119. /** Gets or sets background color (Black by default) */
  67120. background: string;
  67121. /** Gets or sets the width of each cell (20 by default) */
  67122. cellWidth: number;
  67123. /** Gets or sets the height of each cell (20 by default) */
  67124. cellHeight: number;
  67125. /** Gets or sets the tickness of minor lines (1 by default) */
  67126. minorLineTickness: number;
  67127. /** Gets or sets the color of minor lines (DarkGray by default) */
  67128. minorLineColor: string;
  67129. /** Gets or sets the tickness of major lines (2 by default) */
  67130. majorLineTickness: number;
  67131. /** Gets or sets the color of major lines (White by default) */
  67132. majorLineColor: string;
  67133. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67134. majorLineFrequency: number;
  67135. /**
  67136. * Creates a new GridDisplayRectangle
  67137. * @param name defines the control name
  67138. */
  67139. constructor(name?: string | undefined);
  67140. _draw(context: CanvasRenderingContext2D): void;
  67141. protected _getTypeName(): string;
  67142. }
  67143. }
  67144. declare module BABYLON.GUI {
  67145. /**
  67146. * Class used to create slider controls based on images
  67147. */
  67148. export class ImageBasedSlider extends BaseSlider {
  67149. name?: string | undefined;
  67150. private _backgroundImage;
  67151. private _thumbImage;
  67152. private _valueBarImage;
  67153. private _tempMeasure;
  67154. displayThumb: boolean;
  67155. /**
  67156. * Gets or sets the image used to render the background
  67157. */
  67158. backgroundImage: Image;
  67159. /**
  67160. * Gets or sets the image used to render the value bar
  67161. */
  67162. valueBarImage: Image;
  67163. /**
  67164. * Gets or sets the image used to render the thumb
  67165. */
  67166. thumbImage: Image;
  67167. /**
  67168. * Creates a new ImageBasedSlider
  67169. * @param name defines the control name
  67170. */
  67171. constructor(name?: string | undefined);
  67172. protected _getTypeName(): string;
  67173. _draw(context: CanvasRenderingContext2D): void;
  67174. }
  67175. }
  67176. declare module BABYLON.GUI {
  67177. /**
  67178. * Forcing an export so that this code will execute
  67179. * @hidden
  67180. */
  67181. const name = "Statics";
  67182. }
  67183. declare module BABYLON.GUI {
  67184. /**
  67185. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67186. */
  67187. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67188. /**
  67189. * Define the instrumented AdvancedDynamicTexture.
  67190. */
  67191. texture: AdvancedDynamicTexture;
  67192. private _captureRenderTime;
  67193. private _renderTime;
  67194. private _captureLayoutTime;
  67195. private _layoutTime;
  67196. private _onBeginRenderObserver;
  67197. private _onEndRenderObserver;
  67198. private _onBeginLayoutObserver;
  67199. private _onEndLayoutObserver;
  67200. /**
  67201. * Gets the perf counter used to capture render time
  67202. */
  67203. readonly renderTimeCounter: BABYLON.PerfCounter;
  67204. /**
  67205. * Gets the perf counter used to capture layout time
  67206. */
  67207. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67208. /**
  67209. * Enable or disable the render time capture
  67210. */
  67211. captureRenderTime: boolean;
  67212. /**
  67213. * Enable or disable the layout time capture
  67214. */
  67215. captureLayoutTime: boolean;
  67216. /**
  67217. * Instantiates a new advanced dynamic texture instrumentation.
  67218. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67219. * @param texture Defines the AdvancedDynamicTexture to instrument
  67220. */
  67221. constructor(
  67222. /**
  67223. * Define the instrumented AdvancedDynamicTexture.
  67224. */
  67225. texture: AdvancedDynamicTexture);
  67226. /**
  67227. * Dispose and release associated resources.
  67228. */
  67229. dispose(): void;
  67230. }
  67231. }
  67232. declare module BABYLON.GUI {
  67233. /**
  67234. * Class used to load GUI via XML.
  67235. */
  67236. export class XmlLoader {
  67237. private _nodes;
  67238. private _nodeTypes;
  67239. private _isLoaded;
  67240. private _objectAttributes;
  67241. private _parentClass;
  67242. /**
  67243. * Create a new xml loader
  67244. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67245. */
  67246. constructor(parentClass?: null);
  67247. private _getChainElement;
  67248. private _getClassAttribute;
  67249. private _createGuiElement;
  67250. private _parseGrid;
  67251. private _parseElement;
  67252. private _prepareSourceElement;
  67253. private _parseElementsFromSource;
  67254. private _parseXml;
  67255. /**
  67256. * Gets if the loading has finished.
  67257. * @returns whether the loading has finished or not
  67258. */
  67259. isLoaded(): boolean;
  67260. /**
  67261. * Gets a loaded node / control by id.
  67262. * @param id the Controls id set in the xml
  67263. * @returns element of type Control
  67264. */
  67265. getNodeById(id: string): any;
  67266. /**
  67267. * Gets all loaded nodes / controls
  67268. * @returns Array of controls
  67269. */
  67270. getNodes(): any;
  67271. /**
  67272. * Initiates the xml layout loading
  67273. * @param xmlFile defines the xml layout to load
  67274. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67275. * @param callback defines the callback called on layout load.
  67276. */
  67277. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67278. }
  67279. }
  67280. declare module BABYLON.GUI {
  67281. /**
  67282. * Class used to create containers for controls
  67283. */
  67284. export class Container3D extends Control3D {
  67285. private _blockLayout;
  67286. /**
  67287. * Gets the list of child controls
  67288. */
  67289. protected _children: Control3D[];
  67290. /**
  67291. * Gets the list of child controls
  67292. */
  67293. readonly children: Array<Control3D>;
  67294. /**
  67295. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67296. * This is helpful to optimize layout operation when adding multiple children in a row
  67297. */
  67298. blockLayout: boolean;
  67299. /**
  67300. * Creates a new container
  67301. * @param name defines the container name
  67302. */
  67303. constructor(name?: string);
  67304. /**
  67305. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67306. * @returns the current container
  67307. */
  67308. updateLayout(): Container3D;
  67309. /**
  67310. * Gets a boolean indicating if the given control is in the children of this control
  67311. * @param control defines the control to check
  67312. * @returns true if the control is in the child list
  67313. */
  67314. containsControl(control: Control3D): boolean;
  67315. /**
  67316. * Adds a control to the children of this control
  67317. * @param control defines the control to add
  67318. * @returns the current container
  67319. */
  67320. addControl(control: Control3D): Container3D;
  67321. /**
  67322. * This function will be called everytime a new control is added
  67323. */
  67324. protected _arrangeChildren(): void;
  67325. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67326. /**
  67327. * Removes a control from the children of this control
  67328. * @param control defines the control to remove
  67329. * @returns the current container
  67330. */
  67331. removeControl(control: Control3D): Container3D;
  67332. protected _getTypeName(): string;
  67333. /**
  67334. * Releases all associated resources
  67335. */
  67336. dispose(): void;
  67337. /** Control rotation will remain unchanged */
  67338. static readonly UNSET_ORIENTATION: number;
  67339. /** Control will rotate to make it look at sphere central axis */
  67340. static readonly FACEORIGIN_ORIENTATION: number;
  67341. /** Control will rotate to make it look back at sphere central axis */
  67342. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67343. /** Control will rotate to look at z axis (0, 0, 1) */
  67344. static readonly FACEFORWARD_ORIENTATION: number;
  67345. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67346. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67347. }
  67348. }
  67349. declare module BABYLON.GUI {
  67350. /**
  67351. * Class used to manage 3D user interface
  67352. * @see http://doc.babylonjs.com/how_to/gui3d
  67353. */
  67354. export class GUI3DManager implements BABYLON.IDisposable {
  67355. private _scene;
  67356. private _sceneDisposeObserver;
  67357. private _utilityLayer;
  67358. private _rootContainer;
  67359. private _pointerObserver;
  67360. private _pointerOutObserver;
  67361. /** @hidden */
  67362. _lastPickedControl: Control3D;
  67363. /** @hidden */
  67364. _lastControlOver: {
  67365. [pointerId: number]: Control3D;
  67366. };
  67367. /** @hidden */
  67368. _lastControlDown: {
  67369. [pointerId: number]: Control3D;
  67370. };
  67371. /**
  67372. * BABYLON.Observable raised when the point picked by the pointer events changed
  67373. */
  67374. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67375. /** @hidden */
  67376. _sharedMaterials: {
  67377. [key: string]: BABYLON.Material;
  67378. };
  67379. /** Gets the hosting scene */
  67380. readonly scene: BABYLON.Scene;
  67381. /** Gets associated utility layer */
  67382. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67383. /**
  67384. * Creates a new GUI3DManager
  67385. * @param scene
  67386. */
  67387. constructor(scene?: BABYLON.Scene);
  67388. private _handlePointerOut;
  67389. private _doPicking;
  67390. /**
  67391. * Gets the root container
  67392. */
  67393. readonly rootContainer: Container3D;
  67394. /**
  67395. * Gets a boolean indicating if the given control is in the root child list
  67396. * @param control defines the control to check
  67397. * @returns true if the control is in the root child list
  67398. */
  67399. containsControl(control: Control3D): boolean;
  67400. /**
  67401. * Adds a control to the root child list
  67402. * @param control defines the control to add
  67403. * @returns the current manager
  67404. */
  67405. addControl(control: Control3D): GUI3DManager;
  67406. /**
  67407. * Removes a control from the root child list
  67408. * @param control defines the control to remove
  67409. * @returns the current container
  67410. */
  67411. removeControl(control: Control3D): GUI3DManager;
  67412. /**
  67413. * Releases all associated resources
  67414. */
  67415. dispose(): void;
  67416. }
  67417. }
  67418. declare module BABYLON.GUI {
  67419. /**
  67420. * Class used to transport BABYLON.Vector3 information for pointer events
  67421. */
  67422. export class Vector3WithInfo extends BABYLON.Vector3 {
  67423. /** defines the current mouse button index */
  67424. buttonIndex: number;
  67425. /**
  67426. * Creates a new Vector3WithInfo
  67427. * @param source defines the vector3 data to transport
  67428. * @param buttonIndex defines the current mouse button index
  67429. */
  67430. constructor(source: BABYLON.Vector3,
  67431. /** defines the current mouse button index */
  67432. buttonIndex?: number);
  67433. }
  67434. }
  67435. declare module BABYLON.GUI {
  67436. /**
  67437. * Class used as base class for controls
  67438. */
  67439. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67440. /** Defines the control name */
  67441. name?: string | undefined;
  67442. /** @hidden */
  67443. _host: GUI3DManager;
  67444. private _node;
  67445. private _downCount;
  67446. private _enterCount;
  67447. private _downPointerIds;
  67448. private _isVisible;
  67449. /** Gets or sets the control position in world space */
  67450. position: BABYLON.Vector3;
  67451. /** Gets or sets the control scaling in world space */
  67452. scaling: BABYLON.Vector3;
  67453. /** Callback used to start pointer enter animation */
  67454. pointerEnterAnimation: () => void;
  67455. /** Callback used to start pointer out animation */
  67456. pointerOutAnimation: () => void;
  67457. /** Callback used to start pointer down animation */
  67458. pointerDownAnimation: () => void;
  67459. /** Callback used to start pointer up animation */
  67460. pointerUpAnimation: () => void;
  67461. /**
  67462. * An event triggered when the pointer move over the control
  67463. */
  67464. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67465. /**
  67466. * An event triggered when the pointer move out of the control
  67467. */
  67468. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67469. /**
  67470. * An event triggered when the pointer taps the control
  67471. */
  67472. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67473. /**
  67474. * An event triggered when pointer is up
  67475. */
  67476. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67477. /**
  67478. * An event triggered when a control is clicked on (with a mouse)
  67479. */
  67480. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67481. /**
  67482. * An event triggered when pointer enters the control
  67483. */
  67484. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67485. /**
  67486. * Gets or sets the parent container
  67487. */
  67488. parent: BABYLON.Nullable<Container3D>;
  67489. private _behaviors;
  67490. /**
  67491. * Gets the list of attached behaviors
  67492. * @see http://doc.babylonjs.com/features/behaviour
  67493. */
  67494. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67495. /**
  67496. * Attach a behavior to the control
  67497. * @see http://doc.babylonjs.com/features/behaviour
  67498. * @param behavior defines the behavior to attach
  67499. * @returns the current control
  67500. */
  67501. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67502. /**
  67503. * Remove an attached behavior
  67504. * @see http://doc.babylonjs.com/features/behaviour
  67505. * @param behavior defines the behavior to attach
  67506. * @returns the current control
  67507. */
  67508. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67509. /**
  67510. * Gets an attached behavior by name
  67511. * @param name defines the name of the behavior to look for
  67512. * @see http://doc.babylonjs.com/features/behaviour
  67513. * @returns null if behavior was not found else the requested behavior
  67514. */
  67515. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67516. /** Gets or sets a boolean indicating if the control is visible */
  67517. isVisible: boolean;
  67518. /**
  67519. * Creates a new control
  67520. * @param name defines the control name
  67521. */
  67522. constructor(
  67523. /** Defines the control name */
  67524. name?: string | undefined);
  67525. /**
  67526. * Gets a string representing the class name
  67527. */
  67528. readonly typeName: string;
  67529. /**
  67530. * Get the current class name of the control.
  67531. * @returns current class name
  67532. */
  67533. getClassName(): string;
  67534. protected _getTypeName(): string;
  67535. /**
  67536. * Gets the transform node used by this control
  67537. */
  67538. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67539. /**
  67540. * Gets the mesh used to render this control
  67541. */
  67542. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67543. /**
  67544. * Link the control as child of the given node
  67545. * @param node defines the node to link to. Use null to unlink the control
  67546. * @returns the current control
  67547. */
  67548. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67549. /** @hidden **/
  67550. _prepareNode(scene: BABYLON.Scene): void;
  67551. /**
  67552. * Node creation.
  67553. * Can be overriden by children
  67554. * @param scene defines the scene where the node must be attached
  67555. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67556. */
  67557. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67558. /**
  67559. * Affect a material to the given mesh
  67560. * @param mesh defines the mesh which will represent the control
  67561. */
  67562. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67563. /** @hidden */
  67564. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67565. /** @hidden */
  67566. _onPointerEnter(target: Control3D): boolean;
  67567. /** @hidden */
  67568. _onPointerOut(target: Control3D): void;
  67569. /** @hidden */
  67570. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67571. /** @hidden */
  67572. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67573. /** @hidden */
  67574. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67575. /** @hidden */
  67576. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67577. /** @hidden */
  67578. _disposeNode(): void;
  67579. /**
  67580. * Releases all associated resources
  67581. */
  67582. dispose(): void;
  67583. }
  67584. }
  67585. declare module BABYLON.GUI {
  67586. /**
  67587. * Class used as a root to all buttons
  67588. */
  67589. export class AbstractButton3D extends Control3D {
  67590. /**
  67591. * Creates a new button
  67592. * @param name defines the control name
  67593. */
  67594. constructor(name?: string);
  67595. protected _getTypeName(): string;
  67596. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67597. }
  67598. }
  67599. declare module BABYLON.GUI {
  67600. /**
  67601. * Class used to create a button in 3D
  67602. */
  67603. export class Button3D extends AbstractButton3D {
  67604. /** @hidden */
  67605. protected _currentMaterial: BABYLON.Material;
  67606. private _facadeTexture;
  67607. private _content;
  67608. private _contentResolution;
  67609. private _contentScaleRatio;
  67610. /**
  67611. * Gets or sets the texture resolution used to render content (512 by default)
  67612. */
  67613. contentResolution: BABYLON.int;
  67614. /**
  67615. * Gets or sets the texture scale ratio used to render content (2 by default)
  67616. */
  67617. contentScaleRatio: number;
  67618. protected _disposeFacadeTexture(): void;
  67619. protected _resetContent(): void;
  67620. /**
  67621. * Creates a new button
  67622. * @param name defines the control name
  67623. */
  67624. constructor(name?: string);
  67625. /**
  67626. * Gets or sets the GUI 2D content used to display the button's facade
  67627. */
  67628. content: Control;
  67629. /**
  67630. * Apply the facade texture (created from the content property).
  67631. * This function can be overloaded by child classes
  67632. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67633. */
  67634. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67635. protected _getTypeName(): string;
  67636. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67637. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67638. /**
  67639. * Releases all associated resources
  67640. */
  67641. dispose(): void;
  67642. }
  67643. }
  67644. declare module BABYLON.GUI {
  67645. /**
  67646. * Abstract class used to create a container panel deployed on the surface of a volume
  67647. */
  67648. export abstract class VolumeBasedPanel extends Container3D {
  67649. private _columns;
  67650. private _rows;
  67651. private _rowThenColum;
  67652. private _orientation;
  67653. protected _cellWidth: number;
  67654. protected _cellHeight: number;
  67655. /**
  67656. * Gets or sets the distance between elements
  67657. */
  67658. margin: number;
  67659. /**
  67660. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67661. * | Value | Type | Description |
  67662. * | ----- | ----------------------------------- | ----------- |
  67663. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67664. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67665. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67666. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67667. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67668. */
  67669. orientation: number;
  67670. /**
  67671. * Gets or sets the number of columns requested (10 by default).
  67672. * The panel will automatically compute the number of rows based on number of child controls.
  67673. */
  67674. columns: BABYLON.int;
  67675. /**
  67676. * Gets or sets a the number of rows requested.
  67677. * The panel will automatically compute the number of columns based on number of child controls.
  67678. */
  67679. rows: BABYLON.int;
  67680. /**
  67681. * Creates new VolumeBasedPanel
  67682. */
  67683. constructor();
  67684. protected _arrangeChildren(): void;
  67685. /** Child classes must implement this function to provide correct control positioning */
  67686. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67687. /** Child classes can implement this function to provide additional processing */
  67688. protected _finalProcessing(): void;
  67689. }
  67690. }
  67691. declare module BABYLON.GUI {
  67692. /**
  67693. * Class used to create a container panel deployed on the surface of a cylinder
  67694. */
  67695. export class CylinderPanel extends VolumeBasedPanel {
  67696. private _radius;
  67697. /**
  67698. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67699. */
  67700. radius: BABYLON.float;
  67701. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67702. private _cylindricalMapping;
  67703. }
  67704. }
  67705. declare module BABYLON.GUI {
  67706. /** @hidden */
  67707. export var fluentVertexShader: {
  67708. name: string;
  67709. shader: string;
  67710. };
  67711. }
  67712. declare module BABYLON.GUI {
  67713. /** @hidden */
  67714. export var fluentPixelShader: {
  67715. name: string;
  67716. shader: string;
  67717. };
  67718. }
  67719. declare module BABYLON.GUI {
  67720. /** @hidden */
  67721. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67722. INNERGLOW: boolean;
  67723. BORDER: boolean;
  67724. HOVERLIGHT: boolean;
  67725. TEXTURE: boolean;
  67726. constructor();
  67727. }
  67728. /**
  67729. * Class used to render controls with fluent desgin
  67730. */
  67731. export class FluentMaterial extends BABYLON.PushMaterial {
  67732. /**
  67733. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67734. */
  67735. innerGlowColorIntensity: number;
  67736. /**
  67737. * Gets or sets the inner glow color (white by default)
  67738. */
  67739. innerGlowColor: BABYLON.Color3;
  67740. /**
  67741. * Gets or sets alpha value (default is 1.0)
  67742. */
  67743. alpha: number;
  67744. /**
  67745. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67746. */
  67747. albedoColor: BABYLON.Color3;
  67748. /**
  67749. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67750. */
  67751. renderBorders: boolean;
  67752. /**
  67753. * Gets or sets border width (default is 0.5)
  67754. */
  67755. borderWidth: number;
  67756. /**
  67757. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67758. */
  67759. edgeSmoothingValue: number;
  67760. /**
  67761. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67762. */
  67763. borderMinValue: number;
  67764. /**
  67765. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67766. */
  67767. renderHoverLight: boolean;
  67768. /**
  67769. * Gets or sets the radius used to render the hover light (default is 1.0)
  67770. */
  67771. hoverRadius: number;
  67772. /**
  67773. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67774. */
  67775. hoverColor: BABYLON.Color4;
  67776. /**
  67777. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67778. */
  67779. hoverPosition: BABYLON.Vector3;
  67780. private _albedoTexture;
  67781. /** Gets or sets the texture to use for albedo color */
  67782. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67783. /**
  67784. * Creates a new Fluent material
  67785. * @param name defines the name of the material
  67786. * @param scene defines the hosting scene
  67787. */
  67788. constructor(name: string, scene: BABYLON.Scene);
  67789. needAlphaBlending(): boolean;
  67790. needAlphaTesting(): boolean;
  67791. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67792. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67793. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67794. getActiveTextures(): BABYLON.BaseTexture[];
  67795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67796. dispose(forceDisposeEffect?: boolean): void;
  67797. clone(name: string): FluentMaterial;
  67798. serialize(): any;
  67799. getClassName(): string;
  67800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67801. }
  67802. }
  67803. declare module BABYLON.GUI {
  67804. /**
  67805. * Class used to create a holographic button in 3D
  67806. */
  67807. export class HolographicButton extends Button3D {
  67808. private _backPlate;
  67809. private _textPlate;
  67810. private _frontPlate;
  67811. private _text;
  67812. private _imageUrl;
  67813. private _shareMaterials;
  67814. private _frontMaterial;
  67815. private _backMaterial;
  67816. private _plateMaterial;
  67817. private _pickedPointObserver;
  67818. private _tooltipFade;
  67819. private _tooltipTextBlock;
  67820. private _tooltipTexture;
  67821. private _tooltipMesh;
  67822. private _tooltipHoverObserver;
  67823. private _tooltipOutObserver;
  67824. private _disposeTooltip;
  67825. /**
  67826. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67827. */
  67828. tooltipText: BABYLON.Nullable<string>;
  67829. /**
  67830. * Gets or sets text for the button
  67831. */
  67832. text: string;
  67833. /**
  67834. * Gets or sets the image url for the button
  67835. */
  67836. imageUrl: string;
  67837. /**
  67838. * Gets the back material used by this button
  67839. */
  67840. readonly backMaterial: FluentMaterial;
  67841. /**
  67842. * Gets the front material used by this button
  67843. */
  67844. readonly frontMaterial: FluentMaterial;
  67845. /**
  67846. * Gets the plate material used by this button
  67847. */
  67848. readonly plateMaterial: BABYLON.StandardMaterial;
  67849. /**
  67850. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67851. */
  67852. readonly shareMaterials: boolean;
  67853. /**
  67854. * Creates a new button
  67855. * @param name defines the control name
  67856. */
  67857. constructor(name?: string, shareMaterials?: boolean);
  67858. protected _getTypeName(): string;
  67859. private _rebuildContent;
  67860. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67861. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67862. private _createBackMaterial;
  67863. private _createFrontMaterial;
  67864. private _createPlateMaterial;
  67865. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67866. /**
  67867. * Releases all associated resources
  67868. */
  67869. dispose(): void;
  67870. }
  67871. }
  67872. declare module BABYLON.GUI {
  67873. /**
  67874. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67875. */
  67876. export class MeshButton3D extends Button3D {
  67877. /** @hidden */
  67878. protected _currentMesh: BABYLON.Mesh;
  67879. /**
  67880. * Creates a new 3D button based on a mesh
  67881. * @param mesh mesh to become a 3D button
  67882. * @param name defines the control name
  67883. */
  67884. constructor(mesh: BABYLON.Mesh, name?: string);
  67885. protected _getTypeName(): string;
  67886. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67887. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67888. }
  67889. }
  67890. declare module BABYLON.GUI {
  67891. /**
  67892. * Class used to create a container panel deployed on the surface of a plane
  67893. */
  67894. export class PlanePanel extends VolumeBasedPanel {
  67895. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67896. }
  67897. }
  67898. declare module BABYLON.GUI {
  67899. /**
  67900. * Class used to create a container panel where items get randomized planar mapping
  67901. */
  67902. export class ScatterPanel extends VolumeBasedPanel {
  67903. private _iteration;
  67904. /**
  67905. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67906. */
  67907. iteration: BABYLON.float;
  67908. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67909. private _scatterMapping;
  67910. protected _finalProcessing(): void;
  67911. }
  67912. }
  67913. declare module BABYLON.GUI {
  67914. /**
  67915. * Class used to create a container panel deployed on the surface of a sphere
  67916. */
  67917. export class SpherePanel extends VolumeBasedPanel {
  67918. private _radius;
  67919. /**
  67920. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67921. */
  67922. radius: BABYLON.float;
  67923. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67924. private _sphericalMapping;
  67925. }
  67926. }
  67927. declare module BABYLON.GUI {
  67928. /**
  67929. * Class used to create a stack panel in 3D on XY plane
  67930. */
  67931. export class StackPanel3D extends Container3D {
  67932. private _isVertical;
  67933. /**
  67934. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67935. */
  67936. isVertical: boolean;
  67937. /**
  67938. * Gets or sets the distance between elements
  67939. */
  67940. margin: number;
  67941. /**
  67942. * Creates new StackPanel
  67943. * @param isVertical
  67944. */
  67945. constructor(isVertical?: boolean);
  67946. protected _arrangeChildren(): void;
  67947. }
  67948. }
  67949. declare module BABYLON {
  67950. /**
  67951. * Mode that determines the coordinate system to use.
  67952. */
  67953. export enum GLTFLoaderCoordinateSystemMode {
  67954. /**
  67955. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67956. */
  67957. AUTO = 0,
  67958. /**
  67959. * Sets the useRightHandedSystem flag on the scene.
  67960. */
  67961. FORCE_RIGHT_HANDED = 1
  67962. }
  67963. /**
  67964. * Mode that determines what animations will start.
  67965. */
  67966. export enum GLTFLoaderAnimationStartMode {
  67967. /**
  67968. * No animation will start.
  67969. */
  67970. NONE = 0,
  67971. /**
  67972. * The first animation will start.
  67973. */
  67974. FIRST = 1,
  67975. /**
  67976. * All animations will start.
  67977. */
  67978. ALL = 2
  67979. }
  67980. /**
  67981. * Interface that contains the data for the glTF asset.
  67982. */
  67983. export interface IGLTFLoaderData {
  67984. /**
  67985. * Object that represents the glTF JSON.
  67986. */
  67987. json: Object;
  67988. /**
  67989. * The BIN chunk of a binary glTF.
  67990. */
  67991. bin: Nullable<ArrayBufferView>;
  67992. }
  67993. /**
  67994. * Interface for extending the loader.
  67995. */
  67996. export interface IGLTFLoaderExtension {
  67997. /**
  67998. * The name of this extension.
  67999. */
  68000. readonly name: string;
  68001. /**
  68002. * Defines whether this extension is enabled.
  68003. */
  68004. enabled: boolean;
  68005. }
  68006. /**
  68007. * Loader state.
  68008. */
  68009. export enum GLTFLoaderState {
  68010. /**
  68011. * The asset is loading.
  68012. */
  68013. LOADING = 0,
  68014. /**
  68015. * The asset is ready for rendering.
  68016. */
  68017. READY = 1,
  68018. /**
  68019. * The asset is completely loaded.
  68020. */
  68021. COMPLETE = 2
  68022. }
  68023. /** @hidden */
  68024. export interface IGLTFLoader extends IDisposable {
  68025. readonly state: Nullable<GLTFLoaderState>;
  68026. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68027. meshes: AbstractMesh[];
  68028. particleSystems: IParticleSystem[];
  68029. skeletons: Skeleton[];
  68030. animationGroups: AnimationGroup[];
  68031. }>;
  68032. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68033. }
  68034. /**
  68035. * File loader for loading glTF files into a scene.
  68036. */
  68037. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68038. /** @hidden */
  68039. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68040. /** @hidden */
  68041. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68042. /**
  68043. * Raised when the asset has been parsed
  68044. */
  68045. onParsedObservable: Observable<IGLTFLoaderData>;
  68046. private _onParsedObserver;
  68047. /**
  68048. * Raised when the asset has been parsed
  68049. */
  68050. onParsed: (loaderData: IGLTFLoaderData) => void;
  68051. /**
  68052. * 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.
  68053. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68054. * Defaults to true.
  68055. * @hidden
  68056. */
  68057. static IncrementalLoading: boolean;
  68058. /**
  68059. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68060. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68061. * @hidden
  68062. */
  68063. static HomogeneousCoordinates: boolean;
  68064. /**
  68065. * The coordinate system mode. Defaults to AUTO.
  68066. */
  68067. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68068. /**
  68069. * The animation start mode. Defaults to FIRST.
  68070. */
  68071. animationStartMode: GLTFLoaderAnimationStartMode;
  68072. /**
  68073. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68074. */
  68075. compileMaterials: boolean;
  68076. /**
  68077. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68078. */
  68079. useClipPlane: boolean;
  68080. /**
  68081. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68082. */
  68083. compileShadowGenerators: boolean;
  68084. /**
  68085. * Defines if the Alpha blended materials are only applied as coverage.
  68086. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68087. * If true, no extra effects are applied to transparent pixels.
  68088. */
  68089. transparencyAsCoverage: boolean;
  68090. /**
  68091. * Function called before loading a url referenced by the asset.
  68092. */
  68093. preprocessUrlAsync: (url: string) => Promise<string>;
  68094. /**
  68095. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68096. */
  68097. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68098. private _onMeshLoadedObserver;
  68099. /**
  68100. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68101. */
  68102. onMeshLoaded: (mesh: AbstractMesh) => void;
  68103. /**
  68104. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68105. */
  68106. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68107. private _onTextureLoadedObserver;
  68108. /**
  68109. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68110. */
  68111. onTextureLoaded: (texture: BaseTexture) => void;
  68112. /**
  68113. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68114. */
  68115. readonly onMaterialLoadedObservable: Observable<Material>;
  68116. private _onMaterialLoadedObserver;
  68117. /**
  68118. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68119. */
  68120. onMaterialLoaded: (material: Material) => void;
  68121. /**
  68122. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68123. */
  68124. readonly onCameraLoadedObservable: Observable<Camera>;
  68125. private _onCameraLoadedObserver;
  68126. /**
  68127. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68128. */
  68129. onCameraLoaded: (camera: Camera) => void;
  68130. /**
  68131. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68132. * For assets with LODs, raised when all of the LODs are complete.
  68133. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68134. */
  68135. readonly onCompleteObservable: Observable<void>;
  68136. private _onCompleteObserver;
  68137. /**
  68138. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68139. * For assets with LODs, raised when all of the LODs are complete.
  68140. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68141. */
  68142. onComplete: () => void;
  68143. /**
  68144. * Observable raised when an error occurs.
  68145. */
  68146. readonly onErrorObservable: Observable<any>;
  68147. private _onErrorObserver;
  68148. /**
  68149. * Callback raised when an error occurs.
  68150. */
  68151. onError: (reason: any) => void;
  68152. /**
  68153. * Observable raised after the loader is disposed.
  68154. */
  68155. readonly onDisposeObservable: Observable<void>;
  68156. private _onDisposeObserver;
  68157. /**
  68158. * Callback raised after the loader is disposed.
  68159. */
  68160. onDispose: () => void;
  68161. /**
  68162. * Observable raised after a loader extension is created.
  68163. * Set additional options for a loader extension in this event.
  68164. */
  68165. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68166. private _onExtensionLoadedObserver;
  68167. /**
  68168. * Callback raised after a loader extension is created.
  68169. */
  68170. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68171. /**
  68172. * Defines if the loader logging is enabled.
  68173. */
  68174. loggingEnabled: boolean;
  68175. /**
  68176. * Defines if the loader should capture performance counters.
  68177. */
  68178. capturePerformanceCounters: boolean;
  68179. /**
  68180. * Defines if the loader should validate the asset.
  68181. */
  68182. validate: boolean;
  68183. /**
  68184. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68185. */
  68186. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68187. private _onValidatedObserver;
  68188. /**
  68189. * Callback raised after a loader extension is created.
  68190. */
  68191. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68192. private _loader;
  68193. /**
  68194. * Name of the loader ("gltf")
  68195. */
  68196. name: string;
  68197. /**
  68198. * Supported file extensions of the loader (.gltf, .glb)
  68199. */
  68200. extensions: ISceneLoaderPluginExtensions;
  68201. /**
  68202. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68203. */
  68204. dispose(): void;
  68205. /** @hidden */
  68206. _clear(): void;
  68207. /**
  68208. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  68209. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68210. * @param scene the scene the meshes should be added to
  68211. * @param data the glTF data to load
  68212. * @param rootUrl root url to load from
  68213. * @param onProgress event that fires when loading progress has occured
  68214. * @param fileName Defines the name of the file to load
  68215. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68216. */
  68217. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68218. meshes: AbstractMesh[];
  68219. particleSystems: IParticleSystem[];
  68220. skeletons: Skeleton[];
  68221. animationGroups: AnimationGroup[];
  68222. }>;
  68223. /**
  68224. * Imports all objects from the loaded glTF data and adds them to the scene
  68225. * @param scene the scene the objects should be added to
  68226. * @param data the glTF data to load
  68227. * @param rootUrl root url to load from
  68228. * @param onProgress event that fires when loading progress has occured
  68229. * @param fileName Defines the name of the file to load
  68230. * @returns a promise which completes when objects have been loaded to the scene
  68231. */
  68232. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68233. /**
  68234. * Load into an asset container.
  68235. * @param scene The scene to load into
  68236. * @param data The data to import
  68237. * @param rootUrl The root url for scene and resources
  68238. * @param onProgress The callback when the load progresses
  68239. * @param fileName Defines the name of the file to load
  68240. * @returns The loaded asset container
  68241. */
  68242. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68243. /**
  68244. * If the data string can be loaded directly.
  68245. * @param data string contianing the file data
  68246. * @returns if the data can be loaded directly
  68247. */
  68248. canDirectLoad(data: string): boolean;
  68249. /**
  68250. * Rewrites a url by combining a root url and response url.
  68251. */
  68252. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  68253. /**
  68254. * Instantiates a glTF file loader plugin.
  68255. * @returns the created plugin
  68256. */
  68257. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68258. /**
  68259. * The loader state or null if the loader is not active.
  68260. */
  68261. readonly loaderState: Nullable<GLTFLoaderState>;
  68262. /**
  68263. * Returns a promise that resolves when the asset is completely loaded.
  68264. * @returns a promise that resolves when the asset is completely loaded.
  68265. */
  68266. whenCompleteAsync(): Promise<void>;
  68267. private _parseAsync;
  68268. private _validateAsync;
  68269. private _getLoader;
  68270. private _unpackBinary;
  68271. private _unpackBinaryV1;
  68272. private _unpackBinaryV2;
  68273. private static _parseVersion;
  68274. private static _compareVersion;
  68275. private static _decodeBufferToText;
  68276. private static readonly _logSpaces;
  68277. private _logIndentLevel;
  68278. private _loggingEnabled;
  68279. /** @hidden */
  68280. _log: (message: string) => void;
  68281. /** @hidden */
  68282. _logOpen(message: string): void;
  68283. /** @hidden */
  68284. _logClose(): void;
  68285. private _logEnabled;
  68286. private _logDisabled;
  68287. private _capturePerformanceCounters;
  68288. /** @hidden */
  68289. _startPerformanceCounter: (counterName: string) => void;
  68290. /** @hidden */
  68291. _endPerformanceCounter: (counterName: string) => void;
  68292. private _startPerformanceCounterEnabled;
  68293. private _startPerformanceCounterDisabled;
  68294. private _endPerformanceCounterEnabled;
  68295. private _endPerformanceCounterDisabled;
  68296. }
  68297. }
  68298. declare module BABYLON.GLTF1 {
  68299. /**
  68300. * Enums
  68301. * @hidden
  68302. */
  68303. export enum EComponentType {
  68304. BYTE = 5120,
  68305. UNSIGNED_BYTE = 5121,
  68306. SHORT = 5122,
  68307. UNSIGNED_SHORT = 5123,
  68308. FLOAT = 5126
  68309. }
  68310. /** @hidden */
  68311. export enum EShaderType {
  68312. FRAGMENT = 35632,
  68313. VERTEX = 35633
  68314. }
  68315. /** @hidden */
  68316. export enum EParameterType {
  68317. BYTE = 5120,
  68318. UNSIGNED_BYTE = 5121,
  68319. SHORT = 5122,
  68320. UNSIGNED_SHORT = 5123,
  68321. INT = 5124,
  68322. UNSIGNED_INT = 5125,
  68323. FLOAT = 5126,
  68324. FLOAT_VEC2 = 35664,
  68325. FLOAT_VEC3 = 35665,
  68326. FLOAT_VEC4 = 35666,
  68327. INT_VEC2 = 35667,
  68328. INT_VEC3 = 35668,
  68329. INT_VEC4 = 35669,
  68330. BOOL = 35670,
  68331. BOOL_VEC2 = 35671,
  68332. BOOL_VEC3 = 35672,
  68333. BOOL_VEC4 = 35673,
  68334. FLOAT_MAT2 = 35674,
  68335. FLOAT_MAT3 = 35675,
  68336. FLOAT_MAT4 = 35676,
  68337. SAMPLER_2D = 35678
  68338. }
  68339. /** @hidden */
  68340. export enum ETextureWrapMode {
  68341. CLAMP_TO_EDGE = 33071,
  68342. MIRRORED_REPEAT = 33648,
  68343. REPEAT = 10497
  68344. }
  68345. /** @hidden */
  68346. export enum ETextureFilterType {
  68347. NEAREST = 9728,
  68348. LINEAR = 9728,
  68349. NEAREST_MIPMAP_NEAREST = 9984,
  68350. LINEAR_MIPMAP_NEAREST = 9985,
  68351. NEAREST_MIPMAP_LINEAR = 9986,
  68352. LINEAR_MIPMAP_LINEAR = 9987
  68353. }
  68354. /** @hidden */
  68355. export enum ETextureFormat {
  68356. ALPHA = 6406,
  68357. RGB = 6407,
  68358. RGBA = 6408,
  68359. LUMINANCE = 6409,
  68360. LUMINANCE_ALPHA = 6410
  68361. }
  68362. /** @hidden */
  68363. export enum ECullingType {
  68364. FRONT = 1028,
  68365. BACK = 1029,
  68366. FRONT_AND_BACK = 1032
  68367. }
  68368. /** @hidden */
  68369. export enum EBlendingFunction {
  68370. ZERO = 0,
  68371. ONE = 1,
  68372. SRC_COLOR = 768,
  68373. ONE_MINUS_SRC_COLOR = 769,
  68374. DST_COLOR = 774,
  68375. ONE_MINUS_DST_COLOR = 775,
  68376. SRC_ALPHA = 770,
  68377. ONE_MINUS_SRC_ALPHA = 771,
  68378. DST_ALPHA = 772,
  68379. ONE_MINUS_DST_ALPHA = 773,
  68380. CONSTANT_COLOR = 32769,
  68381. ONE_MINUS_CONSTANT_COLOR = 32770,
  68382. CONSTANT_ALPHA = 32771,
  68383. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68384. SRC_ALPHA_SATURATE = 776
  68385. }
  68386. /** @hidden */
  68387. export interface IGLTFProperty {
  68388. extensions?: {
  68389. [key: string]: any;
  68390. };
  68391. extras?: Object;
  68392. }
  68393. /** @hidden */
  68394. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68395. name?: string;
  68396. }
  68397. /** @hidden */
  68398. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68399. bufferView: string;
  68400. byteOffset: number;
  68401. byteStride: number;
  68402. count: number;
  68403. type: string;
  68404. componentType: EComponentType;
  68405. max?: number[];
  68406. min?: number[];
  68407. name?: string;
  68408. }
  68409. /** @hidden */
  68410. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68411. buffer: string;
  68412. byteOffset: number;
  68413. byteLength: number;
  68414. byteStride: number;
  68415. target?: number;
  68416. }
  68417. /** @hidden */
  68418. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68419. uri: string;
  68420. byteLength?: number;
  68421. type?: string;
  68422. }
  68423. /** @hidden */
  68424. export interface IGLTFShader extends IGLTFChildRootProperty {
  68425. uri: string;
  68426. type: EShaderType;
  68427. }
  68428. /** @hidden */
  68429. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68430. attributes: string[];
  68431. fragmentShader: string;
  68432. vertexShader: string;
  68433. }
  68434. /** @hidden */
  68435. export interface IGLTFTechniqueParameter {
  68436. type: number;
  68437. count?: number;
  68438. semantic?: string;
  68439. node?: string;
  68440. value?: number | boolean | string | Array<any>;
  68441. source?: string;
  68442. babylonValue?: any;
  68443. }
  68444. /** @hidden */
  68445. export interface IGLTFTechniqueCommonProfile {
  68446. lightingModel: string;
  68447. texcoordBindings: Object;
  68448. parameters?: Array<any>;
  68449. }
  68450. /** @hidden */
  68451. export interface IGLTFTechniqueStatesFunctions {
  68452. blendColor?: number[];
  68453. blendEquationSeparate?: number[];
  68454. blendFuncSeparate?: number[];
  68455. colorMask: boolean[];
  68456. cullFace: number[];
  68457. }
  68458. /** @hidden */
  68459. export interface IGLTFTechniqueStates {
  68460. enable: number[];
  68461. functions: IGLTFTechniqueStatesFunctions;
  68462. }
  68463. /** @hidden */
  68464. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68465. parameters: {
  68466. [key: string]: IGLTFTechniqueParameter;
  68467. };
  68468. program: string;
  68469. attributes: {
  68470. [key: string]: string;
  68471. };
  68472. uniforms: {
  68473. [key: string]: string;
  68474. };
  68475. states: IGLTFTechniqueStates;
  68476. }
  68477. /** @hidden */
  68478. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68479. technique?: string;
  68480. values: string[];
  68481. }
  68482. /** @hidden */
  68483. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68484. attributes: {
  68485. [key: string]: string;
  68486. };
  68487. indices: string;
  68488. material: string;
  68489. mode?: number;
  68490. }
  68491. /** @hidden */
  68492. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68493. primitives: IGLTFMeshPrimitive[];
  68494. }
  68495. /** @hidden */
  68496. export interface IGLTFImage extends IGLTFChildRootProperty {
  68497. uri: string;
  68498. }
  68499. /** @hidden */
  68500. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68501. magFilter?: number;
  68502. minFilter?: number;
  68503. wrapS?: number;
  68504. wrapT?: number;
  68505. }
  68506. /** @hidden */
  68507. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68508. sampler: string;
  68509. source: string;
  68510. format?: ETextureFormat;
  68511. internalFormat?: ETextureFormat;
  68512. target?: number;
  68513. type?: number;
  68514. babylonTexture?: Texture;
  68515. }
  68516. /** @hidden */
  68517. export interface IGLTFAmbienLight {
  68518. color?: number[];
  68519. }
  68520. /** @hidden */
  68521. export interface IGLTFDirectionalLight {
  68522. color?: number[];
  68523. }
  68524. /** @hidden */
  68525. export interface IGLTFPointLight {
  68526. color?: number[];
  68527. constantAttenuation?: number;
  68528. linearAttenuation?: number;
  68529. quadraticAttenuation?: number;
  68530. }
  68531. /** @hidden */
  68532. export interface IGLTFSpotLight {
  68533. color?: number[];
  68534. constantAttenuation?: number;
  68535. fallOfAngle?: number;
  68536. fallOffExponent?: number;
  68537. linearAttenuation?: number;
  68538. quadraticAttenuation?: number;
  68539. }
  68540. /** @hidden */
  68541. export interface IGLTFLight extends IGLTFChildRootProperty {
  68542. type: string;
  68543. }
  68544. /** @hidden */
  68545. export interface IGLTFCameraOrthographic {
  68546. xmag: number;
  68547. ymag: number;
  68548. zfar: number;
  68549. znear: number;
  68550. }
  68551. /** @hidden */
  68552. export interface IGLTFCameraPerspective {
  68553. aspectRatio: number;
  68554. yfov: number;
  68555. zfar: number;
  68556. znear: number;
  68557. }
  68558. /** @hidden */
  68559. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68560. type: string;
  68561. }
  68562. /** @hidden */
  68563. export interface IGLTFAnimationChannelTarget {
  68564. id: string;
  68565. path: string;
  68566. }
  68567. /** @hidden */
  68568. export interface IGLTFAnimationChannel {
  68569. sampler: string;
  68570. target: IGLTFAnimationChannelTarget;
  68571. }
  68572. /** @hidden */
  68573. export interface IGLTFAnimationSampler {
  68574. input: string;
  68575. output: string;
  68576. interpolation?: string;
  68577. }
  68578. /** @hidden */
  68579. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68580. channels?: IGLTFAnimationChannel[];
  68581. parameters?: {
  68582. [key: string]: string;
  68583. };
  68584. samplers?: {
  68585. [key: string]: IGLTFAnimationSampler;
  68586. };
  68587. }
  68588. /** @hidden */
  68589. export interface IGLTFNodeInstanceSkin {
  68590. skeletons: string[];
  68591. skin: string;
  68592. meshes: string[];
  68593. }
  68594. /** @hidden */
  68595. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68596. bindShapeMatrix: number[];
  68597. inverseBindMatrices: string;
  68598. jointNames: string[];
  68599. babylonSkeleton?: Skeleton;
  68600. }
  68601. /** @hidden */
  68602. export interface IGLTFNode extends IGLTFChildRootProperty {
  68603. camera?: string;
  68604. children: string[];
  68605. skin?: string;
  68606. jointName?: string;
  68607. light?: string;
  68608. matrix: number[];
  68609. mesh?: string;
  68610. meshes?: string[];
  68611. rotation?: number[];
  68612. scale?: number[];
  68613. translation?: number[];
  68614. babylonNode?: Node;
  68615. }
  68616. /** @hidden */
  68617. export interface IGLTFScene extends IGLTFChildRootProperty {
  68618. nodes: string[];
  68619. }
  68620. /** @hidden */
  68621. export interface IGLTFRuntime {
  68622. extensions: {
  68623. [key: string]: any;
  68624. };
  68625. accessors: {
  68626. [key: string]: IGLTFAccessor;
  68627. };
  68628. buffers: {
  68629. [key: string]: IGLTFBuffer;
  68630. };
  68631. bufferViews: {
  68632. [key: string]: IGLTFBufferView;
  68633. };
  68634. meshes: {
  68635. [key: string]: IGLTFMesh;
  68636. };
  68637. lights: {
  68638. [key: string]: IGLTFLight;
  68639. };
  68640. cameras: {
  68641. [key: string]: IGLTFCamera;
  68642. };
  68643. nodes: {
  68644. [key: string]: IGLTFNode;
  68645. };
  68646. images: {
  68647. [key: string]: IGLTFImage;
  68648. };
  68649. textures: {
  68650. [key: string]: IGLTFTexture;
  68651. };
  68652. shaders: {
  68653. [key: string]: IGLTFShader;
  68654. };
  68655. programs: {
  68656. [key: string]: IGLTFProgram;
  68657. };
  68658. samplers: {
  68659. [key: string]: IGLTFSampler;
  68660. };
  68661. techniques: {
  68662. [key: string]: IGLTFTechnique;
  68663. };
  68664. materials: {
  68665. [key: string]: IGLTFMaterial;
  68666. };
  68667. animations: {
  68668. [key: string]: IGLTFAnimation;
  68669. };
  68670. skins: {
  68671. [key: string]: IGLTFSkins;
  68672. };
  68673. currentScene?: Object;
  68674. scenes: {
  68675. [key: string]: IGLTFScene;
  68676. };
  68677. extensionsUsed: string[];
  68678. extensionsRequired?: string[];
  68679. buffersCount: number;
  68680. shaderscount: number;
  68681. scene: Scene;
  68682. rootUrl: string;
  68683. loadedBufferCount: number;
  68684. loadedBufferViews: {
  68685. [name: string]: ArrayBufferView;
  68686. };
  68687. loadedShaderCount: number;
  68688. importOnlyMeshes: boolean;
  68689. importMeshesNames?: string[];
  68690. dummyNodes: Node[];
  68691. }
  68692. /** @hidden */
  68693. export interface INodeToRoot {
  68694. bone: Bone;
  68695. node: IGLTFNode;
  68696. id: string;
  68697. }
  68698. /** @hidden */
  68699. export interface IJointNode {
  68700. node: IGLTFNode;
  68701. id: string;
  68702. }
  68703. }
  68704. declare module BABYLON.GLTF1 {
  68705. /**
  68706. * Utils functions for GLTF
  68707. * @hidden
  68708. */
  68709. export class GLTFUtils {
  68710. /**
  68711. * Sets the given "parameter" matrix
  68712. * @param scene: the Scene object
  68713. * @param source: the source node where to pick the matrix
  68714. * @param parameter: the GLTF technique parameter
  68715. * @param uniformName: the name of the shader's uniform
  68716. * @param shaderMaterial: the shader material
  68717. */
  68718. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68719. /**
  68720. * Sets the given "parameter" matrix
  68721. * @param shaderMaterial: the shader material
  68722. * @param uniform: the name of the shader's uniform
  68723. * @param value: the value of the uniform
  68724. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68725. */
  68726. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68727. /**
  68728. * Returns the wrap mode of the texture
  68729. * @param mode: the mode value
  68730. */
  68731. static GetWrapMode(mode: number): number;
  68732. /**
  68733. * Returns the byte stride giving an accessor
  68734. * @param accessor: the GLTF accessor objet
  68735. */
  68736. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68737. /**
  68738. * Returns the texture filter mode giving a mode value
  68739. * @param mode: the filter mode value
  68740. */
  68741. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68742. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68743. /**
  68744. * Returns a buffer from its accessor
  68745. * @param gltfRuntime: the GLTF runtime
  68746. * @param accessor: the GLTF accessor
  68747. */
  68748. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68749. /**
  68750. * Decodes a buffer view into a string
  68751. * @param view: the buffer view
  68752. */
  68753. static DecodeBufferToText(view: ArrayBufferView): string;
  68754. /**
  68755. * Returns the default material of gltf. Related to
  68756. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68757. * @param scene: the Babylon.js scene
  68758. */
  68759. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68760. private static _DefaultMaterial;
  68761. }
  68762. }
  68763. declare module BABYLON.GLTF1 {
  68764. /**
  68765. * Implementation of the base glTF spec
  68766. * @hidden
  68767. */
  68768. export class GLTFLoaderBase {
  68769. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68770. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68771. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68772. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68773. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68774. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68775. }
  68776. /**
  68777. * glTF V1 Loader
  68778. * @hidden
  68779. */
  68780. export class GLTFLoader implements IGLTFLoader {
  68781. static Extensions: {
  68782. [name: string]: GLTFLoaderExtension;
  68783. };
  68784. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68785. state: Nullable<GLTFLoaderState>;
  68786. dispose(): void;
  68787. private _importMeshAsync;
  68788. /**
  68789. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68790. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68791. * @param scene the scene the meshes should be added to
  68792. * @param data gltf data containing information of the meshes in a loaded file
  68793. * @param rootUrl root url to load from
  68794. * @param onProgress event that fires when loading progress has occured
  68795. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68796. */
  68797. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68798. meshes: AbstractMesh[];
  68799. particleSystems: IParticleSystem[];
  68800. skeletons: Skeleton[];
  68801. animationGroups: AnimationGroup[];
  68802. }>;
  68803. private _loadAsync;
  68804. /**
  68805. * Imports all objects from a loaded gltf file and adds them to the scene
  68806. * @param scene the scene the objects should be added to
  68807. * @param data gltf data containing information of the meshes in a loaded file
  68808. * @param rootUrl root url to load from
  68809. * @param onProgress event that fires when loading progress has occured
  68810. * @returns a promise which completes when objects have been loaded to the scene
  68811. */
  68812. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68813. private _loadShadersAsync;
  68814. private _loadBuffersAsync;
  68815. private _createNodes;
  68816. }
  68817. /** @hidden */
  68818. export abstract class GLTFLoaderExtension {
  68819. private _name;
  68820. constructor(name: string);
  68821. readonly name: string;
  68822. /**
  68823. * Defines an override for loading the runtime
  68824. * Return true to stop further extensions from loading the runtime
  68825. */
  68826. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68827. /**
  68828. * Defines an onverride for creating gltf runtime
  68829. * Return true to stop further extensions from creating the runtime
  68830. */
  68831. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68832. /**
  68833. * Defines an override for loading buffers
  68834. * Return true to stop further extensions from loading this buffer
  68835. */
  68836. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68837. /**
  68838. * Defines an override for loading texture buffers
  68839. * Return true to stop further extensions from loading this texture data
  68840. */
  68841. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68842. /**
  68843. * Defines an override for creating textures
  68844. * Return true to stop further extensions from loading this texture
  68845. */
  68846. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68847. /**
  68848. * Defines an override for loading shader strings
  68849. * Return true to stop further extensions from loading this shader data
  68850. */
  68851. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68852. /**
  68853. * Defines an override for loading materials
  68854. * Return true to stop further extensions from loading this material
  68855. */
  68856. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68857. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68858. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68859. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68860. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68861. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68862. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68863. private static LoadTextureBufferAsync;
  68864. private static CreateTextureAsync;
  68865. private static ApplyExtensions;
  68866. }
  68867. }
  68868. declare module BABYLON.GLTF1 {
  68869. /** @hidden */
  68870. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68871. private _bin;
  68872. constructor();
  68873. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68874. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68875. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68876. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68877. }
  68878. }
  68879. declare module BABYLON.GLTF1 {
  68880. /** @hidden */
  68881. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68882. constructor();
  68883. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68884. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68885. private _loadTexture;
  68886. }
  68887. }
  68888. declare module BABYLON.GLTF2.Loader {
  68889. /**
  68890. * Loader interface with an index field.
  68891. */
  68892. export interface IArrayItem {
  68893. /**
  68894. * The index of this item in the array.
  68895. */
  68896. index: number;
  68897. }
  68898. /**
  68899. * Loader interface with additional members.
  68900. */
  68901. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68902. /** @hidden */
  68903. _data?: Promise<ArrayBufferView>;
  68904. /** @hidden */
  68905. _babylonVertexBuffer?: Promise<VertexBuffer>;
  68906. }
  68907. /**
  68908. * Loader interface with additional members.
  68909. */
  68910. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68911. }
  68912. /** @hidden */
  68913. export interface _IAnimationSamplerData {
  68914. input: Float32Array;
  68915. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68916. output: Float32Array;
  68917. }
  68918. /**
  68919. * Loader interface with additional members.
  68920. */
  68921. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68922. /** @hidden */
  68923. _data?: Promise<_IAnimationSamplerData>;
  68924. }
  68925. /**
  68926. * Loader interface with additional members.
  68927. */
  68928. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68929. channels: IAnimationChannel[];
  68930. samplers: IAnimationSampler[];
  68931. /** @hidden */
  68932. _babylonAnimationGroup?: AnimationGroup;
  68933. }
  68934. /**
  68935. * Loader interface with additional members.
  68936. */
  68937. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68938. /** @hidden */
  68939. _data?: Promise<ArrayBufferView>;
  68940. }
  68941. /**
  68942. * Loader interface with additional members.
  68943. */
  68944. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68945. /** @hidden */
  68946. _data?: Promise<ArrayBufferView>;
  68947. /** @hidden */
  68948. _babylonBuffer?: Promise<Buffer>;
  68949. }
  68950. /**
  68951. * Loader interface with additional members.
  68952. */
  68953. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68954. }
  68955. /**
  68956. * Loader interface with additional members.
  68957. */
  68958. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68959. /** @hidden */
  68960. _data?: Promise<ArrayBufferView>;
  68961. }
  68962. /**
  68963. * Loader interface with additional members.
  68964. */
  68965. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68966. }
  68967. /**
  68968. * Loader interface with additional members.
  68969. */
  68970. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68971. }
  68972. /**
  68973. * Loader interface with additional members.
  68974. */
  68975. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68976. baseColorTexture?: ITextureInfo;
  68977. metallicRoughnessTexture?: ITextureInfo;
  68978. }
  68979. /**
  68980. * Loader interface with additional members.
  68981. */
  68982. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68983. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68984. normalTexture?: IMaterialNormalTextureInfo;
  68985. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68986. emissiveTexture?: ITextureInfo;
  68987. /** @hidden */
  68988. _data?: {
  68989. [babylonDrawMode: number]: {
  68990. babylonMaterial: Material;
  68991. babylonMeshes: AbstractMesh[];
  68992. promise: Promise<void>;
  68993. };
  68994. };
  68995. }
  68996. /**
  68997. * Loader interface with additional members.
  68998. */
  68999. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69000. primitives: IMeshPrimitive[];
  69001. }
  69002. /**
  69003. * Loader interface with additional members.
  69004. */
  69005. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69006. /** @hidden */
  69007. _instanceData?: {
  69008. babylonSourceMesh: Mesh;
  69009. promise: Promise<any>;
  69010. };
  69011. }
  69012. /**
  69013. * Loader interface with additional members.
  69014. */
  69015. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69016. /**
  69017. * The parent glTF node.
  69018. */
  69019. parent?: INode;
  69020. /** @hidden */
  69021. _babylonTransformNode?: TransformNode;
  69022. /** @hidden */
  69023. _primitiveBabylonMeshes?: AbstractMesh[];
  69024. /** @hidden */
  69025. _babylonBones?: Bone[];
  69026. /** @hidden */
  69027. _numMorphTargets?: number;
  69028. }
  69029. /** @hidden */
  69030. export interface _ISamplerData {
  69031. noMipMaps: boolean;
  69032. samplingMode: number;
  69033. wrapU: number;
  69034. wrapV: number;
  69035. }
  69036. /**
  69037. * Loader interface with additional members.
  69038. */
  69039. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69040. /** @hidden */
  69041. _data?: _ISamplerData;
  69042. }
  69043. /**
  69044. * Loader interface with additional members.
  69045. */
  69046. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69047. }
  69048. /**
  69049. * Loader interface with additional members.
  69050. */
  69051. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69052. /** @hidden */
  69053. _data?: {
  69054. babylonSkeleton: Skeleton;
  69055. promise: Promise<void>;
  69056. };
  69057. }
  69058. /**
  69059. * Loader interface with additional members.
  69060. */
  69061. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69062. }
  69063. /**
  69064. * Loader interface with additional members.
  69065. */
  69066. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69067. }
  69068. /**
  69069. * Loader interface with additional members.
  69070. */
  69071. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69072. accessors?: IAccessor[];
  69073. animations?: IAnimation[];
  69074. buffers?: IBuffer[];
  69075. bufferViews?: IBufferView[];
  69076. cameras?: ICamera[];
  69077. images?: IImage[];
  69078. materials?: IMaterial[];
  69079. meshes?: IMesh[];
  69080. nodes?: INode[];
  69081. samplers?: ISampler[];
  69082. scenes?: IScene[];
  69083. skins?: ISkin[];
  69084. textures?: ITexture[];
  69085. }
  69086. }
  69087. declare module BABYLON.GLTF2 {
  69088. /**
  69089. * Interface for a glTF loader extension.
  69090. */
  69091. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69092. /**
  69093. * Called after the loader state changes to LOADING.
  69094. */
  69095. onLoading?(): void;
  69096. /**
  69097. * Called after the loader state changes to READY.
  69098. */
  69099. onReady?(): void;
  69100. /**
  69101. * Define this method to modify the default behavior when loading scenes.
  69102. * @param context The context when loading the asset
  69103. * @param scene The glTF scene property
  69104. * @returns A promise that resolves when the load is complete or null if not handled
  69105. */
  69106. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69107. /**
  69108. * Define this method to modify the default behavior when loading nodes.
  69109. * @param context The context when loading the asset
  69110. * @param node The glTF node property
  69111. * @param assign A function called synchronously after parsing the glTF properties
  69112. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69113. */
  69114. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69115. /**
  69116. * Define this method to modify the default behavior when loading cameras.
  69117. * @param context The context when loading the asset
  69118. * @param camera The glTF camera property
  69119. * @param assign A function called synchronously after parsing the glTF properties
  69120. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69121. */
  69122. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69123. /**
  69124. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69125. * @param context The context when loading the asset
  69126. * @param primitive The glTF mesh primitive property
  69127. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69128. */
  69129. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69130. /**
  69131. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69132. * @param context The context when loading the asset
  69133. * @param name The mesh name when loading the asset
  69134. * @param node The glTF node when loading the asset
  69135. * @param mesh The glTF mesh when loading the asset
  69136. * @param primitive The glTF mesh primitive property
  69137. * @param assign A function called synchronously after parsing the glTF properties
  69138. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69139. */
  69140. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69141. /**
  69142. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69143. * @param context The context when loading the asset
  69144. * @param material The glTF material property
  69145. * @param assign A function called synchronously after parsing the glTF properties
  69146. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69147. */
  69148. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69149. /**
  69150. * Define this method to modify the default behavior when creating materials.
  69151. * @param context The context when loading the asset
  69152. * @param material The glTF material property
  69153. * @param babylonDrawMode The draw mode for the Babylon material
  69154. * @returns The Babylon material or null if not handled
  69155. */
  69156. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69157. /**
  69158. * Define this method to modify the default behavior when loading material properties.
  69159. * @param context The context when loading the asset
  69160. * @param material The glTF material property
  69161. * @param babylonMaterial The Babylon material
  69162. * @returns A promise that resolves when the load is complete or null if not handled
  69163. */
  69164. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69165. /**
  69166. * Define this method to modify the default behavior when loading texture infos.
  69167. * @param context The context when loading the asset
  69168. * @param textureInfo The glTF texture info property
  69169. * @param assign A function called synchronously after parsing the glTF properties
  69170. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69171. */
  69172. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69173. /**
  69174. * Define this method to modify the default behavior when loading animations.
  69175. * @param context The context when loading the asset
  69176. * @param animation The glTF animation property
  69177. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69178. */
  69179. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69180. /**
  69181. * @hidden Define this method to modify the default behavior when loading skins.
  69182. * @param context The context when loading the asset
  69183. * @param node The glTF node property
  69184. * @param skin The glTF skin property
  69185. * @returns A promise that resolves when the load is complete or null if not handled
  69186. */
  69187. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69188. /**
  69189. * @hidden Define this method to modify the default behavior when loading uris.
  69190. * @param context The context when loading the asset
  69191. * @param property The glTF property associated with the uri
  69192. * @param uri The uri to load
  69193. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69194. */
  69195. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69196. /**
  69197. * Define this method to modify the default behavior when loading buffer views.
  69198. * @param context The context when loading the asset
  69199. * @param bufferView The glTF buffer view property
  69200. * @returns A promise that resolves with the loaded buffer view when the load is complete or null if not handled
  69201. */
  69202. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69203. }
  69204. }
  69205. declare module BABYLON.GLTF2 {
  69206. /**
  69207. * Helper class for working with arrays when loading the glTF asset
  69208. */
  69209. export class ArrayItem {
  69210. /**
  69211. * Gets an item from the given array.
  69212. * @param context The context when loading the asset
  69213. * @param array The array to get the item from
  69214. * @param index The index to the array
  69215. * @returns The array item
  69216. */
  69217. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69218. /**
  69219. * Assign an `index` field to each item of the given array.
  69220. * @param array The array of items
  69221. */
  69222. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69223. }
  69224. /**
  69225. * The glTF 2.0 loader
  69226. */
  69227. export class GLTFLoader implements IGLTFLoader {
  69228. /** @hidden */
  69229. _completePromises: Promise<any>[];
  69230. private _disposed;
  69231. private _parent;
  69232. private _state;
  69233. private _extensions;
  69234. private _rootUrl;
  69235. private _fileName;
  69236. private _uniqueRootUrl;
  69237. private _gltf;
  69238. private _babylonScene;
  69239. private _rootBabylonMesh;
  69240. private _defaultBabylonMaterialData;
  69241. private _progressCallback?;
  69242. private _requests;
  69243. private static readonly _DefaultSampler;
  69244. private static _ExtensionNames;
  69245. private static _ExtensionFactories;
  69246. /**
  69247. * Registers a loader extension.
  69248. * @param name The name of the loader extension.
  69249. * @param factory The factory function that creates the loader extension.
  69250. */
  69251. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69252. /**
  69253. * Unregisters a loader extension.
  69254. * @param name The name of the loader extenion.
  69255. * @returns A boolean indicating whether the extension has been unregistered
  69256. */
  69257. static UnregisterExtension(name: string): boolean;
  69258. /**
  69259. * Gets the loader state.
  69260. */
  69261. readonly state: Nullable<GLTFLoaderState>;
  69262. /**
  69263. * The glTF object parsed from the JSON.
  69264. */
  69265. readonly gltf: IGLTF;
  69266. /**
  69267. * The Babylon scene when loading the asset.
  69268. */
  69269. readonly babylonScene: Scene;
  69270. /**
  69271. * The root Babylon mesh when loading the asset.
  69272. */
  69273. readonly rootBabylonMesh: Mesh;
  69274. /** @hidden */
  69275. constructor(parent: GLTFFileLoader);
  69276. /** @hidden */
  69277. dispose(): void;
  69278. /** @hidden */
  69279. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69280. meshes: AbstractMesh[];
  69281. particleSystems: IParticleSystem[];
  69282. skeletons: Skeleton[];
  69283. animationGroups: AnimationGroup[];
  69284. }>;
  69285. /** @hidden */
  69286. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69287. private _loadAsync;
  69288. private _loadData;
  69289. private _setupData;
  69290. private _loadExtensions;
  69291. private _checkExtensions;
  69292. private _setState;
  69293. private _createRootNode;
  69294. /**
  69295. * Loads a glTF scene.
  69296. * @param context The context when loading the asset
  69297. * @param scene The glTF scene property
  69298. * @returns A promise that resolves when the load is complete
  69299. */
  69300. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69301. private _forEachPrimitive;
  69302. private _getMeshes;
  69303. private _getSkeletons;
  69304. private _getAnimationGroups;
  69305. private _startAnimations;
  69306. /**
  69307. * Loads a glTF node.
  69308. * @param context The context when loading the asset
  69309. * @param node The glTF node property
  69310. * @param assign A function called synchronously after parsing the glTF properties
  69311. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69312. */
  69313. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69314. private _loadMeshAsync;
  69315. /**
  69316. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69317. * @param context The context when loading the asset
  69318. * @param name The mesh name when loading the asset
  69319. * @param node The glTF node when loading the asset
  69320. * @param mesh The glTF mesh when loading the asset
  69321. * @param primitive The glTF mesh primitive property
  69322. * @param assign A function called synchronously after parsing the glTF properties
  69323. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69324. */
  69325. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69326. private _loadVertexDataAsync;
  69327. private _createMorphTargets;
  69328. private _loadMorphTargetsAsync;
  69329. private _loadMorphTargetVertexDataAsync;
  69330. private static _LoadTransform;
  69331. private _loadSkinAsync;
  69332. private _loadBones;
  69333. private _loadBone;
  69334. private _loadSkinInverseBindMatricesDataAsync;
  69335. private _updateBoneMatrices;
  69336. private _getNodeMatrix;
  69337. /**
  69338. * Loads a glTF camera.
  69339. * @param context The context when loading the asset
  69340. * @param camera The glTF camera property
  69341. * @param assign A function called synchronously after parsing the glTF properties
  69342. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69343. */
  69344. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69345. private _loadAnimationsAsync;
  69346. /**
  69347. * Loads a glTF animation.
  69348. * @param context The context when loading the asset
  69349. * @param animation The glTF animation property
  69350. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69351. */
  69352. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69353. /**
  69354. * @hidden Loads a glTF animation channel.
  69355. * @param context The context when loading the asset
  69356. * @param animationContext The context of the animation when loading the asset
  69357. * @param animation The glTF animation property
  69358. * @param channel The glTF animation channel property
  69359. * @param babylonAnimationGroup The babylon animation group property
  69360. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69361. * @returns A void promise when the channel load is complete
  69362. */
  69363. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69364. private _loadAnimationSamplerAsync;
  69365. private _loadBufferAsync;
  69366. /**
  69367. * Loads a glTF buffer view.
  69368. * @param context The context when loading the asset
  69369. * @param bufferView The glTF buffer view property
  69370. * @returns A promise that resolves with the loaded data when the load is complete
  69371. */
  69372. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69373. private _loadAccessorAsync;
  69374. private _loadFloatAccessorAsync;
  69375. private _loadIndicesAccessorAsync;
  69376. private _loadVertexBufferViewAsync;
  69377. private _loadVertexAccessorAsync;
  69378. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69379. /** @hidden */
  69380. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69381. private _createDefaultMaterial;
  69382. /**
  69383. * Creates a Babylon material from a glTF material.
  69384. * @param context The context when loading the asset
  69385. * @param material The glTF material property
  69386. * @param babylonDrawMode The draw mode for the Babylon material
  69387. * @returns The Babylon material
  69388. */
  69389. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69390. /**
  69391. * Loads properties from a glTF material into a Babylon material.
  69392. * @param context The context when loading the asset
  69393. * @param material The glTF material property
  69394. * @param babylonMaterial The Babylon material
  69395. * @returns A promise that resolves when the load is complete
  69396. */
  69397. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69398. /**
  69399. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69400. * @param context The context when loading the asset
  69401. * @param material The glTF material property
  69402. * @param babylonMaterial The Babylon material
  69403. * @returns A promise that resolves when the load is complete
  69404. */
  69405. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69406. /**
  69407. * Loads the alpha properties from a glTF material into a Babylon material.
  69408. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69409. * @param context The context when loading the asset
  69410. * @param material The glTF material property
  69411. * @param babylonMaterial The Babylon material
  69412. */
  69413. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69414. /**
  69415. * Loads a glTF texture info.
  69416. * @param context The context when loading the asset
  69417. * @param textureInfo The glTF texture info property
  69418. * @param assign A function called synchronously after parsing the glTF properties
  69419. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69420. */
  69421. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69422. private _loadTextureAsync;
  69423. private _loadSampler;
  69424. /**
  69425. * Loads a glTF image.
  69426. * @param context The context when loading the asset
  69427. * @param image The glTF image property
  69428. * @returns A promise that resolves with the loaded data when the load is complete
  69429. */
  69430. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69431. /**
  69432. * Loads a glTF uri.
  69433. * @param context The context when loading the asset
  69434. * @param property The glTF property associated with the uri
  69435. * @param uri The base64 or relative uri
  69436. * @returns A promise that resolves with the loaded data when the load is complete
  69437. */
  69438. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69439. private _onProgress;
  69440. /**
  69441. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69442. * @param babylonObject the Babylon object with metadata
  69443. * @param pointer the JSON pointer
  69444. */
  69445. static AddPointerMetadata(babylonObject: {
  69446. metadata: any;
  69447. }, pointer: string): void;
  69448. private static _GetTextureWrapMode;
  69449. private static _GetTextureSamplingMode;
  69450. private static _GetTypedArrayConstructor;
  69451. private static _GetTypedArray;
  69452. private static _GetNumComponents;
  69453. private static _ValidateUri;
  69454. private static _GetDrawMode;
  69455. private _compileMaterialsAsync;
  69456. private _compileShadowGeneratorsAsync;
  69457. private _forEachExtensions;
  69458. private _applyExtensions;
  69459. private _extensionsOnLoading;
  69460. private _extensionsOnReady;
  69461. private _extensionsLoadSceneAsync;
  69462. private _extensionsLoadNodeAsync;
  69463. private _extensionsLoadCameraAsync;
  69464. private _extensionsLoadVertexDataAsync;
  69465. private _extensionsLoadMeshPrimitiveAsync;
  69466. private _extensionsLoadMaterialAsync;
  69467. private _extensionsCreateMaterial;
  69468. private _extensionsLoadMaterialPropertiesAsync;
  69469. private _extensionsLoadTextureInfoAsync;
  69470. private _extensionsLoadAnimationAsync;
  69471. private _extensionsLoadSkinAsync;
  69472. private _extensionsLoadUriAsync;
  69473. private _extensionsLoadBufferViewAsync;
  69474. /**
  69475. * Helper method called by a loader extension to load an glTF extension.
  69476. * @param context The context when loading the asset
  69477. * @param property The glTF property to load the extension from
  69478. * @param extensionName The name of the extension to load
  69479. * @param actionAsync The action to run
  69480. * @returns The promise returned by actionAsync or null if the extension does not exist
  69481. */
  69482. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69483. /**
  69484. * Helper method called by a loader extension to load a glTF extra.
  69485. * @param context The context when loading the asset
  69486. * @param property The glTF property to load the extra from
  69487. * @param extensionName The name of the extension to load
  69488. * @param actionAsync The action to run
  69489. * @returns The promise returned by actionAsync or null if the extra does not exist
  69490. */
  69491. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69492. /**
  69493. * Increments the indentation level and logs a message.
  69494. * @param message The message to log
  69495. */
  69496. logOpen(message: string): void;
  69497. /**
  69498. * Decrements the indentation level.
  69499. */
  69500. logClose(): void;
  69501. /**
  69502. * Logs a message
  69503. * @param message The message to log
  69504. */
  69505. log(message: string): void;
  69506. /**
  69507. * Starts a performance counter.
  69508. * @param counterName The name of the performance counter
  69509. */
  69510. startPerformanceCounter(counterName: string): void;
  69511. /**
  69512. * Ends a performance counter.
  69513. * @param counterName The name of the performance counter
  69514. */
  69515. endPerformanceCounter(counterName: string): void;
  69516. }
  69517. }
  69518. declare module BABYLON.GLTF2.Loader.Extensions {
  69519. /**
  69520. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  69521. */
  69522. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69523. /** The name of this extension. */
  69524. readonly name: string;
  69525. /** Defines whether this extension is enabled. */
  69526. enabled: boolean;
  69527. private _loader;
  69528. private _lights?;
  69529. /** @hidden */
  69530. constructor(loader: GLTFLoader);
  69531. /** @hidden */
  69532. dispose(): void;
  69533. /** @hidden */
  69534. onLoading(): void;
  69535. /** @hidden */
  69536. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69537. private _loadLightAsync;
  69538. }
  69539. }
  69540. declare module BABYLON.GLTF2.Loader.Extensions {
  69541. /**
  69542. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69543. */
  69544. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69545. /** The name of this extension. */
  69546. readonly name: string;
  69547. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69548. dracoCompression?: DracoCompression;
  69549. /** Defines whether this extension is enabled. */
  69550. enabled: boolean;
  69551. private _loader;
  69552. /** @hidden */
  69553. constructor(loader: GLTFLoader);
  69554. /** @hidden */
  69555. dispose(): void;
  69556. /** @hidden */
  69557. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69558. }
  69559. }
  69560. declare module BABYLON.GLTF2.Loader.Extensions {
  69561. /**
  69562. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  69563. */
  69564. export class KHR_lights implements IGLTFLoaderExtension {
  69565. /** The name of this extension. */
  69566. readonly name: string;
  69567. /** Defines whether this extension is enabled. */
  69568. enabled: boolean;
  69569. private _loader;
  69570. private _lights?;
  69571. /** @hidden */
  69572. constructor(loader: GLTFLoader);
  69573. /** @hidden */
  69574. dispose(): void;
  69575. /** @hidden */
  69576. onLoading(): void;
  69577. /** @hidden */
  69578. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69579. }
  69580. }
  69581. declare module BABYLON.GLTF2.Loader.Extensions {
  69582. /**
  69583. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69584. */
  69585. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69586. /** The name of this extension. */
  69587. readonly name: string;
  69588. /** Defines whether this extension is enabled. */
  69589. enabled: boolean;
  69590. private _loader;
  69591. /** @hidden */
  69592. constructor(loader: GLTFLoader);
  69593. /** @hidden */
  69594. dispose(): void;
  69595. /** @hidden */
  69596. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69597. private _loadSpecularGlossinessPropertiesAsync;
  69598. }
  69599. }
  69600. declare module BABYLON.GLTF2.Loader.Extensions {
  69601. /**
  69602. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69603. */
  69604. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69605. /** The name of this extension. */
  69606. readonly name: string;
  69607. /** Defines whether this extension is enabled. */
  69608. enabled: boolean;
  69609. private _loader;
  69610. /** @hidden */
  69611. constructor(loader: GLTFLoader);
  69612. /** @hidden */
  69613. dispose(): void;
  69614. /** @hidden */
  69615. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69616. private _loadUnlitPropertiesAsync;
  69617. }
  69618. }
  69619. declare module BABYLON.GLTF2.Loader.Extensions {
  69620. /**
  69621. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69622. */
  69623. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69624. /** The name of this extension. */
  69625. readonly name: string;
  69626. /** Defines whether this extension is enabled. */
  69627. enabled: boolean;
  69628. private _loader;
  69629. /** @hidden */
  69630. constructor(loader: GLTFLoader);
  69631. /** @hidden */
  69632. dispose(): void;
  69633. /** @hidden */
  69634. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69635. }
  69636. }
  69637. declare module BABYLON.GLTF2.Loader.Extensions {
  69638. /**
  69639. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69640. */
  69641. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69642. /** The name of this extension. */
  69643. readonly name: string;
  69644. /** Defines whether this extension is enabled. */
  69645. enabled: boolean;
  69646. private _loader;
  69647. private _clips;
  69648. private _emitters;
  69649. /** @hidden */
  69650. constructor(loader: GLTFLoader);
  69651. /** @hidden */
  69652. dispose(): void;
  69653. /** @hidden */
  69654. onLoading(): void;
  69655. /** @hidden */
  69656. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69657. /** @hidden */
  69658. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69659. /** @hidden */
  69660. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69661. private _loadClipAsync;
  69662. private _loadEmitterAsync;
  69663. private _getEventAction;
  69664. private _loadAnimationEventAsync;
  69665. }
  69666. }
  69667. declare module BABYLON.GLTF2.Loader.Extensions {
  69668. /**
  69669. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69670. */
  69671. export class MSFT_lod implements IGLTFLoaderExtension {
  69672. /** The name of this extension. */
  69673. readonly name: string;
  69674. /** Defines whether this extension is enabled. */
  69675. enabled: boolean;
  69676. /**
  69677. * Maximum number of LODs to load, starting from the lowest LOD.
  69678. */
  69679. maxLODsToLoad: number;
  69680. /**
  69681. * Observable raised when all node LODs of one level are loaded.
  69682. * The event data is the index of the loaded LOD starting from zero.
  69683. * Dispose the loader to cancel the loading of the next level of LODs.
  69684. */
  69685. onNodeLODsLoadedObservable: Observable<number>;
  69686. /**
  69687. * Observable raised when all material LODs of one level are loaded.
  69688. * The event data is the index of the loaded LOD starting from zero.
  69689. * Dispose the loader to cancel the loading of the next level of LODs.
  69690. */
  69691. onMaterialLODsLoadedObservable: Observable<number>;
  69692. private _loader;
  69693. private _nodeIndexLOD;
  69694. private _nodeSignalLODs;
  69695. private _nodePromiseLODs;
  69696. private _materialIndexLOD;
  69697. private _materialSignalLODs;
  69698. private _materialPromiseLODs;
  69699. /** @hidden */
  69700. constructor(loader: GLTFLoader);
  69701. /** @hidden */
  69702. dispose(): void;
  69703. /** @hidden */
  69704. onReady(): void;
  69705. /** @hidden */
  69706. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69707. /** @hidden */
  69708. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69709. /** @hidden */
  69710. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69711. /**
  69712. * Gets an array of LOD properties from lowest to highest.
  69713. */
  69714. private _getLODs;
  69715. private _disposeUnusedMaterials;
  69716. }
  69717. }
  69718. declare module BABYLON.GLTF2.Loader.Extensions {
  69719. /** @hidden */
  69720. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69721. readonly name: string;
  69722. enabled: boolean;
  69723. private _loader;
  69724. constructor(loader: GLTFLoader);
  69725. dispose(): void;
  69726. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69727. }
  69728. }
  69729. declare module BABYLON.GLTF2.Loader.Extensions {
  69730. /** @hidden */
  69731. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69732. readonly name: string;
  69733. enabled: boolean;
  69734. private _loader;
  69735. constructor(loader: GLTFLoader);
  69736. dispose(): void;
  69737. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69738. }
  69739. }
  69740. declare module BABYLON.GLTF2.Loader.Extensions {
  69741. /**
  69742. * Store glTF extras (if present) in BJS objects' metadata
  69743. */
  69744. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69745. /** The name of this extension. */
  69746. readonly name: string;
  69747. /** Defines whether this extension is enabled. */
  69748. enabled: boolean;
  69749. private _loader;
  69750. private _assignExtras;
  69751. /** @hidden */
  69752. constructor(loader: GLTFLoader);
  69753. /** @hidden */
  69754. dispose(): void;
  69755. /** @hidden */
  69756. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69757. /** @hidden */
  69758. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69759. /** @hidden */
  69760. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69761. }
  69762. }
  69763. declare module BABYLON {
  69764. /**
  69765. * Class reading and parsing the MTL file bundled with the obj file.
  69766. */
  69767. export class MTLFileLoader {
  69768. /**
  69769. * All material loaded from the mtl will be set here
  69770. */
  69771. materials: StandardMaterial[];
  69772. /**
  69773. * This function will read the mtl file and create each material described inside
  69774. * This function could be improve by adding :
  69775. * -some component missing (Ni, Tf...)
  69776. * -including the specific options available
  69777. *
  69778. * @param scene defines the scene the material will be created in
  69779. * @param data defines the mtl data to parse
  69780. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69781. */
  69782. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69783. /**
  69784. * Gets the texture for the material.
  69785. *
  69786. * If the material is imported from input file,
  69787. * We sanitize the url to ensure it takes the textre from aside the material.
  69788. *
  69789. * @param rootUrl The root url to load from
  69790. * @param value The value stored in the mtl
  69791. * @return The Texture
  69792. */
  69793. private static _getTexture;
  69794. }
  69795. /**
  69796. * Options for loading OBJ/MTL files
  69797. */
  69798. type MeshLoadOptions = {
  69799. /**
  69800. * Defines if UVs are optimized by default during load.
  69801. */
  69802. OptimizeWithUV: boolean;
  69803. /**
  69804. * Defines custom scaling of UV coordinates of loaded meshes.
  69805. */
  69806. UVScaling: Vector2;
  69807. /**
  69808. * Invert model on y-axis (does a model scaling inversion)
  69809. */
  69810. InvertY: boolean;
  69811. /**
  69812. * Invert Y-Axis of referenced textures on load
  69813. */
  69814. InvertTextureY: boolean;
  69815. /**
  69816. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69817. */
  69818. ImportVertexColors: boolean;
  69819. /**
  69820. * Compute the normals for the model, even if normals are present in the file.
  69821. */
  69822. ComputeNormals: boolean;
  69823. /**
  69824. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69825. */
  69826. SkipMaterials: boolean;
  69827. /**
  69828. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69829. */
  69830. MaterialLoadingFailsSilently: boolean;
  69831. };
  69832. /**
  69833. * OBJ file type loader.
  69834. * This is a babylon scene loader plugin.
  69835. */
  69836. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  69837. /**
  69838. * Defines if UVs are optimized by default during load.
  69839. */
  69840. static OPTIMIZE_WITH_UV: boolean;
  69841. /**
  69842. * Invert model on y-axis (does a model scaling inversion)
  69843. */
  69844. static INVERT_Y: boolean;
  69845. /**
  69846. * Invert Y-Axis of referenced textures on load
  69847. */
  69848. static INVERT_TEXTURE_Y: boolean;
  69849. /**
  69850. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  69851. */
  69852. static IMPORT_VERTEX_COLORS: boolean;
  69853. /**
  69854. * Compute the normals for the model, even if normals are present in the file.
  69855. */
  69856. static COMPUTE_NORMALS: boolean;
  69857. /**
  69858. * Defines custom scaling of UV coordinates of loaded meshes.
  69859. */
  69860. static UV_SCALING: Vector2;
  69861. /**
  69862. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69863. */
  69864. static SKIP_MATERIALS: boolean;
  69865. /**
  69866. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69867. *
  69868. * Defaults to true for backwards compatibility.
  69869. */
  69870. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69871. /**
  69872. * Defines the name of the plugin.
  69873. */
  69874. name: string;
  69875. /**
  69876. * Defines the extension the plugin is able to load.
  69877. */
  69878. extensions: string;
  69879. /** @hidden */
  69880. obj: RegExp;
  69881. /** @hidden */
  69882. group: RegExp;
  69883. /** @hidden */
  69884. mtllib: RegExp;
  69885. /** @hidden */
  69886. usemtl: RegExp;
  69887. /** @hidden */
  69888. smooth: RegExp;
  69889. /** @hidden */
  69890. vertexPattern: RegExp;
  69891. /** @hidden */
  69892. normalPattern: RegExp;
  69893. /** @hidden */
  69894. uvPattern: RegExp;
  69895. /** @hidden */
  69896. facePattern1: RegExp;
  69897. /** @hidden */
  69898. facePattern2: RegExp;
  69899. /** @hidden */
  69900. facePattern3: RegExp;
  69901. /** @hidden */
  69902. facePattern4: RegExp;
  69903. /** @hidden */
  69904. facePattern5: RegExp;
  69905. private _meshLoadOptions;
  69906. /**
  69907. * Creates loader for .OBJ files
  69908. *
  69909. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69910. */
  69911. constructor(meshLoadOptions?: MeshLoadOptions);
  69912. private static readonly currentMeshLoadOptions;
  69913. /**
  69914. * Calls synchronously the MTL file attached to this obj.
  69915. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69916. * Without this function materials are not displayed in the first frame (but displayed after).
  69917. * In consequence it is impossible to get material information in your HTML file
  69918. *
  69919. * @param url The URL of the MTL file
  69920. * @param rootUrl
  69921. * @param onSuccess Callback function to be called when the MTL file is loaded
  69922. * @private
  69923. */
  69924. private _loadMTL;
  69925. /**
  69926. * Instantiates a OBJ file loader plugin.
  69927. * @returns the created plugin
  69928. */
  69929. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69930. /**
  69931. * If the data string can be loaded directly.
  69932. *
  69933. * @param data string containing the file data
  69934. * @returns if the data can be loaded directly
  69935. */
  69936. canDirectLoad(data: string): boolean;
  69937. /**
  69938. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69939. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69940. * @param scene the scene the meshes should be added to
  69941. * @param data the OBJ data to load
  69942. * @param rootUrl root url to load from
  69943. * @param onProgress event that fires when loading progress has occured
  69944. * @param fileName Defines the name of the file to load
  69945. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69946. */
  69947. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69948. meshes: AbstractMesh[];
  69949. particleSystems: IParticleSystem[];
  69950. skeletons: Skeleton[];
  69951. animationGroups: AnimationGroup[];
  69952. }>;
  69953. /**
  69954. * Imports all objects from the loaded OBJ data and adds them to the scene
  69955. * @param scene the scene the objects should be added to
  69956. * @param data the OBJ data to load
  69957. * @param rootUrl root url to load from
  69958. * @param onProgress event that fires when loading progress has occured
  69959. * @param fileName Defines the name of the file to load
  69960. * @returns a promise which completes when objects have been loaded to the scene
  69961. */
  69962. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69963. /**
  69964. * Load into an asset container.
  69965. * @param scene The scene to load into
  69966. * @param data The data to import
  69967. * @param rootUrl The root url for scene and resources
  69968. * @param onProgress The callback when the load progresses
  69969. * @param fileName Defines the name of the file to load
  69970. * @returns The loaded asset container
  69971. */
  69972. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69973. /**
  69974. * Read the OBJ file and create an Array of meshes.
  69975. * Each mesh contains all information given by the OBJ and the MTL file.
  69976. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69977. *
  69978. * @param meshesNames
  69979. * @param scene Scene The scene where are displayed the data
  69980. * @param data String The content of the obj file
  69981. * @param rootUrl String The path to the folder
  69982. * @returns Array<AbstractMesh>
  69983. * @private
  69984. */
  69985. private _parseSolid;
  69986. }
  69987. }
  69988. declare module BABYLON {
  69989. /**
  69990. * STL file type loader.
  69991. * This is a babylon scene loader plugin.
  69992. */
  69993. export class STLFileLoader implements ISceneLoaderPlugin {
  69994. /** @hidden */
  69995. solidPattern: RegExp;
  69996. /** @hidden */
  69997. facetsPattern: RegExp;
  69998. /** @hidden */
  69999. normalPattern: RegExp;
  70000. /** @hidden */
  70001. vertexPattern: RegExp;
  70002. /**
  70003. * Defines the name of the plugin.
  70004. */
  70005. name: string;
  70006. /**
  70007. * Defines the extensions the stl loader is able to load.
  70008. * force data to come in as an ArrayBuffer
  70009. * we'll convert to string if it looks like it's an ASCII .stl
  70010. */
  70011. extensions: ISceneLoaderPluginExtensions;
  70012. /**
  70013. * Import meshes into a scene.
  70014. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70015. * @param scene The scene to import into
  70016. * @param data The data to import
  70017. * @param rootUrl The root url for scene and resources
  70018. * @param meshes The meshes array to import into
  70019. * @param particleSystems The particle systems array to import into
  70020. * @param skeletons The skeletons array to import into
  70021. * @param onError The callback when import fails
  70022. * @returns True if successful or false otherwise
  70023. */
  70024. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70025. /**
  70026. * Load into a scene.
  70027. * @param scene The scene to load into
  70028. * @param data The data to import
  70029. * @param rootUrl The root url for scene and resources
  70030. * @param onError The callback when import fails
  70031. * @returns true if successful or false otherwise
  70032. */
  70033. load(scene: Scene, data: any, rootUrl: string): boolean;
  70034. /**
  70035. * Load into an asset container.
  70036. * @param scene The scene to load into
  70037. * @param data The data to import
  70038. * @param rootUrl The root url for scene and resources
  70039. * @param onError The callback when import fails
  70040. * @returns The loaded asset container
  70041. */
  70042. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70043. private _isBinary;
  70044. private _parseBinary;
  70045. private _parseASCII;
  70046. }
  70047. }
  70048. declare module BABYLON {
  70049. /**
  70050. * Class for generating OBJ data from a Babylon scene.
  70051. */
  70052. export class OBJExport {
  70053. /**
  70054. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70055. * @param mesh defines the list of meshes to serialize
  70056. * @param materials defines if materials should be exported
  70057. * @param matlibname defines the name of the associated mtl file
  70058. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70059. * @returns the OBJ content
  70060. */
  70061. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70062. /**
  70063. * Exports the material(s) of a mesh in .MTL file format (text)
  70064. * @param mesh defines the mesh to extract the material from
  70065. * @returns the mtl content
  70066. */
  70067. static MTL(mesh: Mesh): string;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /** @hidden */
  70072. export var __IGLTFExporterExtension: number;
  70073. /**
  70074. * Interface for extending the exporter
  70075. * @hidden
  70076. */
  70077. export interface IGLTFExporterExtension {
  70078. /**
  70079. * The name of this extension
  70080. */
  70081. readonly name: string;
  70082. /**
  70083. * Defines whether this extension is enabled
  70084. */
  70085. enabled: boolean;
  70086. /**
  70087. * Defines whether this extension is required
  70088. */
  70089. required: boolean;
  70090. }
  70091. }
  70092. declare module BABYLON.GLTF2.Exporter {
  70093. /** @hidden */
  70094. export var __IGLTFExporterExtensionV2: number;
  70095. /**
  70096. * Interface for a glTF exporter extension
  70097. * @hidden
  70098. */
  70099. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70100. /**
  70101. * Define this method to modify the default behavior before exporting a texture
  70102. * @param context The context when loading the asset
  70103. * @param babylonTexture The glTF texture info property
  70104. * @param mimeType The mime-type of the generated image
  70105. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70106. */
  70107. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70108. /**
  70109. * Define this method to modify the default behavior when exporting texture info
  70110. * @param context The context when loading the asset
  70111. * @param meshPrimitive glTF mesh primitive
  70112. * @param babylonSubMesh Babylon submesh
  70113. * @param binaryWriter glTF serializer binary writer instance
  70114. * @returns nullable IMeshPrimitive promise
  70115. */
  70116. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70117. /**
  70118. * Define this method to modify the default behavior when exporting a node
  70119. * @param context The context when exporting the node
  70120. * @param node glTF node
  70121. * @param babylonNode BabylonJS node
  70122. * @returns nullable INode promise
  70123. */
  70124. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70125. /**
  70126. * Called after the exporter state changes to EXPORTING
  70127. */
  70128. onExporting?(): void;
  70129. }
  70130. }
  70131. declare module BABYLON.GLTF2.Exporter {
  70132. /**
  70133. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70134. * @hidden
  70135. */
  70136. export class _GLTFMaterialExporter {
  70137. /**
  70138. * Represents the dielectric specular values for R, G and B
  70139. */
  70140. private static readonly _DielectricSpecular;
  70141. /**
  70142. * Allows the maximum specular power to be defined for material calculations
  70143. */
  70144. private static readonly _MaxSpecularPower;
  70145. /**
  70146. * Mapping to store textures
  70147. */
  70148. private _textureMap;
  70149. /**
  70150. * Numeric tolerance value
  70151. */
  70152. private static readonly _Epsilon;
  70153. /**
  70154. * Reference to the glTF Exporter
  70155. */
  70156. private _exporter;
  70157. constructor(exporter: _Exporter);
  70158. /**
  70159. * Specifies if two colors are approximately equal in value
  70160. * @param color1 first color to compare to
  70161. * @param color2 second color to compare to
  70162. * @param epsilon threshold value
  70163. */
  70164. private static FuzzyEquals;
  70165. /**
  70166. * Gets the materials from a Babylon scene and converts them to glTF materials
  70167. * @param scene babylonjs scene
  70168. * @param mimeType texture mime type
  70169. * @param images array of images
  70170. * @param textures array of textures
  70171. * @param materials array of materials
  70172. * @param imageData mapping of texture names to base64 textures
  70173. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70174. */
  70175. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70176. /**
  70177. * Makes a copy of the glTF material without the texture parameters
  70178. * @param originalMaterial original glTF material
  70179. * @returns glTF material without texture parameters
  70180. */
  70181. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70182. /**
  70183. * Specifies if the material has any texture parameters present
  70184. * @param material glTF Material
  70185. * @returns boolean specifying if texture parameters are present
  70186. */
  70187. _hasTexturesPresent(material: IMaterial): boolean;
  70188. /**
  70189. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70190. * @param babylonStandardMaterial
  70191. * @returns glTF Metallic Roughness Material representation
  70192. */
  70193. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70194. /**
  70195. * Computes the metallic factor
  70196. * @param diffuse diffused value
  70197. * @param specular specular value
  70198. * @param oneMinusSpecularStrength one minus the specular strength
  70199. * @returns metallic value
  70200. */
  70201. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70202. /**
  70203. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70204. * @param glTFMaterial glTF material
  70205. * @param babylonMaterial Babylon material
  70206. */
  70207. private static _SetAlphaMode;
  70208. /**
  70209. * Converts a Babylon Standard Material to a glTF Material
  70210. * @param babylonStandardMaterial BJS Standard Material
  70211. * @param mimeType mime type to use for the textures
  70212. * @param images array of glTF image interfaces
  70213. * @param textures array of glTF texture interfaces
  70214. * @param materials array of glTF material interfaces
  70215. * @param imageData map of image file name to data
  70216. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70217. */
  70218. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70219. /**
  70220. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70221. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70222. * @param mimeType mime type to use for the textures
  70223. * @param images array of glTF image interfaces
  70224. * @param textures array of glTF texture interfaces
  70225. * @param materials array of glTF material interfaces
  70226. * @param imageData map of image file name to data
  70227. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70228. */
  70229. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70230. /**
  70231. * Converts an image typed array buffer to a base64 image
  70232. * @param buffer typed array buffer
  70233. * @param width width of the image
  70234. * @param height height of the image
  70235. * @param mimeType mimetype of the image
  70236. * @returns base64 image string
  70237. */
  70238. private _createBase64FromCanvasAsync;
  70239. /**
  70240. * Generates a white texture based on the specified width and height
  70241. * @param width width of the texture in pixels
  70242. * @param height height of the texture in pixels
  70243. * @param scene babylonjs scene
  70244. * @returns white texture
  70245. */
  70246. private _createWhiteTexture;
  70247. /**
  70248. * 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
  70249. * @param texture1 first texture to resize
  70250. * @param texture2 second texture to resize
  70251. * @param scene babylonjs scene
  70252. * @returns resized textures or null
  70253. */
  70254. private _resizeTexturesToSameDimensions;
  70255. /**
  70256. * Converts an array of pixels to a Float32Array
  70257. * Throws an error if the pixel format is not supported
  70258. * @param pixels - array buffer containing pixel values
  70259. * @returns Float32 of pixels
  70260. */
  70261. private _convertPixelArrayToFloat32;
  70262. /**
  70263. * Convert Specular Glossiness Textures to Metallic Roughness
  70264. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70265. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70266. * @param diffuseTexture texture used to store diffuse information
  70267. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70268. * @param factors specular glossiness material factors
  70269. * @param mimeType the mime type to use for the texture
  70270. * @returns pbr metallic roughness interface or null
  70271. */
  70272. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70273. /**
  70274. * Converts specular glossiness material properties to metallic roughness
  70275. * @param specularGlossiness interface with specular glossiness material properties
  70276. * @returns interface with metallic roughness material properties
  70277. */
  70278. private _convertSpecularGlossinessToMetallicRoughness;
  70279. /**
  70280. * Calculates the surface reflectance, independent of lighting conditions
  70281. * @param color Color source to calculate brightness from
  70282. * @returns number representing the perceived brightness, or zero if color is undefined
  70283. */
  70284. private _getPerceivedBrightness;
  70285. /**
  70286. * Returns the maximum color component value
  70287. * @param color
  70288. * @returns maximum color component value, or zero if color is null or undefined
  70289. */
  70290. private _getMaxComponent;
  70291. /**
  70292. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70293. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70294. * @param mimeType mime type to use for the textures
  70295. * @param images array of glTF image interfaces
  70296. * @param textures array of glTF texture interfaces
  70297. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70298. * @param imageData map of image file name to data
  70299. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70300. * @returns glTF PBR Metallic Roughness factors
  70301. */
  70302. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70303. private _getGLTFTextureSampler;
  70304. private _getGLTFTextureWrapMode;
  70305. private _getGLTFTextureWrapModesSampler;
  70306. /**
  70307. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70308. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70309. * @param mimeType mime type to use for the textures
  70310. * @param images array of glTF image interfaces
  70311. * @param textures array of glTF texture interfaces
  70312. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70313. * @param imageData map of image file name to data
  70314. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70315. * @returns glTF PBR Metallic Roughness factors
  70316. */
  70317. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70318. /**
  70319. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70320. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70321. * @param mimeType mime type to use for the textures
  70322. * @param images array of glTF image interfaces
  70323. * @param textures array of glTF texture interfaces
  70324. * @param materials array of glTF material interfaces
  70325. * @param imageData map of image file name to data
  70326. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70327. */
  70328. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70329. private setMetallicRoughnessPbrMaterial;
  70330. private getPixelsFromTexture;
  70331. /**
  70332. * Extracts a texture from a Babylon texture into file data and glTF data
  70333. * @param babylonTexture Babylon texture to extract
  70334. * @param mimeType Mime Type of the babylonTexture
  70335. * @return glTF texture info, or null if the texture format is not supported
  70336. */
  70337. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70338. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70339. /**
  70340. * Builds a texture from base64 string
  70341. * @param base64Texture base64 texture string
  70342. * @param baseTextureName Name to use for the texture
  70343. * @param mimeType image mime type for the texture
  70344. * @param images array of images
  70345. * @param textures array of textures
  70346. * @param imageData map of image data
  70347. * @returns glTF texture info, or null if the texture format is not supported
  70348. */
  70349. private _getTextureInfoFromBase64;
  70350. }
  70351. }
  70352. declare module BABYLON {
  70353. /**
  70354. * Class for holding and downloading glTF file data
  70355. */
  70356. export class GLTFData {
  70357. /**
  70358. * Object which contains the file name as the key and its data as the value
  70359. */
  70360. glTFFiles: {
  70361. [fileName: string]: string | Blob;
  70362. };
  70363. /**
  70364. * Initializes the glTF file object
  70365. */
  70366. constructor();
  70367. /**
  70368. * Downloads the glTF data as files based on their names and data
  70369. */
  70370. downloadFiles(): void;
  70371. }
  70372. }
  70373. declare module BABYLON {
  70374. /**
  70375. * Holds a collection of exporter options and parameters
  70376. */
  70377. export interface IExportOptions {
  70378. /**
  70379. * Function which indicates whether a babylon node should be exported or not
  70380. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70381. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70382. */
  70383. shouldExportNode?(node: Node): boolean;
  70384. /**
  70385. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70386. * @param metadata source metadata to read from
  70387. * @returns the data to store to glTF node extras
  70388. */
  70389. metadataSelector?(metadata: any): any;
  70390. /**
  70391. * The sample rate to bake animation curves
  70392. */
  70393. animationSampleRate?: number;
  70394. /**
  70395. * Begin serialization without waiting for the scene to be ready
  70396. */
  70397. exportWithoutWaitingForScene?: boolean;
  70398. }
  70399. /**
  70400. * Class for generating glTF data from a Babylon scene.
  70401. */
  70402. export class GLTF2Export {
  70403. /**
  70404. * Exports the geometry of the scene to .gltf file format asynchronously
  70405. * @param scene Babylon scene with scene hierarchy information
  70406. * @param filePrefix File prefix to use when generating the glTF file
  70407. * @param options Exporter options
  70408. * @returns Returns an object with a .gltf file and associates texture names
  70409. * as keys and their data and paths as values
  70410. */
  70411. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70412. private static _PreExportAsync;
  70413. private static _PostExportAsync;
  70414. /**
  70415. * Exports the geometry of the scene to .glb file format asychronously
  70416. * @param scene Babylon scene with scene hierarchy information
  70417. * @param filePrefix File prefix to use when generating glb file
  70418. * @param options Exporter options
  70419. * @returns Returns an object with a .glb filename as key and data as value
  70420. */
  70421. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70422. }
  70423. }
  70424. declare module BABYLON.GLTF2.Exporter {
  70425. /**
  70426. * @hidden
  70427. */
  70428. export class _GLTFUtilities {
  70429. /**
  70430. * Creates a buffer view based on the supplied arguments
  70431. * @param bufferIndex index value of the specified buffer
  70432. * @param byteOffset byte offset value
  70433. * @param byteLength byte length of the bufferView
  70434. * @param byteStride byte distance between conequential elements
  70435. * @param name name of the buffer view
  70436. * @returns bufferView for glTF
  70437. */
  70438. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70439. /**
  70440. * Creates an accessor based on the supplied arguments
  70441. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70442. * @param name The name of the accessor
  70443. * @param type The type of the accessor
  70444. * @param componentType The datatype of components in the attribute
  70445. * @param count The number of attributes referenced by this accessor
  70446. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70447. * @param min Minimum value of each component in this attribute
  70448. * @param max Maximum value of each component in this attribute
  70449. * @returns accessor for glTF
  70450. */
  70451. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70452. /**
  70453. * Calculates the minimum and maximum values of an array of position floats
  70454. * @param positions Positions array of a mesh
  70455. * @param vertexStart Starting vertex offset to calculate min and max values
  70456. * @param vertexCount Number of vertices to check for min and max values
  70457. * @returns min number array and max number array
  70458. */
  70459. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70460. min: number[];
  70461. max: number[];
  70462. };
  70463. /**
  70464. * Converts a new right-handed Vector3
  70465. * @param vector vector3 array
  70466. * @returns right-handed Vector3
  70467. */
  70468. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70469. /**
  70470. * Converts a Vector3 to right-handed
  70471. * @param vector Vector3 to convert to right-handed
  70472. */
  70473. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70474. /**
  70475. * Converts a three element number array to right-handed
  70476. * @param vector number array to convert to right-handed
  70477. */
  70478. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70479. /**
  70480. * Converts a new right-handed Vector3
  70481. * @param vector vector3 array
  70482. * @returns right-handed Vector3
  70483. */
  70484. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70485. /**
  70486. * Converts a Vector3 to right-handed
  70487. * @param vector Vector3 to convert to right-handed
  70488. */
  70489. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70490. /**
  70491. * Converts a three element number array to right-handed
  70492. * @param vector number array to convert to right-handed
  70493. */
  70494. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70495. /**
  70496. * Converts a Vector4 to right-handed
  70497. * @param vector Vector4 to convert to right-handed
  70498. */
  70499. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70500. /**
  70501. * Converts a Vector4 to right-handed
  70502. * @param vector Vector4 to convert to right-handed
  70503. */
  70504. static _GetRightHandedArray4FromRef(vector: number[]): void;
  70505. /**
  70506. * Converts a Quaternion to right-handed
  70507. * @param quaternion Source quaternion to convert to right-handed
  70508. */
  70509. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70510. /**
  70511. * Converts a Quaternion to right-handed
  70512. * @param quaternion Source quaternion to convert to right-handed
  70513. */
  70514. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  70515. static _NormalizeTangentFromRef(tangent: Vector4): void;
  70516. }
  70517. }
  70518. declare module BABYLON.GLTF2.Exporter {
  70519. /**
  70520. * Converts Babylon Scene into glTF 2.0.
  70521. * @hidden
  70522. */
  70523. export class _Exporter {
  70524. /**
  70525. * Stores the glTF to export
  70526. */
  70527. _glTF: IGLTF;
  70528. /**
  70529. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70530. */
  70531. _bufferViews: IBufferView[];
  70532. /**
  70533. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70534. */
  70535. _accessors: IAccessor[];
  70536. /**
  70537. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70538. */
  70539. private _nodes;
  70540. /**
  70541. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70542. */
  70543. private _scenes;
  70544. /**
  70545. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70546. */
  70547. private _meshes;
  70548. /**
  70549. * Stores all the generated material information, which represents the appearance of each primitive
  70550. */
  70551. _materials: IMaterial[];
  70552. _materialMap: {
  70553. [materialID: number]: number;
  70554. };
  70555. /**
  70556. * Stores all the generated texture information, which is referenced by glTF materials
  70557. */
  70558. _textures: ITexture[];
  70559. /**
  70560. * Stores all the generated image information, which is referenced by glTF textures
  70561. */
  70562. _images: IImage[];
  70563. /**
  70564. * Stores all the texture samplers
  70565. */
  70566. _samplers: ISampler[];
  70567. /**
  70568. * Stores all the generated animation samplers, which is referenced by glTF animations
  70569. */
  70570. /**
  70571. * Stores the animations for glTF models
  70572. */
  70573. private _animations;
  70574. /**
  70575. * Stores the total amount of bytes stored in the glTF buffer
  70576. */
  70577. private _totalByteLength;
  70578. /**
  70579. * Stores a reference to the Babylon scene containing the source geometry and material information
  70580. */
  70581. _babylonScene: Scene;
  70582. /**
  70583. * Stores a map of the image data, where the key is the file name and the value
  70584. * is the image data
  70585. */
  70586. _imageData: {
  70587. [fileName: string]: {
  70588. data: Uint8Array;
  70589. mimeType: ImageMimeType;
  70590. };
  70591. };
  70592. /**
  70593. * Stores a map of the unique id of a node to its index in the node array
  70594. */
  70595. private _nodeMap;
  70596. /**
  70597. * Specifies if the Babylon scene should be converted to right-handed on export
  70598. */
  70599. _convertToRightHandedSystem: boolean;
  70600. /**
  70601. * Baked animation sample rate
  70602. */
  70603. private _animationSampleRate;
  70604. private _options;
  70605. private _localEngine;
  70606. _glTFMaterialExporter: _GLTFMaterialExporter;
  70607. private _extensions;
  70608. private static _ExtensionNames;
  70609. private static _ExtensionFactories;
  70610. private _applyExtensions;
  70611. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70612. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70613. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70614. private _forEachExtensions;
  70615. private _extensionsOnExporting;
  70616. /**
  70617. * Load glTF serializer extensions
  70618. */
  70619. private _loadExtensions;
  70620. /**
  70621. * Creates a glTF Exporter instance, which can accept optional exporter options
  70622. * @param babylonScene Babylon scene object
  70623. * @param options Options to modify the behavior of the exporter
  70624. */
  70625. constructor(babylonScene: Scene, options?: IExportOptions);
  70626. /**
  70627. * Registers a glTF exporter extension
  70628. * @param name Name of the extension to export
  70629. * @param factory The factory function that creates the exporter extension
  70630. */
  70631. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70632. /**
  70633. * Un-registers an exporter extension
  70634. * @param name The name fo the exporter extension
  70635. * @returns A boolean indicating whether the extension has been un-registered
  70636. */
  70637. static UnregisterExtension(name: string): boolean;
  70638. /**
  70639. * Lazy load a local engine with premultiplied alpha set to false
  70640. */
  70641. _getLocalEngine(): Engine;
  70642. private reorderIndicesBasedOnPrimitiveMode;
  70643. /**
  70644. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70645. * clock-wise during export to glTF
  70646. * @param submesh BabylonJS submesh
  70647. * @param primitiveMode Primitive mode of the mesh
  70648. * @param sideOrientation the winding order of the submesh
  70649. * @param vertexBufferKind The type of vertex attribute
  70650. * @param meshAttributeArray The vertex attribute data
  70651. * @param byteOffset The offset to the binary data
  70652. * @param binaryWriter The binary data for the glTF file
  70653. */
  70654. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70655. /**
  70656. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70657. * clock-wise during export to glTF
  70658. * @param submesh BabylonJS submesh
  70659. * @param primitiveMode Primitive mode of the mesh
  70660. * @param sideOrientation the winding order of the submesh
  70661. * @param vertexBufferKind The type of vertex attribute
  70662. * @param meshAttributeArray The vertex attribute data
  70663. * @param byteOffset The offset to the binary data
  70664. * @param binaryWriter The binary data for the glTF file
  70665. */
  70666. private reorderTriangleFillMode;
  70667. /**
  70668. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70669. * clock-wise during export to glTF
  70670. * @param submesh BabylonJS submesh
  70671. * @param primitiveMode Primitive mode of the mesh
  70672. * @param sideOrientation the winding order of the submesh
  70673. * @param vertexBufferKind The type of vertex attribute
  70674. * @param meshAttributeArray The vertex attribute data
  70675. * @param byteOffset The offset to the binary data
  70676. * @param binaryWriter The binary data for the glTF file
  70677. */
  70678. private reorderTriangleStripDrawMode;
  70679. /**
  70680. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70681. * clock-wise during export to glTF
  70682. * @param submesh BabylonJS submesh
  70683. * @param primitiveMode Primitive mode of the mesh
  70684. * @param sideOrientation the winding order of the submesh
  70685. * @param vertexBufferKind The type of vertex attribute
  70686. * @param meshAttributeArray The vertex attribute data
  70687. * @param byteOffset The offset to the binary data
  70688. * @param binaryWriter The binary data for the glTF file
  70689. */
  70690. private reorderTriangleFanMode;
  70691. /**
  70692. * Writes the vertex attribute data to binary
  70693. * @param vertices The vertices to write to the binary writer
  70694. * @param byteOffset The offset into the binary writer to overwrite binary data
  70695. * @param vertexAttributeKind The vertex attribute type
  70696. * @param meshAttributeArray The vertex attribute data
  70697. * @param binaryWriter The writer containing the binary data
  70698. */
  70699. private writeVertexAttributeData;
  70700. /**
  70701. * Writes mesh attribute data to a data buffer
  70702. * Returns the bytelength of the data
  70703. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70704. * @param meshAttributeArray Array containing the attribute data
  70705. * @param binaryWriter The buffer to write the binary data to
  70706. * @param indices Used to specify the order of the vertex data
  70707. */
  70708. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70709. /**
  70710. * Generates glTF json data
  70711. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70712. * @param glTFPrefix Text to use when prefixing a glTF file
  70713. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70714. * @returns json data as string
  70715. */
  70716. private generateJSON;
  70717. /**
  70718. * Generates data for .gltf and .bin files based on the glTF prefix string
  70719. * @param glTFPrefix Text to use when prefixing a glTF file
  70720. * @returns GLTFData with glTF file data
  70721. */
  70722. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70723. /**
  70724. * Creates a binary buffer for glTF
  70725. * @returns array buffer for binary data
  70726. */
  70727. private _generateBinaryAsync;
  70728. /**
  70729. * Pads the number to a multiple of 4
  70730. * @param num number to pad
  70731. * @returns padded number
  70732. */
  70733. private _getPadding;
  70734. /**
  70735. * Generates a glb file from the json and binary data
  70736. * Returns an object with the glb file name as the key and data as the value
  70737. * @param glTFPrefix
  70738. * @returns object with glb filename as key and data as value
  70739. */
  70740. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70741. /**
  70742. * Sets the TRS for each node
  70743. * @param node glTF Node for storing the transformation data
  70744. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70745. */
  70746. private setNodeTransformation;
  70747. private getVertexBufferFromMesh;
  70748. /**
  70749. * Creates a bufferview based on the vertices type for the Babylon mesh
  70750. * @param kind Indicates the type of vertices data
  70751. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70752. * @param binaryWriter The buffer to write the bufferview data to
  70753. */
  70754. private createBufferViewKind;
  70755. /**
  70756. * The primitive mode of the Babylon mesh
  70757. * @param babylonMesh The BabylonJS mesh
  70758. */
  70759. private getMeshPrimitiveMode;
  70760. /**
  70761. * Sets the primitive mode of the glTF mesh primitive
  70762. * @param meshPrimitive glTF mesh primitive
  70763. * @param primitiveMode The primitive mode
  70764. */
  70765. private setPrimitiveMode;
  70766. /**
  70767. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70768. * @param meshPrimitive glTF mesh primitive
  70769. * @param attributeKind vertex attribute
  70770. * @returns boolean specifying if uv coordinates are present
  70771. */
  70772. private setAttributeKind;
  70773. /**
  70774. * Sets data for the primitive attributes of each submesh
  70775. * @param mesh glTF Mesh object to store the primitive attribute information
  70776. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70777. * @param binaryWriter Buffer to write the attribute data to
  70778. */
  70779. private setPrimitiveAttributesAsync;
  70780. /**
  70781. * Creates a glTF scene based on the array of meshes
  70782. * Returns the the total byte offset
  70783. * @param babylonScene Babylon scene to get the mesh data from
  70784. * @param binaryWriter Buffer to write binary data to
  70785. */
  70786. private createSceneAsync;
  70787. /**
  70788. * Creates a mapping of Node unique id to node index and handles animations
  70789. * @param babylonScene Babylon Scene
  70790. * @param nodes Babylon transform nodes
  70791. * @param binaryWriter Buffer to write binary data to
  70792. * @returns Node mapping of unique id to index
  70793. */
  70794. private createNodeMapAndAnimationsAsync;
  70795. /**
  70796. * Creates a glTF node from a Babylon mesh
  70797. * @param babylonMesh Source Babylon mesh
  70798. * @param binaryWriter Buffer for storing geometry data
  70799. * @returns glTF node
  70800. */
  70801. private createNodeAsync;
  70802. }
  70803. /**
  70804. * @hidden
  70805. *
  70806. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  70807. */
  70808. export class _BinaryWriter {
  70809. /**
  70810. * Array buffer which stores all binary data
  70811. */
  70812. private _arrayBuffer;
  70813. /**
  70814. * View of the array buffer
  70815. */
  70816. private _dataView;
  70817. /**
  70818. * byte offset of data in array buffer
  70819. */
  70820. private _byteOffset;
  70821. /**
  70822. * Initialize binary writer with an initial byte length
  70823. * @param byteLength Initial byte length of the array buffer
  70824. */
  70825. constructor(byteLength: number);
  70826. /**
  70827. * Resize the array buffer to the specified byte length
  70828. * @param byteLength
  70829. */
  70830. private resizeBuffer;
  70831. /**
  70832. * Get an array buffer with the length of the byte offset
  70833. * @returns ArrayBuffer resized to the byte offset
  70834. */
  70835. getArrayBuffer(): ArrayBuffer;
  70836. /**
  70837. * Get the byte offset of the array buffer
  70838. * @returns byte offset
  70839. */
  70840. getByteOffset(): number;
  70841. /**
  70842. * Stores an UInt8 in the array buffer
  70843. * @param entry
  70844. * @param byteOffset If defined, specifies where to set the value as an offset.
  70845. */
  70846. setUInt8(entry: number, byteOffset?: number): void;
  70847. /**
  70848. * Gets an UInt32 in the array buffer
  70849. * @param entry
  70850. * @param byteOffset If defined, specifies where to set the value as an offset.
  70851. */
  70852. getUInt32(byteOffset: number): number;
  70853. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70854. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  70855. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70856. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  70857. /**
  70858. * Stores a Float32 in the array buffer
  70859. * @param entry
  70860. */
  70861. setFloat32(entry: number, byteOffset?: number): void;
  70862. /**
  70863. * Stores an UInt32 in the array buffer
  70864. * @param entry
  70865. * @param byteOffset If defined, specifies where to set the value as an offset.
  70866. */
  70867. setUInt32(entry: number, byteOffset?: number): void;
  70868. }
  70869. }
  70870. declare module BABYLON.GLTF2.Exporter {
  70871. /**
  70872. * @hidden
  70873. * Interface to store animation data.
  70874. */
  70875. export interface _IAnimationData {
  70876. /**
  70877. * Keyframe data.
  70878. */
  70879. inputs: number[];
  70880. /**
  70881. * Value data.
  70882. */
  70883. outputs: number[][];
  70884. /**
  70885. * Animation interpolation data.
  70886. */
  70887. samplerInterpolation: AnimationSamplerInterpolation;
  70888. /**
  70889. * Minimum keyframe value.
  70890. */
  70891. inputsMin: number;
  70892. /**
  70893. * Maximum keyframe value.
  70894. */
  70895. inputsMax: number;
  70896. }
  70897. /**
  70898. * @hidden
  70899. */
  70900. export interface _IAnimationInfo {
  70901. /**
  70902. * The target channel for the animation
  70903. */
  70904. animationChannelTargetPath: AnimationChannelTargetPath;
  70905. /**
  70906. * The glTF accessor type for the data.
  70907. */
  70908. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70909. /**
  70910. * Specifies if quaternions should be used.
  70911. */
  70912. useQuaternion: boolean;
  70913. }
  70914. /**
  70915. * @hidden
  70916. * Utility class for generating glTF animation data from BabylonJS.
  70917. */
  70918. export class _GLTFAnimation {
  70919. /**
  70920. * @ignore
  70921. *
  70922. * Creates glTF channel animation from BabylonJS animation.
  70923. * @param babylonTransformNode - BabylonJS mesh.
  70924. * @param animation - animation.
  70925. * @param animationChannelTargetPath - The target animation channel.
  70926. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70927. * @param useQuaternion - Specifies if quaternions are used.
  70928. * @returns nullable IAnimationData
  70929. */
  70930. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70931. private static _DeduceAnimationInfo;
  70932. /**
  70933. * @ignore
  70934. * Create node animations from the transform node animations
  70935. * @param babylonNode
  70936. * @param runtimeGLTFAnimation
  70937. * @param idleGLTFAnimations
  70938. * @param nodeMap
  70939. * @param nodes
  70940. * @param binaryWriter
  70941. * @param bufferViews
  70942. * @param accessors
  70943. * @param convertToRightHandedSystem
  70944. */
  70945. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70946. [key: number]: number;
  70947. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70948. /**
  70949. * @ignore
  70950. * Create node animations from the animation groups
  70951. * @param babylonScene
  70952. * @param glTFAnimations
  70953. * @param nodeMap
  70954. * @param nodes
  70955. * @param binaryWriter
  70956. * @param bufferViews
  70957. * @param accessors
  70958. * @param convertToRightHandedSystem
  70959. */
  70960. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70961. [key: number]: number;
  70962. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70963. private static AddAnimation;
  70964. /**
  70965. * Create a baked animation
  70966. * @param babylonTransformNode BabylonJS mesh
  70967. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70968. * @param animationChannelTargetPath animation target channel
  70969. * @param minFrame minimum animation frame
  70970. * @param maxFrame maximum animation frame
  70971. * @param fps frames per second of the animation
  70972. * @param inputs input key frames of the animation
  70973. * @param outputs output key frame data of the animation
  70974. * @param convertToRightHandedSystem converts the values to right-handed
  70975. * @param useQuaternion specifies if quaternions should be used
  70976. */
  70977. private static _CreateBakedAnimation;
  70978. private static _ConvertFactorToVector3OrQuaternion;
  70979. private static _SetInterpolatedValue;
  70980. /**
  70981. * Creates linear animation from the animation key frames
  70982. * @param babylonTransformNode BabylonJS mesh
  70983. * @param animation BabylonJS animation
  70984. * @param animationChannelTargetPath The target animation channel
  70985. * @param frameDelta The difference between the last and first frame of the animation
  70986. * @param inputs Array to store the key frame times
  70987. * @param outputs Array to store the key frame data
  70988. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70989. * @param useQuaternion Specifies if quaternions are used in the animation
  70990. */
  70991. private static _CreateLinearOrStepAnimation;
  70992. /**
  70993. * Creates cubic spline animation from the animation key frames
  70994. * @param babylonTransformNode BabylonJS mesh
  70995. * @param animation BabylonJS animation
  70996. * @param animationChannelTargetPath The target animation channel
  70997. * @param frameDelta The difference between the last and first frame of the animation
  70998. * @param inputs Array to store the key frame times
  70999. * @param outputs Array to store the key frame data
  71000. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71001. * @param useQuaternion Specifies if quaternions are used in the animation
  71002. */
  71003. private static _CreateCubicSplineAnimation;
  71004. private static _GetBasePositionRotationOrScale;
  71005. /**
  71006. * Adds a key frame value
  71007. * @param keyFrame
  71008. * @param animation
  71009. * @param outputs
  71010. * @param animationChannelTargetPath
  71011. * @param basePositionRotationOrScale
  71012. * @param convertToRightHandedSystem
  71013. * @param useQuaternion
  71014. */
  71015. private static _AddKeyframeValue;
  71016. /**
  71017. * Determine the interpolation based on the key frames
  71018. * @param keyFrames
  71019. * @param animationChannelTargetPath
  71020. * @param useQuaternion
  71021. */
  71022. private static _DeduceInterpolation;
  71023. /**
  71024. * Adds an input tangent or output tangent to the output data
  71025. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71026. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71027. * @param outputs The animation data by keyframe
  71028. * @param animationChannelTargetPath The target animation channel
  71029. * @param interpolation The interpolation type
  71030. * @param keyFrame The key frame with the animation data
  71031. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71032. * @param useQuaternion Specifies if quaternions are used
  71033. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71034. */
  71035. private static AddSplineTangent;
  71036. /**
  71037. * Get the minimum and maximum key frames' frame values
  71038. * @param keyFrames animation key frames
  71039. * @returns the minimum and maximum key frame value
  71040. */
  71041. private static calculateMinMaxKeyFrames;
  71042. }
  71043. }
  71044. declare module BABYLON.GLTF2.Exporter {
  71045. /** @hidden */
  71046. export var textureTransformPixelShader: {
  71047. name: string;
  71048. shader: string;
  71049. };
  71050. }
  71051. declare module BABYLON.GLTF2.Exporter.Extensions {
  71052. /**
  71053. * @hidden
  71054. */
  71055. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71056. /** Name of this extension */
  71057. readonly name: string;
  71058. /** Defines whether this extension is enabled */
  71059. enabled: boolean;
  71060. /** Defines whether this extension is required */
  71061. required: boolean;
  71062. /** Reference to the glTF exporter */
  71063. private _exporter;
  71064. constructor(exporter: _Exporter);
  71065. dispose(): void;
  71066. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71067. /**
  71068. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71069. * @param babylonTexture
  71070. * @param offset
  71071. * @param rotation
  71072. * @param scale
  71073. * @param scene
  71074. */
  71075. private _textureTransformTextureAsync;
  71076. }
  71077. }
  71078. declare module BABYLON.GLTF2.Exporter.Extensions {
  71079. /**
  71080. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71081. */
  71082. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71083. /** The name of this extension. */
  71084. readonly name: string;
  71085. /** Defines whether this extension is enabled. */
  71086. enabled: boolean;
  71087. /** Defines whether this extension is required */
  71088. required: boolean;
  71089. /** Reference to the glTF exporter */
  71090. private _exporter;
  71091. private _lights;
  71092. /** @hidden */
  71093. constructor(exporter: _Exporter);
  71094. /** @hidden */
  71095. dispose(): void;
  71096. /** @hidden */
  71097. onExporting(): void;
  71098. /**
  71099. * Define this method to modify the default behavior when exporting a node
  71100. * @param context The context when exporting the node
  71101. * @param node glTF node
  71102. * @param babylonNode BabylonJS node
  71103. * @returns nullable INode promise
  71104. */
  71105. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71106. }
  71107. }
  71108. declare module BABYLON {
  71109. /**
  71110. * Class for generating STL data from a Babylon scene.
  71111. */
  71112. export class STLExport {
  71113. /**
  71114. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71115. * @param meshes list defines the mesh to serialize
  71116. * @param download triggers the automatic download of the file.
  71117. * @param fileName changes the downloads fileName.
  71118. * @param binary changes the STL to a binary type.
  71119. * @param isLittleEndian toggle for binary type exporter.
  71120. * @returns the STL as UTF8 string
  71121. */
  71122. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71123. }
  71124. }
  71125. declare module "babylonjs-gltf2interface" {
  71126. export = BABYLON.GLTF2;
  71127. }
  71128. /**
  71129. * Module for glTF 2.0 Interface
  71130. */
  71131. declare module BABYLON.GLTF2 {
  71132. /**
  71133. * The datatype of the components in the attribute
  71134. */
  71135. const enum AccessorComponentType {
  71136. /**
  71137. * Byte
  71138. */
  71139. BYTE = 5120,
  71140. /**
  71141. * Unsigned Byte
  71142. */
  71143. UNSIGNED_BYTE = 5121,
  71144. /**
  71145. * Short
  71146. */
  71147. SHORT = 5122,
  71148. /**
  71149. * Unsigned Short
  71150. */
  71151. UNSIGNED_SHORT = 5123,
  71152. /**
  71153. * Unsigned Int
  71154. */
  71155. UNSIGNED_INT = 5125,
  71156. /**
  71157. * Float
  71158. */
  71159. FLOAT = 5126,
  71160. }
  71161. /**
  71162. * Specifies if the attirbute is a scalar, vector, or matrix
  71163. */
  71164. const enum AccessorType {
  71165. /**
  71166. * Scalar
  71167. */
  71168. SCALAR = "SCALAR",
  71169. /**
  71170. * Vector2
  71171. */
  71172. VEC2 = "VEC2",
  71173. /**
  71174. * Vector3
  71175. */
  71176. VEC3 = "VEC3",
  71177. /**
  71178. * Vector4
  71179. */
  71180. VEC4 = "VEC4",
  71181. /**
  71182. * Matrix2x2
  71183. */
  71184. MAT2 = "MAT2",
  71185. /**
  71186. * Matrix3x3
  71187. */
  71188. MAT3 = "MAT3",
  71189. /**
  71190. * Matrix4x4
  71191. */
  71192. MAT4 = "MAT4",
  71193. }
  71194. /**
  71195. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71196. */
  71197. const enum AnimationChannelTargetPath {
  71198. /**
  71199. * Translation
  71200. */
  71201. TRANSLATION = "translation",
  71202. /**
  71203. * Rotation
  71204. */
  71205. ROTATION = "rotation",
  71206. /**
  71207. * Scale
  71208. */
  71209. SCALE = "scale",
  71210. /**
  71211. * Weights
  71212. */
  71213. WEIGHTS = "weights",
  71214. }
  71215. /**
  71216. * Interpolation algorithm
  71217. */
  71218. const enum AnimationSamplerInterpolation {
  71219. /**
  71220. * The animated values are linearly interpolated between keyframes
  71221. */
  71222. LINEAR = "LINEAR",
  71223. /**
  71224. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71225. */
  71226. STEP = "STEP",
  71227. /**
  71228. * The animation's interpolation is computed using a cubic spline with specified tangents
  71229. */
  71230. CUBICSPLINE = "CUBICSPLINE",
  71231. }
  71232. /**
  71233. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71234. */
  71235. const enum CameraType {
  71236. /**
  71237. * A perspective camera containing properties to create a perspective projection matrix
  71238. */
  71239. PERSPECTIVE = "perspective",
  71240. /**
  71241. * An orthographic camera containing properties to create an orthographic projection matrix
  71242. */
  71243. ORTHOGRAPHIC = "orthographic",
  71244. }
  71245. /**
  71246. * The mime-type of the image
  71247. */
  71248. const enum ImageMimeType {
  71249. /**
  71250. * JPEG Mime-type
  71251. */
  71252. JPEG = "image/jpeg",
  71253. /**
  71254. * PNG Mime-type
  71255. */
  71256. PNG = "image/png",
  71257. }
  71258. /**
  71259. * The alpha rendering mode of the material
  71260. */
  71261. const enum MaterialAlphaMode {
  71262. /**
  71263. * The alpha value is ignored and the rendered output is fully opaque
  71264. */
  71265. OPAQUE = "OPAQUE",
  71266. /**
  71267. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71268. */
  71269. MASK = "MASK",
  71270. /**
  71271. * 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)
  71272. */
  71273. BLEND = "BLEND",
  71274. }
  71275. /**
  71276. * The type of the primitives to render
  71277. */
  71278. const enum MeshPrimitiveMode {
  71279. /**
  71280. * Points
  71281. */
  71282. POINTS = 0,
  71283. /**
  71284. * Lines
  71285. */
  71286. LINES = 1,
  71287. /**
  71288. * Line Loop
  71289. */
  71290. LINE_LOOP = 2,
  71291. /**
  71292. * Line Strip
  71293. */
  71294. LINE_STRIP = 3,
  71295. /**
  71296. * Triangles
  71297. */
  71298. TRIANGLES = 4,
  71299. /**
  71300. * Triangle Strip
  71301. */
  71302. TRIANGLE_STRIP = 5,
  71303. /**
  71304. * Triangle Fan
  71305. */
  71306. TRIANGLE_FAN = 6,
  71307. }
  71308. /**
  71309. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71310. */
  71311. const enum TextureMagFilter {
  71312. /**
  71313. * Nearest
  71314. */
  71315. NEAREST = 9728,
  71316. /**
  71317. * Linear
  71318. */
  71319. LINEAR = 9729,
  71320. }
  71321. /**
  71322. * Minification filter. All valid values correspond to WebGL enums
  71323. */
  71324. const enum TextureMinFilter {
  71325. /**
  71326. * Nearest
  71327. */
  71328. NEAREST = 9728,
  71329. /**
  71330. * Linear
  71331. */
  71332. LINEAR = 9729,
  71333. /**
  71334. * Nearest Mip-Map Nearest
  71335. */
  71336. NEAREST_MIPMAP_NEAREST = 9984,
  71337. /**
  71338. * Linear Mipmap Nearest
  71339. */
  71340. LINEAR_MIPMAP_NEAREST = 9985,
  71341. /**
  71342. * Nearest Mipmap Linear
  71343. */
  71344. NEAREST_MIPMAP_LINEAR = 9986,
  71345. /**
  71346. * Linear Mipmap Linear
  71347. */
  71348. LINEAR_MIPMAP_LINEAR = 9987,
  71349. }
  71350. /**
  71351. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71352. */
  71353. const enum TextureWrapMode {
  71354. /**
  71355. * Clamp to Edge
  71356. */
  71357. CLAMP_TO_EDGE = 33071,
  71358. /**
  71359. * Mirrored Repeat
  71360. */
  71361. MIRRORED_REPEAT = 33648,
  71362. /**
  71363. * Repeat
  71364. */
  71365. REPEAT = 10497,
  71366. }
  71367. /**
  71368. * glTF Property
  71369. */
  71370. interface IProperty {
  71371. /**
  71372. * Dictionary object with extension-specific objects
  71373. */
  71374. extensions?: {
  71375. [key: string]: any;
  71376. };
  71377. /**
  71378. * Application-Specific data
  71379. */
  71380. extras?: any;
  71381. }
  71382. /**
  71383. * glTF Child of Root Property
  71384. */
  71385. interface IChildRootProperty extends IProperty {
  71386. /**
  71387. * The user-defined name of this object
  71388. */
  71389. name?: string;
  71390. }
  71391. /**
  71392. * Indices of those attributes that deviate from their initialization value
  71393. */
  71394. interface IAccessorSparseIndices extends IProperty {
  71395. /**
  71396. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71397. */
  71398. bufferView: number;
  71399. /**
  71400. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71401. */
  71402. byteOffset?: number;
  71403. /**
  71404. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71405. */
  71406. componentType: AccessorComponentType;
  71407. }
  71408. /**
  71409. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71410. */
  71411. interface IAccessorSparseValues extends IProperty {
  71412. /**
  71413. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71414. */
  71415. bufferView: number;
  71416. /**
  71417. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71418. */
  71419. byteOffset?: number;
  71420. }
  71421. /**
  71422. * Sparse storage of attributes that deviate from their initialization value
  71423. */
  71424. interface IAccessorSparse extends IProperty {
  71425. /**
  71426. * The number of attributes encoded in this sparse accessor
  71427. */
  71428. count: number;
  71429. /**
  71430. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71431. */
  71432. indices: IAccessorSparseIndices;
  71433. /**
  71434. * 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
  71435. */
  71436. values: IAccessorSparseValues;
  71437. }
  71438. /**
  71439. * 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
  71440. */
  71441. interface IAccessor extends IChildRootProperty {
  71442. /**
  71443. * The index of the bufferview
  71444. */
  71445. bufferView?: number;
  71446. /**
  71447. * The offset relative to the start of the bufferView in bytes
  71448. */
  71449. byteOffset?: number;
  71450. /**
  71451. * The datatype of components in the attribute
  71452. */
  71453. componentType: AccessorComponentType;
  71454. /**
  71455. * Specifies whether integer data values should be normalized
  71456. */
  71457. normalized?: boolean;
  71458. /**
  71459. * The number of attributes referenced by this accessor
  71460. */
  71461. count: number;
  71462. /**
  71463. * Specifies if the attribute is a scalar, vector, or matrix
  71464. */
  71465. type: AccessorType;
  71466. /**
  71467. * Maximum value of each component in this attribute
  71468. */
  71469. max?: number[];
  71470. /**
  71471. * Minimum value of each component in this attribute
  71472. */
  71473. min?: number[];
  71474. /**
  71475. * Sparse storage of attributes that deviate from their initialization value
  71476. */
  71477. sparse?: IAccessorSparse;
  71478. }
  71479. /**
  71480. * Targets an animation's sampler at a node's property
  71481. */
  71482. interface IAnimationChannel extends IProperty {
  71483. /**
  71484. * The index of a sampler in this animation used to compute the value for the target
  71485. */
  71486. sampler: number;
  71487. /**
  71488. * The index of the node and TRS property to target
  71489. */
  71490. target: IAnimationChannelTarget;
  71491. }
  71492. /**
  71493. * The index of the node and TRS property that an animation channel targets
  71494. */
  71495. interface IAnimationChannelTarget extends IProperty {
  71496. /**
  71497. * The index of the node to target
  71498. */
  71499. node: number;
  71500. /**
  71501. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71502. */
  71503. path: AnimationChannelTargetPath;
  71504. }
  71505. /**
  71506. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71507. */
  71508. interface IAnimationSampler extends IProperty {
  71509. /**
  71510. * The index of an accessor containing keyframe input values, e.g., time
  71511. */
  71512. input: number;
  71513. /**
  71514. * Interpolation algorithm
  71515. */
  71516. interpolation?: AnimationSamplerInterpolation;
  71517. /**
  71518. * The index of an accessor, containing keyframe output values
  71519. */
  71520. output: number;
  71521. }
  71522. /**
  71523. * A keyframe animation
  71524. */
  71525. interface IAnimation extends IChildRootProperty {
  71526. /**
  71527. * An array of channels, each of which targets an animation's sampler at a node's property
  71528. */
  71529. channels: IAnimationChannel[];
  71530. /**
  71531. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71532. */
  71533. samplers: IAnimationSampler[];
  71534. }
  71535. /**
  71536. * Metadata about the glTF asset
  71537. */
  71538. interface IAsset extends IChildRootProperty {
  71539. /**
  71540. * A copyright message suitable for display to credit the content creator
  71541. */
  71542. copyright?: string;
  71543. /**
  71544. * Tool that generated this glTF model. Useful for debugging
  71545. */
  71546. generator?: string;
  71547. /**
  71548. * The glTF version that this asset targets
  71549. */
  71550. version: string;
  71551. /**
  71552. * The minimum glTF version that this asset targets
  71553. */
  71554. minVersion?: string;
  71555. }
  71556. /**
  71557. * A buffer points to binary geometry, animation, or skins
  71558. */
  71559. interface IBuffer extends IChildRootProperty {
  71560. /**
  71561. * 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
  71562. */
  71563. uri?: string;
  71564. /**
  71565. * The length of the buffer in bytes
  71566. */
  71567. byteLength: number;
  71568. }
  71569. /**
  71570. * A view into a buffer generally representing a subset of the buffer
  71571. */
  71572. interface IBufferView extends IChildRootProperty {
  71573. /**
  71574. * The index of the buffer
  71575. */
  71576. buffer: number;
  71577. /**
  71578. * The offset into the buffer in bytes
  71579. */
  71580. byteOffset?: number;
  71581. /**
  71582. * The lenth of the bufferView in bytes
  71583. */
  71584. byteLength: number;
  71585. /**
  71586. * The stride, in bytes
  71587. */
  71588. byteStride?: number;
  71589. }
  71590. /**
  71591. * An orthographic camera containing properties to create an orthographic projection matrix
  71592. */
  71593. interface ICameraOrthographic extends IProperty {
  71594. /**
  71595. * The floating-point horizontal magnification of the view. Must not be zero
  71596. */
  71597. xmag: number;
  71598. /**
  71599. * The floating-point vertical magnification of the view. Must not be zero
  71600. */
  71601. ymag: number;
  71602. /**
  71603. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71604. */
  71605. zfar: number;
  71606. /**
  71607. * The floating-point distance to the near clipping plane
  71608. */
  71609. znear: number;
  71610. }
  71611. /**
  71612. * A perspective camera containing properties to create a perspective projection matrix
  71613. */
  71614. interface ICameraPerspective extends IProperty {
  71615. /**
  71616. * The floating-point aspect ratio of the field of view
  71617. */
  71618. aspectRatio?: number;
  71619. /**
  71620. * The floating-point vertical field of view in radians
  71621. */
  71622. yfov: number;
  71623. /**
  71624. * The floating-point distance to the far clipping plane
  71625. */
  71626. zfar?: number;
  71627. /**
  71628. * The floating-point distance to the near clipping plane
  71629. */
  71630. znear: number;
  71631. }
  71632. /**
  71633. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71634. */
  71635. interface ICamera extends IChildRootProperty {
  71636. /**
  71637. * An orthographic camera containing properties to create an orthographic projection matrix
  71638. */
  71639. orthographic?: ICameraOrthographic;
  71640. /**
  71641. * A perspective camera containing properties to create a perspective projection matrix
  71642. */
  71643. perspective?: ICameraPerspective;
  71644. /**
  71645. * Specifies if the camera uses a perspective or orthographic projection
  71646. */
  71647. type: CameraType;
  71648. }
  71649. /**
  71650. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71651. */
  71652. interface IImage extends IChildRootProperty {
  71653. /**
  71654. * 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
  71655. */
  71656. uri?: string;
  71657. /**
  71658. * The image's MIME type
  71659. */
  71660. mimeType?: ImageMimeType;
  71661. /**
  71662. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71663. */
  71664. bufferView?: number;
  71665. }
  71666. /**
  71667. * Material Normal Texture Info
  71668. */
  71669. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71670. /**
  71671. * The scalar multiplier applied to each normal vector of the normal texture
  71672. */
  71673. scale?: number;
  71674. }
  71675. /**
  71676. * Material Occlusion Texture Info
  71677. */
  71678. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71679. /**
  71680. * A scalar multiplier controlling the amount of occlusion applied
  71681. */
  71682. strength?: number;
  71683. }
  71684. /**
  71685. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71686. */
  71687. interface IMaterialPbrMetallicRoughness {
  71688. /**
  71689. * The material's base color factor
  71690. */
  71691. baseColorFactor?: number[];
  71692. /**
  71693. * The base color texture
  71694. */
  71695. baseColorTexture?: ITextureInfo;
  71696. /**
  71697. * The metalness of the material
  71698. */
  71699. metallicFactor?: number;
  71700. /**
  71701. * The roughness of the material
  71702. */
  71703. roughnessFactor?: number;
  71704. /**
  71705. * The metallic-roughness texture
  71706. */
  71707. metallicRoughnessTexture?: ITextureInfo;
  71708. }
  71709. /**
  71710. * The material appearance of a primitive
  71711. */
  71712. interface IMaterial extends IChildRootProperty {
  71713. /**
  71714. * 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
  71715. */
  71716. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71717. /**
  71718. * The normal map texture
  71719. */
  71720. normalTexture?: IMaterialNormalTextureInfo;
  71721. /**
  71722. * The occlusion map texture
  71723. */
  71724. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71725. /**
  71726. * The emissive map texture
  71727. */
  71728. emissiveTexture?: ITextureInfo;
  71729. /**
  71730. * 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
  71731. */
  71732. emissiveFactor?: number[];
  71733. /**
  71734. * The alpha rendering mode of the material
  71735. */
  71736. alphaMode?: MaterialAlphaMode;
  71737. /**
  71738. * The alpha cutoff value of the material
  71739. */
  71740. alphaCutoff?: number;
  71741. /**
  71742. * Specifies whether the material is double sided
  71743. */
  71744. doubleSided?: boolean;
  71745. }
  71746. /**
  71747. * Geometry to be rendered with the given material
  71748. */
  71749. interface IMeshPrimitive extends IProperty {
  71750. /**
  71751. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71752. */
  71753. attributes: {
  71754. [name: string]: number;
  71755. };
  71756. /**
  71757. * The index of the accessor that contains the indices
  71758. */
  71759. indices?: number;
  71760. /**
  71761. * The index of the material to apply to this primitive when rendering
  71762. */
  71763. material?: number;
  71764. /**
  71765. * The type of primitives to render. All valid values correspond to WebGL enums
  71766. */
  71767. mode?: MeshPrimitiveMode;
  71768. /**
  71769. * 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
  71770. */
  71771. targets?: {
  71772. [name: string]: number;
  71773. }[];
  71774. }
  71775. /**
  71776. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71777. */
  71778. interface IMesh extends IChildRootProperty {
  71779. /**
  71780. * An array of primitives, each defining geometry to be rendered with a material
  71781. */
  71782. primitives: IMeshPrimitive[];
  71783. /**
  71784. * Array of weights to be applied to the Morph Targets
  71785. */
  71786. weights?: number[];
  71787. }
  71788. /**
  71789. * A node in the node hierarchy
  71790. */
  71791. interface INode extends IChildRootProperty {
  71792. /**
  71793. * The index of the camera referenced by this node
  71794. */
  71795. camera?: number;
  71796. /**
  71797. * The indices of this node's children
  71798. */
  71799. children?: number[];
  71800. /**
  71801. * The index of the skin referenced by this node
  71802. */
  71803. skin?: number;
  71804. /**
  71805. * A floating-point 4x4 transformation matrix stored in column-major order
  71806. */
  71807. matrix?: number[];
  71808. /**
  71809. * The index of the mesh in this node
  71810. */
  71811. mesh?: number;
  71812. /**
  71813. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  71814. */
  71815. rotation?: number[];
  71816. /**
  71817. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  71818. */
  71819. scale?: number[];
  71820. /**
  71821. * The node's translation along the x, y, and z axes
  71822. */
  71823. translation?: number[];
  71824. /**
  71825. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  71826. */
  71827. weights?: number[];
  71828. }
  71829. /**
  71830. * Texture sampler properties for filtering and wrapping modes
  71831. */
  71832. interface ISampler extends IChildRootProperty {
  71833. /**
  71834. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71835. */
  71836. magFilter?: TextureMagFilter;
  71837. /**
  71838. * Minification filter. All valid values correspond to WebGL enums
  71839. */
  71840. minFilter?: TextureMinFilter;
  71841. /**
  71842. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71843. */
  71844. wrapS?: TextureWrapMode;
  71845. /**
  71846. * T (V) wrapping mode. All valid values correspond to WebGL enums
  71847. */
  71848. wrapT?: TextureWrapMode;
  71849. }
  71850. /**
  71851. * The root nodes of a scene
  71852. */
  71853. interface IScene extends IChildRootProperty {
  71854. /**
  71855. * The indices of each root node
  71856. */
  71857. nodes: number[];
  71858. }
  71859. /**
  71860. * Joints and matrices defining a skin
  71861. */
  71862. interface ISkin extends IChildRootProperty {
  71863. /**
  71864. * 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
  71865. */
  71866. inverseBindMatrices?: number;
  71867. /**
  71868. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  71869. */
  71870. skeleton?: number;
  71871. /**
  71872. * 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)
  71873. */
  71874. joints: number[];
  71875. }
  71876. /**
  71877. * A texture and its sampler
  71878. */
  71879. interface ITexture extends IChildRootProperty {
  71880. /**
  71881. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  71882. */
  71883. sampler?: number;
  71884. /**
  71885. * The index of the image used by this texture
  71886. */
  71887. source: number;
  71888. }
  71889. /**
  71890. * Reference to a texture
  71891. */
  71892. interface ITextureInfo extends IProperty {
  71893. /**
  71894. * The index of the texture
  71895. */
  71896. index: number;
  71897. /**
  71898. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71899. */
  71900. texCoord?: number;
  71901. }
  71902. /**
  71903. * The root object for a glTF asset
  71904. */
  71905. interface IGLTF extends IProperty {
  71906. /**
  71907. * An array of accessors. An accessor is a typed view into a bufferView
  71908. */
  71909. accessors?: IAccessor[];
  71910. /**
  71911. * An array of keyframe animations
  71912. */
  71913. animations?: IAnimation[];
  71914. /**
  71915. * Metadata about the glTF asset
  71916. */
  71917. asset: IAsset;
  71918. /**
  71919. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71920. */
  71921. buffers?: IBuffer[];
  71922. /**
  71923. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71924. */
  71925. bufferViews?: IBufferView[];
  71926. /**
  71927. * An array of cameras
  71928. */
  71929. cameras?: ICamera[];
  71930. /**
  71931. * Names of glTF extensions used somewhere in this asset
  71932. */
  71933. extensionsUsed?: string[];
  71934. /**
  71935. * Names of glTF extensions required to properly load this asset
  71936. */
  71937. extensionsRequired?: string[];
  71938. /**
  71939. * An array of images. An image defines data used to create a texture
  71940. */
  71941. images?: IImage[];
  71942. /**
  71943. * An array of materials. A material defines the appearance of a primitive
  71944. */
  71945. materials?: IMaterial[];
  71946. /**
  71947. * An array of meshes. A mesh is a set of primitives to be rendered
  71948. */
  71949. meshes?: IMesh[];
  71950. /**
  71951. * An array of nodes
  71952. */
  71953. nodes?: INode[];
  71954. /**
  71955. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71956. */
  71957. samplers?: ISampler[];
  71958. /**
  71959. * The index of the default scene
  71960. */
  71961. scene?: number;
  71962. /**
  71963. * An array of scenes
  71964. */
  71965. scenes?: IScene[];
  71966. /**
  71967. * An array of skins. A skin is defined by joints and matrices
  71968. */
  71969. skins?: ISkin[];
  71970. /**
  71971. * An array of textures
  71972. */
  71973. textures?: ITexture[];
  71974. }
  71975. /**
  71976. * The glTF validation results
  71977. * @ignore
  71978. */
  71979. interface IGLTFValidationResults {
  71980. info: {
  71981. generator: string;
  71982. hasAnimations: boolean;
  71983. hasDefaultScene: boolean;
  71984. hasMaterials: boolean;
  71985. hasMorphTargets: boolean;
  71986. hasSkins: boolean;
  71987. hasTextures: boolean;
  71988. maxAttributesUsed: number;
  71989. primitivesCount: number
  71990. };
  71991. issues: {
  71992. messages: Array<string>;
  71993. numErrors: number;
  71994. numHints: number;
  71995. numInfos: number;
  71996. numWarnings: number;
  71997. truncated: boolean
  71998. };
  71999. mimeType: string;
  72000. uri: string;
  72001. validatedAt: string;
  72002. validatorVersion: string;
  72003. }
  72004. /**
  72005. * The glTF validation options
  72006. */
  72007. interface IGLTFValidationOptions {
  72008. /** Uri to use */
  72009. uri?: string;
  72010. /** Function used to load external resources */
  72011. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72012. /** Boolean indicating that we need to validate accessor data */
  72013. validateAccessorData?: boolean;
  72014. /** max number of issues allowed */
  72015. maxIssues?: number;
  72016. /** Ignored issues */
  72017. ignoredIssues?: Array<string>;
  72018. /** Value to override severy settings */
  72019. severityOverrides?: Object;
  72020. }
  72021. /**
  72022. * The glTF validator object
  72023. * @ignore
  72024. */
  72025. interface IGLTFValidator {
  72026. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72027. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72028. }
  72029. }
  72030. declare module BABYLON {
  72031. /** @hidden */
  72032. export var cellPixelShader: {
  72033. name: string;
  72034. shader: string;
  72035. };
  72036. }
  72037. declare module BABYLON {
  72038. /** @hidden */
  72039. export var cellVertexShader: {
  72040. name: string;
  72041. shader: string;
  72042. };
  72043. }
  72044. declare module BABYLON {
  72045. export class CellMaterial extends BABYLON.PushMaterial {
  72046. private _diffuseTexture;
  72047. diffuseTexture: BABYLON.BaseTexture;
  72048. diffuseColor: BABYLON.Color3;
  72049. _computeHighLevel: boolean;
  72050. computeHighLevel: boolean;
  72051. private _disableLighting;
  72052. disableLighting: boolean;
  72053. private _maxSimultaneousLights;
  72054. maxSimultaneousLights: number;
  72055. private _renderId;
  72056. constructor(name: string, scene: BABYLON.Scene);
  72057. needAlphaBlending(): boolean;
  72058. needAlphaTesting(): boolean;
  72059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72062. getAnimatables(): BABYLON.IAnimatable[];
  72063. getActiveTextures(): BABYLON.BaseTexture[];
  72064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72065. dispose(forceDisposeEffect?: boolean): void;
  72066. getClassName(): string;
  72067. clone(name: string): CellMaterial;
  72068. serialize(): any;
  72069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72070. }
  72071. }
  72072. declare module BABYLON {
  72073. export class CustomShaderStructure {
  72074. FragmentStore: string;
  72075. VertexStore: string;
  72076. constructor();
  72077. }
  72078. export class ShaderSpecialParts {
  72079. constructor();
  72080. Fragment_Begin: string;
  72081. Fragment_Definitions: string;
  72082. Fragment_MainBegin: string;
  72083. Fragment_Custom_Diffuse: string;
  72084. Fragment_Before_Lights: string;
  72085. Fragment_Before_Fog: string;
  72086. Fragment_Custom_Alpha: string;
  72087. Fragment_Before_FragColor: string;
  72088. Vertex_Begin: string;
  72089. Vertex_Definitions: string;
  72090. Vertex_MainBegin: string;
  72091. Vertex_Before_PositionUpdated: string;
  72092. Vertex_Before_NormalUpdated: string;
  72093. Vertex_MainEnd: string;
  72094. }
  72095. export class CustomMaterial extends BABYLON.StandardMaterial {
  72096. static ShaderIndexer: number;
  72097. CustomParts: ShaderSpecialParts;
  72098. _isCreatedShader: boolean;
  72099. _createdShaderName: string;
  72100. _customUniform: string[];
  72101. _newUniforms: string[];
  72102. _newUniformInstances: any[];
  72103. _newSamplerInstances: BABYLON.Texture[];
  72104. FragmentShader: string;
  72105. VertexShader: string;
  72106. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72107. ReviewUniform(name: string, arr: string[]): string[];
  72108. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72109. constructor(name: string, scene: BABYLON.Scene);
  72110. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72111. Fragment_Begin(shaderPart: string): CustomMaterial;
  72112. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72113. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72114. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72115. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72116. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72117. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72118. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72119. Vertex_Begin(shaderPart: string): CustomMaterial;
  72120. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72121. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72122. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72123. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72124. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72125. }
  72126. }
  72127. declare module BABYLON {
  72128. export class ShaderAlebdoParts {
  72129. constructor();
  72130. Fragment_Begin: string;
  72131. Fragment_Definitions: string;
  72132. Fragment_MainBegin: string;
  72133. Fragment_Custom_Albedo: string;
  72134. Fragment_Before_Lights: string;
  72135. Fragment_Custom_MetallicRoughness: string;
  72136. Fragment_Custom_MicroSurface: string;
  72137. Fragment_Before_Fog: string;
  72138. Fragment_Custom_Alpha: string;
  72139. Fragment_Before_FragColor: string;
  72140. Vertex_Begin: string;
  72141. Vertex_Definitions: string;
  72142. Vertex_MainBegin: string;
  72143. Vertex_Before_PositionUpdated: string;
  72144. Vertex_Before_NormalUpdated: string;
  72145. Vertex_MainEnd: string;
  72146. }
  72147. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72148. static ShaderIndexer: number;
  72149. CustomParts: ShaderAlebdoParts;
  72150. _isCreatedShader: boolean;
  72151. _createdShaderName: string;
  72152. _customUniform: string[];
  72153. _newUniforms: string[];
  72154. _newUniformInstances: any[];
  72155. _newSamplerInstances: BABYLON.Texture[];
  72156. FragmentShader: string;
  72157. VertexShader: string;
  72158. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72159. ReviewUniform(name: string, arr: string[]): string[];
  72160. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72161. constructor(name: string, scene: BABYLON.Scene);
  72162. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72163. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72164. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72165. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72166. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72167. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72168. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72169. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72170. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72171. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72172. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72173. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72174. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72175. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72176. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72177. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72178. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72179. }
  72180. }
  72181. declare module BABYLON {
  72182. /** @hidden */
  72183. export var firePixelShader: {
  72184. name: string;
  72185. shader: string;
  72186. };
  72187. }
  72188. declare module BABYLON {
  72189. /** @hidden */
  72190. export var fireVertexShader: {
  72191. name: string;
  72192. shader: string;
  72193. };
  72194. }
  72195. declare module BABYLON {
  72196. export class FireMaterial extends BABYLON.PushMaterial {
  72197. private _diffuseTexture;
  72198. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72199. private _distortionTexture;
  72200. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72201. private _opacityTexture;
  72202. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72203. diffuseColor: BABYLON.Color3;
  72204. speed: number;
  72205. private _scaledDiffuse;
  72206. private _renderId;
  72207. private _lastTime;
  72208. constructor(name: string, scene: BABYLON.Scene);
  72209. needAlphaBlending(): boolean;
  72210. needAlphaTesting(): boolean;
  72211. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72214. getAnimatables(): BABYLON.IAnimatable[];
  72215. getActiveTextures(): BABYLON.BaseTexture[];
  72216. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72217. getClassName(): string;
  72218. dispose(forceDisposeEffect?: boolean): void;
  72219. clone(name: string): FireMaterial;
  72220. serialize(): any;
  72221. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72222. }
  72223. }
  72224. declare module BABYLON {
  72225. /** @hidden */
  72226. export var furPixelShader: {
  72227. name: string;
  72228. shader: string;
  72229. };
  72230. }
  72231. declare module BABYLON {
  72232. /** @hidden */
  72233. export var furVertexShader: {
  72234. name: string;
  72235. shader: string;
  72236. };
  72237. }
  72238. declare module BABYLON {
  72239. export class FurMaterial extends BABYLON.PushMaterial {
  72240. private _diffuseTexture;
  72241. diffuseTexture: BABYLON.BaseTexture;
  72242. private _heightTexture;
  72243. heightTexture: BABYLON.BaseTexture;
  72244. diffuseColor: BABYLON.Color3;
  72245. furLength: number;
  72246. furAngle: number;
  72247. furColor: BABYLON.Color3;
  72248. furOffset: number;
  72249. furSpacing: number;
  72250. furGravity: BABYLON.Vector3;
  72251. furSpeed: number;
  72252. furDensity: number;
  72253. furOcclusion: number;
  72254. furTexture: BABYLON.DynamicTexture;
  72255. private _disableLighting;
  72256. disableLighting: boolean;
  72257. private _maxSimultaneousLights;
  72258. maxSimultaneousLights: number;
  72259. highLevelFur: boolean;
  72260. _meshes: BABYLON.AbstractMesh[];
  72261. private _renderId;
  72262. private _furTime;
  72263. constructor(name: string, scene: BABYLON.Scene);
  72264. furTime: number;
  72265. needAlphaBlending(): boolean;
  72266. needAlphaTesting(): boolean;
  72267. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72268. updateFur(): void;
  72269. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72270. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72271. getAnimatables(): BABYLON.IAnimatable[];
  72272. getActiveTextures(): BABYLON.BaseTexture[];
  72273. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72274. dispose(forceDisposeEffect?: boolean): void;
  72275. clone(name: string): FurMaterial;
  72276. serialize(): any;
  72277. getClassName(): string;
  72278. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72279. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72280. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72281. }
  72282. }
  72283. declare module BABYLON {
  72284. /** @hidden */
  72285. export var gradientPixelShader: {
  72286. name: string;
  72287. shader: string;
  72288. };
  72289. }
  72290. declare module BABYLON {
  72291. /** @hidden */
  72292. export var gradientVertexShader: {
  72293. name: string;
  72294. shader: string;
  72295. };
  72296. }
  72297. declare module BABYLON {
  72298. export class GradientMaterial extends BABYLON.PushMaterial {
  72299. private _maxSimultaneousLights;
  72300. maxSimultaneousLights: number;
  72301. topColor: BABYLON.Color3;
  72302. topColorAlpha: number;
  72303. bottomColor: BABYLON.Color3;
  72304. bottomColorAlpha: number;
  72305. offset: number;
  72306. scale: number;
  72307. smoothness: number;
  72308. private _disableLighting;
  72309. disableLighting: boolean;
  72310. private _renderId;
  72311. constructor(name: string, scene: BABYLON.Scene);
  72312. needAlphaBlending(): boolean;
  72313. needAlphaTesting(): boolean;
  72314. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72315. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72317. getAnimatables(): BABYLON.IAnimatable[];
  72318. dispose(forceDisposeEffect?: boolean): void;
  72319. clone(name: string): GradientMaterial;
  72320. serialize(): any;
  72321. getClassName(): string;
  72322. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72323. }
  72324. }
  72325. declare module BABYLON {
  72326. /** @hidden */
  72327. export var gridPixelShader: {
  72328. name: string;
  72329. shader: string;
  72330. };
  72331. }
  72332. declare module BABYLON {
  72333. /** @hidden */
  72334. export var gridVertexShader: {
  72335. name: string;
  72336. shader: string;
  72337. };
  72338. }
  72339. declare module BABYLON {
  72340. /**
  72341. * The grid materials allows you to wrap any shape with a grid.
  72342. * Colors are customizable.
  72343. */
  72344. export class GridMaterial extends BABYLON.PushMaterial {
  72345. /**
  72346. * Main color of the grid (e.g. between lines)
  72347. */
  72348. mainColor: BABYLON.Color3;
  72349. /**
  72350. * Color of the grid lines.
  72351. */
  72352. lineColor: BABYLON.Color3;
  72353. /**
  72354. * The scale of the grid compared to unit.
  72355. */
  72356. gridRatio: number;
  72357. /**
  72358. * Allows setting an offset for the grid lines.
  72359. */
  72360. gridOffset: BABYLON.Vector3;
  72361. /**
  72362. * The frequency of thicker lines.
  72363. */
  72364. majorUnitFrequency: number;
  72365. /**
  72366. * The visibility of minor units in the grid.
  72367. */
  72368. minorUnitVisibility: number;
  72369. /**
  72370. * The grid opacity outside of the lines.
  72371. */
  72372. opacity: number;
  72373. /**
  72374. * Determine RBG output is premultiplied by alpha value.
  72375. */
  72376. preMultiplyAlpha: boolean;
  72377. private _opacityTexture;
  72378. opacityTexture: BABYLON.BaseTexture;
  72379. private _gridControl;
  72380. private _renderId;
  72381. /**
  72382. * constructor
  72383. * @param name The name given to the material in order to identify it afterwards.
  72384. * @param scene The scene the material is used in.
  72385. */
  72386. constructor(name: string, scene: BABYLON.Scene);
  72387. /**
  72388. * Returns wehter or not the grid requires alpha blending.
  72389. */
  72390. needAlphaBlending(): boolean;
  72391. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72392. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72393. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72394. /**
  72395. * Dispose the material and its associated resources.
  72396. * @param forceDisposeEffect will also dispose the used effect when true
  72397. */
  72398. dispose(forceDisposeEffect?: boolean): void;
  72399. clone(name: string): GridMaterial;
  72400. serialize(): any;
  72401. getClassName(): string;
  72402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72403. }
  72404. }
  72405. declare module BABYLON {
  72406. /** @hidden */
  72407. export var lavaPixelShader: {
  72408. name: string;
  72409. shader: string;
  72410. };
  72411. }
  72412. declare module BABYLON {
  72413. /** @hidden */
  72414. export var lavaVertexShader: {
  72415. name: string;
  72416. shader: string;
  72417. };
  72418. }
  72419. declare module BABYLON {
  72420. export class LavaMaterial extends BABYLON.PushMaterial {
  72421. private _diffuseTexture;
  72422. diffuseTexture: BABYLON.BaseTexture;
  72423. noiseTexture: BABYLON.BaseTexture;
  72424. fogColor: BABYLON.Color3;
  72425. speed: number;
  72426. movingSpeed: number;
  72427. lowFrequencySpeed: number;
  72428. fogDensity: number;
  72429. private _lastTime;
  72430. diffuseColor: BABYLON.Color3;
  72431. private _disableLighting;
  72432. disableLighting: boolean;
  72433. private _unlit;
  72434. unlit: boolean;
  72435. private _maxSimultaneousLights;
  72436. maxSimultaneousLights: number;
  72437. private _scaledDiffuse;
  72438. private _renderId;
  72439. constructor(name: string, scene: BABYLON.Scene);
  72440. needAlphaBlending(): boolean;
  72441. needAlphaTesting(): boolean;
  72442. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72443. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72444. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72445. getAnimatables(): BABYLON.IAnimatable[];
  72446. getActiveTextures(): BABYLON.BaseTexture[];
  72447. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72448. dispose(forceDisposeEffect?: boolean): void;
  72449. clone(name: string): LavaMaterial;
  72450. serialize(): any;
  72451. getClassName(): string;
  72452. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72453. }
  72454. }
  72455. declare module BABYLON {
  72456. /** @hidden */
  72457. export var mixPixelShader: {
  72458. name: string;
  72459. shader: string;
  72460. };
  72461. }
  72462. declare module BABYLON {
  72463. /** @hidden */
  72464. export var mixVertexShader: {
  72465. name: string;
  72466. shader: string;
  72467. };
  72468. }
  72469. declare module BABYLON {
  72470. export class MixMaterial extends BABYLON.PushMaterial {
  72471. /**
  72472. * Mix textures
  72473. */
  72474. private _mixTexture1;
  72475. mixTexture1: BABYLON.BaseTexture;
  72476. private _mixTexture2;
  72477. mixTexture2: BABYLON.BaseTexture;
  72478. /**
  72479. * Diffuse textures
  72480. */
  72481. private _diffuseTexture1;
  72482. diffuseTexture1: BABYLON.Texture;
  72483. private _diffuseTexture2;
  72484. diffuseTexture2: BABYLON.Texture;
  72485. private _diffuseTexture3;
  72486. diffuseTexture3: BABYLON.Texture;
  72487. private _diffuseTexture4;
  72488. diffuseTexture4: BABYLON.Texture;
  72489. private _diffuseTexture5;
  72490. diffuseTexture5: BABYLON.Texture;
  72491. private _diffuseTexture6;
  72492. diffuseTexture6: BABYLON.Texture;
  72493. private _diffuseTexture7;
  72494. diffuseTexture7: BABYLON.Texture;
  72495. private _diffuseTexture8;
  72496. diffuseTexture8: BABYLON.Texture;
  72497. /**
  72498. * Uniforms
  72499. */
  72500. diffuseColor: BABYLON.Color3;
  72501. specularColor: BABYLON.Color3;
  72502. specularPower: number;
  72503. private _disableLighting;
  72504. disableLighting: boolean;
  72505. private _maxSimultaneousLights;
  72506. maxSimultaneousLights: number;
  72507. private _renderId;
  72508. constructor(name: string, scene: BABYLON.Scene);
  72509. needAlphaBlending(): boolean;
  72510. needAlphaTesting(): boolean;
  72511. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72512. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72513. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72514. getAnimatables(): BABYLON.IAnimatable[];
  72515. getActiveTextures(): BABYLON.BaseTexture[];
  72516. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72517. dispose(forceDisposeEffect?: boolean): void;
  72518. clone(name: string): MixMaterial;
  72519. serialize(): any;
  72520. getClassName(): string;
  72521. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72522. }
  72523. }
  72524. declare module BABYLON {
  72525. /** @hidden */
  72526. export var normalPixelShader: {
  72527. name: string;
  72528. shader: string;
  72529. };
  72530. }
  72531. declare module BABYLON {
  72532. /** @hidden */
  72533. export var normalVertexShader: {
  72534. name: string;
  72535. shader: string;
  72536. };
  72537. }
  72538. declare module BABYLON {
  72539. export class NormalMaterial extends BABYLON.PushMaterial {
  72540. private _diffuseTexture;
  72541. diffuseTexture: BABYLON.BaseTexture;
  72542. diffuseColor: BABYLON.Color3;
  72543. private _disableLighting;
  72544. disableLighting: boolean;
  72545. private _maxSimultaneousLights;
  72546. maxSimultaneousLights: number;
  72547. private _renderId;
  72548. constructor(name: string, scene: BABYLON.Scene);
  72549. needAlphaBlending(): boolean;
  72550. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72551. needAlphaTesting(): boolean;
  72552. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72553. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72554. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72555. getAnimatables(): BABYLON.IAnimatable[];
  72556. getActiveTextures(): BABYLON.BaseTexture[];
  72557. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72558. dispose(forceDisposeEffect?: boolean): void;
  72559. clone(name: string): NormalMaterial;
  72560. serialize(): any;
  72561. getClassName(): string;
  72562. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72563. }
  72564. }
  72565. declare module BABYLON {
  72566. /** @hidden */
  72567. export var shadowOnlyPixelShader: {
  72568. name: string;
  72569. shader: string;
  72570. };
  72571. }
  72572. declare module BABYLON {
  72573. /** @hidden */
  72574. export var shadowOnlyVertexShader: {
  72575. name: string;
  72576. shader: string;
  72577. };
  72578. }
  72579. declare module BABYLON {
  72580. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72581. private _renderId;
  72582. private _activeLight;
  72583. constructor(name: string, scene: BABYLON.Scene);
  72584. shadowColor: BABYLON.Color3;
  72585. needAlphaBlending(): boolean;
  72586. needAlphaTesting(): boolean;
  72587. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72588. activeLight: BABYLON.IShadowLight;
  72589. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72590. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72591. clone(name: string): ShadowOnlyMaterial;
  72592. serialize(): any;
  72593. getClassName(): string;
  72594. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72595. }
  72596. }
  72597. declare module BABYLON {
  72598. /** @hidden */
  72599. export var simplePixelShader: {
  72600. name: string;
  72601. shader: string;
  72602. };
  72603. }
  72604. declare module BABYLON {
  72605. /** @hidden */
  72606. export var simpleVertexShader: {
  72607. name: string;
  72608. shader: string;
  72609. };
  72610. }
  72611. declare module BABYLON {
  72612. export class SimpleMaterial extends BABYLON.PushMaterial {
  72613. private _diffuseTexture;
  72614. diffuseTexture: BABYLON.BaseTexture;
  72615. diffuseColor: BABYLON.Color3;
  72616. private _disableLighting;
  72617. disableLighting: boolean;
  72618. private _maxSimultaneousLights;
  72619. maxSimultaneousLights: number;
  72620. private _renderId;
  72621. constructor(name: string, scene: BABYLON.Scene);
  72622. needAlphaBlending(): boolean;
  72623. needAlphaTesting(): boolean;
  72624. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72625. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72626. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72627. getAnimatables(): BABYLON.IAnimatable[];
  72628. getActiveTextures(): BABYLON.BaseTexture[];
  72629. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72630. dispose(forceDisposeEffect?: boolean): void;
  72631. clone(name: string): SimpleMaterial;
  72632. serialize(): any;
  72633. getClassName(): string;
  72634. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72635. }
  72636. }
  72637. declare module BABYLON {
  72638. /** @hidden */
  72639. export var skyPixelShader: {
  72640. name: string;
  72641. shader: string;
  72642. };
  72643. }
  72644. declare module BABYLON {
  72645. /** @hidden */
  72646. export var skyVertexShader: {
  72647. name: string;
  72648. shader: string;
  72649. };
  72650. }
  72651. declare module BABYLON {
  72652. /**
  72653. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72654. * @see https://doc.babylonjs.com/extensions/sky
  72655. */
  72656. export class SkyMaterial extends BABYLON.PushMaterial {
  72657. /**
  72658. * Defines the overall luminance of sky in interval ]0, 1[.
  72659. */
  72660. luminance: number;
  72661. /**
  72662. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72663. */
  72664. turbidity: number;
  72665. /**
  72666. * Defines the sky appearance (light intensity).
  72667. */
  72668. rayleigh: number;
  72669. /**
  72670. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72671. */
  72672. mieCoefficient: number;
  72673. /**
  72674. * Defines the amount of haze particles following the Mie scattering theory.
  72675. */
  72676. mieDirectionalG: number;
  72677. /**
  72678. * Defines the distance of the sun according to the active scene camera.
  72679. */
  72680. distance: number;
  72681. /**
  72682. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72683. * "inclined".
  72684. */
  72685. inclination: number;
  72686. /**
  72687. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72688. * an object direction and a reference direction.
  72689. */
  72690. azimuth: number;
  72691. /**
  72692. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72693. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72694. */
  72695. sunPosition: BABYLON.Vector3;
  72696. /**
  72697. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72698. * .sunPosition property.
  72699. */
  72700. useSunPosition: boolean;
  72701. /**
  72702. * Defines an offset vector used to get a horizon offset.
  72703. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72704. */
  72705. cameraOffset: BABYLON.Vector3;
  72706. private _cameraPosition;
  72707. private _renderId;
  72708. /**
  72709. * Instantiates a new sky material.
  72710. * This material allows to create dynamic and texture free
  72711. * effects for skyboxes by taking care of the atmosphere state.
  72712. * @see https://doc.babylonjs.com/extensions/sky
  72713. * @param name Define the name of the material in the scene
  72714. * @param scene Define the scene the material belong to
  72715. */
  72716. constructor(name: string, scene: BABYLON.Scene);
  72717. /**
  72718. * Specifies if the material will require alpha blending
  72719. * @returns a boolean specifying if alpha blending is needed
  72720. */
  72721. needAlphaBlending(): boolean;
  72722. /**
  72723. * Specifies if this material should be rendered in alpha test mode
  72724. * @returns false as the sky material doesn't need alpha testing.
  72725. */
  72726. needAlphaTesting(): boolean;
  72727. /**
  72728. * Get the texture used for alpha test purpose.
  72729. * @returns null as the sky material has no texture.
  72730. */
  72731. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72732. /**
  72733. * Get if the submesh is ready to be used and all its information available.
  72734. * Child classes can use it to update shaders
  72735. * @param mesh defines the mesh to check
  72736. * @param subMesh defines which submesh to check
  72737. * @param useInstances specifies that instances should be used
  72738. * @returns a boolean indicating that the submesh is ready or not
  72739. */
  72740. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72741. /**
  72742. * Binds the submesh to this material by preparing the effect and shader to draw
  72743. * @param world defines the world transformation matrix
  72744. * @param mesh defines the mesh containing the submesh
  72745. * @param subMesh defines the submesh to bind the material to
  72746. */
  72747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72748. /**
  72749. * Get the list of animatables in the material.
  72750. * @returns the list of animatables object used in the material
  72751. */
  72752. getAnimatables(): BABYLON.IAnimatable[];
  72753. /**
  72754. * Disposes the material
  72755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72756. */
  72757. dispose(forceDisposeEffect?: boolean): void;
  72758. /**
  72759. * Makes a duplicate of the material, and gives it a new name
  72760. * @param name defines the new name for the duplicated material
  72761. * @returns the cloned material
  72762. */
  72763. clone(name: string): SkyMaterial;
  72764. /**
  72765. * Serializes this material in a JSON representation
  72766. * @returns the serialized material object
  72767. */
  72768. serialize(): any;
  72769. /**
  72770. * Gets the current class name of the material e.g. "SkyMaterial"
  72771. * Mainly use in serialization.
  72772. * @returns the class name
  72773. */
  72774. getClassName(): string;
  72775. /**
  72776. * Creates a sky material from parsed material data
  72777. * @param source defines the JSON representation of the material
  72778. * @param scene defines the hosting scene
  72779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72780. * @returns a new sky material
  72781. */
  72782. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72783. }
  72784. }
  72785. declare module BABYLON {
  72786. /** @hidden */
  72787. export var terrainPixelShader: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. declare module BABYLON {
  72793. /** @hidden */
  72794. export var terrainVertexShader: {
  72795. name: string;
  72796. shader: string;
  72797. };
  72798. }
  72799. declare module BABYLON {
  72800. export class TerrainMaterial extends BABYLON.PushMaterial {
  72801. private _mixTexture;
  72802. mixTexture: BABYLON.BaseTexture;
  72803. private _diffuseTexture1;
  72804. diffuseTexture1: BABYLON.Texture;
  72805. private _diffuseTexture2;
  72806. diffuseTexture2: BABYLON.Texture;
  72807. private _diffuseTexture3;
  72808. diffuseTexture3: BABYLON.Texture;
  72809. private _bumpTexture1;
  72810. bumpTexture1: BABYLON.Texture;
  72811. private _bumpTexture2;
  72812. bumpTexture2: BABYLON.Texture;
  72813. private _bumpTexture3;
  72814. bumpTexture3: BABYLON.Texture;
  72815. diffuseColor: BABYLON.Color3;
  72816. specularColor: BABYLON.Color3;
  72817. specularPower: number;
  72818. private _disableLighting;
  72819. disableLighting: boolean;
  72820. private _maxSimultaneousLights;
  72821. maxSimultaneousLights: number;
  72822. private _renderId;
  72823. constructor(name: string, scene: BABYLON.Scene);
  72824. needAlphaBlending(): boolean;
  72825. needAlphaTesting(): boolean;
  72826. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72827. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72828. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72829. getAnimatables(): BABYLON.IAnimatable[];
  72830. getActiveTextures(): BABYLON.BaseTexture[];
  72831. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72832. dispose(forceDisposeEffect?: boolean): void;
  72833. clone(name: string): TerrainMaterial;
  72834. serialize(): any;
  72835. getClassName(): string;
  72836. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  72837. }
  72838. }
  72839. declare module BABYLON {
  72840. /** @hidden */
  72841. export var triplanarPixelShader: {
  72842. name: string;
  72843. shader: string;
  72844. };
  72845. }
  72846. declare module BABYLON {
  72847. /** @hidden */
  72848. export var triplanarVertexShader: {
  72849. name: string;
  72850. shader: string;
  72851. };
  72852. }
  72853. declare module BABYLON {
  72854. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  72855. mixTexture: BABYLON.BaseTexture;
  72856. private _diffuseTextureX;
  72857. diffuseTextureX: BABYLON.BaseTexture;
  72858. private _diffuseTextureY;
  72859. diffuseTextureY: BABYLON.BaseTexture;
  72860. private _diffuseTextureZ;
  72861. diffuseTextureZ: BABYLON.BaseTexture;
  72862. private _normalTextureX;
  72863. normalTextureX: BABYLON.BaseTexture;
  72864. private _normalTextureY;
  72865. normalTextureY: BABYLON.BaseTexture;
  72866. private _normalTextureZ;
  72867. normalTextureZ: BABYLON.BaseTexture;
  72868. tileSize: number;
  72869. diffuseColor: BABYLON.Color3;
  72870. specularColor: BABYLON.Color3;
  72871. specularPower: number;
  72872. private _disableLighting;
  72873. disableLighting: boolean;
  72874. private _maxSimultaneousLights;
  72875. maxSimultaneousLights: number;
  72876. private _renderId;
  72877. constructor(name: string, scene: BABYLON.Scene);
  72878. needAlphaBlending(): boolean;
  72879. needAlphaTesting(): boolean;
  72880. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72881. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72882. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72883. getAnimatables(): BABYLON.IAnimatable[];
  72884. getActiveTextures(): BABYLON.BaseTexture[];
  72885. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72886. dispose(forceDisposeEffect?: boolean): void;
  72887. clone(name: string): TriPlanarMaterial;
  72888. serialize(): any;
  72889. getClassName(): string;
  72890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  72891. }
  72892. }
  72893. declare module BABYLON {
  72894. /** @hidden */
  72895. export var waterPixelShader: {
  72896. name: string;
  72897. shader: string;
  72898. };
  72899. }
  72900. declare module BABYLON {
  72901. /** @hidden */
  72902. export var waterVertexShader: {
  72903. name: string;
  72904. shader: string;
  72905. };
  72906. }
  72907. declare module BABYLON {
  72908. export class WaterMaterial extends BABYLON.PushMaterial {
  72909. renderTargetSize: BABYLON.Vector2;
  72910. private _bumpTexture;
  72911. bumpTexture: BABYLON.BaseTexture;
  72912. diffuseColor: BABYLON.Color3;
  72913. specularColor: BABYLON.Color3;
  72914. specularPower: number;
  72915. private _disableLighting;
  72916. disableLighting: boolean;
  72917. private _maxSimultaneousLights;
  72918. maxSimultaneousLights: number;
  72919. /**
  72920. * @param {number}: Represents the wind force
  72921. */
  72922. windForce: number;
  72923. /**
  72924. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72925. */
  72926. windDirection: BABYLON.Vector2;
  72927. /**
  72928. * @param {number}: Wave height, represents the height of the waves
  72929. */
  72930. waveHeight: number;
  72931. /**
  72932. * @param {number}: Bump height, represents the bump height related to the bump map
  72933. */
  72934. bumpHeight: number;
  72935. /**
  72936. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72937. */
  72938. private _bumpSuperimpose;
  72939. bumpSuperimpose: boolean;
  72940. /**
  72941. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72942. */
  72943. private _fresnelSeparate;
  72944. fresnelSeparate: boolean;
  72945. /**
  72946. * @param {boolean}: bump Waves modify the reflection.
  72947. */
  72948. private _bumpAffectsReflection;
  72949. bumpAffectsReflection: boolean;
  72950. /**
  72951. * @param {number}: The water color blended with the refraction (near)
  72952. */
  72953. waterColor: BABYLON.Color3;
  72954. /**
  72955. * @param {number}: The blend factor related to the water color
  72956. */
  72957. colorBlendFactor: number;
  72958. /**
  72959. * @param {number}: The water color blended with the reflection (far)
  72960. */
  72961. waterColor2: BABYLON.Color3;
  72962. /**
  72963. * @param {number}: The blend factor related to the water color (reflection, far)
  72964. */
  72965. colorBlendFactor2: number;
  72966. /**
  72967. * @param {number}: Represents the maximum length of a wave
  72968. */
  72969. waveLength: number;
  72970. /**
  72971. * @param {number}: Defines the waves speed
  72972. */
  72973. waveSpeed: number;
  72974. /**
  72975. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72976. * will avoid calculating useless pixels in the pixel shader of the water material.
  72977. */
  72978. disableClipPlane: boolean;
  72979. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72980. private _mesh;
  72981. private _refractionRTT;
  72982. private _reflectionRTT;
  72983. private _reflectionTransform;
  72984. private _lastTime;
  72985. private _lastDeltaTime;
  72986. private _renderId;
  72987. private _useLogarithmicDepth;
  72988. private _waitingRenderList;
  72989. private _imageProcessingConfiguration;
  72990. private _imageProcessingObserver;
  72991. /**
  72992. * Gets a boolean indicating that current material needs to register RTT
  72993. */
  72994. readonly hasRenderTargetTextures: boolean;
  72995. /**
  72996. * Constructor
  72997. */
  72998. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72999. useLogarithmicDepth: boolean;
  73000. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73001. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73002. addToRenderList(node: any): void;
  73003. enableRenderTargets(enable: boolean): void;
  73004. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73005. readonly renderTargetsEnabled: boolean;
  73006. needAlphaBlending(): boolean;
  73007. needAlphaTesting(): boolean;
  73008. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73009. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73010. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73011. private _createRenderTargets;
  73012. getAnimatables(): BABYLON.IAnimatable[];
  73013. getActiveTextures(): BABYLON.BaseTexture[];
  73014. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73015. dispose(forceDisposeEffect?: boolean): void;
  73016. clone(name: string): WaterMaterial;
  73017. serialize(): any;
  73018. getClassName(): string;
  73019. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73020. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73021. }
  73022. }
  73023. declare module BABYLON {
  73024. /** @hidden */
  73025. export var asciiartPixelShader: {
  73026. name: string;
  73027. shader: string;
  73028. };
  73029. }
  73030. declare module BABYLON {
  73031. /**
  73032. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73033. *
  73034. * It basically takes care rendering the font front the given font size to a texture.
  73035. * This is used later on in the postprocess.
  73036. */
  73037. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73038. private _font;
  73039. private _text;
  73040. private _charSize;
  73041. /**
  73042. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73043. */
  73044. readonly charSize: number;
  73045. /**
  73046. * Create a new instance of the Ascii Art FontTexture class
  73047. * @param name the name of the texture
  73048. * @param font the font to use, use the W3C CSS notation
  73049. * @param text the caracter set to use in the rendering.
  73050. * @param scene the scene that owns the texture
  73051. */
  73052. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73053. /**
  73054. * Gets the max char width of a font.
  73055. * @param font the font to use, use the W3C CSS notation
  73056. * @return the max char width
  73057. */
  73058. private getFontWidth;
  73059. /**
  73060. * Gets the max char height of a font.
  73061. * @param font the font to use, use the W3C CSS notation
  73062. * @return the max char height
  73063. */
  73064. private getFontHeight;
  73065. /**
  73066. * Clones the current AsciiArtTexture.
  73067. * @return the clone of the texture.
  73068. */
  73069. clone(): AsciiArtFontTexture;
  73070. /**
  73071. * Parses a json object representing the texture and returns an instance of it.
  73072. * @param source the source JSON representation
  73073. * @param scene the scene to create the texture for
  73074. * @return the parsed texture
  73075. */
  73076. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73077. }
  73078. /**
  73079. * Option available in the Ascii Art Post Process.
  73080. */
  73081. export interface IAsciiArtPostProcessOptions {
  73082. /**
  73083. * The font to use following the w3c font definition.
  73084. */
  73085. font?: string;
  73086. /**
  73087. * The character set to use in the postprocess.
  73088. */
  73089. characterSet?: string;
  73090. /**
  73091. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73092. * This number is defined between 0 and 1;
  73093. */
  73094. mixToTile?: number;
  73095. /**
  73096. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73097. * This number is defined between 0 and 1;
  73098. */
  73099. mixToNormal?: number;
  73100. }
  73101. /**
  73102. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73103. *
  73104. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73105. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73106. */
  73107. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73108. /**
  73109. * The font texture used to render the char in the post process.
  73110. */
  73111. private _asciiArtFontTexture;
  73112. /**
  73113. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73114. * This number is defined between 0 and 1;
  73115. */
  73116. mixToTile: number;
  73117. /**
  73118. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73119. * This number is defined between 0 and 1;
  73120. */
  73121. mixToNormal: number;
  73122. /**
  73123. * Instantiates a new Ascii Art Post Process.
  73124. * @param name the name to give to the postprocess
  73125. * @camera the camera to apply the post process to.
  73126. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73127. */
  73128. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73129. }
  73130. }
  73131. declare module BABYLON {
  73132. /** @hidden */
  73133. export var digitalrainPixelShader: {
  73134. name: string;
  73135. shader: string;
  73136. };
  73137. }
  73138. declare module BABYLON {
  73139. /**
  73140. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73141. *
  73142. * It basically takes care rendering the font front the given font size to a texture.
  73143. * This is used later on in the postprocess.
  73144. */
  73145. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73146. private _font;
  73147. private _text;
  73148. private _charSize;
  73149. /**
  73150. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73151. */
  73152. readonly charSize: number;
  73153. /**
  73154. * Create a new instance of the Digital Rain FontTexture class
  73155. * @param name the name of the texture
  73156. * @param font the font to use, use the W3C CSS notation
  73157. * @param text the caracter set to use in the rendering.
  73158. * @param scene the scene that owns the texture
  73159. */
  73160. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73161. /**
  73162. * Gets the max char width of a font.
  73163. * @param font the font to use, use the W3C CSS notation
  73164. * @return the max char width
  73165. */
  73166. private getFontWidth;
  73167. /**
  73168. * Gets the max char height of a font.
  73169. * @param font the font to use, use the W3C CSS notation
  73170. * @return the max char height
  73171. */
  73172. private getFontHeight;
  73173. /**
  73174. * Clones the current DigitalRainFontTexture.
  73175. * @return the clone of the texture.
  73176. */
  73177. clone(): DigitalRainFontTexture;
  73178. /**
  73179. * Parses a json object representing the texture and returns an instance of it.
  73180. * @param source the source JSON representation
  73181. * @param scene the scene to create the texture for
  73182. * @return the parsed texture
  73183. */
  73184. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73185. }
  73186. /**
  73187. * Option available in the Digital Rain Post Process.
  73188. */
  73189. export interface IDigitalRainPostProcessOptions {
  73190. /**
  73191. * The font to use following the w3c font definition.
  73192. */
  73193. font?: string;
  73194. /**
  73195. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73196. * This number is defined between 0 and 1;
  73197. */
  73198. mixToTile?: number;
  73199. /**
  73200. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73201. * This number is defined between 0 and 1;
  73202. */
  73203. mixToNormal?: number;
  73204. }
  73205. /**
  73206. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73207. *
  73208. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73209. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73210. */
  73211. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73212. /**
  73213. * The font texture used to render the char in the post process.
  73214. */
  73215. private _digitalRainFontTexture;
  73216. /**
  73217. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73218. * This number is defined between 0 and 1;
  73219. */
  73220. mixToTile: number;
  73221. /**
  73222. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73223. * This number is defined between 0 and 1;
  73224. */
  73225. mixToNormal: number;
  73226. /**
  73227. * Instantiates a new Digital Rain Post Process.
  73228. * @param name the name to give to the postprocess
  73229. * @camera the camera to apply the post process to.
  73230. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73231. */
  73232. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73233. }
  73234. }
  73235. declare module BABYLON {
  73236. /** @hidden */
  73237. export var oceanPostProcessPixelShader: {
  73238. name: string;
  73239. shader: string;
  73240. };
  73241. }
  73242. declare module BABYLON {
  73243. /**
  73244. * Option available in the Ocean Post Process.
  73245. */
  73246. export interface IOceanPostProcessOptions {
  73247. /**
  73248. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73249. */
  73250. reflectionSize?: number | {
  73251. width: number;
  73252. height: number;
  73253. } | {
  73254. ratio: number;
  73255. };
  73256. /**
  73257. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73258. */
  73259. refractionSize?: number | {
  73260. width: number;
  73261. height: number;
  73262. } | {
  73263. ratio: number;
  73264. };
  73265. }
  73266. /**
  73267. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73268. *
  73269. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73270. * Example usage:
  73271. * var pp = new OceanPostProcess("myOcean", camera);
  73272. * pp.reflectionEnabled = true;
  73273. * pp.refractionEnabled = true;
  73274. */
  73275. export class OceanPostProcess extends BABYLON.PostProcess {
  73276. /**
  73277. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73278. */
  73279. /**
  73280. * Sets weither or not the real-time reflection is enabled on the ocean.
  73281. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73282. */
  73283. reflectionEnabled: boolean;
  73284. /**
  73285. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73286. */
  73287. /**
  73288. * Sets weither or not the real-time refraction is enabled on the ocean.
  73289. * Is set to true, the refraction render target texture will be used as refraction texture.
  73290. */
  73291. refractionEnabled: boolean;
  73292. /**
  73293. * Gets wether or not the post-processes is supported by the running hardware.
  73294. * This requires draw buffer supports.
  73295. */
  73296. readonly isSupported: boolean;
  73297. /**
  73298. * This is the reflection mirror texture used to display reflections on the ocean.
  73299. * By default, render list is empty.
  73300. */
  73301. reflectionTexture: BABYLON.MirrorTexture;
  73302. /**
  73303. * This is the refraction render target texture used to display refraction on the ocean.
  73304. * By default, render list is empty.
  73305. */
  73306. refractionTexture: BABYLON.RenderTargetTexture;
  73307. private _time;
  73308. private _cameraRotation;
  73309. private _cameraViewMatrix;
  73310. private _reflectionEnabled;
  73311. private _refractionEnabled;
  73312. private _geometryRenderer;
  73313. /**
  73314. * Instantiates a new Ocean Post Process.
  73315. * @param name the name to give to the postprocess.
  73316. * @camera the camera to apply the post process to.
  73317. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73318. */
  73319. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73320. /**
  73321. * Returns the appropriate defines according to the current configuration.
  73322. */
  73323. private _getDefines;
  73324. /**
  73325. * Computes the current camera rotation as the shader requires a camera rotation.
  73326. */
  73327. private _computeCameraRotation;
  73328. }
  73329. }
  73330. declare module BABYLON {
  73331. /** @hidden */
  73332. export var brickProceduralTexturePixelShader: {
  73333. name: string;
  73334. shader: string;
  73335. };
  73336. }
  73337. declare module BABYLON {
  73338. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73339. private _numberOfBricksHeight;
  73340. private _numberOfBricksWidth;
  73341. private _jointColor;
  73342. private _brickColor;
  73343. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73344. updateShaderUniforms(): void;
  73345. numberOfBricksHeight: number;
  73346. numberOfBricksWidth: number;
  73347. jointColor: BABYLON.Color3;
  73348. brickColor: BABYLON.Color3;
  73349. /**
  73350. * Serializes this brick procedural texture
  73351. * @returns a serialized brick procedural texture object
  73352. */
  73353. serialize(): any;
  73354. /**
  73355. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73356. * @param parsedTexture defines parsed texture data
  73357. * @param scene defines the current scene
  73358. * @param rootUrl defines the root URL containing brick procedural texture information
  73359. * @returns a parsed Brick Procedural BABYLON.Texture
  73360. */
  73361. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73362. }
  73363. }
  73364. declare module BABYLON {
  73365. /** @hidden */
  73366. export var cloudProceduralTexturePixelShader: {
  73367. name: string;
  73368. shader: string;
  73369. };
  73370. }
  73371. declare module BABYLON {
  73372. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73373. private _skyColor;
  73374. private _cloudColor;
  73375. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73376. updateShaderUniforms(): void;
  73377. skyColor: BABYLON.Color4;
  73378. cloudColor: BABYLON.Color4;
  73379. /**
  73380. * Serializes this cloud procedural texture
  73381. * @returns a serialized cloud procedural texture object
  73382. */
  73383. serialize(): any;
  73384. /**
  73385. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73386. * @param parsedTexture defines parsed texture data
  73387. * @param scene defines the current scene
  73388. * @param rootUrl defines the root URL containing cloud procedural texture information
  73389. * @returns a parsed Cloud Procedural BABYLON.Texture
  73390. */
  73391. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73392. }
  73393. }
  73394. declare module BABYLON {
  73395. /** @hidden */
  73396. export var fireProceduralTexturePixelShader: {
  73397. name: string;
  73398. shader: string;
  73399. };
  73400. }
  73401. declare module BABYLON {
  73402. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73403. private _time;
  73404. private _speed;
  73405. private _autoGenerateTime;
  73406. private _fireColors;
  73407. private _alphaThreshold;
  73408. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73409. updateShaderUniforms(): void;
  73410. render(useCameraPostProcess?: boolean): void;
  73411. static readonly PurpleFireColors: BABYLON.Color3[];
  73412. static readonly GreenFireColors: BABYLON.Color3[];
  73413. static readonly RedFireColors: BABYLON.Color3[];
  73414. static readonly BlueFireColors: BABYLON.Color3[];
  73415. autoGenerateTime: boolean;
  73416. fireColors: BABYLON.Color3[];
  73417. time: number;
  73418. speed: BABYLON.Vector2;
  73419. alphaThreshold: number;
  73420. /**
  73421. * Serializes this fire procedural texture
  73422. * @returns a serialized fire procedural texture object
  73423. */
  73424. serialize(): any;
  73425. /**
  73426. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73427. * @param parsedTexture defines parsed texture data
  73428. * @param scene defines the current scene
  73429. * @param rootUrl defines the root URL containing fire procedural texture information
  73430. * @returns a parsed Fire Procedural BABYLON.Texture
  73431. */
  73432. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73433. }
  73434. }
  73435. declare module BABYLON {
  73436. /** @hidden */
  73437. export var grassProceduralTexturePixelShader: {
  73438. name: string;
  73439. shader: string;
  73440. };
  73441. }
  73442. declare module BABYLON {
  73443. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73444. private _grassColors;
  73445. private _groundColor;
  73446. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73447. updateShaderUniforms(): void;
  73448. grassColors: BABYLON.Color3[];
  73449. groundColor: BABYLON.Color3;
  73450. /**
  73451. * Serializes this grass procedural texture
  73452. * @returns a serialized grass procedural texture object
  73453. */
  73454. serialize(): any;
  73455. /**
  73456. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73457. * @param parsedTexture defines parsed texture data
  73458. * @param scene defines the current scene
  73459. * @param rootUrl defines the root URL containing grass procedural texture information
  73460. * @returns a parsed Grass Procedural BABYLON.Texture
  73461. */
  73462. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73463. }
  73464. }
  73465. declare module BABYLON {
  73466. /** @hidden */
  73467. export var marbleProceduralTexturePixelShader: {
  73468. name: string;
  73469. shader: string;
  73470. };
  73471. }
  73472. declare module BABYLON {
  73473. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73474. private _numberOfTilesHeight;
  73475. private _numberOfTilesWidth;
  73476. private _amplitude;
  73477. private _jointColor;
  73478. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73479. updateShaderUniforms(): void;
  73480. numberOfTilesHeight: number;
  73481. amplitude: number;
  73482. numberOfTilesWidth: number;
  73483. jointColor: BABYLON.Color3;
  73484. /**
  73485. * Serializes this marble procedural texture
  73486. * @returns a serialized marble procedural texture object
  73487. */
  73488. serialize(): any;
  73489. /**
  73490. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73491. * @param parsedTexture defines parsed texture data
  73492. * @param scene defines the current scene
  73493. * @param rootUrl defines the root URL containing marble procedural texture information
  73494. * @returns a parsed Marble Procedural BABYLON.Texture
  73495. */
  73496. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73497. }
  73498. }
  73499. declare module BABYLON {
  73500. /** @hidden */
  73501. export var normalMapProceduralTexturePixelShader: {
  73502. name: string;
  73503. shader: string;
  73504. };
  73505. }
  73506. declare module BABYLON {
  73507. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73508. private _baseTexture;
  73509. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73510. updateShaderUniforms(): void;
  73511. render(useCameraPostProcess?: boolean): void;
  73512. resize(size: any, generateMipMaps: any): void;
  73513. baseTexture: BABYLON.Texture;
  73514. /**
  73515. * Serializes this normal map procedural texture
  73516. * @returns a serialized normal map procedural texture object
  73517. */
  73518. serialize(): any;
  73519. /**
  73520. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73521. * @param parsedTexture defines parsed texture data
  73522. * @param scene defines the current scene
  73523. * @param rootUrl defines the root URL containing normal map procedural texture information
  73524. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73525. */
  73526. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73527. }
  73528. }
  73529. declare module BABYLON {
  73530. /** @hidden */
  73531. export var perlinNoiseProceduralTexturePixelShader: {
  73532. name: string;
  73533. shader: string;
  73534. };
  73535. }
  73536. declare module BABYLON {
  73537. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73538. time: number;
  73539. timeScale: number;
  73540. translationSpeed: number;
  73541. private _currentTranslation;
  73542. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73543. updateShaderUniforms(): void;
  73544. render(useCameraPostProcess?: boolean): void;
  73545. resize(size: any, generateMipMaps: any): void;
  73546. /**
  73547. * Serializes this perlin noise procedural texture
  73548. * @returns a serialized perlin noise procedural texture object
  73549. */
  73550. serialize(): any;
  73551. /**
  73552. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73553. * @param parsedTexture defines parsed texture data
  73554. * @param scene defines the current scene
  73555. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73556. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73557. */
  73558. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73559. }
  73560. }
  73561. declare module BABYLON {
  73562. /** @hidden */
  73563. export var roadProceduralTexturePixelShader: {
  73564. name: string;
  73565. shader: string;
  73566. };
  73567. }
  73568. declare module BABYLON {
  73569. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73570. private _roadColor;
  73571. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73572. updateShaderUniforms(): void;
  73573. roadColor: BABYLON.Color3;
  73574. /**
  73575. * Serializes this road procedural texture
  73576. * @returns a serialized road procedural texture object
  73577. */
  73578. serialize(): any;
  73579. /**
  73580. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73581. * @param parsedTexture defines parsed texture data
  73582. * @param scene defines the current scene
  73583. * @param rootUrl defines the root URL containing road procedural texture information
  73584. * @returns a parsed Road Procedural BABYLON.Texture
  73585. */
  73586. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73587. }
  73588. }
  73589. declare module BABYLON {
  73590. /** @hidden */
  73591. export var starfieldProceduralTexturePixelShader: {
  73592. name: string;
  73593. shader: string;
  73594. };
  73595. }
  73596. declare module BABYLON {
  73597. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73598. private _time;
  73599. private _alpha;
  73600. private _beta;
  73601. private _zoom;
  73602. private _formuparam;
  73603. private _stepsize;
  73604. private _tile;
  73605. private _brightness;
  73606. private _darkmatter;
  73607. private _distfading;
  73608. private _saturation;
  73609. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73610. updateShaderUniforms(): void;
  73611. time: number;
  73612. alpha: number;
  73613. beta: number;
  73614. formuparam: number;
  73615. stepsize: number;
  73616. zoom: number;
  73617. tile: number;
  73618. brightness: number;
  73619. darkmatter: number;
  73620. distfading: number;
  73621. saturation: number;
  73622. /**
  73623. * Serializes this starfield procedural texture
  73624. * @returns a serialized starfield procedural texture object
  73625. */
  73626. serialize(): any;
  73627. /**
  73628. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73629. * @param parsedTexture defines parsed texture data
  73630. * @param scene defines the current scene
  73631. * @param rootUrl defines the root URL containing startfield procedural texture information
  73632. * @returns a parsed Starfield Procedural BABYLON.Texture
  73633. */
  73634. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73635. }
  73636. }
  73637. declare module BABYLON {
  73638. /** @hidden */
  73639. export var woodProceduralTexturePixelShader: {
  73640. name: string;
  73641. shader: string;
  73642. };
  73643. }
  73644. declare module BABYLON {
  73645. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73646. private _ampScale;
  73647. private _woodColor;
  73648. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73649. updateShaderUniforms(): void;
  73650. ampScale: number;
  73651. woodColor: BABYLON.Color3;
  73652. /**
  73653. * Serializes this wood procedural texture
  73654. * @returns a serialized wood procedural texture object
  73655. */
  73656. serialize(): any;
  73657. /**
  73658. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73659. * @param parsedTexture defines parsed texture data
  73660. * @param scene defines the current scene
  73661. * @param rootUrl defines the root URL containing wood procedural texture information
  73662. * @returns a parsed Wood Procedural BABYLON.Texture
  73663. */
  73664. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73665. }
  73666. }