documentation.d.ts 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vector3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * 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)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * 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
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. 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;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * 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"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * 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".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * 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"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * 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".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * 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.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * 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.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * 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).
  4349. * 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.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @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.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** 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 */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** 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 */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** 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 */
  4520. static readonly GEQUAL: number;
  4521. /** 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 */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * 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.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * 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.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /** @hidden */
  5295. export interface IShaderProcessor {
  5296. attributeProcessor?: (attribute: string) => string;
  5297. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5298. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5299. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5300. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5301. lineProcessor?: (line: string, isFragment: boolean) => string;
  5302. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5304. }
  5305. }
  5306. declare module BABYLON {
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. platformName: string;
  5321. lookForClosingBracketForUniformBuffer?: boolean;
  5322. }
  5323. }
  5324. declare module BABYLON {
  5325. /** @hidden */
  5326. export class ShaderCodeNode {
  5327. line: string;
  5328. children: ShaderCodeNode[];
  5329. additionalDefineKey?: string;
  5330. additionalDefineValue?: string;
  5331. isValid(preprocessors: {
  5332. [key: string]: string;
  5333. }): boolean;
  5334. process(preprocessors: {
  5335. [key: string]: string;
  5336. }, options: ProcessingOptions): string;
  5337. }
  5338. }
  5339. declare module BABYLON {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. /** @hidden */
  5351. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5352. process(preprocessors: {
  5353. [key: string]: string;
  5354. }, options: ProcessingOptions): string;
  5355. }
  5356. }
  5357. declare module BABYLON {
  5358. /** @hidden */
  5359. export class ShaderDefineExpression {
  5360. isTrue(preprocessors: {
  5361. [key: string]: string;
  5362. }): boolean;
  5363. }
  5364. }
  5365. declare module BABYLON {
  5366. /** @hidden */
  5367. export class ShaderCodeTestNode extends ShaderCodeNode {
  5368. testExpression: ShaderDefineExpression;
  5369. isValid(preprocessors: {
  5370. [key: string]: string;
  5371. }): boolean;
  5372. }
  5373. }
  5374. declare module BABYLON {
  5375. /** @hidden */
  5376. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5377. define: string;
  5378. not: boolean;
  5379. constructor(define: string, not?: boolean);
  5380. isTrue(preprocessors: {
  5381. [key: string]: string;
  5382. }): boolean;
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. /** @hidden */
  5387. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5388. leftOperand: ShaderDefineExpression;
  5389. rightOperand: ShaderDefineExpression;
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module BABYLON {
  5396. /** @hidden */
  5397. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5398. leftOperand: ShaderDefineExpression;
  5399. rightOperand: ShaderDefineExpression;
  5400. isTrue(preprocessors: {
  5401. [key: string]: string;
  5402. }): boolean;
  5403. }
  5404. }
  5405. declare module BABYLON {
  5406. /** @hidden */
  5407. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5408. define: string;
  5409. operand: string;
  5410. testValue: string;
  5411. constructor(define: string, operand: string, testValue: string);
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module BABYLON {
  5418. /** @hidden */
  5419. export class ShaderProcessor {
  5420. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5421. private static _ProcessPrecision;
  5422. private static _ExtractOperation;
  5423. private static _BuildSubExpression;
  5424. private static _BuildExpression;
  5425. private static _MoveCursorWithinIf;
  5426. private static _MoveCursor;
  5427. private static _EvaluatePreProcessors;
  5428. private static _PreparePreProcessors;
  5429. private static _ProcessShaderConversion;
  5430. private static _ProcessIncludes;
  5431. }
  5432. }
  5433. declare module BABYLON {
  5434. /**
  5435. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5436. */
  5437. export class PerformanceMonitor {
  5438. private _enabled;
  5439. private _rollingFrameTime;
  5440. private _lastFrameTimeMs;
  5441. /**
  5442. * constructor
  5443. * @param frameSampleSize The number of samples required to saturate the sliding window
  5444. */
  5445. constructor(frameSampleSize?: number);
  5446. /**
  5447. * Samples current frame
  5448. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5449. */
  5450. sampleFrame(timeMs?: number): void;
  5451. /**
  5452. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5453. */
  5454. readonly averageFrameTime: number;
  5455. /**
  5456. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTimeVariance: number;
  5459. /**
  5460. * Returns the frame time of the most recent frame
  5461. */
  5462. readonly instantaneousFrameTime: number;
  5463. /**
  5464. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5465. */
  5466. readonly averageFPS: number;
  5467. /**
  5468. * Returns the average framerate in frames per second using the most recent frame time
  5469. */
  5470. readonly instantaneousFPS: number;
  5471. /**
  5472. * Returns true if enough samples have been taken to completely fill the sliding window
  5473. */
  5474. readonly isSaturated: boolean;
  5475. /**
  5476. * Enables contributions to the sliding window sample set
  5477. */
  5478. enable(): void;
  5479. /**
  5480. * Disables contributions to the sliding window sample set
  5481. * Samples will not be interpolated over the disabled period
  5482. */
  5483. disable(): void;
  5484. /**
  5485. * Returns true if sampling is enabled
  5486. */
  5487. readonly isEnabled: boolean;
  5488. /**
  5489. * Resets performance monitor
  5490. */
  5491. reset(): void;
  5492. }
  5493. /**
  5494. * RollingAverage
  5495. *
  5496. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5497. */
  5498. export class RollingAverage {
  5499. /**
  5500. * Current average
  5501. */
  5502. average: number;
  5503. /**
  5504. * Current variance
  5505. */
  5506. variance: number;
  5507. protected _samples: Array<number>;
  5508. protected _sampleCount: number;
  5509. protected _pos: number;
  5510. protected _m2: number;
  5511. /**
  5512. * constructor
  5513. * @param length The number of samples required to saturate the sliding window
  5514. */
  5515. constructor(length: number);
  5516. /**
  5517. * Adds a sample to the sample set
  5518. * @param v The sample value
  5519. */
  5520. add(v: number): void;
  5521. /**
  5522. * Returns previously added values or null if outside of history or outside the sliding window domain
  5523. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5524. * @return Value previously recorded with add() or null if outside of range
  5525. */
  5526. history(i: number): number;
  5527. /**
  5528. * Returns true if enough samples have been taken to completely fill the sliding window
  5529. * @return true if sample-set saturated
  5530. */
  5531. isSaturated(): boolean;
  5532. /**
  5533. * Resets the rolling average (equivalent to 0 samples taken so far)
  5534. */
  5535. reset(): void;
  5536. /**
  5537. * Wraps a value around the sample range boundaries
  5538. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5539. * @return Wrapped position in sample range
  5540. */
  5541. protected _wrapPosition(i: number): number;
  5542. }
  5543. }
  5544. declare module BABYLON {
  5545. /**
  5546. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5547. * The underlying implementation relies on an associative array to ensure the best performances.
  5548. * The value can be anything including 'null' but except 'undefined'
  5549. */
  5550. export class StringDictionary<T> {
  5551. /**
  5552. * This will clear this dictionary and copy the content from the 'source' one.
  5553. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5554. * @param source the dictionary to take the content from and copy to this dictionary
  5555. */
  5556. copyFrom(source: StringDictionary<T>): void;
  5557. /**
  5558. * Get a value based from its key
  5559. * @param key the given key to get the matching value from
  5560. * @return the value if found, otherwise undefined is returned
  5561. */
  5562. get(key: string): T | undefined;
  5563. /**
  5564. * Get a value from its key or add it if it doesn't exist.
  5565. * This method will ensure you that a given key/data will be present in the dictionary.
  5566. * @param key the given key to get the matching value from
  5567. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5568. * The factory will only be invoked if there's no data for the given key.
  5569. * @return the value corresponding to the key.
  5570. */
  5571. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5572. /**
  5573. * Get a value from its key if present in the dictionary otherwise add it
  5574. * @param key the key to get the value from
  5575. * @param val if there's no such key/value pair in the dictionary add it with this value
  5576. * @return the value corresponding to the key
  5577. */
  5578. getOrAdd(key: string, val: T): T;
  5579. /**
  5580. * Check if there's a given key in the dictionary
  5581. * @param key the key to check for
  5582. * @return true if the key is present, false otherwise
  5583. */
  5584. contains(key: string): boolean;
  5585. /**
  5586. * Add a new key and its corresponding value
  5587. * @param key the key to add
  5588. * @param value the value corresponding to the key
  5589. * @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
  5590. */
  5591. add(key: string, value: T): boolean;
  5592. /**
  5593. * Update a specific value associated to a key
  5594. * @param key defines the key to use
  5595. * @param value defines the value to store
  5596. * @returns true if the value was updated (or false if the key was not found)
  5597. */
  5598. set(key: string, value: T): boolean;
  5599. /**
  5600. * Get the element of the given key and remove it from the dictionary
  5601. * @param key defines the key to search
  5602. * @returns the value associated with the key or null if not found
  5603. */
  5604. getAndRemove(key: string): Nullable<T>;
  5605. /**
  5606. * Remove a key/value from the dictionary.
  5607. * @param key the key to remove
  5608. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5609. */
  5610. remove(key: string): boolean;
  5611. /**
  5612. * Clear the whole content of the dictionary
  5613. */
  5614. clear(): void;
  5615. /**
  5616. * Gets the current count
  5617. */
  5618. readonly count: number;
  5619. /**
  5620. * Execute a callback on each key/val of the dictionary.
  5621. * Note that you can remove any element in this dictionary in the callback implementation
  5622. * @param callback the callback to execute on a given key/value pair
  5623. */
  5624. forEach(callback: (key: string, val: T) => void): void;
  5625. /**
  5626. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5627. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5628. * Note that you can remove any element in this dictionary in the callback implementation
  5629. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5630. * @returns the first item
  5631. */
  5632. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5633. private _count;
  5634. private _data;
  5635. }
  5636. }
  5637. declare module BABYLON {
  5638. /**
  5639. * Helper class that provides a small promise polyfill
  5640. */
  5641. export class PromisePolyfill {
  5642. /**
  5643. * Static function used to check if the polyfill is required
  5644. * If this is the case then the function will inject the polyfill to window.Promise
  5645. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5646. */
  5647. static Apply(force?: boolean): void;
  5648. }
  5649. }
  5650. declare module BABYLON {
  5651. /**
  5652. * Class used to store data that will be store in GPU memory
  5653. */
  5654. export class Buffer {
  5655. private _engine;
  5656. private _buffer;
  5657. /** @hidden */
  5658. _data: Nullable<DataArray>;
  5659. private _updatable;
  5660. private _instanced;
  5661. /**
  5662. * Gets the byte stride.
  5663. */
  5664. readonly byteStride: number;
  5665. /**
  5666. * Constructor
  5667. * @param engine the engine
  5668. * @param data the data to use for this buffer
  5669. * @param updatable whether the data is updatable
  5670. * @param stride the stride (optional)
  5671. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5672. * @param instanced whether the buffer is instanced (optional)
  5673. * @param useBytes set to true if the stride in in bytes (optional)
  5674. */
  5675. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5676. /**
  5677. * Create a new VertexBuffer based on the current buffer
  5678. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5679. * @param offset defines offset in the buffer (0 by default)
  5680. * @param size defines the size in floats of attributes (position is 3 for instance)
  5681. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5682. * @param instanced defines if the vertex buffer contains indexed data
  5683. * @param useBytes defines if the offset and stride are in bytes
  5684. * @returns the new vertex buffer
  5685. */
  5686. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5687. /**
  5688. * Gets a boolean indicating if the Buffer is updatable?
  5689. * @returns true if the buffer is updatable
  5690. */
  5691. isUpdatable(): boolean;
  5692. /**
  5693. * Gets current buffer's data
  5694. * @returns a DataArray or null
  5695. */
  5696. getData(): Nullable<DataArray>;
  5697. /**
  5698. * Gets underlying native buffer
  5699. * @returns underlying native buffer
  5700. */
  5701. getBuffer(): Nullable<DataBuffer>;
  5702. /**
  5703. * Gets the stride in float32 units (i.e. byte stride / 4).
  5704. * May not be an integer if the byte stride is not divisible by 4.
  5705. * DEPRECATED. Use byteStride instead.
  5706. * @returns the stride in float32 units
  5707. */
  5708. getStrideSize(): number;
  5709. /**
  5710. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5711. * @param data defines the data to store
  5712. */
  5713. create(data?: Nullable<DataArray>): void;
  5714. /** @hidden */
  5715. _rebuild(): void;
  5716. /**
  5717. * Update current buffer data
  5718. * @param data defines the data to store
  5719. */
  5720. update(data: DataArray): void;
  5721. /**
  5722. * Updates the data directly.
  5723. * @param data the new data
  5724. * @param offset the new offset
  5725. * @param vertexCount the vertex count (optional)
  5726. * @param useBytes set to true if the offset is in bytes
  5727. */
  5728. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5729. /**
  5730. * Release all resources
  5731. */
  5732. dispose(): void;
  5733. }
  5734. /**
  5735. * Specialized buffer used to store vertex data
  5736. */
  5737. export class VertexBuffer {
  5738. /** @hidden */
  5739. _buffer: Buffer;
  5740. private _kind;
  5741. private _size;
  5742. private _ownsBuffer;
  5743. private _instanced;
  5744. private _instanceDivisor;
  5745. /**
  5746. * The byte type.
  5747. */
  5748. static readonly BYTE: number;
  5749. /**
  5750. * The unsigned byte type.
  5751. */
  5752. static readonly UNSIGNED_BYTE: number;
  5753. /**
  5754. * The short type.
  5755. */
  5756. static readonly SHORT: number;
  5757. /**
  5758. * The unsigned short type.
  5759. */
  5760. static readonly UNSIGNED_SHORT: number;
  5761. /**
  5762. * The integer type.
  5763. */
  5764. static readonly INT: number;
  5765. /**
  5766. * The unsigned integer type.
  5767. */
  5768. static readonly UNSIGNED_INT: number;
  5769. /**
  5770. * The float type.
  5771. */
  5772. static readonly FLOAT: number;
  5773. /**
  5774. * Gets or sets the instance divisor when in instanced mode
  5775. */
  5776. instanceDivisor: number;
  5777. /**
  5778. * Gets the byte stride.
  5779. */
  5780. readonly byteStride: number;
  5781. /**
  5782. * Gets the byte offset.
  5783. */
  5784. readonly byteOffset: number;
  5785. /**
  5786. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5787. */
  5788. readonly normalized: boolean;
  5789. /**
  5790. * Gets the data type of each component in the array.
  5791. */
  5792. readonly type: number;
  5793. /**
  5794. * Constructor
  5795. * @param engine the engine
  5796. * @param data the data to use for this vertex buffer
  5797. * @param kind the vertex buffer kind
  5798. * @param updatable whether the data is updatable
  5799. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5800. * @param stride the stride (optional)
  5801. * @param instanced whether the buffer is instanced (optional)
  5802. * @param offset the offset of the data (optional)
  5803. * @param size the number of components (optional)
  5804. * @param type the type of the component (optional)
  5805. * @param normalized whether the data contains normalized data (optional)
  5806. * @param useBytes set to true if stride and offset are in bytes (optional)
  5807. */
  5808. 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);
  5809. /** @hidden */
  5810. _rebuild(): void;
  5811. /**
  5812. * Returns the kind of the VertexBuffer (string)
  5813. * @returns a string
  5814. */
  5815. getKind(): string;
  5816. /**
  5817. * Gets a boolean indicating if the VertexBuffer is updatable?
  5818. * @returns true if the buffer is updatable
  5819. */
  5820. isUpdatable(): boolean;
  5821. /**
  5822. * Gets current buffer's data
  5823. * @returns a DataArray or null
  5824. */
  5825. getData(): Nullable<DataArray>;
  5826. /**
  5827. * Gets underlying native buffer
  5828. * @returns underlying native buffer
  5829. */
  5830. getBuffer(): Nullable<DataBuffer>;
  5831. /**
  5832. * Gets the stride in float32 units (i.e. byte stride / 4).
  5833. * May not be an integer if the byte stride is not divisible by 4.
  5834. * DEPRECATED. Use byteStride instead.
  5835. * @returns the stride in float32 units
  5836. */
  5837. getStrideSize(): number;
  5838. /**
  5839. * Returns the offset as a multiple of the type byte length.
  5840. * DEPRECATED. Use byteOffset instead.
  5841. * @returns the offset in bytes
  5842. */
  5843. getOffset(): number;
  5844. /**
  5845. * Returns the number of components per vertex attribute (integer)
  5846. * @returns the size in float
  5847. */
  5848. getSize(): number;
  5849. /**
  5850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5851. * @returns true if this buffer is instanced
  5852. */
  5853. getIsInstanced(): boolean;
  5854. /**
  5855. * Returns the instancing divisor, zero for non-instanced (integer).
  5856. * @returns a number
  5857. */
  5858. getInstanceDivisor(): number;
  5859. /**
  5860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5861. * @param data defines the data to store
  5862. */
  5863. create(data?: DataArray): void;
  5864. /**
  5865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5866. * This function will create a new buffer if the current one is not updatable
  5867. * @param data defines the data to store
  5868. */
  5869. update(data: DataArray): void;
  5870. /**
  5871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5872. * Returns the directly updated WebGLBuffer.
  5873. * @param data the new data
  5874. * @param offset the new offset
  5875. * @param useBytes set to true if the offset is in bytes
  5876. */
  5877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5878. /**
  5879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5880. */
  5881. dispose(): void;
  5882. /**
  5883. * Enumerates each value of this vertex buffer as numbers.
  5884. * @param count the number of values to enumerate
  5885. * @param callback the callback function called for each value
  5886. */
  5887. forEach(count: number, callback: (value: number, index: number) => void): void;
  5888. /**
  5889. * Positions
  5890. */
  5891. static readonly PositionKind: string;
  5892. /**
  5893. * Normals
  5894. */
  5895. static readonly NormalKind: string;
  5896. /**
  5897. * Tangents
  5898. */
  5899. static readonly TangentKind: string;
  5900. /**
  5901. * Texture coordinates
  5902. */
  5903. static readonly UVKind: string;
  5904. /**
  5905. * Texture coordinates 2
  5906. */
  5907. static readonly UV2Kind: string;
  5908. /**
  5909. * Texture coordinates 3
  5910. */
  5911. static readonly UV3Kind: string;
  5912. /**
  5913. * Texture coordinates 4
  5914. */
  5915. static readonly UV4Kind: string;
  5916. /**
  5917. * Texture coordinates 5
  5918. */
  5919. static readonly UV5Kind: string;
  5920. /**
  5921. * Texture coordinates 6
  5922. */
  5923. static readonly UV6Kind: string;
  5924. /**
  5925. * Colors
  5926. */
  5927. static readonly ColorKind: string;
  5928. /**
  5929. * Matrix indices (for bones)
  5930. */
  5931. static readonly MatricesIndicesKind: string;
  5932. /**
  5933. * Matrix weights (for bones)
  5934. */
  5935. static readonly MatricesWeightsKind: string;
  5936. /**
  5937. * Additional matrix indices (for bones)
  5938. */
  5939. static readonly MatricesIndicesExtraKind: string;
  5940. /**
  5941. * Additional matrix weights (for bones)
  5942. */
  5943. static readonly MatricesWeightsExtraKind: string;
  5944. /**
  5945. * Deduces the stride given a kind.
  5946. * @param kind The kind string to deduce
  5947. * @returns The deduced stride
  5948. */
  5949. static DeduceStride(kind: string): number;
  5950. /**
  5951. * Gets the byte length of the given type.
  5952. * @param type the type
  5953. * @returns the number of bytes
  5954. */
  5955. static GetTypeByteLength(type: number): number;
  5956. /**
  5957. * Enumerates each value of the given parameters as numbers.
  5958. * @param data the data to enumerate
  5959. * @param byteOffset the byte offset of the data
  5960. * @param byteStride the byte stride of the data
  5961. * @param componentCount the number of components per element
  5962. * @param componentType the type of the component
  5963. * @param count the number of values to enumerate
  5964. * @param normalized whether the data is normalized
  5965. * @param callback the callback function called for each value
  5966. */
  5967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5968. private static _GetFloatValue;
  5969. }
  5970. }
  5971. declare module BABYLON {
  5972. /**
  5973. * Class representing spherical harmonics coefficients to the 3rd degree
  5974. */
  5975. export class SphericalHarmonics {
  5976. /**
  5977. * Defines whether or not the harmonics have been prescaled for rendering.
  5978. */
  5979. preScaled: boolean;
  5980. /**
  5981. * The l0,0 coefficients of the spherical harmonics
  5982. */
  5983. l00: Vector3;
  5984. /**
  5985. * The l1,-1 coefficients of the spherical harmonics
  5986. */
  5987. l1_1: Vector3;
  5988. /**
  5989. * The l1,0 coefficients of the spherical harmonics
  5990. */
  5991. l10: Vector3;
  5992. /**
  5993. * The l1,1 coefficients of the spherical harmonics
  5994. */
  5995. l11: Vector3;
  5996. /**
  5997. * The l2,-2 coefficients of the spherical harmonics
  5998. */
  5999. l2_2: Vector3;
  6000. /**
  6001. * The l2,-1 coefficients of the spherical harmonics
  6002. */
  6003. l2_1: Vector3;
  6004. /**
  6005. * The l2,0 coefficients of the spherical harmonics
  6006. */
  6007. l20: Vector3;
  6008. /**
  6009. * The l2,1 coefficients of the spherical harmonics
  6010. */
  6011. l21: Vector3;
  6012. /**
  6013. * The l2,2 coefficients of the spherical harmonics
  6014. */
  6015. l22: Vector3;
  6016. /**
  6017. * Adds a light to the spherical harmonics
  6018. * @param direction the direction of the light
  6019. * @param color the color of the light
  6020. * @param deltaSolidAngle the delta solid angle of the light
  6021. */
  6022. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6023. /**
  6024. * Scales the spherical harmonics by the given amount
  6025. * @param scale the amount to scale
  6026. */
  6027. scaleInPlace(scale: number): void;
  6028. /**
  6029. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6030. *
  6031. * ```
  6032. * E_lm = A_l * L_lm
  6033. * ```
  6034. *
  6035. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6036. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6037. * the scaling factors are given in equation 9.
  6038. */
  6039. convertIncidentRadianceToIrradiance(): void;
  6040. /**
  6041. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6042. *
  6043. * ```
  6044. * L = (1/pi) * E * rho
  6045. * ```
  6046. *
  6047. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6048. */
  6049. convertIrradianceToLambertianRadiance(): void;
  6050. /**
  6051. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6052. * required operations at run time.
  6053. *
  6054. * This is simply done by scaling back the SH with Ylm constants parameter.
  6055. * The trigonometric part being applied by the shader at run time.
  6056. */
  6057. preScaleForRendering(): void;
  6058. /**
  6059. * Constructs a spherical harmonics from an array.
  6060. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6061. * @returns the spherical harmonics
  6062. */
  6063. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6064. /**
  6065. * Gets the spherical harmonics from polynomial
  6066. * @param polynomial the spherical polynomial
  6067. * @returns the spherical harmonics
  6068. */
  6069. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6070. }
  6071. /**
  6072. * Class representing spherical polynomial coefficients to the 3rd degree
  6073. */
  6074. export class SphericalPolynomial {
  6075. private _harmonics;
  6076. /**
  6077. * The spherical harmonics used to create the polynomials.
  6078. */
  6079. readonly preScaledHarmonics: SphericalHarmonics;
  6080. /**
  6081. * The x coefficients of the spherical polynomial
  6082. */
  6083. x: Vector3;
  6084. /**
  6085. * The y coefficients of the spherical polynomial
  6086. */
  6087. y: Vector3;
  6088. /**
  6089. * The z coefficients of the spherical polynomial
  6090. */
  6091. z: Vector3;
  6092. /**
  6093. * The xx coefficients of the spherical polynomial
  6094. */
  6095. xx: Vector3;
  6096. /**
  6097. * The yy coefficients of the spherical polynomial
  6098. */
  6099. yy: Vector3;
  6100. /**
  6101. * The zz coefficients of the spherical polynomial
  6102. */
  6103. zz: Vector3;
  6104. /**
  6105. * The xy coefficients of the spherical polynomial
  6106. */
  6107. xy: Vector3;
  6108. /**
  6109. * The yz coefficients of the spherical polynomial
  6110. */
  6111. yz: Vector3;
  6112. /**
  6113. * The zx coefficients of the spherical polynomial
  6114. */
  6115. zx: Vector3;
  6116. /**
  6117. * Adds an ambient color to the spherical polynomial
  6118. * @param color the color to add
  6119. */
  6120. addAmbient(color: Color3): void;
  6121. /**
  6122. * Scales the spherical polynomial by the given amount
  6123. * @param scale the amount to scale
  6124. */
  6125. scaleInPlace(scale: number): void;
  6126. /**
  6127. * Gets the spherical polynomial from harmonics
  6128. * @param harmonics the spherical harmonics
  6129. * @returns the spherical polynomial
  6130. */
  6131. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6132. /**
  6133. * Constructs a spherical polynomial from an array.
  6134. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6135. * @returns the spherical polynomial
  6136. */
  6137. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6138. }
  6139. }
  6140. declare module BABYLON {
  6141. /**
  6142. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6143. */
  6144. export interface CubeMapInfo {
  6145. /**
  6146. * The pixel array for the front face.
  6147. * This is stored in format, left to right, up to down format.
  6148. */
  6149. front: Nullable<ArrayBufferView>;
  6150. /**
  6151. * The pixel array for the back face.
  6152. * This is stored in format, left to right, up to down format.
  6153. */
  6154. back: Nullable<ArrayBufferView>;
  6155. /**
  6156. * The pixel array for the left face.
  6157. * This is stored in format, left to right, up to down format.
  6158. */
  6159. left: Nullable<ArrayBufferView>;
  6160. /**
  6161. * The pixel array for the right face.
  6162. * This is stored in format, left to right, up to down format.
  6163. */
  6164. right: Nullable<ArrayBufferView>;
  6165. /**
  6166. * The pixel array for the up face.
  6167. * This is stored in format, left to right, up to down format.
  6168. */
  6169. up: Nullable<ArrayBufferView>;
  6170. /**
  6171. * The pixel array for the down face.
  6172. * This is stored in format, left to right, up to down format.
  6173. */
  6174. down: Nullable<ArrayBufferView>;
  6175. /**
  6176. * The size of the cubemap stored.
  6177. *
  6178. * Each faces will be size * size pixels.
  6179. */
  6180. size: number;
  6181. /**
  6182. * The format of the texture.
  6183. *
  6184. * RGBA, RGB.
  6185. */
  6186. format: number;
  6187. /**
  6188. * The type of the texture data.
  6189. *
  6190. * UNSIGNED_INT, FLOAT.
  6191. */
  6192. type: number;
  6193. /**
  6194. * Specifies whether the texture is in gamma space.
  6195. */
  6196. gammaSpace: boolean;
  6197. }
  6198. /**
  6199. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6200. */
  6201. export class PanoramaToCubeMapTools {
  6202. private static FACE_FRONT;
  6203. private static FACE_BACK;
  6204. private static FACE_RIGHT;
  6205. private static FACE_LEFT;
  6206. private static FACE_DOWN;
  6207. private static FACE_UP;
  6208. /**
  6209. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6210. *
  6211. * @param float32Array The source data.
  6212. * @param inputWidth The width of the input panorama.
  6213. * @param inputHeight The height of the input panorama.
  6214. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6215. * @return The cubemap data
  6216. */
  6217. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6218. private static CreateCubemapTexture;
  6219. private static CalcProjectionSpherical;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Helper class dealing with the extraction of spherical polynomial dataArray
  6225. * from a cube map.
  6226. */
  6227. export class CubeMapToSphericalPolynomialTools {
  6228. private static FileFaces;
  6229. /**
  6230. * Converts a texture to the according Spherical Polynomial data.
  6231. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6232. *
  6233. * @param texture The texture to extract the information from.
  6234. * @return The Spherical Polynomial data.
  6235. */
  6236. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6237. /**
  6238. * Converts a cubemap to the according Spherical Polynomial data.
  6239. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6240. *
  6241. * @param cubeInfo The Cube map to extract the information from.
  6242. * @return The Spherical Polynomial data.
  6243. */
  6244. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6245. }
  6246. }
  6247. declare module BABYLON {
  6248. /**
  6249. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6250. * during the life time of the application.
  6251. */
  6252. export class EngineStore {
  6253. /** Gets the list of created engines */
  6254. static Instances: Engine[];
  6255. /** @hidden */
  6256. static _LastCreatedScene: Nullable<Scene>;
  6257. /**
  6258. * Gets the latest created engine
  6259. */
  6260. static readonly LastCreatedEngine: Nullable<Engine>;
  6261. /**
  6262. * Gets the latest created scene
  6263. */
  6264. static readonly LastCreatedScene: Nullable<Scene>;
  6265. }
  6266. }
  6267. declare module BABYLON {
  6268. /**
  6269. * Define options used to create a render target texture
  6270. */
  6271. export class RenderTargetCreationOptions {
  6272. /**
  6273. * Specifies is mipmaps must be generated
  6274. */
  6275. generateMipMaps?: boolean;
  6276. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6277. generateDepthBuffer?: boolean;
  6278. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6279. generateStencilBuffer?: boolean;
  6280. /** Defines texture type (int by default) */
  6281. type?: number;
  6282. /** Defines sampling mode (trilinear by default) */
  6283. samplingMode?: number;
  6284. /** Defines format (RGBA by default) */
  6285. format?: number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * @hidden
  6291. **/
  6292. export class _AlphaState {
  6293. private _isAlphaBlendDirty;
  6294. private _isBlendFunctionParametersDirty;
  6295. private _isBlendEquationParametersDirty;
  6296. private _isBlendConstantsDirty;
  6297. private _alphaBlend;
  6298. private _blendFunctionParameters;
  6299. private _blendEquationParameters;
  6300. private _blendConstants;
  6301. /**
  6302. * Initializes the state.
  6303. */
  6304. constructor();
  6305. readonly isDirty: boolean;
  6306. alphaBlend: boolean;
  6307. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6308. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6309. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6310. reset(): void;
  6311. apply(gl: WebGLRenderingContext): void;
  6312. }
  6313. }
  6314. declare module BABYLON {
  6315. /**
  6316. * @hidden
  6317. **/
  6318. export class _DepthCullingState {
  6319. private _isDepthTestDirty;
  6320. private _isDepthMaskDirty;
  6321. private _isDepthFuncDirty;
  6322. private _isCullFaceDirty;
  6323. private _isCullDirty;
  6324. private _isZOffsetDirty;
  6325. private _isFrontFaceDirty;
  6326. private _depthTest;
  6327. private _depthMask;
  6328. private _depthFunc;
  6329. private _cull;
  6330. private _cullFace;
  6331. private _zOffset;
  6332. private _frontFace;
  6333. /**
  6334. * Initializes the state.
  6335. */
  6336. constructor();
  6337. readonly isDirty: boolean;
  6338. zOffset: number;
  6339. cullFace: Nullable<number>;
  6340. cull: Nullable<boolean>;
  6341. depthFunc: Nullable<number>;
  6342. depthMask: boolean;
  6343. depthTest: boolean;
  6344. frontFace: Nullable<number>;
  6345. reset(): void;
  6346. apply(gl: WebGLRenderingContext): void;
  6347. }
  6348. }
  6349. declare module BABYLON {
  6350. /**
  6351. * @hidden
  6352. **/
  6353. export class _StencilState {
  6354. /** 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 */
  6355. static readonly ALWAYS: number;
  6356. /** Passed to stencilOperation to specify that stencil value must be kept */
  6357. static readonly KEEP: number;
  6358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6359. static readonly REPLACE: number;
  6360. private _isStencilTestDirty;
  6361. private _isStencilMaskDirty;
  6362. private _isStencilFuncDirty;
  6363. private _isStencilOpDirty;
  6364. private _stencilTest;
  6365. private _stencilMask;
  6366. private _stencilFunc;
  6367. private _stencilFuncRef;
  6368. private _stencilFuncMask;
  6369. private _stencilOpStencilFail;
  6370. private _stencilOpDepthFail;
  6371. private _stencilOpStencilDepthPass;
  6372. readonly isDirty: boolean;
  6373. stencilFunc: number;
  6374. stencilFuncRef: number;
  6375. stencilFuncMask: number;
  6376. stencilOpStencilFail: number;
  6377. stencilOpDepthFail: number;
  6378. stencilOpStencilDepthPass: number;
  6379. stencilMask: number;
  6380. stencilTest: boolean;
  6381. constructor();
  6382. reset(): void;
  6383. apply(gl: WebGLRenderingContext): void;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * @hidden
  6389. **/
  6390. export class _TimeToken {
  6391. _startTimeQuery: Nullable<WebGLQuery>;
  6392. _endTimeQuery: Nullable<WebGLQuery>;
  6393. _timeElapsedQuery: Nullable<WebGLQuery>;
  6394. _timeElapsedQueryEnded: boolean;
  6395. }
  6396. }
  6397. declare module BABYLON {
  6398. /**
  6399. * Class used to store data associated with WebGL texture data for the engine
  6400. * This class should not be used directly
  6401. */
  6402. export class InternalTexture {
  6403. /** @hidden */
  6404. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6405. /**
  6406. * The source of the texture data is unknown
  6407. */
  6408. static DATASOURCE_UNKNOWN: number;
  6409. /**
  6410. * Texture data comes from an URL
  6411. */
  6412. static DATASOURCE_URL: number;
  6413. /**
  6414. * Texture data is only used for temporary storage
  6415. */
  6416. static DATASOURCE_TEMP: number;
  6417. /**
  6418. * Texture data comes from raw data (ArrayBuffer)
  6419. */
  6420. static DATASOURCE_RAW: number;
  6421. /**
  6422. * Texture content is dynamic (video or dynamic texture)
  6423. */
  6424. static DATASOURCE_DYNAMIC: number;
  6425. /**
  6426. * Texture content is generated by rendering to it
  6427. */
  6428. static DATASOURCE_RENDERTARGET: number;
  6429. /**
  6430. * Texture content is part of a multi render target process
  6431. */
  6432. static DATASOURCE_MULTIRENDERTARGET: number;
  6433. /**
  6434. * Texture data comes from a cube data file
  6435. */
  6436. static DATASOURCE_CUBE: number;
  6437. /**
  6438. * Texture data comes from a raw cube data
  6439. */
  6440. static DATASOURCE_CUBERAW: number;
  6441. /**
  6442. * Texture data come from a prefiltered cube data file
  6443. */
  6444. static DATASOURCE_CUBEPREFILTERED: number;
  6445. /**
  6446. * Texture content is raw 3D data
  6447. */
  6448. static DATASOURCE_RAW3D: number;
  6449. /**
  6450. * Texture content is a depth texture
  6451. */
  6452. static DATASOURCE_DEPTHTEXTURE: number;
  6453. /**
  6454. * Texture data comes from a raw cube data encoded with RGBD
  6455. */
  6456. static DATASOURCE_CUBERAW_RGBD: number;
  6457. /**
  6458. * Defines if the texture is ready
  6459. */
  6460. isReady: boolean;
  6461. /**
  6462. * Defines if the texture is a cube texture
  6463. */
  6464. isCube: boolean;
  6465. /**
  6466. * Defines if the texture contains 3D data
  6467. */
  6468. is3D: boolean;
  6469. /**
  6470. * Defines if the texture contains multiview data
  6471. */
  6472. isMultiview: boolean;
  6473. /**
  6474. * Gets the URL used to load this texture
  6475. */
  6476. url: string;
  6477. /**
  6478. * Gets the sampling mode of the texture
  6479. */
  6480. samplingMode: number;
  6481. /**
  6482. * Gets a boolean indicating if the texture needs mipmaps generation
  6483. */
  6484. generateMipMaps: boolean;
  6485. /**
  6486. * Gets the number of samples used by the texture (WebGL2+ only)
  6487. */
  6488. samples: number;
  6489. /**
  6490. * Gets the type of the texture (int, float...)
  6491. */
  6492. type: number;
  6493. /**
  6494. * Gets the format of the texture (RGB, RGBA...)
  6495. */
  6496. format: number;
  6497. /**
  6498. * Observable called when the texture is loaded
  6499. */
  6500. onLoadedObservable: Observable<InternalTexture>;
  6501. /**
  6502. * Gets the width of the texture
  6503. */
  6504. width: number;
  6505. /**
  6506. * Gets the height of the texture
  6507. */
  6508. height: number;
  6509. /**
  6510. * Gets the depth of the texture
  6511. */
  6512. depth: number;
  6513. /**
  6514. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6515. */
  6516. baseWidth: number;
  6517. /**
  6518. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseHeight: number;
  6521. /**
  6522. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseDepth: number;
  6525. /**
  6526. * Gets a boolean indicating if the texture is inverted on Y axis
  6527. */
  6528. invertY: boolean;
  6529. /** @hidden */
  6530. _invertVScale: boolean;
  6531. /** @hidden */
  6532. _associatedChannel: number;
  6533. /** @hidden */
  6534. _dataSource: number;
  6535. /** @hidden */
  6536. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6537. /** @hidden */
  6538. _bufferView: Nullable<ArrayBufferView>;
  6539. /** @hidden */
  6540. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6541. /** @hidden */
  6542. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6543. /** @hidden */
  6544. _size: number;
  6545. /** @hidden */
  6546. _extension: string;
  6547. /** @hidden */
  6548. _files: Nullable<string[]>;
  6549. /** @hidden */
  6550. _workingCanvas: Nullable<HTMLCanvasElement>;
  6551. /** @hidden */
  6552. _workingContext: Nullable<CanvasRenderingContext2D>;
  6553. /** @hidden */
  6554. _framebuffer: Nullable<WebGLFramebuffer>;
  6555. /** @hidden */
  6556. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6557. /** @hidden */
  6558. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _attachments: Nullable<number[]>;
  6563. /** @hidden */
  6564. _cachedCoordinatesMode: Nullable<number>;
  6565. /** @hidden */
  6566. _cachedWrapU: Nullable<number>;
  6567. /** @hidden */
  6568. _cachedWrapV: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapR: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6573. /** @hidden */
  6574. _isDisabled: boolean;
  6575. /** @hidden */
  6576. _compression: Nullable<string>;
  6577. /** @hidden */
  6578. _generateStencilBuffer: boolean;
  6579. /** @hidden */
  6580. _generateDepthBuffer: boolean;
  6581. /** @hidden */
  6582. _comparisonFunction: number;
  6583. /** @hidden */
  6584. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6585. /** @hidden */
  6586. _lodGenerationScale: number;
  6587. /** @hidden */
  6588. _lodGenerationOffset: number;
  6589. /** @hidden */
  6590. _colorTextureArray: Nullable<WebGLTexture>;
  6591. /** @hidden */
  6592. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6593. /** @hidden */
  6594. _lodTextureHigh: Nullable<BaseTexture>;
  6595. /** @hidden */
  6596. _lodTextureMid: Nullable<BaseTexture>;
  6597. /** @hidden */
  6598. _lodTextureLow: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _isRGBD: boolean;
  6601. /** @hidden */
  6602. _linearSpecularLOD: boolean;
  6603. /** @hidden */
  6604. _irradianceTexture: Nullable<BaseTexture>;
  6605. /** @hidden */
  6606. _webGLTexture: Nullable<WebGLTexture>;
  6607. /** @hidden */
  6608. _references: number;
  6609. private _engine;
  6610. /**
  6611. * Gets the Engine the texture belongs to.
  6612. * @returns The babylon engine
  6613. */
  6614. getEngine(): Engine;
  6615. /**
  6616. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6617. */
  6618. readonly dataSource: number;
  6619. /**
  6620. * Creates a new InternalTexture
  6621. * @param engine defines the engine to use
  6622. * @param dataSource defines the type of data that will be used
  6623. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6624. */
  6625. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6626. /**
  6627. * Increments the number of references (ie. the number of Texture that point to it)
  6628. */
  6629. incrementReferences(): void;
  6630. /**
  6631. * Change the size of the texture (not the size of the content)
  6632. * @param width defines the new width
  6633. * @param height defines the new height
  6634. * @param depth defines the new depth (1 by default)
  6635. */
  6636. updateSize(width: int, height: int, depth?: int): void;
  6637. /** @hidden */
  6638. _rebuild(): void;
  6639. /** @hidden */
  6640. _swapAndDie(target: InternalTexture): void;
  6641. /**
  6642. * Dispose the current allocated resources
  6643. */
  6644. dispose(): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /**
  6649. * This represents the main contract an easing function should follow.
  6650. * Easing functions are used throughout the animation system.
  6651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6652. */
  6653. export interface IEasingFunction {
  6654. /**
  6655. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6656. * of the easing function.
  6657. * The link below provides some of the most common examples of easing functions.
  6658. * @see https://easings.net/
  6659. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6660. * @returns the corresponding value on the curve defined by the easing function
  6661. */
  6662. ease(gradient: number): number;
  6663. }
  6664. /**
  6665. * Base class used for every default easing function.
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class EasingFunction implements IEasingFunction {
  6669. /**
  6670. * Interpolation follows the mathematical formula associated with the easing function.
  6671. */
  6672. static readonly EASINGMODE_EASEIN: number;
  6673. /**
  6674. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEOUT: number;
  6677. /**
  6678. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6679. */
  6680. static readonly EASINGMODE_EASEINOUT: number;
  6681. private _easingMode;
  6682. /**
  6683. * Sets the easing mode of the current function.
  6684. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6685. */
  6686. setEasingMode(easingMode: number): void;
  6687. /**
  6688. * Gets the current easing mode.
  6689. * @returns the easing mode
  6690. */
  6691. getEasingMode(): number;
  6692. /**
  6693. * @hidden
  6694. */
  6695. easeInCore(gradient: number): number;
  6696. /**
  6697. * Given an input gradient between 0 and 1, this returns the corresponding value
  6698. * of the easing function.
  6699. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6700. * @returns the corresponding value on the curve defined by the easing function
  6701. */
  6702. ease(gradient: number): number;
  6703. }
  6704. /**
  6705. * Easing function with a circle shape (see link below).
  6706. * @see https://easings.net/#easeInCirc
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class CircleEase extends EasingFunction implements IEasingFunction {
  6710. /** @hidden */
  6711. easeInCore(gradient: number): number;
  6712. }
  6713. /**
  6714. * Easing function with a ease back shape (see link below).
  6715. * @see https://easings.net/#easeInBack
  6716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6717. */
  6718. export class BackEase extends EasingFunction implements IEasingFunction {
  6719. /** Defines the amplitude of the function */
  6720. amplitude: number;
  6721. /**
  6722. * Instantiates a back ease easing
  6723. * @see https://easings.net/#easeInBack
  6724. * @param amplitude Defines the amplitude of the function
  6725. */
  6726. constructor(
  6727. /** Defines the amplitude of the function */
  6728. amplitude?: number);
  6729. /** @hidden */
  6730. easeInCore(gradient: number): number;
  6731. }
  6732. /**
  6733. * Easing function with a bouncing shape (see link below).
  6734. * @see https://easings.net/#easeInBounce
  6735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6736. */
  6737. export class BounceEase extends EasingFunction implements IEasingFunction {
  6738. /** Defines the number of bounces */
  6739. bounces: number;
  6740. /** Defines the amplitude of the bounce */
  6741. bounciness: number;
  6742. /**
  6743. * Instantiates a bounce easing
  6744. * @see https://easings.net/#easeInBounce
  6745. * @param bounces Defines the number of bounces
  6746. * @param bounciness Defines the amplitude of the bounce
  6747. */
  6748. constructor(
  6749. /** Defines the number of bounces */
  6750. bounces?: number,
  6751. /** Defines the amplitude of the bounce */
  6752. bounciness?: number);
  6753. /** @hidden */
  6754. easeInCore(gradient: number): number;
  6755. }
  6756. /**
  6757. * Easing function with a power of 3 shape (see link below).
  6758. * @see https://easings.net/#easeInCubic
  6759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6760. */
  6761. export class CubicEase extends EasingFunction implements IEasingFunction {
  6762. /** @hidden */
  6763. easeInCore(gradient: number): number;
  6764. }
  6765. /**
  6766. * Easing function with an elastic shape (see link below).
  6767. * @see https://easings.net/#easeInElastic
  6768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6769. */
  6770. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6771. /** Defines the number of oscillations*/
  6772. oscillations: number;
  6773. /** Defines the amplitude of the oscillations*/
  6774. springiness: number;
  6775. /**
  6776. * Instantiates an elastic easing function
  6777. * @see https://easings.net/#easeInElastic
  6778. * @param oscillations Defines the number of oscillations
  6779. * @param springiness Defines the amplitude of the oscillations
  6780. */
  6781. constructor(
  6782. /** Defines the number of oscillations*/
  6783. oscillations?: number,
  6784. /** Defines the amplitude of the oscillations*/
  6785. springiness?: number);
  6786. /** @hidden */
  6787. easeInCore(gradient: number): number;
  6788. }
  6789. /**
  6790. * Easing function with an exponential shape (see link below).
  6791. * @see https://easings.net/#easeInExpo
  6792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6793. */
  6794. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6795. /** Defines the exponent of the function */
  6796. exponent: number;
  6797. /**
  6798. * Instantiates an exponential easing function
  6799. * @see https://easings.net/#easeInExpo
  6800. * @param exponent Defines the exponent of the function
  6801. */
  6802. constructor(
  6803. /** Defines the exponent of the function */
  6804. exponent?: number);
  6805. /** @hidden */
  6806. easeInCore(gradient: number): number;
  6807. }
  6808. /**
  6809. * Easing function with a power shape (see link below).
  6810. * @see https://easings.net/#easeInQuad
  6811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6812. */
  6813. export class PowerEase extends EasingFunction implements IEasingFunction {
  6814. /** Defines the power of the function */
  6815. power: number;
  6816. /**
  6817. * Instantiates an power base easing function
  6818. * @see https://easings.net/#easeInQuad
  6819. * @param power Defines the power of the function
  6820. */
  6821. constructor(
  6822. /** Defines the power of the function */
  6823. power?: number);
  6824. /** @hidden */
  6825. easeInCore(gradient: number): number;
  6826. }
  6827. /**
  6828. * Easing function with a power of 2 shape (see link below).
  6829. * @see https://easings.net/#easeInQuad
  6830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6831. */
  6832. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6833. /** @hidden */
  6834. easeInCore(gradient: number): number;
  6835. }
  6836. /**
  6837. * Easing function with a power of 4 shape (see link below).
  6838. * @see https://easings.net/#easeInQuart
  6839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6840. */
  6841. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power of 5 shape (see link below).
  6847. * @see https://easings.net/#easeInQuint
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6851. /** @hidden */
  6852. easeInCore(gradient: number): number;
  6853. }
  6854. /**
  6855. * Easing function with a sin shape (see link below).
  6856. * @see https://easings.net/#easeInSine
  6857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6858. */
  6859. export class SineEase extends EasingFunction implements IEasingFunction {
  6860. /** @hidden */
  6861. easeInCore(gradient: number): number;
  6862. }
  6863. /**
  6864. * Easing function with a bezier shape (see link below).
  6865. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6866. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6867. */
  6868. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6869. /** Defines the x component of the start tangent in the bezier curve */
  6870. x1: number;
  6871. /** Defines the y component of the start tangent in the bezier curve */
  6872. y1: number;
  6873. /** Defines the x component of the end tangent in the bezier curve */
  6874. x2: number;
  6875. /** Defines the y component of the end tangent in the bezier curve */
  6876. y2: number;
  6877. /**
  6878. * Instantiates a bezier function
  6879. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6880. * @param x1 Defines the x component of the start tangent in the bezier curve
  6881. * @param y1 Defines the y component of the start tangent in the bezier curve
  6882. * @param x2 Defines the x component of the end tangent in the bezier curve
  6883. * @param y2 Defines the y component of the end tangent in the bezier curve
  6884. */
  6885. constructor(
  6886. /** Defines the x component of the start tangent in the bezier curve */
  6887. x1?: number,
  6888. /** Defines the y component of the start tangent in the bezier curve */
  6889. y1?: number,
  6890. /** Defines the x component of the end tangent in the bezier curve */
  6891. x2?: number,
  6892. /** Defines the y component of the end tangent in the bezier curve */
  6893. y2?: number);
  6894. /** @hidden */
  6895. easeInCore(gradient: number): number;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Defines an interface which represents an animation key frame
  6901. */
  6902. export interface IAnimationKey {
  6903. /**
  6904. * Frame of the key frame
  6905. */
  6906. frame: number;
  6907. /**
  6908. * Value at the specifies key frame
  6909. */
  6910. value: any;
  6911. /**
  6912. * The input tangent for the cubic hermite spline
  6913. */
  6914. inTangent?: any;
  6915. /**
  6916. * The output tangent for the cubic hermite spline
  6917. */
  6918. outTangent?: any;
  6919. /**
  6920. * The animation interpolation type
  6921. */
  6922. interpolation?: AnimationKeyInterpolation;
  6923. }
  6924. /**
  6925. * Enum for the animation key frame interpolation type
  6926. */
  6927. export enum AnimationKeyInterpolation {
  6928. /**
  6929. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6930. */
  6931. STEP = 1
  6932. }
  6933. }
  6934. declare module BABYLON {
  6935. /**
  6936. * Represents the range of an animation
  6937. */
  6938. export class AnimationRange {
  6939. /**The name of the animation range**/
  6940. name: string;
  6941. /**The starting frame of the animation */
  6942. from: number;
  6943. /**The ending frame of the animation*/
  6944. to: number;
  6945. /**
  6946. * Initializes the range of an animation
  6947. * @param name The name of the animation range
  6948. * @param from The starting frame of the animation
  6949. * @param to The ending frame of the animation
  6950. */
  6951. constructor(
  6952. /**The name of the animation range**/
  6953. name: string,
  6954. /**The starting frame of the animation */
  6955. from: number,
  6956. /**The ending frame of the animation*/
  6957. to: number);
  6958. /**
  6959. * Makes a copy of the animation range
  6960. * @returns A copy of the animation range
  6961. */
  6962. clone(): AnimationRange;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Composed of a frame, and an action function
  6968. */
  6969. export class AnimationEvent {
  6970. /** The frame for which the event is triggered **/
  6971. frame: number;
  6972. /** The event to perform when triggered **/
  6973. action: (currentFrame: number) => void;
  6974. /** Specifies if the event should be triggered only once**/
  6975. onlyOnce?: boolean | undefined;
  6976. /**
  6977. * Specifies if the animation event is done
  6978. */
  6979. isDone: boolean;
  6980. /**
  6981. * Initializes the animation event
  6982. * @param frame The frame for which the event is triggered
  6983. * @param action The event to perform when triggered
  6984. * @param onlyOnce Specifies if the event should be triggered only once
  6985. */
  6986. constructor(
  6987. /** The frame for which the event is triggered **/
  6988. frame: number,
  6989. /** The event to perform when triggered **/
  6990. action: (currentFrame: number) => void,
  6991. /** Specifies if the event should be triggered only once**/
  6992. onlyOnce?: boolean | undefined);
  6993. /** @hidden */
  6994. _clone(): AnimationEvent;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Interface used to define a behavior
  7000. */
  7001. export interface Behavior<T> {
  7002. /** gets or sets behavior's name */
  7003. name: string;
  7004. /**
  7005. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7006. */
  7007. init(): void;
  7008. /**
  7009. * Called when the behavior is attached to a target
  7010. * @param target defines the target where the behavior is attached to
  7011. */
  7012. attach(target: T): void;
  7013. /**
  7014. * Called when the behavior is detached from its target
  7015. */
  7016. detach(): void;
  7017. }
  7018. /**
  7019. * Interface implemented by classes supporting behaviors
  7020. */
  7021. export interface IBehaviorAware<T> {
  7022. /**
  7023. * Attach a behavior
  7024. * @param behavior defines the behavior to attach
  7025. * @returns the current host
  7026. */
  7027. addBehavior(behavior: Behavior<T>): T;
  7028. /**
  7029. * Remove a behavior from the current object
  7030. * @param behavior defines the behavior to detach
  7031. * @returns the current host
  7032. */
  7033. removeBehavior(behavior: Behavior<T>): T;
  7034. /**
  7035. * Gets a behavior using its name to search
  7036. * @param name defines the name to search
  7037. * @returns the behavior or null if not found
  7038. */
  7039. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7040. }
  7041. }
  7042. declare module BABYLON {
  7043. /**
  7044. * @hidden
  7045. */
  7046. export class IntersectionInfo {
  7047. bu: Nullable<number>;
  7048. bv: Nullable<number>;
  7049. distance: number;
  7050. faceId: number;
  7051. subMeshId: number;
  7052. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7053. }
  7054. }
  7055. declare module BABYLON {
  7056. /**
  7057. * Class used to store bounding sphere information
  7058. */
  7059. export class BoundingSphere {
  7060. /**
  7061. * Gets the center of the bounding sphere in local space
  7062. */
  7063. readonly center: Vector3;
  7064. /**
  7065. * Radius of the bounding sphere in local space
  7066. */
  7067. radius: number;
  7068. /**
  7069. * Gets the center of the bounding sphere in world space
  7070. */
  7071. readonly centerWorld: Vector3;
  7072. /**
  7073. * Radius of the bounding sphere in world space
  7074. */
  7075. radiusWorld: number;
  7076. /**
  7077. * Gets the minimum vector in local space
  7078. */
  7079. readonly minimum: Vector3;
  7080. /**
  7081. * Gets the maximum vector in local space
  7082. */
  7083. readonly maximum: Vector3;
  7084. private _worldMatrix;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Creates a new bounding sphere
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding sphere by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingSphere;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding sphere is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding sphere center is in between the frustum planes.
  7121. * Used for optimistic fast inclusion.
  7122. * @param frustumPlanes defines the frustum planes to test
  7123. * @returns true if the sphere center is in between the frustum planes
  7124. */
  7125. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7126. /**
  7127. * Tests if a point is inside the bounding sphere
  7128. * @param point defines the point to test
  7129. * @returns true if the point is inside the bounding sphere
  7130. */
  7131. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Checks if two sphere intersct
  7134. * @param sphere0 sphere 0
  7135. * @param sphere1 sphere 1
  7136. * @returns true if the speres intersect
  7137. */
  7138. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /**
  7143. * Class used to store bounding box information
  7144. */
  7145. export class BoundingBox implements ICullable {
  7146. /**
  7147. * Gets the 8 vectors representing the bounding box in local space
  7148. */
  7149. readonly vectors: Vector3[];
  7150. /**
  7151. * Gets the center of the bounding box in local space
  7152. */
  7153. readonly center: Vector3;
  7154. /**
  7155. * Gets the center of the bounding box in world space
  7156. */
  7157. readonly centerWorld: Vector3;
  7158. /**
  7159. * Gets the extend size in local space
  7160. */
  7161. readonly extendSize: Vector3;
  7162. /**
  7163. * Gets the extend size in world space
  7164. */
  7165. readonly extendSizeWorld: Vector3;
  7166. /**
  7167. * Gets the OBB (object bounding box) directions
  7168. */
  7169. readonly directions: Vector3[];
  7170. /**
  7171. * Gets the 8 vectors representing the bounding box in world space
  7172. */
  7173. readonly vectorsWorld: Vector3[];
  7174. /**
  7175. * Gets the minimum vector in world space
  7176. */
  7177. readonly minimumWorld: Vector3;
  7178. /**
  7179. * Gets the maximum vector in world space
  7180. */
  7181. readonly maximumWorld: Vector3;
  7182. /**
  7183. * Gets the minimum vector in local space
  7184. */
  7185. readonly minimum: Vector3;
  7186. /**
  7187. * Gets the maximum vector in local space
  7188. */
  7189. readonly maximum: Vector3;
  7190. private _worldMatrix;
  7191. private static readonly TmpVector3;
  7192. /**
  7193. * @hidden
  7194. */
  7195. _tag: number;
  7196. /**
  7197. * Creates a new bounding box
  7198. * @param min defines the minimum vector (in local space)
  7199. * @param max defines the maximum vector (in local space)
  7200. * @param worldMatrix defines the new world matrix
  7201. */
  7202. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7203. /**
  7204. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7205. * @param min defines the new minimum vector (in local space)
  7206. * @param max defines the new maximum vector (in local space)
  7207. * @param worldMatrix defines the new world matrix
  7208. */
  7209. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7210. /**
  7211. * Scale the current bounding box by applying a scale factor
  7212. * @param factor defines the scale factor to apply
  7213. * @returns the current bounding box
  7214. */
  7215. scale(factor: number): BoundingBox;
  7216. /**
  7217. * Gets the world matrix of the bounding box
  7218. * @returns a matrix
  7219. */
  7220. getWorldMatrix(): DeepImmutable<Matrix>;
  7221. /** @hidden */
  7222. _update(world: DeepImmutable<Matrix>): void;
  7223. /**
  7224. * Tests if the bounding box is intersecting the frustum planes
  7225. * @param frustumPlanes defines the frustum planes to test
  7226. * @returns true if there is an intersection
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7229. /**
  7230. * Tests if the bounding box is entirely inside the frustum planes
  7231. * @param frustumPlanes defines the frustum planes to test
  7232. * @returns true if there is an inclusion
  7233. */
  7234. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7235. /**
  7236. * Tests if a point is inside the bounding box
  7237. * @param point defines the point to test
  7238. * @returns true if the point is inside the bounding box
  7239. */
  7240. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7241. /**
  7242. * Tests if the bounding box intersects with a bounding sphere
  7243. * @param sphere defines the sphere to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7247. /**
  7248. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7249. * @param min defines the min vector to use
  7250. * @param max defines the max vector to use
  7251. * @returns true if there is an intersection
  7252. */
  7253. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7254. /**
  7255. * Tests if two bounding boxes are intersections
  7256. * @param box0 defines the first box to test
  7257. * @param box1 defines the second box to test
  7258. * @returns true if there is an intersection
  7259. */
  7260. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7261. /**
  7262. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7263. * @param minPoint defines the minimum vector of the bounding box
  7264. * @param maxPoint defines the maximum vector of the bounding box
  7265. * @param sphereCenter defines the sphere center
  7266. * @param sphereRadius defines the sphere radius
  7267. * @returns true if there is an intersection
  7268. */
  7269. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7270. /**
  7271. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7272. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7273. * @param frustumPlanes defines the frustum planes to test
  7274. * @return true if there is an inclusion
  7275. */
  7276. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7277. /**
  7278. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7279. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @return true if there is an intersection
  7282. */
  7283. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /** @hidden */
  7288. export class Collider {
  7289. /** Define if a collision was found */
  7290. collisionFound: boolean;
  7291. /**
  7292. * Define last intersection point in local space
  7293. */
  7294. intersectionPoint: Vector3;
  7295. /**
  7296. * Define last collided mesh
  7297. */
  7298. collidedMesh: Nullable<AbstractMesh>;
  7299. private _collisionPoint;
  7300. private _planeIntersectionPoint;
  7301. private _tempVector;
  7302. private _tempVector2;
  7303. private _tempVector3;
  7304. private _tempVector4;
  7305. private _edge;
  7306. private _baseToVertex;
  7307. private _destinationPoint;
  7308. private _slidePlaneNormal;
  7309. private _displacementVector;
  7310. /** @hidden */
  7311. _radius: Vector3;
  7312. /** @hidden */
  7313. _retry: number;
  7314. private _velocity;
  7315. private _basePoint;
  7316. private _epsilon;
  7317. /** @hidden */
  7318. _velocityWorldLength: number;
  7319. /** @hidden */
  7320. _basePointWorld: Vector3;
  7321. private _velocityWorld;
  7322. private _normalizedVelocity;
  7323. /** @hidden */
  7324. _initialVelocity: Vector3;
  7325. /** @hidden */
  7326. _initialPosition: Vector3;
  7327. private _nearestDistance;
  7328. private _collisionMask;
  7329. collisionMask: number;
  7330. /**
  7331. * Gets the plane normal used to compute the sliding response (in local space)
  7332. */
  7333. readonly slidePlaneNormal: Vector3;
  7334. /** @hidden */
  7335. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7336. /** @hidden */
  7337. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7338. /** @hidden */
  7339. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7340. /** @hidden */
  7341. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7342. /** @hidden */
  7343. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7344. /** @hidden */
  7345. _getResponse(pos: Vector3, vel: Vector3): void;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Interface for cullable objects
  7351. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7352. */
  7353. export interface ICullable {
  7354. /**
  7355. * Checks if the object or part of the object is in the frustum
  7356. * @param frustumPlanes Camera near/planes
  7357. * @returns true if the object is in frustum otherwise false
  7358. */
  7359. isInFrustum(frustumPlanes: Plane[]): boolean;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7367. }
  7368. /**
  7369. * Info for a bounding data of a mesh
  7370. */
  7371. export class BoundingInfo implements ICullable {
  7372. /**
  7373. * Bounding box for the mesh
  7374. */
  7375. readonly boundingBox: BoundingBox;
  7376. /**
  7377. * Bounding sphere for the mesh
  7378. */
  7379. readonly boundingSphere: BoundingSphere;
  7380. private _isLocked;
  7381. private static readonly TmpVector3;
  7382. /**
  7383. * Constructs bounding info
  7384. * @param minimum min vector of the bounding box/sphere
  7385. * @param maximum max vector of the bounding box/sphere
  7386. * @param worldMatrix defines the new world matrix
  7387. */
  7388. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7389. /**
  7390. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7391. * @param min defines the new minimum vector (in local space)
  7392. * @param max defines the new maximum vector (in local space)
  7393. * @param worldMatrix defines the new world matrix
  7394. */
  7395. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7396. /**
  7397. * min vector of the bounding box/sphere
  7398. */
  7399. readonly minimum: Vector3;
  7400. /**
  7401. * max vector of the bounding box/sphere
  7402. */
  7403. readonly maximum: Vector3;
  7404. /**
  7405. * If the info is locked and won't be updated to avoid perf overhead
  7406. */
  7407. isLocked: boolean;
  7408. /**
  7409. * Updates the bounding sphere and box
  7410. * @param world world matrix to be used to update
  7411. */
  7412. update(world: DeepImmutable<Matrix>): void;
  7413. /**
  7414. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7415. * @param center New center of the bounding info
  7416. * @param extend New extend of the bounding info
  7417. * @returns the current bounding info
  7418. */
  7419. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7420. /**
  7421. * Scale the current bounding info by applying a scale factor
  7422. * @param factor defines the scale factor to apply
  7423. * @returns the current bounding info
  7424. */
  7425. scale(factor: number): BoundingInfo;
  7426. /**
  7427. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7428. * @param frustumPlanes defines the frustum to test
  7429. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7430. * @returns true if the bounding info is in the frustum planes
  7431. */
  7432. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7433. /**
  7434. * Gets the world distance between the min and max points of the bounding box
  7435. */
  7436. readonly diagonalLength: number;
  7437. /**
  7438. * Checks if a cullable object (mesh...) is in the camera frustum
  7439. * Unlike isInFrustum this cheks the full bounding box
  7440. * @param frustumPlanes Camera near/planes
  7441. * @returns true if the object is in frustum otherwise false
  7442. */
  7443. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7444. /** @hidden */
  7445. _checkCollision(collider: Collider): boolean;
  7446. /**
  7447. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7448. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7449. * @param point the point to check intersection with
  7450. * @returns if the point intersects
  7451. */
  7452. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7453. /**
  7454. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7455. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7456. * @param boundingInfo the bounding info to check intersection with
  7457. * @param precise if the intersection should be done using OBB
  7458. * @returns if the bounding info intersects
  7459. */
  7460. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7461. }
  7462. }
  7463. declare module BABYLON {
  7464. /**
  7465. * Defines an array and its length.
  7466. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7467. */
  7468. export interface ISmartArrayLike<T> {
  7469. /**
  7470. * The data of the array.
  7471. */
  7472. data: Array<T>;
  7473. /**
  7474. * The active length of the array.
  7475. */
  7476. length: number;
  7477. }
  7478. /**
  7479. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7480. */
  7481. export class SmartArray<T> implements ISmartArrayLike<T> {
  7482. /**
  7483. * The full set of data from the array.
  7484. */
  7485. data: Array<T>;
  7486. /**
  7487. * The active length of the array.
  7488. */
  7489. length: number;
  7490. protected _id: number;
  7491. /**
  7492. * Instantiates a Smart Array.
  7493. * @param capacity defines the default capacity of the array.
  7494. */
  7495. constructor(capacity: number);
  7496. /**
  7497. * Pushes a value at the end of the active data.
  7498. * @param value defines the object to push in the array.
  7499. */
  7500. push(value: T): void;
  7501. /**
  7502. * Iterates over the active data and apply the lambda to them.
  7503. * @param func defines the action to apply on each value.
  7504. */
  7505. forEach(func: (content: T) => void): void;
  7506. /**
  7507. * Sorts the full sets of data.
  7508. * @param compareFn defines the comparison function to apply.
  7509. */
  7510. sort(compareFn: (a: T, b: T) => number): void;
  7511. /**
  7512. * Resets the active data to an empty array.
  7513. */
  7514. reset(): void;
  7515. /**
  7516. * Releases all the data from the array as well as the array.
  7517. */
  7518. dispose(): void;
  7519. /**
  7520. * Concats the active data with a given array.
  7521. * @param array defines the data to concatenate with.
  7522. */
  7523. concat(array: any): void;
  7524. /**
  7525. * Returns the position of a value in the active data.
  7526. * @param value defines the value to find the index for
  7527. * @returns the index if found in the active data otherwise -1
  7528. */
  7529. indexOf(value: T): number;
  7530. /**
  7531. * Returns whether an element is part of the active data.
  7532. * @param value defines the value to look for
  7533. * @returns true if found in the active data otherwise false
  7534. */
  7535. contains(value: T): boolean;
  7536. private static _GlobalId;
  7537. }
  7538. /**
  7539. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7540. * The data in this array can only be present once
  7541. */
  7542. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7543. private _duplicateId;
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7547. * @param value defines the object to push in the array.
  7548. */
  7549. push(value: T): void;
  7550. /**
  7551. * Pushes a value at the end of the active data.
  7552. * If the data is already present, it won t be added again
  7553. * @param value defines the object to push in the array.
  7554. * @returns true if added false if it was already present
  7555. */
  7556. pushNoDuplicate(value: T): boolean;
  7557. /**
  7558. * Resets the active data to an empty array.
  7559. */
  7560. reset(): void;
  7561. /**
  7562. * Concats the active data with a given array.
  7563. * This ensures no dupplicate will be present in the result.
  7564. * @param array defines the data to concatenate with.
  7565. */
  7566. concatWithNoDuplicate(array: any): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4
  7594. }
  7595. /**
  7596. * Interface used to define custom inspectable properties.
  7597. * This interface is used by the inspector to display custom property grids
  7598. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7599. */
  7600. export interface IInspectable {
  7601. /**
  7602. * Gets the label to display
  7603. */
  7604. label: string;
  7605. /**
  7606. * Gets the name of the property to edit
  7607. */
  7608. propertyName: string;
  7609. /**
  7610. * Gets the type of the editor to use
  7611. */
  7612. type: InspectableType;
  7613. /**
  7614. * Gets the minimum value of the property when using in "slider" mode
  7615. */
  7616. min?: number;
  7617. /**
  7618. * Gets the maximum value of the property when using in "slider" mode
  7619. */
  7620. max?: number;
  7621. /**
  7622. * Gets the setp to use when using in "slider" mode
  7623. */
  7624. step?: number;
  7625. }
  7626. }
  7627. declare module BABYLON {
  7628. /**
  7629. * This represents the required contract to create a new type of texture loader.
  7630. */
  7631. export interface IInternalTextureLoader {
  7632. /**
  7633. * Defines wether the loader supports cascade loading the different faces.
  7634. */
  7635. supportCascades: boolean;
  7636. /**
  7637. * This returns if the loader support the current file information.
  7638. * @param extension defines the file extension of the file being loaded
  7639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7640. * @param fallback defines the fallback internal texture if any
  7641. * @param isBase64 defines whether the texture is encoded as a base64
  7642. * @param isBuffer defines whether the texture data are stored as a buffer
  7643. * @returns true if the loader can load the specified file
  7644. */
  7645. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7646. /**
  7647. * Transform the url before loading if required.
  7648. * @param rootUrl the url of the texture
  7649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7650. * @returns the transformed texture
  7651. */
  7652. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7653. /**
  7654. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7655. * @param rootUrl the url of the texture
  7656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7657. * @returns the fallback texture
  7658. */
  7659. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7660. /**
  7661. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7662. * @param data contains the texture data
  7663. * @param texture defines the BabylonJS internal texture
  7664. * @param createPolynomials will be true if polynomials have been requested
  7665. * @param onLoad defines the callback to trigger once the texture is ready
  7666. * @param onError defines the callback to trigger in case of error
  7667. */
  7668. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /**
  7670. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7671. * @param data contains the texture data
  7672. * @param texture defines the BabylonJS internal texture
  7673. * @param callback defines the method to call once ready to upload
  7674. */
  7675. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7676. }
  7677. }
  7678. declare module BABYLON {
  7679. interface Engine {
  7680. /**
  7681. * Creates a depth stencil cube texture.
  7682. * This is only available in WebGL 2.
  7683. * @param size The size of face edge in the cube texture.
  7684. * @param options The options defining the cube texture.
  7685. * @returns The cube texture
  7686. */
  7687. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7688. /**
  7689. * Creates a cube texture
  7690. * @param rootUrl defines the url where the files to load is located
  7691. * @param scene defines the current scene
  7692. * @param files defines the list of files to load (1 per face)
  7693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7694. * @param onLoad defines an optional callback raised when the texture is loaded
  7695. * @param onError defines an optional callback raised if there is an issue to load the texture
  7696. * @param format defines the format of the data
  7697. * @param forcedExtension defines the extension to use to pick the right loader
  7698. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7699. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7700. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7701. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7703. * @returns the cube texture as an InternalTexture
  7704. */
  7705. 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;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @returns the cube texture as an InternalTexture
  7717. */
  7718. 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;
  7719. /**
  7720. * Creates a cube texture
  7721. * @param rootUrl defines the url where the files to load is located
  7722. * @param scene defines the current scene
  7723. * @param files defines the list of files to load (1 per face)
  7724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7725. * @param onLoad defines an optional callback raised when the texture is loaded
  7726. * @param onError defines an optional callback raised if there is an issue to load the texture
  7727. * @param format defines the format of the data
  7728. * @param forcedExtension defines the extension to use to pick the right loader
  7729. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. 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;
  7735. /** @hidden */
  7736. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7737. /** @hidden */
  7738. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7739. /** @hidden */
  7740. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. /**
  7769. * Returns the bounding box size
  7770. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7771. */
  7772. boundingBoxSize: Vector3;
  7773. protected _rotationY: number;
  7774. /**
  7775. * Sets texture matrix rotation angle around Y axis in radians.
  7776. */
  7777. /**
  7778. * Gets texture matrix rotation angle around Y axis radians.
  7779. */
  7780. rotationY: number;
  7781. /**
  7782. * Are mip maps generated for this texture or not.
  7783. */
  7784. readonly noMipmap: boolean;
  7785. private _noMipmap;
  7786. private _files;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /** @hidden */
  7792. _prefiltered: boolean;
  7793. /**
  7794. * Creates a cube texture from an array of image urls
  7795. * @param files defines an array of image urls
  7796. * @param scene defines the hosting scene
  7797. * @param noMipmap specifies if mip maps are not used
  7798. * @returns a cube texture
  7799. */
  7800. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7801. /**
  7802. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7803. * @param url defines the url of the prefiltered texture
  7804. * @param scene defines the scene the texture is attached to
  7805. * @param forcedExtension defines the extension of the file if different from the url
  7806. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7807. * @return the prefiltered texture
  7808. */
  7809. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7810. /**
  7811. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7812. * as prefiltered data.
  7813. * @param rootUrl defines the url of the texture or the root name of the six images
  7814. * @param scene defines the scene the texture is attached to
  7815. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7816. * @param noMipmap defines if mipmaps should be created or not
  7817. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7818. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7819. * @param onError defines a callback triggered in case of error during load
  7820. * @param format defines the internal format to use for the texture once loaded
  7821. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7822. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7823. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7824. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7825. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7826. * @return the cube texture
  7827. */
  7828. 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);
  7829. /**
  7830. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7831. */
  7832. readonly isPrefiltered: boolean;
  7833. /**
  7834. * Get the current class name of the texture useful for serialization or dynamic coding.
  7835. * @returns "CubeTexture"
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Update the url (and optional buffer) of this texture if url was null during construction.
  7840. * @param url the url of the texture
  7841. * @param forcedExtension defines the extension to use
  7842. * @param onLoad callback called when the texture is loaded (defaults to null)
  7843. */
  7844. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7845. /**
  7846. * Delays loading of the cube texture
  7847. * @param forcedExtension defines the extension to use
  7848. */
  7849. delayLoad(forcedExtension?: string): void;
  7850. /**
  7851. * Returns the reflection texture matrix
  7852. * @returns the reflection texture matrix
  7853. */
  7854. getReflectionTextureMatrix(): Matrix;
  7855. /**
  7856. * Sets the reflection texture matrix
  7857. * @param value Reflection texture matrix
  7858. */
  7859. setReflectionTextureMatrix(value: Matrix): void;
  7860. /**
  7861. * Parses text to create a cube texture
  7862. * @param parsedTexture define the serialized text to read from
  7863. * @param scene defines the hosting scene
  7864. * @param rootUrl defines the root url of the cube texture
  7865. * @returns a cube texture
  7866. */
  7867. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7868. /**
  7869. * Makes a clone, or deep copy, of the cube texture
  7870. * @returns a new cube texture
  7871. */
  7872. clone(): CubeTexture;
  7873. }
  7874. }
  7875. declare module BABYLON {
  7876. /** @hidden */
  7877. export var postprocessVertexShader: {
  7878. name: string;
  7879. shader: string;
  7880. };
  7881. }
  7882. declare module BABYLON {
  7883. /**
  7884. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7885. * This is the base of the follow, arc rotate cameras and Free camera
  7886. * @see http://doc.babylonjs.com/features/cameras
  7887. */
  7888. export class TargetCamera extends Camera {
  7889. private static _RigCamTransformMatrix;
  7890. private static _TargetTransformMatrix;
  7891. private static _TargetFocalPoint;
  7892. /**
  7893. * Define the current direction the camera is moving to
  7894. */
  7895. cameraDirection: Vector3;
  7896. /**
  7897. * Define the current rotation the camera is rotating to
  7898. */
  7899. cameraRotation: Vector2;
  7900. /**
  7901. * When set, the up vector of the camera will be updated by the rotation of the camera
  7902. */
  7903. updateUpVectorFromRotation: boolean;
  7904. private _tmpQuaternion;
  7905. /**
  7906. * Define the current rotation of the camera
  7907. */
  7908. rotation: Vector3;
  7909. /**
  7910. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7911. */
  7912. rotationQuaternion: Quaternion;
  7913. /**
  7914. * Define the current speed of the camera
  7915. */
  7916. speed: number;
  7917. /**
  7918. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7919. * around all axis.
  7920. */
  7921. noRotationConstraint: boolean;
  7922. /**
  7923. * Define the current target of the camera as an object or a position.
  7924. */
  7925. lockedTarget: any;
  7926. /** @hidden */
  7927. _currentTarget: Vector3;
  7928. /** @hidden */
  7929. _initialFocalDistance: number;
  7930. /** @hidden */
  7931. _viewMatrix: Matrix;
  7932. /** @hidden */
  7933. _camMatrix: Matrix;
  7934. /** @hidden */
  7935. _cameraTransformMatrix: Matrix;
  7936. /** @hidden */
  7937. _cameraRotationMatrix: Matrix;
  7938. /** @hidden */
  7939. _referencePoint: Vector3;
  7940. /** @hidden */
  7941. _transformedReferencePoint: Vector3;
  7942. protected _globalCurrentTarget: Vector3;
  7943. protected _globalCurrentUpVector: Vector3;
  7944. /** @hidden */
  7945. _reset: () => void;
  7946. private _defaultUp;
  7947. /**
  7948. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7949. * This is the base of the follow, arc rotate cameras and Free camera
  7950. * @see http://doc.babylonjs.com/features/cameras
  7951. * @param name Defines the name of the camera in the scene
  7952. * @param position Defines the start position of the camera in the scene
  7953. * @param scene Defines the scene the camera belongs to
  7954. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7955. */
  7956. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7957. /**
  7958. * Gets the position in front of the camera at a given distance.
  7959. * @param distance The distance from the camera we want the position to be
  7960. * @returns the position
  7961. */
  7962. getFrontPosition(distance: number): Vector3;
  7963. /** @hidden */
  7964. _getLockedTargetPosition(): Nullable<Vector3>;
  7965. private _storedPosition;
  7966. private _storedRotation;
  7967. private _storedRotationQuaternion;
  7968. /**
  7969. * Store current camera state of the camera (fov, position, rotation, etc..)
  7970. * @returns the camera
  7971. */
  7972. storeState(): Camera;
  7973. /**
  7974. * Restored camera state. You must call storeState() first
  7975. * @returns whether it was successful or not
  7976. * @hidden
  7977. */
  7978. _restoreStateValues(): boolean;
  7979. /** @hidden */
  7980. _initCache(): void;
  7981. /** @hidden */
  7982. _updateCache(ignoreParentClass?: boolean): void;
  7983. /** @hidden */
  7984. _isSynchronizedViewMatrix(): boolean;
  7985. /** @hidden */
  7986. _computeLocalCameraSpeed(): number;
  7987. /**
  7988. * Defines the target the camera should look at.
  7989. * This will automatically adapt alpha beta and radius to fit within the new target.
  7990. * @param target Defines the new target as a Vector or a mesh
  7991. */
  7992. setTarget(target: Vector3): void;
  7993. /**
  7994. * Return the current target position of the camera. This value is expressed in local space.
  7995. * @returns the target position
  7996. */
  7997. getTarget(): Vector3;
  7998. /** @hidden */
  7999. _decideIfNeedsToMove(): boolean;
  8000. /** @hidden */
  8001. _updatePosition(): void;
  8002. /** @hidden */
  8003. _checkInputs(): void;
  8004. protected _updateCameraRotationMatrix(): void;
  8005. /**
  8006. * 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)
  8007. * @returns the current camera
  8008. */
  8009. private _rotateUpVectorWithCameraRotationMatrix;
  8010. private _cachedRotationZ;
  8011. private _cachedQuaternionRotationZ;
  8012. /** @hidden */
  8013. _getViewMatrix(): Matrix;
  8014. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8015. /**
  8016. * @hidden
  8017. */
  8018. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8019. /**
  8020. * @hidden
  8021. */
  8022. _updateRigCameras(): void;
  8023. private _getRigCamPositionAndTarget;
  8024. /**
  8025. * Gets the current object class name.
  8026. * @return the class name
  8027. */
  8028. getClassName(): string;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /**
  8033. * @ignore
  8034. * This is a list of all the different input types that are available in the application.
  8035. * Fo instance: ArcRotateCameraGamepadInput...
  8036. */
  8037. export var CameraInputTypes: {};
  8038. /**
  8039. * This is the contract to implement in order to create a new input class.
  8040. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8041. */
  8042. export interface ICameraInput<TCamera extends Camera> {
  8043. /**
  8044. * Defines the camera the input is attached to.
  8045. */
  8046. camera: Nullable<TCamera>;
  8047. /**
  8048. * Gets the class name of the current intput.
  8049. * @returns the class name
  8050. */
  8051. getClassName(): string;
  8052. /**
  8053. * Get the friendly name associated with the input class.
  8054. * @returns the input friendly name
  8055. */
  8056. getSimpleName(): string;
  8057. /**
  8058. * Attach the input controls to a specific dom element to get the input from.
  8059. * @param element Defines the element the controls should be listened from
  8060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8061. */
  8062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8063. /**
  8064. * Detach the current controls from the specified dom element.
  8065. * @param element Defines the element to stop listening the inputs from
  8066. */
  8067. detachControl(element: Nullable<HTMLElement>): void;
  8068. /**
  8069. * Update the current camera state depending on the inputs that have been used this frame.
  8070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8071. */
  8072. checkInputs?: () => void;
  8073. }
  8074. /**
  8075. * Represents a map of input types to input instance or input index to input instance.
  8076. */
  8077. export interface CameraInputsMap<TCamera extends Camera> {
  8078. /**
  8079. * Accessor to the input by input type.
  8080. */
  8081. [name: string]: ICameraInput<TCamera>;
  8082. /**
  8083. * Accessor to the input by input index.
  8084. */
  8085. [idx: number]: ICameraInput<TCamera>;
  8086. }
  8087. /**
  8088. * This represents the input manager used within a camera.
  8089. * It helps dealing with all the different kind of input attached to a camera.
  8090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8091. */
  8092. export class CameraInputsManager<TCamera extends Camera> {
  8093. /**
  8094. * Defines the list of inputs attahed to the camera.
  8095. */
  8096. attached: CameraInputsMap<TCamera>;
  8097. /**
  8098. * Defines the dom element the camera is collecting inputs from.
  8099. * This is null if the controls have not been attached.
  8100. */
  8101. attachedElement: Nullable<HTMLElement>;
  8102. /**
  8103. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8104. */
  8105. noPreventDefault: boolean;
  8106. /**
  8107. * Defined the camera the input manager belongs to.
  8108. */
  8109. camera: TCamera;
  8110. /**
  8111. * Update the current camera state depending on the inputs that have been used this frame.
  8112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8113. */
  8114. checkInputs: () => void;
  8115. /**
  8116. * Instantiate a new Camera Input Manager.
  8117. * @param camera Defines the camera the input manager blongs to
  8118. */
  8119. constructor(camera: TCamera);
  8120. /**
  8121. * Add an input method to a camera
  8122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8123. * @param input camera input method
  8124. */
  8125. add(input: ICameraInput<TCamera>): void;
  8126. /**
  8127. * Remove a specific input method from a camera
  8128. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8129. * @param inputToRemove camera input method
  8130. */
  8131. remove(inputToRemove: ICameraInput<TCamera>): void;
  8132. /**
  8133. * Remove a specific input type from a camera
  8134. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8135. * @param inputType the type of the input to remove
  8136. */
  8137. removeByType(inputType: string): void;
  8138. private _addCheckInputs;
  8139. /**
  8140. * Attach the input controls to the currently attached dom element to listen the events from.
  8141. * @param input Defines the input to attach
  8142. */
  8143. attachInput(input: ICameraInput<TCamera>): void;
  8144. /**
  8145. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8146. * @param element Defines the dom element to collect the events from
  8147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8148. */
  8149. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8150. /**
  8151. * Detach the current manager inputs controls from a specific dom element.
  8152. * @param element Defines the dom element to collect the events from
  8153. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8154. */
  8155. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8156. /**
  8157. * Rebuild the dynamic inputCheck function from the current list of
  8158. * defined inputs in the manager.
  8159. */
  8160. rebuildInputCheck(): void;
  8161. /**
  8162. * Remove all attached input methods from a camera
  8163. */
  8164. clear(): void;
  8165. /**
  8166. * Serialize the current input manager attached to a camera.
  8167. * This ensures than once parsed,
  8168. * the input associated to the camera will be identical to the current ones
  8169. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8170. */
  8171. serialize(serializedCamera: any): void;
  8172. /**
  8173. * Parses an input manager serialized JSON to restore the previous list of inputs
  8174. * and states associated to a camera.
  8175. * @param parsedCamera Defines the JSON to parse
  8176. */
  8177. parse(parsedCamera: any): void;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Gather the list of keyboard event types as constants.
  8183. */
  8184. export class KeyboardEventTypes {
  8185. /**
  8186. * The keydown event is fired when a key becomes active (pressed).
  8187. */
  8188. static readonly KEYDOWN: number;
  8189. /**
  8190. * The keyup event is fired when a key has been released.
  8191. */
  8192. static readonly KEYUP: number;
  8193. }
  8194. /**
  8195. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8196. */
  8197. export class KeyboardInfo {
  8198. /**
  8199. * Defines the type of event (KeyboardEventTypes)
  8200. */
  8201. type: number;
  8202. /**
  8203. * Defines the related dom event
  8204. */
  8205. event: KeyboardEvent;
  8206. /**
  8207. * Instantiates a new keyboard info.
  8208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8209. * @param type Defines the type of event (KeyboardEventTypes)
  8210. * @param event Defines the related dom event
  8211. */
  8212. constructor(
  8213. /**
  8214. * Defines the type of event (KeyboardEventTypes)
  8215. */
  8216. type: number,
  8217. /**
  8218. * Defines the related dom event
  8219. */
  8220. event: KeyboardEvent);
  8221. }
  8222. /**
  8223. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8224. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8225. */
  8226. export class KeyboardInfoPre extends KeyboardInfo {
  8227. /**
  8228. * Defines the type of event (KeyboardEventTypes)
  8229. */
  8230. type: number;
  8231. /**
  8232. * Defines the related dom event
  8233. */
  8234. event: KeyboardEvent;
  8235. /**
  8236. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8237. */
  8238. skipOnPointerObservable: boolean;
  8239. /**
  8240. * Instantiates a new keyboard pre info.
  8241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8242. * @param type Defines the type of event (KeyboardEventTypes)
  8243. * @param event Defines the related dom event
  8244. */
  8245. constructor(
  8246. /**
  8247. * Defines the type of event (KeyboardEventTypes)
  8248. */
  8249. type: number,
  8250. /**
  8251. * Defines the related dom event
  8252. */
  8253. event: KeyboardEvent);
  8254. }
  8255. }
  8256. declare module BABYLON {
  8257. /**
  8258. * Manage the keyboard inputs to control the movement of a free camera.
  8259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8260. */
  8261. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8262. /**
  8263. * Defines the camera the input is attached to.
  8264. */
  8265. camera: FreeCamera;
  8266. /**
  8267. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8268. */
  8269. keysUp: number[];
  8270. /**
  8271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8272. */
  8273. keysDown: number[];
  8274. /**
  8275. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8276. */
  8277. keysLeft: number[];
  8278. /**
  8279. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8280. */
  8281. keysRight: number[];
  8282. private _keys;
  8283. private _onCanvasBlurObserver;
  8284. private _onKeyboardObserver;
  8285. private _engine;
  8286. private _scene;
  8287. /**
  8288. * Attach the input controls to a specific dom element to get the input from.
  8289. * @param element Defines the element the controls should be listened from
  8290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8291. */
  8292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8293. /**
  8294. * Detach the current controls from the specified dom element.
  8295. * @param element Defines the element to stop listening the inputs from
  8296. */
  8297. detachControl(element: Nullable<HTMLElement>): void;
  8298. /**
  8299. * Update the current camera state depending on the inputs that have been used this frame.
  8300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8301. */
  8302. checkInputs(): void;
  8303. /**
  8304. * Gets the class name of the current intput.
  8305. * @returns the class name
  8306. */
  8307. getClassName(): string;
  8308. /** @hidden */
  8309. _onLostFocus(): void;
  8310. /**
  8311. * Get the friendly name associated with the input class.
  8312. * @returns the input friendly name
  8313. */
  8314. getSimpleName(): string;
  8315. }
  8316. }
  8317. declare module BABYLON {
  8318. /**
  8319. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8320. * separate meshes. This can be use to improve performances.
  8321. * @see http://doc.babylonjs.com/how_to/multi_materials
  8322. */
  8323. export class MultiMaterial extends Material {
  8324. private _subMaterials;
  8325. /**
  8326. * Gets or Sets the list of Materials used within the multi material.
  8327. * They need to be ordered according to the submeshes order in the associated mesh
  8328. */
  8329. subMaterials: Nullable<Material>[];
  8330. /**
  8331. * Function used to align with Node.getChildren()
  8332. * @returns the list of Materials used within the multi material
  8333. */
  8334. getChildren(): Nullable<Material>[];
  8335. /**
  8336. * Instantiates a new Multi Material
  8337. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8338. * separate meshes. This can be use to improve performances.
  8339. * @see http://doc.babylonjs.com/how_to/multi_materials
  8340. * @param name Define the name in the scene
  8341. * @param scene Define the scene the material belongs to
  8342. */
  8343. constructor(name: string, scene: Scene);
  8344. private _hookArray;
  8345. /**
  8346. * Get one of the submaterial by its index in the submaterials array
  8347. * @param index The index to look the sub material at
  8348. * @returns The Material if the index has been defined
  8349. */
  8350. getSubMaterial(index: number): Nullable<Material>;
  8351. /**
  8352. * Get the list of active textures for the whole sub materials list.
  8353. * @returns All the textures that will be used during the rendering
  8354. */
  8355. getActiveTextures(): BaseTexture[];
  8356. /**
  8357. * Gets the current class name of the material e.g. "MultiMaterial"
  8358. * Mainly use in serialization.
  8359. * @returns the class name
  8360. */
  8361. getClassName(): string;
  8362. /**
  8363. * Checks if the material is ready to render the requested sub mesh
  8364. * @param mesh Define the mesh the submesh belongs to
  8365. * @param subMesh Define the sub mesh to look readyness for
  8366. * @param useInstances Define whether or not the material is used with instances
  8367. * @returns true if ready, otherwise false
  8368. */
  8369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8370. /**
  8371. * Clones the current material and its related sub materials
  8372. * @param name Define the name of the newly cloned material
  8373. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8374. * @returns the cloned material
  8375. */
  8376. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8377. /**
  8378. * Serializes the materials into a JSON representation.
  8379. * @returns the JSON representation
  8380. */
  8381. serialize(): any;
  8382. /**
  8383. * Dispose the material and release its associated resources
  8384. * @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)
  8385. * @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)
  8386. * @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)
  8387. */
  8388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8389. /**
  8390. * Creates a MultiMaterial from parsed MultiMaterial data.
  8391. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8392. * @param scene defines the hosting scene
  8393. * @returns a new MultiMaterial
  8394. */
  8395. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8396. }
  8397. }
  8398. declare module BABYLON {
  8399. /**
  8400. * Class used to represent data loading progression
  8401. */
  8402. export class SceneLoaderFlags {
  8403. private static _ForceFullSceneLoadingForIncremental;
  8404. private static _ShowLoadingScreen;
  8405. private static _CleanBoneMatrixWeights;
  8406. private static _loggingLevel;
  8407. /**
  8408. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8409. */
  8410. static ForceFullSceneLoadingForIncremental: boolean;
  8411. /**
  8412. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8413. */
  8414. static ShowLoadingScreen: boolean;
  8415. /**
  8416. * Defines the current logging level (while loading the scene)
  8417. * @ignorenaming
  8418. */
  8419. static loggingLevel: number;
  8420. /**
  8421. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8422. */
  8423. static CleanBoneMatrixWeights: boolean;
  8424. }
  8425. }
  8426. declare module BABYLON {
  8427. /**
  8428. * 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.
  8429. * @see https://doc.babylonjs.com/how_to/transformnode
  8430. */
  8431. export class TransformNode extends Node {
  8432. /**
  8433. * Object will not rotate to face the camera
  8434. */
  8435. static BILLBOARDMODE_NONE: number;
  8436. /**
  8437. * Object will rotate to face the camera but only on the x axis
  8438. */
  8439. static BILLBOARDMODE_X: number;
  8440. /**
  8441. * Object will rotate to face the camera but only on the y axis
  8442. */
  8443. static BILLBOARDMODE_Y: number;
  8444. /**
  8445. * Object will rotate to face the camera but only on the z axis
  8446. */
  8447. static BILLBOARDMODE_Z: number;
  8448. /**
  8449. * Object will rotate to face the camera
  8450. */
  8451. static BILLBOARDMODE_ALL: number;
  8452. private _forward;
  8453. private _forwardInverted;
  8454. private _up;
  8455. private _right;
  8456. private _rightInverted;
  8457. private _position;
  8458. private _rotation;
  8459. private _rotationQuaternion;
  8460. protected _scaling: Vector3;
  8461. protected _isDirty: boolean;
  8462. private _transformToBoneReferal;
  8463. private _billboardMode;
  8464. /**
  8465. * Gets or sets the billboard mode. Default is 0.
  8466. *
  8467. * | Value | Type | Description |
  8468. * | --- | --- | --- |
  8469. * | 0 | BILLBOARDMODE_NONE | |
  8470. * | 1 | BILLBOARDMODE_X | |
  8471. * | 2 | BILLBOARDMODE_Y | |
  8472. * | 4 | BILLBOARDMODE_Z | |
  8473. * | 7 | BILLBOARDMODE_ALL | |
  8474. *
  8475. */
  8476. billboardMode: number;
  8477. private _preserveParentRotationForBillboard;
  8478. /**
  8479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8481. */
  8482. preserveParentRotationForBillboard: boolean;
  8483. /**
  8484. * 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
  8485. */
  8486. scalingDeterminant: number;
  8487. private _infiniteDistance;
  8488. /**
  8489. * Gets or sets the distance of the object to max, often used by skybox
  8490. */
  8491. infiniteDistance: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8494. * By default the system will update normals to compensate
  8495. */
  8496. ignoreNonUniformScaling: boolean;
  8497. /**
  8498. * 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
  8499. */
  8500. reIntegrateRotationIntoRotationQuaternion: boolean;
  8501. /** @hidden */
  8502. _poseMatrix: Nullable<Matrix>;
  8503. /** @hidden */
  8504. _localMatrix: Matrix;
  8505. private _usePivotMatrix;
  8506. private _absolutePosition;
  8507. private _pivotMatrix;
  8508. private _pivotMatrixInverse;
  8509. protected _postMultiplyPivotMatrix: boolean;
  8510. protected _isWorldMatrixFrozen: boolean;
  8511. /** @hidden */
  8512. _indexInSceneTransformNodesArray: number;
  8513. /**
  8514. * An event triggered after the world matrix is updated
  8515. */
  8516. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8517. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8518. /**
  8519. * Gets a string identifying the name of the class
  8520. * @returns "TransformNode" string
  8521. */
  8522. getClassName(): string;
  8523. /**
  8524. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8525. */
  8526. position: Vector3;
  8527. /**
  8528. * 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)).
  8529. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8530. */
  8531. rotation: Vector3;
  8532. /**
  8533. * 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)).
  8534. */
  8535. scaling: Vector3;
  8536. /**
  8537. * 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).
  8538. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8539. */
  8540. rotationQuaternion: Nullable<Quaternion>;
  8541. /**
  8542. * The forward direction of that transform in world space.
  8543. */
  8544. readonly forward: Vector3;
  8545. /**
  8546. * The up direction of that transform in world space.
  8547. */
  8548. readonly up: Vector3;
  8549. /**
  8550. * The right direction of that transform in world space.
  8551. */
  8552. readonly right: Vector3;
  8553. /**
  8554. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8555. * @param matrix the matrix to copy the pose from
  8556. * @returns this TransformNode.
  8557. */
  8558. updatePoseMatrix(matrix: Matrix): TransformNode;
  8559. /**
  8560. * Returns the mesh Pose matrix.
  8561. * @returns the pose matrix
  8562. */
  8563. getPoseMatrix(): Matrix;
  8564. /** @hidden */
  8565. _isSynchronized(): boolean;
  8566. /** @hidden */
  8567. _initCache(): void;
  8568. /**
  8569. * Flag the transform node as dirty (Forcing it to update everything)
  8570. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8571. * @returns this transform node
  8572. */
  8573. markAsDirty(property: string): TransformNode;
  8574. /**
  8575. * Returns the current mesh absolute position.
  8576. * Returns a Vector3.
  8577. */
  8578. readonly absolutePosition: Vector3;
  8579. /**
  8580. * Sets a new matrix to apply before all other transformation
  8581. * @param matrix defines the transform matrix
  8582. * @returns the current TransformNode
  8583. */
  8584. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8585. /**
  8586. * Sets a new pivot matrix to the current node
  8587. * @param matrix defines the new pivot matrix to use
  8588. * @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
  8589. * @returns the current TransformNode
  8590. */
  8591. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8592. /**
  8593. * Returns the mesh pivot matrix.
  8594. * Default : Identity.
  8595. * @returns the matrix
  8596. */
  8597. getPivotMatrix(): Matrix;
  8598. /**
  8599. * Prevents the World matrix to be computed any longer.
  8600. * @returns the TransformNode.
  8601. */
  8602. freezeWorldMatrix(): TransformNode;
  8603. /**
  8604. * Allows back the World matrix computation.
  8605. * @returns the TransformNode.
  8606. */
  8607. unfreezeWorldMatrix(): this;
  8608. /**
  8609. * True if the World matrix has been frozen.
  8610. */
  8611. readonly isWorldMatrixFrozen: boolean;
  8612. /**
  8613. * Retuns the mesh absolute position in the World.
  8614. * @returns a Vector3.
  8615. */
  8616. getAbsolutePosition(): Vector3;
  8617. /**
  8618. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8619. * @param absolutePosition the absolute position to set
  8620. * @returns the TransformNode.
  8621. */
  8622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8623. /**
  8624. * Sets the mesh position in its local space.
  8625. * @param vector3 the position to set in localspace
  8626. * @returns the TransformNode.
  8627. */
  8628. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8629. /**
  8630. * Returns the mesh position in the local space from the current World matrix values.
  8631. * @returns a new Vector3.
  8632. */
  8633. getPositionExpressedInLocalSpace(): Vector3;
  8634. /**
  8635. * Translates the mesh along the passed Vector3 in its local space.
  8636. * @param vector3 the distance to translate in localspace
  8637. * @returns the TransformNode.
  8638. */
  8639. locallyTranslate(vector3: Vector3): TransformNode;
  8640. private static _lookAtVectorCache;
  8641. /**
  8642. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8643. * @param targetPoint the position (must be in same space as current mesh) to look at
  8644. * @param yawCor optional yaw (y-axis) correction in radians
  8645. * @param pitchCor optional pitch (x-axis) correction in radians
  8646. * @param rollCor optional roll (z-axis) correction in radians
  8647. * @param space the choosen space of the target
  8648. * @returns the TransformNode.
  8649. */
  8650. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8651. /**
  8652. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8653. * This Vector3 is expressed in the World space.
  8654. * @param localAxis axis to rotate
  8655. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8656. */
  8657. getDirection(localAxis: Vector3): Vector3;
  8658. /**
  8659. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8660. * localAxis is expressed in the mesh local space.
  8661. * result is computed in the Wordl space from the mesh World matrix.
  8662. * @param localAxis axis to rotate
  8663. * @param result the resulting transformnode
  8664. * @returns this TransformNode.
  8665. */
  8666. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8667. /**
  8668. * Sets this transform node rotation to the given local axis.
  8669. * @param localAxis the axis in local space
  8670. * @param yawCor optional yaw (y-axis) correction in radians
  8671. * @param pitchCor optional pitch (x-axis) correction in radians
  8672. * @param rollCor optional roll (z-axis) correction in radians
  8673. * @returns this TransformNode
  8674. */
  8675. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8676. /**
  8677. * Sets a new pivot point to the current node
  8678. * @param point defines the new pivot point to use
  8679. * @param space defines if the point is in world or local space (local by default)
  8680. * @returns the current TransformNode
  8681. */
  8682. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8683. /**
  8684. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8685. * @returns the pivot point
  8686. */
  8687. getPivotPoint(): Vector3;
  8688. /**
  8689. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8690. * @param result the vector3 to store the result
  8691. * @returns this TransformNode.
  8692. */
  8693. getPivotPointToRef(result: Vector3): TransformNode;
  8694. /**
  8695. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8696. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8697. */
  8698. getAbsolutePivotPoint(): Vector3;
  8699. /**
  8700. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8701. * @param result vector3 to store the result
  8702. * @returns this TransformNode.
  8703. */
  8704. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8705. /**
  8706. * Defines the passed node as the parent of the current node.
  8707. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8708. * @see https://doc.babylonjs.com/how_to/parenting
  8709. * @param node the node ot set as the parent
  8710. * @returns this TransformNode.
  8711. */
  8712. setParent(node: Nullable<Node>): TransformNode;
  8713. private _nonUniformScaling;
  8714. /**
  8715. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8716. */
  8717. readonly nonUniformScaling: boolean;
  8718. /** @hidden */
  8719. _updateNonUniformScalingState(value: boolean): boolean;
  8720. /**
  8721. * Attach the current TransformNode to another TransformNode associated with a bone
  8722. * @param bone Bone affecting the TransformNode
  8723. * @param affectedTransformNode TransformNode associated with the bone
  8724. * @returns this object
  8725. */
  8726. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8727. /**
  8728. * Detach the transform node if its associated with a bone
  8729. * @returns this object
  8730. */
  8731. detachFromBone(): TransformNode;
  8732. private static _rotationAxisCache;
  8733. /**
  8734. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8735. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8737. * The passed axis is also normalized.
  8738. * @param axis the axis to rotate around
  8739. * @param amount the amount to rotate in radians
  8740. * @param space Space to rotate in (Default: local)
  8741. * @returns the TransformNode.
  8742. */
  8743. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8744. /**
  8745. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8746. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8747. * The passed axis is also normalized. .
  8748. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8749. * @param point the point to rotate around
  8750. * @param axis the axis to rotate around
  8751. * @param amount the amount to rotate in radians
  8752. * @returns the TransformNode
  8753. */
  8754. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8755. /**
  8756. * Translates the mesh along the axis vector for the passed distance in the given space.
  8757. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8758. * @param axis the axis to translate in
  8759. * @param distance the distance to translate
  8760. * @param space Space to rotate in (Default: local)
  8761. * @returns the TransformNode.
  8762. */
  8763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8764. /**
  8765. * Adds a rotation step to the mesh current rotation.
  8766. * x, y, z are Euler angles expressed in radians.
  8767. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8768. * This means this rotation is made in the mesh local space only.
  8769. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8770. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8771. * ```javascript
  8772. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8773. * ```
  8774. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8775. * 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.
  8776. * @param x Rotation to add
  8777. * @param y Rotation to add
  8778. * @param z Rotation to add
  8779. * @returns the TransformNode.
  8780. */
  8781. addRotation(x: number, y: number, z: number): TransformNode;
  8782. /**
  8783. * @hidden
  8784. */
  8785. protected _getEffectiveParent(): Nullable<Node>;
  8786. /**
  8787. * Computes the world matrix of the node
  8788. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8789. * @returns the world matrix
  8790. */
  8791. computeWorldMatrix(force?: boolean): Matrix;
  8792. protected _afterComputeWorldMatrix(): void;
  8793. /**
  8794. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8795. * @param func callback function to add
  8796. *
  8797. * @returns the TransformNode.
  8798. */
  8799. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8800. /**
  8801. * Removes a registered callback function.
  8802. * @param func callback function to remove
  8803. * @returns the TransformNode.
  8804. */
  8805. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8806. /**
  8807. * Gets the position of the current mesh in camera space
  8808. * @param camera defines the camera to use
  8809. * @returns a position
  8810. */
  8811. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8812. /**
  8813. * Returns the distance from the mesh to the active camera
  8814. * @param camera defines the camera to use
  8815. * @returns the distance
  8816. */
  8817. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8818. /**
  8819. * Clone the current transform node
  8820. * @param name Name of the new clone
  8821. * @param newParent New parent for the clone
  8822. * @param doNotCloneChildren Do not clone children hierarchy
  8823. * @returns the new transform node
  8824. */
  8825. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8826. /**
  8827. * Serializes the objects information.
  8828. * @param currentSerializationObject defines the object to serialize in
  8829. * @returns the serialized object
  8830. */
  8831. serialize(currentSerializationObject?: any): any;
  8832. /**
  8833. * Returns a new TransformNode object parsed from the source provided.
  8834. * @param parsedTransformNode is the source.
  8835. * @param scene the scne the object belongs to
  8836. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8837. * @returns a new TransformNode object parsed from the source provided.
  8838. */
  8839. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8840. /**
  8841. * Get all child-transformNodes of this node
  8842. * @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
  8843. * @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
  8844. * @returns an array of TransformNode
  8845. */
  8846. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8847. /**
  8848. * Releases resources associated with this transform node.
  8849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8851. */
  8852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8853. /**
  8854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8858. * @returns the current mesh
  8859. */
  8860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * Class used to override all child animations of a given target
  8866. */
  8867. export class AnimationPropertiesOverride {
  8868. /**
  8869. * Gets or sets a value indicating if animation blending must be used
  8870. */
  8871. enableBlending: boolean;
  8872. /**
  8873. * Gets or sets the blending speed to use when enableBlending is true
  8874. */
  8875. blendingSpeed: number;
  8876. /**
  8877. * Gets or sets the default loop mode to use
  8878. */
  8879. loopMode: number;
  8880. }
  8881. }
  8882. declare module BABYLON {
  8883. /**
  8884. * Class used to store bone information
  8885. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8886. */
  8887. export class Bone extends Node {
  8888. /**
  8889. * defines the bone name
  8890. */
  8891. name: string;
  8892. private static _tmpVecs;
  8893. private static _tmpQuat;
  8894. private static _tmpMats;
  8895. /**
  8896. * Gets the list of child bones
  8897. */
  8898. children: Bone[];
  8899. /** Gets the animations associated with this bone */
  8900. animations: Animation[];
  8901. /**
  8902. * Gets or sets bone length
  8903. */
  8904. length: number;
  8905. /**
  8906. * @hidden Internal only
  8907. * Set this value to map this bone to a different index in the transform matrices
  8908. * Set this value to -1 to exclude the bone from the transform matrices
  8909. */
  8910. _index: Nullable<number>;
  8911. private _skeleton;
  8912. private _localMatrix;
  8913. private _restPose;
  8914. private _baseMatrix;
  8915. private _absoluteTransform;
  8916. private _invertedAbsoluteTransform;
  8917. private _parent;
  8918. private _scalingDeterminant;
  8919. private _worldTransform;
  8920. private _localScaling;
  8921. private _localRotation;
  8922. private _localPosition;
  8923. private _needToDecompose;
  8924. private _needToCompose;
  8925. /** @hidden */
  8926. _linkedTransformNode: Nullable<TransformNode>;
  8927. /** @hidden */
  8928. _waitingTransformNodeId: Nullable<string>;
  8929. /** @hidden */
  8930. /** @hidden */
  8931. _matrix: Matrix;
  8932. /**
  8933. * Create a new bone
  8934. * @param name defines the bone name
  8935. * @param skeleton defines the parent skeleton
  8936. * @param parentBone defines the parent (can be null if the bone is the root)
  8937. * @param localMatrix defines the local matrix
  8938. * @param restPose defines the rest pose matrix
  8939. * @param baseMatrix defines the base matrix
  8940. * @param index defines index of the bone in the hiearchy
  8941. */
  8942. constructor(
  8943. /**
  8944. * defines the bone name
  8945. */
  8946. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8947. /**
  8948. * Gets the current object class name.
  8949. * @return the class name
  8950. */
  8951. getClassName(): string;
  8952. /**
  8953. * Gets the parent skeleton
  8954. * @returns a skeleton
  8955. */
  8956. getSkeleton(): Skeleton;
  8957. /**
  8958. * Gets parent bone
  8959. * @returns a bone or null if the bone is the root of the bone hierarchy
  8960. */
  8961. getParent(): Nullable<Bone>;
  8962. /**
  8963. * Returns an array containing the root bones
  8964. * @returns an array containing the root bones
  8965. */
  8966. getChildren(): Array<Bone>;
  8967. /**
  8968. * Sets the parent bone
  8969. * @param parent defines the parent (can be null if the bone is the root)
  8970. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8971. */
  8972. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8973. /**
  8974. * Gets the local matrix
  8975. * @returns a matrix
  8976. */
  8977. getLocalMatrix(): Matrix;
  8978. /**
  8979. * Gets the base matrix (initial matrix which remains unchanged)
  8980. * @returns a matrix
  8981. */
  8982. getBaseMatrix(): Matrix;
  8983. /**
  8984. * Gets the rest pose matrix
  8985. * @returns a matrix
  8986. */
  8987. getRestPose(): Matrix;
  8988. /**
  8989. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8990. */
  8991. getWorldMatrix(): Matrix;
  8992. /**
  8993. * Sets the local matrix to rest pose matrix
  8994. */
  8995. returnToRest(): void;
  8996. /**
  8997. * Gets the inverse of the absolute transform matrix.
  8998. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8999. * @returns a matrix
  9000. */
  9001. getInvertedAbsoluteTransform(): Matrix;
  9002. /**
  9003. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9004. * @returns a matrix
  9005. */
  9006. getAbsoluteTransform(): Matrix;
  9007. /**
  9008. * Links with the given transform node.
  9009. * The local matrix of this bone is copied from the transform node every frame.
  9010. * @param transformNode defines the transform node to link to
  9011. */
  9012. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9013. /** Gets or sets current position (in local space) */
  9014. position: Vector3;
  9015. /** Gets or sets current rotation (in local space) */
  9016. rotation: Vector3;
  9017. /** Gets or sets current rotation quaternion (in local space) */
  9018. rotationQuaternion: Quaternion;
  9019. /** Gets or sets current scaling (in local space) */
  9020. scaling: Vector3;
  9021. /**
  9022. * Gets the animation properties override
  9023. */
  9024. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9025. private _decompose;
  9026. private _compose;
  9027. /**
  9028. * Update the base and local matrices
  9029. * @param matrix defines the new base or local matrix
  9030. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9031. * @param updateLocalMatrix defines if the local matrix should be updated
  9032. */
  9033. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9034. /** @hidden */
  9035. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9036. /**
  9037. * Flag the bone as dirty (Forcing it to update everything)
  9038. */
  9039. markAsDirty(): void;
  9040. /** @hidden */
  9041. _markAsDirtyAndCompose(): void;
  9042. private _markAsDirtyAndDecompose;
  9043. /**
  9044. * Translate the bone in local or world space
  9045. * @param vec The amount to translate the bone
  9046. * @param space The space that the translation is in
  9047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9048. */
  9049. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9050. /**
  9051. * Set the postion of the bone in local or world space
  9052. * @param position The position to set the bone
  9053. * @param space The space that the position is in
  9054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9055. */
  9056. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9057. /**
  9058. * Set the absolute position of the bone (world space)
  9059. * @param position The position to set the bone
  9060. * @param mesh The mesh that this bone is attached to
  9061. */
  9062. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9063. /**
  9064. * Scale the bone on the x, y and z axes (in local space)
  9065. * @param x The amount to scale the bone on the x axis
  9066. * @param y The amount to scale the bone on the y axis
  9067. * @param z The amount to scale the bone on the z axis
  9068. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9069. */
  9070. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9071. /**
  9072. * Set the bone scaling in local space
  9073. * @param scale defines the scaling vector
  9074. */
  9075. setScale(scale: Vector3): void;
  9076. /**
  9077. * Gets the current scaling in local space
  9078. * @returns the current scaling vector
  9079. */
  9080. getScale(): Vector3;
  9081. /**
  9082. * Gets the current scaling in local space and stores it in a target vector
  9083. * @param result defines the target vector
  9084. */
  9085. getScaleToRef(result: Vector3): void;
  9086. /**
  9087. * Set the yaw, pitch, and roll of the bone in local or world space
  9088. * @param yaw The rotation of the bone on the y axis
  9089. * @param pitch The rotation of the bone on the x axis
  9090. * @param roll The rotation of the bone on the z axis
  9091. * @param space The space that the axes of rotation are in
  9092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9093. */
  9094. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9095. /**
  9096. * Add a rotation to the bone on an axis in local or world space
  9097. * @param axis The axis to rotate the bone on
  9098. * @param amount The amount to rotate the bone
  9099. * @param space The space that the axis is in
  9100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9101. */
  9102. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9103. /**
  9104. * Set the rotation of the bone to a particular axis angle in local or world space
  9105. * @param axis The axis to rotate the bone on
  9106. * @param angle The angle that the bone should be rotated to
  9107. * @param space The space that the axis is in
  9108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9109. */
  9110. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9111. /**
  9112. * Set the euler rotation of the bone in local of world space
  9113. * @param rotation The euler rotation that the bone should be set to
  9114. * @param space The space that the rotation is in
  9115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9116. */
  9117. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9118. /**
  9119. * Set the quaternion rotation of the bone in local of world space
  9120. * @param quat The quaternion rotation that the bone should be set to
  9121. * @param space The space that the rotation is in
  9122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9123. */
  9124. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9125. /**
  9126. * Set the rotation matrix of the bone in local of world space
  9127. * @param rotMat The rotation matrix that the bone should be set to
  9128. * @param space The space that the rotation is in
  9129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9130. */
  9131. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9132. private _rotateWithMatrix;
  9133. private _getNegativeRotationToRef;
  9134. /**
  9135. * Get the position of the bone in local or world space
  9136. * @param space The space that the returned position is in
  9137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9138. * @returns The position of the bone
  9139. */
  9140. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9141. /**
  9142. * Copy the position of the bone to a vector3 in local or world space
  9143. * @param space The space that the returned position is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. * @param result The vector3 to copy the position to
  9146. */
  9147. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9148. /**
  9149. * Get the absolute position of the bone (world space)
  9150. * @param mesh The mesh that this bone is attached to
  9151. * @returns The absolute position of the bone
  9152. */
  9153. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9154. /**
  9155. * Copy the absolute position of the bone (world space) to the result param
  9156. * @param mesh The mesh that this bone is attached to
  9157. * @param result The vector3 to copy the absolute position to
  9158. */
  9159. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9160. /**
  9161. * Compute the absolute transforms of this bone and its children
  9162. */
  9163. computeAbsoluteTransforms(): void;
  9164. /**
  9165. * Get the world direction from an axis that is in the local space of the bone
  9166. * @param localAxis The local direction that is used to compute the world direction
  9167. * @param mesh The mesh that this bone is attached to
  9168. * @returns The world direction
  9169. */
  9170. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9171. /**
  9172. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9173. * @param localAxis The local direction that is used to compute the world direction
  9174. * @param mesh The mesh that this bone is attached to
  9175. * @param result The vector3 that the world direction will be copied to
  9176. */
  9177. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9178. /**
  9179. * Get the euler rotation of the bone in local or world space
  9180. * @param space The space that the rotation should be in
  9181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9182. * @returns The euler rotation
  9183. */
  9184. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9185. /**
  9186. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9187. * @param space The space that the rotation should be in
  9188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9189. * @param result The vector3 that the rotation should be copied to
  9190. */
  9191. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9192. /**
  9193. * Get the quaternion rotation of the bone in either local or world space
  9194. * @param space The space that the rotation should be in
  9195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9196. * @returns The quaternion rotation
  9197. */
  9198. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9199. /**
  9200. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9201. * @param space The space that the rotation should be in
  9202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9203. * @param result The quaternion that the rotation should be copied to
  9204. */
  9205. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9206. /**
  9207. * Get the rotation matrix of the bone in local or world space
  9208. * @param space The space that the rotation should be in
  9209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9210. * @returns The rotation matrix
  9211. */
  9212. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9213. /**
  9214. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9215. * @param space The space that the rotation should be in
  9216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9217. * @param result The quaternion that the rotation should be copied to
  9218. */
  9219. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9220. /**
  9221. * Get the world position of a point that is in the local space of the bone
  9222. * @param position The local position
  9223. * @param mesh The mesh that this bone is attached to
  9224. * @returns The world position
  9225. */
  9226. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9227. /**
  9228. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9229. * @param position The local position
  9230. * @param mesh The mesh that this bone is attached to
  9231. * @param result The vector3 that the world position should be copied to
  9232. */
  9233. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9234. /**
  9235. * Get the local position of a point that is in world space
  9236. * @param position The world position
  9237. * @param mesh The mesh that this bone is attached to
  9238. * @returns The local position
  9239. */
  9240. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Get the local position of a point that is in world space and copy it to the result param
  9243. * @param position The world position
  9244. * @param mesh The mesh that this bone is attached to
  9245. * @param result The vector3 that the local position should be copied to
  9246. */
  9247. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9248. }
  9249. }
  9250. declare module BABYLON {
  9251. interface Engine {
  9252. /**
  9253. * Creates a raw texture
  9254. * @param data defines the data to store in the texture
  9255. * @param width defines the width of the texture
  9256. * @param height defines the height of the texture
  9257. * @param format defines the format of the data
  9258. * @param generateMipMaps defines if the engine should generate the mip levels
  9259. * @param invertY defines if data must be stored with Y axis inverted
  9260. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9261. * @param compression defines the compression used (null by default)
  9262. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9263. * @returns the raw texture inside an InternalTexture
  9264. */
  9265. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9266. /**
  9267. * Update a raw texture
  9268. * @param texture defines the texture to update
  9269. * @param data defines the data to store in the texture
  9270. * @param format defines the format of the data
  9271. * @param invertY defines if data must be stored with Y axis inverted
  9272. */
  9273. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9274. /**
  9275. * Update a raw texture
  9276. * @param texture defines the texture to update
  9277. * @param data defines the data to store in the texture
  9278. * @param format defines the format of the data
  9279. * @param invertY defines if data must be stored with Y axis inverted
  9280. * @param compression defines the compression used (null by default)
  9281. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9282. */
  9283. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9284. /**
  9285. * Creates a new raw cube texture
  9286. * @param data defines the array of data to use to create each face
  9287. * @param size defines the size of the textures
  9288. * @param format defines the format of the data
  9289. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9290. * @param generateMipMaps defines if the engine should generate the mip levels
  9291. * @param invertY defines if data must be stored with Y axis inverted
  9292. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9293. * @param compression defines the compression used (null by default)
  9294. * @returns the cube texture as an InternalTexture
  9295. */
  9296. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9297. /**
  9298. * Update a raw cube texture
  9299. * @param texture defines the texture to udpdate
  9300. * @param data defines the data to store
  9301. * @param format defines the data format
  9302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9303. * @param invertY defines if data must be stored with Y axis inverted
  9304. */
  9305. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9306. /**
  9307. * Update a raw cube texture
  9308. * @param texture defines the texture to udpdate
  9309. * @param data defines the data to store
  9310. * @param format defines the data format
  9311. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9312. * @param invertY defines if data must be stored with Y axis inverted
  9313. * @param compression defines the compression used (null by default)
  9314. */
  9315. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9316. /**
  9317. * Update a raw cube texture
  9318. * @param texture defines the texture to udpdate
  9319. * @param data defines the data to store
  9320. * @param format defines the data format
  9321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9322. * @param invertY defines if data must be stored with Y axis inverted
  9323. * @param compression defines the compression used (null by default)
  9324. * @param level defines which level of the texture to update
  9325. */
  9326. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9327. /**
  9328. * Creates a new raw cube texture from a specified url
  9329. * @param url defines the url where the data is located
  9330. * @param scene defines the current scene
  9331. * @param size defines the size of the textures
  9332. * @param format defines the format of the data
  9333. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9334. * @param noMipmap defines if the engine should avoid generating the mip levels
  9335. * @param callback defines a callback used to extract texture data from loaded data
  9336. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9337. * @param onLoad defines a callback called when texture is loaded
  9338. * @param onError defines a callback called if there is an error
  9339. * @returns the cube texture as an InternalTexture
  9340. */
  9341. 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;
  9342. /**
  9343. * Creates a new raw cube texture from a specified url
  9344. * @param url defines the url where the data is located
  9345. * @param scene defines the current scene
  9346. * @param size defines the size of the textures
  9347. * @param format defines the format of the data
  9348. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9349. * @param noMipmap defines if the engine should avoid generating the mip levels
  9350. * @param callback defines a callback used to extract texture data from loaded data
  9351. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9352. * @param onLoad defines a callback called when texture is loaded
  9353. * @param onError defines a callback called if there is an error
  9354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9355. * @param invertY defines if data must be stored with Y axis inverted
  9356. * @returns the cube texture as an InternalTexture
  9357. */
  9358. 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;
  9359. /**
  9360. * Creates a new raw 3D texture
  9361. * @param data defines the data used to create the texture
  9362. * @param width defines the width of the texture
  9363. * @param height defines the height of the texture
  9364. * @param depth defines the depth of the texture
  9365. * @param format defines the format of the texture
  9366. * @param generateMipMaps defines if the engine must generate mip levels
  9367. * @param invertY defines if data must be stored with Y axis inverted
  9368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9369. * @param compression defines the compressed used (can be null)
  9370. * @param textureType defines the compressed used (can be null)
  9371. * @returns a new raw 3D texture (stored in an InternalTexture)
  9372. */
  9373. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9374. /**
  9375. * Update a raw 3D texture
  9376. * @param texture defines the texture to update
  9377. * @param data defines the data to store
  9378. * @param format defines the data format
  9379. * @param invertY defines if data must be stored with Y axis inverted
  9380. */
  9381. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9382. /**
  9383. * Update a raw 3D texture
  9384. * @param texture defines the texture to update
  9385. * @param data defines the data to store
  9386. * @param format defines the data format
  9387. * @param invertY defines if data must be stored with Y axis inverted
  9388. * @param compression defines the used compression (can be null)
  9389. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9390. */
  9391. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9392. }
  9393. }
  9394. declare module BABYLON {
  9395. /**
  9396. * Raw texture can help creating a texture directly from an array of data.
  9397. * This can be super useful if you either get the data from an uncompressed source or
  9398. * if you wish to create your texture pixel by pixel.
  9399. */
  9400. export class RawTexture extends Texture {
  9401. /**
  9402. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9403. */
  9404. format: number;
  9405. private _engine;
  9406. /**
  9407. * Instantiates a new RawTexture.
  9408. * Raw texture can help creating a texture directly from an array of data.
  9409. * This can be super useful if you either get the data from an uncompressed source or
  9410. * if you wish to create your texture pixel by pixel.
  9411. * @param data define the array of data to use to create the texture
  9412. * @param width define the width of the texture
  9413. * @param height define the height of the texture
  9414. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9415. * @param scene define the scene the texture belongs to
  9416. * @param generateMipMaps define whether mip maps should be generated or not
  9417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9419. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9420. */
  9421. constructor(data: ArrayBufferView, width: number, height: number,
  9422. /**
  9423. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9424. */
  9425. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9426. /**
  9427. * Updates the texture underlying data.
  9428. * @param data Define the new data of the texture
  9429. */
  9430. update(data: ArrayBufferView): void;
  9431. /**
  9432. * Creates a luminance texture from some data.
  9433. * @param data Define the texture data
  9434. * @param width Define the width of the texture
  9435. * @param height Define the height of the texture
  9436. * @param scene Define the scene the texture belongs to
  9437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9440. * @returns the luminance texture
  9441. */
  9442. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9443. /**
  9444. * Creates a luminance alpha texture from some data.
  9445. * @param data Define the texture data
  9446. * @param width Define the width of the texture
  9447. * @param height Define the height of the texture
  9448. * @param scene Define the scene the texture belongs to
  9449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9452. * @returns the luminance alpha texture
  9453. */
  9454. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9455. /**
  9456. * Creates an alpha texture from some data.
  9457. * @param data Define the texture data
  9458. * @param width Define the width of the texture
  9459. * @param height Define the height of the texture
  9460. * @param scene Define the scene the texture belongs to
  9461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9464. * @returns the alpha texture
  9465. */
  9466. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9467. /**
  9468. * Creates a RGB texture from some data.
  9469. * @param data Define the texture data
  9470. * @param width Define the width of the texture
  9471. * @param height Define the height of the texture
  9472. * @param scene Define the scene the texture belongs to
  9473. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9476. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9477. * @returns the RGB alpha texture
  9478. */
  9479. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9480. /**
  9481. * Creates a RGBA texture from some data.
  9482. * @param data Define the texture data
  9483. * @param width Define the width of the texture
  9484. * @param height Define the height of the texture
  9485. * @param scene Define the scene the texture belongs to
  9486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9490. * @returns the RGBA texture
  9491. */
  9492. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9493. /**
  9494. * Creates a R texture from some data.
  9495. * @param data Define the texture data
  9496. * @param width Define the width of the texture
  9497. * @param height Define the height of the texture
  9498. * @param scene Define the scene the texture belongs to
  9499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9503. * @returns the R texture
  9504. */
  9505. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9506. }
  9507. }
  9508. declare module BABYLON {
  9509. /**
  9510. * Defines a runtime animation
  9511. */
  9512. export class RuntimeAnimation {
  9513. private _events;
  9514. /**
  9515. * The current frame of the runtime animation
  9516. */
  9517. private _currentFrame;
  9518. /**
  9519. * The animation used by the runtime animation
  9520. */
  9521. private _animation;
  9522. /**
  9523. * The target of the runtime animation
  9524. */
  9525. private _target;
  9526. /**
  9527. * The initiating animatable
  9528. */
  9529. private _host;
  9530. /**
  9531. * The original value of the runtime animation
  9532. */
  9533. private _originalValue;
  9534. /**
  9535. * The original blend value of the runtime animation
  9536. */
  9537. private _originalBlendValue;
  9538. /**
  9539. * The offsets cache of the runtime animation
  9540. */
  9541. private _offsetsCache;
  9542. /**
  9543. * The high limits cache of the runtime animation
  9544. */
  9545. private _highLimitsCache;
  9546. /**
  9547. * Specifies if the runtime animation has been stopped
  9548. */
  9549. private _stopped;
  9550. /**
  9551. * The blending factor of the runtime animation
  9552. */
  9553. private _blendingFactor;
  9554. /**
  9555. * The BabylonJS scene
  9556. */
  9557. private _scene;
  9558. /**
  9559. * The current value of the runtime animation
  9560. */
  9561. private _currentValue;
  9562. /** @hidden */
  9563. _animationState: _IAnimationState;
  9564. /**
  9565. * The active target of the runtime animation
  9566. */
  9567. private _activeTargets;
  9568. private _currentActiveTarget;
  9569. private _directTarget;
  9570. /**
  9571. * The target path of the runtime animation
  9572. */
  9573. private _targetPath;
  9574. /**
  9575. * The weight of the runtime animation
  9576. */
  9577. private _weight;
  9578. /**
  9579. * The ratio offset of the runtime animation
  9580. */
  9581. private _ratioOffset;
  9582. /**
  9583. * The previous delay of the runtime animation
  9584. */
  9585. private _previousDelay;
  9586. /**
  9587. * The previous ratio of the runtime animation
  9588. */
  9589. private _previousRatio;
  9590. private _enableBlending;
  9591. private _keys;
  9592. private _minFrame;
  9593. private _maxFrame;
  9594. private _minValue;
  9595. private _maxValue;
  9596. private _targetIsArray;
  9597. /**
  9598. * Gets the current frame of the runtime animation
  9599. */
  9600. readonly currentFrame: number;
  9601. /**
  9602. * Gets the weight of the runtime animation
  9603. */
  9604. readonly weight: number;
  9605. /**
  9606. * Gets the current value of the runtime animation
  9607. */
  9608. readonly currentValue: any;
  9609. /**
  9610. * Gets the target path of the runtime animation
  9611. */
  9612. readonly targetPath: string;
  9613. /**
  9614. * Gets the actual target of the runtime animation
  9615. */
  9616. readonly target: any;
  9617. /** @hidden */
  9618. _onLoop: () => void;
  9619. /**
  9620. * Create a new RuntimeAnimation object
  9621. * @param target defines the target of the animation
  9622. * @param animation defines the source animation object
  9623. * @param scene defines the hosting scene
  9624. * @param host defines the initiating Animatable
  9625. */
  9626. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9627. private _preparePath;
  9628. /**
  9629. * Gets the animation from the runtime animation
  9630. */
  9631. readonly animation: Animation;
  9632. /**
  9633. * Resets the runtime animation to the beginning
  9634. * @param restoreOriginal defines whether to restore the target property to the original value
  9635. */
  9636. reset(restoreOriginal?: boolean): void;
  9637. /**
  9638. * Specifies if the runtime animation is stopped
  9639. * @returns Boolean specifying if the runtime animation is stopped
  9640. */
  9641. isStopped(): boolean;
  9642. /**
  9643. * Disposes of the runtime animation
  9644. */
  9645. dispose(): void;
  9646. /**
  9647. * Apply the interpolated value to the target
  9648. * @param currentValue defines the value computed by the animation
  9649. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9650. */
  9651. setValue(currentValue: any, weight: number): void;
  9652. private _getOriginalValues;
  9653. private _setValue;
  9654. /**
  9655. * Gets the loop pmode of the runtime animation
  9656. * @returns Loop Mode
  9657. */
  9658. private _getCorrectLoopMode;
  9659. /**
  9660. * Move the current animation to a given frame
  9661. * @param frame defines the frame to move to
  9662. */
  9663. goToFrame(frame: number): void;
  9664. /**
  9665. * @hidden Internal use only
  9666. */
  9667. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9668. /**
  9669. * Execute the current animation
  9670. * @param delay defines the delay to add to the current frame
  9671. * @param from defines the lower bound of the animation range
  9672. * @param to defines the upper bound of the animation range
  9673. * @param loop defines if the current animation must loop
  9674. * @param speedRatio defines the current speed ratio
  9675. * @param weight defines the weight of the animation (default is -1 so no weight)
  9676. * @param onLoop optional callback called when animation loops
  9677. * @returns a boolean indicating if the animation is running
  9678. */
  9679. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9680. }
  9681. }
  9682. declare module BABYLON {
  9683. /**
  9684. * Class used to store an actual running animation
  9685. */
  9686. export class Animatable {
  9687. /** defines the target object */
  9688. target: any;
  9689. /** defines the starting frame number (default is 0) */
  9690. fromFrame: number;
  9691. /** defines the ending frame number (default is 100) */
  9692. toFrame: number;
  9693. /** defines if the animation must loop (default is false) */
  9694. loopAnimation: boolean;
  9695. /** defines a callback to call when animation ends if it is not looping */
  9696. onAnimationEnd?: (() => void) | null | undefined;
  9697. /** defines a callback to call when animation loops */
  9698. onAnimationLoop?: (() => void) | null | undefined;
  9699. private _localDelayOffset;
  9700. private _pausedDelay;
  9701. private _runtimeAnimations;
  9702. private _paused;
  9703. private _scene;
  9704. private _speedRatio;
  9705. private _weight;
  9706. private _syncRoot;
  9707. /**
  9708. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9709. * This will only apply for non looping animation (default is true)
  9710. */
  9711. disposeOnEnd: boolean;
  9712. /**
  9713. * Gets a boolean indicating if the animation has started
  9714. */
  9715. animationStarted: boolean;
  9716. /**
  9717. * Observer raised when the animation ends
  9718. */
  9719. onAnimationEndObservable: Observable<Animatable>;
  9720. /**
  9721. * Observer raised when the animation loops
  9722. */
  9723. onAnimationLoopObservable: Observable<Animatable>;
  9724. /**
  9725. * Gets the root Animatable used to synchronize and normalize animations
  9726. */
  9727. readonly syncRoot: Nullable<Animatable>;
  9728. /**
  9729. * Gets the current frame of the first RuntimeAnimation
  9730. * Used to synchronize Animatables
  9731. */
  9732. readonly masterFrame: number;
  9733. /**
  9734. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9735. */
  9736. weight: number;
  9737. /**
  9738. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9739. */
  9740. speedRatio: number;
  9741. /**
  9742. * Creates a new Animatable
  9743. * @param scene defines the hosting scene
  9744. * @param target defines the target object
  9745. * @param fromFrame defines the starting frame number (default is 0)
  9746. * @param toFrame defines the ending frame number (default is 100)
  9747. * @param loopAnimation defines if the animation must loop (default is false)
  9748. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9749. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9750. * @param animations defines a group of animation to add to the new Animatable
  9751. * @param onAnimationLoop defines a callback to call when animation loops
  9752. */
  9753. constructor(scene: Scene,
  9754. /** defines the target object */
  9755. target: any,
  9756. /** defines the starting frame number (default is 0) */
  9757. fromFrame?: number,
  9758. /** defines the ending frame number (default is 100) */
  9759. toFrame?: number,
  9760. /** defines if the animation must loop (default is false) */
  9761. loopAnimation?: boolean, speedRatio?: number,
  9762. /** defines a callback to call when animation ends if it is not looping */
  9763. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9764. /** defines a callback to call when animation loops */
  9765. onAnimationLoop?: (() => void) | null | undefined);
  9766. /**
  9767. * Synchronize and normalize current Animatable with a source Animatable
  9768. * This is useful when using animation weights and when animations are not of the same length
  9769. * @param root defines the root Animatable to synchronize with
  9770. * @returns the current Animatable
  9771. */
  9772. syncWith(root: Animatable): Animatable;
  9773. /**
  9774. * Gets the list of runtime animations
  9775. * @returns an array of RuntimeAnimation
  9776. */
  9777. getAnimations(): RuntimeAnimation[];
  9778. /**
  9779. * Adds more animations to the current animatable
  9780. * @param target defines the target of the animations
  9781. * @param animations defines the new animations to add
  9782. */
  9783. appendAnimations(target: any, animations: Animation[]): void;
  9784. /**
  9785. * Gets the source animation for a specific property
  9786. * @param property defines the propertyu to look for
  9787. * @returns null or the source animation for the given property
  9788. */
  9789. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9790. /**
  9791. * Gets the runtime animation for a specific property
  9792. * @param property defines the propertyu to look for
  9793. * @returns null or the runtime animation for the given property
  9794. */
  9795. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9796. /**
  9797. * Resets the animatable to its original state
  9798. */
  9799. reset(): void;
  9800. /**
  9801. * Allows the animatable to blend with current running animations
  9802. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9803. * @param blendingSpeed defines the blending speed to use
  9804. */
  9805. enableBlending(blendingSpeed: number): void;
  9806. /**
  9807. * Disable animation blending
  9808. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9809. */
  9810. disableBlending(): void;
  9811. /**
  9812. * Jump directly to a given frame
  9813. * @param frame defines the frame to jump to
  9814. */
  9815. goToFrame(frame: number): void;
  9816. /**
  9817. * Pause the animation
  9818. */
  9819. pause(): void;
  9820. /**
  9821. * Restart the animation
  9822. */
  9823. restart(): void;
  9824. private _raiseOnAnimationEnd;
  9825. /**
  9826. * Stop and delete the current animation
  9827. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9828. * @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)
  9829. */
  9830. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9831. /**
  9832. * Wait asynchronously for the animation to end
  9833. * @returns a promise which will be fullfilled when the animation ends
  9834. */
  9835. waitAsync(): Promise<Animatable>;
  9836. /** @hidden */
  9837. _animate(delay: number): boolean;
  9838. }
  9839. interface Scene {
  9840. /** @hidden */
  9841. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9842. /** @hidden */
  9843. _processLateAnimationBindingsForMatrices(holder: {
  9844. totalWeight: number;
  9845. animations: RuntimeAnimation[];
  9846. originalValue: Matrix;
  9847. }): any;
  9848. /** @hidden */
  9849. _processLateAnimationBindingsForQuaternions(holder: {
  9850. totalWeight: number;
  9851. animations: RuntimeAnimation[];
  9852. originalValue: Quaternion;
  9853. }, refQuaternion: Quaternion): Quaternion;
  9854. /** @hidden */
  9855. _processLateAnimationBindings(): void;
  9856. /**
  9857. * Will start the animation sequence of a given target
  9858. * @param target defines the target
  9859. * @param from defines from which frame should animation start
  9860. * @param to defines until which frame should animation run.
  9861. * @param weight defines the weight to apply to the animation (1.0 by default)
  9862. * @param loop defines if the animation loops
  9863. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9864. * @param onAnimationEnd defines the function to be executed when the animation ends
  9865. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9866. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9867. * @param onAnimationLoop defines the callback to call when an animation loops
  9868. * @returns the animatable object created for this animation
  9869. */
  9870. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9871. /**
  9872. * Will start the animation sequence of a given target
  9873. * @param target defines the target
  9874. * @param from defines from which frame should animation start
  9875. * @param to defines until which frame should animation run.
  9876. * @param loop defines if the animation loops
  9877. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9878. * @param onAnimationEnd defines the function to be executed when the animation ends
  9879. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9880. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9881. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9882. * @param onAnimationLoop defines the callback to call when an animation loops
  9883. * @returns the animatable object created for this animation
  9884. */
  9885. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9886. /**
  9887. * Will start the animation sequence of a given target and its hierarchy
  9888. * @param target defines the target
  9889. * @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.
  9890. * @param from defines from which frame should animation start
  9891. * @param to defines until which frame should animation run.
  9892. * @param loop defines if the animation loops
  9893. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9894. * @param onAnimationEnd defines the function to be executed when the animation ends
  9895. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9896. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9897. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9898. * @param onAnimationLoop defines the callback to call when an animation loops
  9899. * @returns the list of created animatables
  9900. */
  9901. 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[];
  9902. /**
  9903. * Begin a new animation on a given node
  9904. * @param target defines the target where the animation will take place
  9905. * @param animations defines the list of animations to start
  9906. * @param from defines the initial value
  9907. * @param to defines the final value
  9908. * @param loop defines if you want animation to loop (off by default)
  9909. * @param speedRatio defines the speed ratio to apply to all animations
  9910. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9911. * @param onAnimationLoop defines the callback to call when an animation loops
  9912. * @returns the list of created animatables
  9913. */
  9914. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9915. /**
  9916. * Begin a new animation on a given node and its hierarchy
  9917. * @param target defines the root node where the animation will take place
  9918. * @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.
  9919. * @param animations defines the list of animations to start
  9920. * @param from defines the initial value
  9921. * @param to defines the final value
  9922. * @param loop defines if you want animation to loop (off by default)
  9923. * @param speedRatio defines the speed ratio to apply to all animations
  9924. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9925. * @param onAnimationLoop defines the callback to call when an animation loops
  9926. * @returns the list of animatables created for all nodes
  9927. */
  9928. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9929. /**
  9930. * Gets the animatable associated with a specific target
  9931. * @param target defines the target of the animatable
  9932. * @returns the required animatable if found
  9933. */
  9934. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9935. /**
  9936. * Gets all animatables associated with a given target
  9937. * @param target defines the target to look animatables for
  9938. * @returns an array of Animatables
  9939. */
  9940. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9941. /**
  9942. * Stops and removes all animations that have been applied to the scene
  9943. */
  9944. stopAllAnimations(): void;
  9945. }
  9946. interface Bone {
  9947. /**
  9948. * Copy an animation range from another bone
  9949. * @param source defines the source bone
  9950. * @param rangeName defines the range name to copy
  9951. * @param frameOffset defines the frame offset
  9952. * @param rescaleAsRequired defines if rescaling must be applied if required
  9953. * @param skelDimensionsRatio defines the scaling ratio
  9954. * @returns true if operation was successful
  9955. */
  9956. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9957. }
  9958. }
  9959. declare module BABYLON {
  9960. /**
  9961. * Class used to handle skinning animations
  9962. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9963. */
  9964. export class Skeleton implements IAnimatable {
  9965. /** defines the skeleton name */
  9966. name: string;
  9967. /** defines the skeleton Id */
  9968. id: string;
  9969. /**
  9970. * Defines the list of child bones
  9971. */
  9972. bones: Bone[];
  9973. /**
  9974. * Defines an estimate of the dimension of the skeleton at rest
  9975. */
  9976. dimensionsAtRest: Vector3;
  9977. /**
  9978. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9979. */
  9980. needInitialSkinMatrix: boolean;
  9981. /**
  9982. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9983. */
  9984. overrideMesh: Nullable<AbstractMesh>;
  9985. /**
  9986. * Gets the list of animations attached to this skeleton
  9987. */
  9988. animations: Array<Animation>;
  9989. private _scene;
  9990. private _isDirty;
  9991. private _transformMatrices;
  9992. private _transformMatrixTexture;
  9993. private _meshesWithPoseMatrix;
  9994. private _animatables;
  9995. private _identity;
  9996. private _synchronizedWithMesh;
  9997. private _ranges;
  9998. private _lastAbsoluteTransformsUpdateId;
  9999. private _canUseTextureForBones;
  10000. private _uniqueId;
  10001. /** @hidden */
  10002. _numBonesWithLinkedTransformNode: number;
  10003. /** @hidden */
  10004. _hasWaitingData: Nullable<boolean>;
  10005. /**
  10006. * Specifies if the skeleton should be serialized
  10007. */
  10008. doNotSerialize: boolean;
  10009. private _useTextureToStoreBoneMatrices;
  10010. /**
  10011. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10012. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10013. */
  10014. useTextureToStoreBoneMatrices: boolean;
  10015. private _animationPropertiesOverride;
  10016. /**
  10017. * Gets or sets the animation properties override
  10018. */
  10019. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10020. /**
  10021. * List of inspectable custom properties (used by the Inspector)
  10022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10023. */
  10024. inspectableCustomProperties: IInspectable[];
  10025. /**
  10026. * An observable triggered before computing the skeleton's matrices
  10027. */
  10028. onBeforeComputeObservable: Observable<Skeleton>;
  10029. /**
  10030. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10031. */
  10032. readonly isUsingTextureForMatrices: boolean;
  10033. /**
  10034. * Gets the unique ID of this skeleton
  10035. */
  10036. readonly uniqueId: number;
  10037. /**
  10038. * Creates a new skeleton
  10039. * @param name defines the skeleton name
  10040. * @param id defines the skeleton Id
  10041. * @param scene defines the hosting scene
  10042. */
  10043. constructor(
  10044. /** defines the skeleton name */
  10045. name: string,
  10046. /** defines the skeleton Id */
  10047. id: string, scene: Scene);
  10048. /**
  10049. * Gets the current object class name.
  10050. * @return the class name
  10051. */
  10052. getClassName(): string;
  10053. /**
  10054. * Returns an array containing the root bones
  10055. * @returns an array containing the root bones
  10056. */
  10057. getChildren(): Array<Bone>;
  10058. /**
  10059. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10060. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10061. * @returns a Float32Array containing matrices data
  10062. */
  10063. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10064. /**
  10065. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10066. * @returns a raw texture containing the data
  10067. */
  10068. getTransformMatrixTexture(): Nullable<RawTexture>;
  10069. /**
  10070. * Gets the current hosting scene
  10071. * @returns a scene object
  10072. */
  10073. getScene(): Scene;
  10074. /**
  10075. * Gets a string representing the current skeleton data
  10076. * @param fullDetails defines a boolean indicating if we want a verbose version
  10077. * @returns a string representing the current skeleton data
  10078. */
  10079. toString(fullDetails?: boolean): string;
  10080. /**
  10081. * Get bone's index searching by name
  10082. * @param name defines bone's name to search for
  10083. * @return the indice of the bone. Returns -1 if not found
  10084. */
  10085. getBoneIndexByName(name: string): number;
  10086. /**
  10087. * Creater a new animation range
  10088. * @param name defines the name of the range
  10089. * @param from defines the start key
  10090. * @param to defines the end key
  10091. */
  10092. createAnimationRange(name: string, from: number, to: number): void;
  10093. /**
  10094. * Delete a specific animation range
  10095. * @param name defines the name of the range
  10096. * @param deleteFrames defines if frames must be removed as well
  10097. */
  10098. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10099. /**
  10100. * Gets a specific animation range
  10101. * @param name defines the name of the range to look for
  10102. * @returns the requested animation range or null if not found
  10103. */
  10104. getAnimationRange(name: string): Nullable<AnimationRange>;
  10105. /**
  10106. * Gets the list of all animation ranges defined on this skeleton
  10107. * @returns an array
  10108. */
  10109. getAnimationRanges(): Nullable<AnimationRange>[];
  10110. /**
  10111. * Copy animation range from a source skeleton.
  10112. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10113. * @param source defines the source skeleton
  10114. * @param name defines the name of the range to copy
  10115. * @param rescaleAsRequired defines if rescaling must be applied if required
  10116. * @returns true if operation was successful
  10117. */
  10118. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10119. /**
  10120. * Forces the skeleton to go to rest pose
  10121. */
  10122. returnToRest(): void;
  10123. private _getHighestAnimationFrame;
  10124. /**
  10125. * Begin a specific animation range
  10126. * @param name defines the name of the range to start
  10127. * @param loop defines if looping must be turned on (false by default)
  10128. * @param speedRatio defines the speed ratio to apply (1 by default)
  10129. * @param onAnimationEnd defines a callback which will be called when animation will end
  10130. * @returns a new animatable
  10131. */
  10132. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10133. /** @hidden */
  10134. _markAsDirty(): void;
  10135. /** @hidden */
  10136. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10137. /** @hidden */
  10138. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10139. private _computeTransformMatrices;
  10140. /**
  10141. * Build all resources required to render a skeleton
  10142. */
  10143. prepare(): void;
  10144. /**
  10145. * Gets the list of animatables currently running for this skeleton
  10146. * @returns an array of animatables
  10147. */
  10148. getAnimatables(): IAnimatable[];
  10149. /**
  10150. * Clone the current skeleton
  10151. * @param name defines the name of the new skeleton
  10152. * @param id defines the id of the new skeleton
  10153. * @returns the new skeleton
  10154. */
  10155. clone(name: string, id: string): Skeleton;
  10156. /**
  10157. * Enable animation blending for this skeleton
  10158. * @param blendingSpeed defines the blending speed to apply
  10159. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10160. */
  10161. enableBlending(blendingSpeed?: number): void;
  10162. /**
  10163. * Releases all resources associated with the current skeleton
  10164. */
  10165. dispose(): void;
  10166. /**
  10167. * Serialize the skeleton in a JSON object
  10168. * @returns a JSON object
  10169. */
  10170. serialize(): any;
  10171. /**
  10172. * Creates a new skeleton from serialized data
  10173. * @param parsedSkeleton defines the serialized data
  10174. * @param scene defines the hosting scene
  10175. * @returns a new skeleton
  10176. */
  10177. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10178. /**
  10179. * Compute all node absolute transforms
  10180. * @param forceUpdate defines if computation must be done even if cache is up to date
  10181. */
  10182. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10183. /**
  10184. * Gets the root pose matrix
  10185. * @returns a matrix
  10186. */
  10187. getPoseMatrix(): Nullable<Matrix>;
  10188. /**
  10189. * Sorts bones per internal index
  10190. */
  10191. sortBones(): void;
  10192. private _sortBones;
  10193. }
  10194. }
  10195. declare module BABYLON {
  10196. /**
  10197. * Defines a target to use with MorphTargetManager
  10198. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10199. */
  10200. export class MorphTarget implements IAnimatable {
  10201. /** defines the name of the target */
  10202. name: string;
  10203. /**
  10204. * Gets or sets the list of animations
  10205. */
  10206. animations: Animation[];
  10207. private _scene;
  10208. private _positions;
  10209. private _normals;
  10210. private _tangents;
  10211. private _uvs;
  10212. private _influence;
  10213. /**
  10214. * Observable raised when the influence changes
  10215. */
  10216. onInfluenceChanged: Observable<boolean>;
  10217. /** @hidden */
  10218. _onDataLayoutChanged: Observable<void>;
  10219. /**
  10220. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10221. */
  10222. influence: number;
  10223. /**
  10224. * Gets or sets the id of the morph Target
  10225. */
  10226. id: string;
  10227. private _animationPropertiesOverride;
  10228. /**
  10229. * Gets or sets the animation properties override
  10230. */
  10231. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10232. /**
  10233. * Creates a new MorphTarget
  10234. * @param name defines the name of the target
  10235. * @param influence defines the influence to use
  10236. * @param scene defines the scene the morphtarget belongs to
  10237. */
  10238. constructor(
  10239. /** defines the name of the target */
  10240. name: string, influence?: number, scene?: Nullable<Scene>);
  10241. /**
  10242. * Gets a boolean defining if the target contains position data
  10243. */
  10244. readonly hasPositions: boolean;
  10245. /**
  10246. * Gets a boolean defining if the target contains normal data
  10247. */
  10248. readonly hasNormals: boolean;
  10249. /**
  10250. * Gets a boolean defining if the target contains tangent data
  10251. */
  10252. readonly hasTangents: boolean;
  10253. /**
  10254. * Gets a boolean defining if the target contains texture coordinates data
  10255. */
  10256. readonly hasUVs: boolean;
  10257. /**
  10258. * Affects position data to this target
  10259. * @param data defines the position data to use
  10260. */
  10261. setPositions(data: Nullable<FloatArray>): void;
  10262. /**
  10263. * Gets the position data stored in this target
  10264. * @returns a FloatArray containing the position data (or null if not present)
  10265. */
  10266. getPositions(): Nullable<FloatArray>;
  10267. /**
  10268. * Affects normal data to this target
  10269. * @param data defines the normal data to use
  10270. */
  10271. setNormals(data: Nullable<FloatArray>): void;
  10272. /**
  10273. * Gets the normal data stored in this target
  10274. * @returns a FloatArray containing the normal data (or null if not present)
  10275. */
  10276. getNormals(): Nullable<FloatArray>;
  10277. /**
  10278. * Affects tangent data to this target
  10279. * @param data defines the tangent data to use
  10280. */
  10281. setTangents(data: Nullable<FloatArray>): void;
  10282. /**
  10283. * Gets the tangent data stored in this target
  10284. * @returns a FloatArray containing the tangent data (or null if not present)
  10285. */
  10286. getTangents(): Nullable<FloatArray>;
  10287. /**
  10288. * Affects texture coordinates data to this target
  10289. * @param data defines the texture coordinates data to use
  10290. */
  10291. setUVs(data: Nullable<FloatArray>): void;
  10292. /**
  10293. * Gets the texture coordinates data stored in this target
  10294. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10295. */
  10296. getUVs(): Nullable<FloatArray>;
  10297. /**
  10298. * Serializes the current target into a Serialization object
  10299. * @returns the serialized object
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Returns the string "MorphTarget"
  10304. * @returns "MorphTarget"
  10305. */
  10306. getClassName(): string;
  10307. /**
  10308. * Creates a new target from serialized data
  10309. * @param serializationObject defines the serialized data to use
  10310. * @returns a new MorphTarget
  10311. */
  10312. static Parse(serializationObject: any): MorphTarget;
  10313. /**
  10314. * Creates a MorphTarget from mesh data
  10315. * @param mesh defines the source mesh
  10316. * @param name defines the name to use for the new target
  10317. * @param influence defines the influence to attach to the target
  10318. * @returns a new MorphTarget
  10319. */
  10320. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10321. }
  10322. }
  10323. declare module BABYLON {
  10324. /**
  10325. * This class is used to deform meshes using morphing between different targets
  10326. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10327. */
  10328. export class MorphTargetManager {
  10329. private _targets;
  10330. private _targetInfluenceChangedObservers;
  10331. private _targetDataLayoutChangedObservers;
  10332. private _activeTargets;
  10333. private _scene;
  10334. private _influences;
  10335. private _supportsNormals;
  10336. private _supportsTangents;
  10337. private _supportsUVs;
  10338. private _vertexCount;
  10339. private _uniqueId;
  10340. private _tempInfluences;
  10341. /**
  10342. * Creates a new MorphTargetManager
  10343. * @param scene defines the current scene
  10344. */
  10345. constructor(scene?: Nullable<Scene>);
  10346. /**
  10347. * Gets the unique ID of this manager
  10348. */
  10349. readonly uniqueId: number;
  10350. /**
  10351. * Gets the number of vertices handled by this manager
  10352. */
  10353. readonly vertexCount: number;
  10354. /**
  10355. * Gets a boolean indicating if this manager supports morphing of normals
  10356. */
  10357. readonly supportsNormals: boolean;
  10358. /**
  10359. * Gets a boolean indicating if this manager supports morphing of tangents
  10360. */
  10361. readonly supportsTangents: boolean;
  10362. /**
  10363. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10364. */
  10365. readonly supportsUVs: boolean;
  10366. /**
  10367. * Gets the number of targets stored in this manager
  10368. */
  10369. readonly numTargets: number;
  10370. /**
  10371. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10372. */
  10373. readonly numInfluencers: number;
  10374. /**
  10375. * Gets the list of influences (one per target)
  10376. */
  10377. readonly influences: Float32Array;
  10378. /**
  10379. * Gets the active target at specified index. An active target is a target with an influence > 0
  10380. * @param index defines the index to check
  10381. * @returns the requested target
  10382. */
  10383. getActiveTarget(index: number): MorphTarget;
  10384. /**
  10385. * Gets the target at specified index
  10386. * @param index defines the index to check
  10387. * @returns the requested target
  10388. */
  10389. getTarget(index: number): MorphTarget;
  10390. /**
  10391. * Add a new target to this manager
  10392. * @param target defines the target to add
  10393. */
  10394. addTarget(target: MorphTarget): void;
  10395. /**
  10396. * Removes a target from the manager
  10397. * @param target defines the target to remove
  10398. */
  10399. removeTarget(target: MorphTarget): void;
  10400. /**
  10401. * Serializes the current manager into a Serialization object
  10402. * @returns the serialized object
  10403. */
  10404. serialize(): any;
  10405. private _syncActiveTargets;
  10406. /**
  10407. * Syncrhonize the targets with all the meshes using this morph target manager
  10408. */
  10409. synchronize(): void;
  10410. /**
  10411. * Creates a new MorphTargetManager from serialized data
  10412. * @param serializationObject defines the serialized data
  10413. * @param scene defines the hosting scene
  10414. * @returns the new MorphTargetManager
  10415. */
  10416. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10417. }
  10418. }
  10419. declare module BABYLON {
  10420. /**
  10421. * Groups all the scene component constants in one place to ease maintenance.
  10422. * @hidden
  10423. */
  10424. export class SceneComponentConstants {
  10425. static readonly NAME_EFFECTLAYER: string;
  10426. static readonly NAME_LAYER: string;
  10427. static readonly NAME_LENSFLARESYSTEM: string;
  10428. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10429. static readonly NAME_PARTICLESYSTEM: string;
  10430. static readonly NAME_GAMEPAD: string;
  10431. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10432. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10433. static readonly NAME_DEPTHRENDERER: string;
  10434. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10435. static readonly NAME_SPRITE: string;
  10436. static readonly NAME_OUTLINERENDERER: string;
  10437. static readonly NAME_PROCEDURALTEXTURE: string;
  10438. static readonly NAME_SHADOWGENERATOR: string;
  10439. static readonly NAME_OCTREE: string;
  10440. static readonly NAME_PHYSICSENGINE: string;
  10441. static readonly NAME_AUDIO: string;
  10442. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10443. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10444. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10445. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10446. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10447. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10448. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10449. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10450. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10451. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10452. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10453. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10454. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10455. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10456. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10457. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10458. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10459. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10461. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10462. static readonly STEP_AFTERRENDER_AUDIO: number;
  10463. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10464. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10465. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10466. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10467. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10468. static readonly STEP_POINTERMOVE_SPRITE: number;
  10469. static readonly STEP_POINTERDOWN_SPRITE: number;
  10470. static readonly STEP_POINTERUP_SPRITE: number;
  10471. }
  10472. /**
  10473. * This represents a scene component.
  10474. *
  10475. * This is used to decouple the dependency the scene is having on the different workloads like
  10476. * layers, post processes...
  10477. */
  10478. export interface ISceneComponent {
  10479. /**
  10480. * The name of the component. Each component must have a unique name.
  10481. */
  10482. name: string;
  10483. /**
  10484. * The scene the component belongs to.
  10485. */
  10486. scene: Scene;
  10487. /**
  10488. * Register the component to one instance of a scene.
  10489. */
  10490. register(): void;
  10491. /**
  10492. * Rebuilds the elements related to this component in case of
  10493. * context lost for instance.
  10494. */
  10495. rebuild(): void;
  10496. /**
  10497. * Disposes the component and the associated ressources.
  10498. */
  10499. dispose(): void;
  10500. }
  10501. /**
  10502. * This represents a SERIALIZABLE scene component.
  10503. *
  10504. * This extends Scene Component to add Serialization methods on top.
  10505. */
  10506. export interface ISceneSerializableComponent extends ISceneComponent {
  10507. /**
  10508. * Adds all the elements from the container to the scene
  10509. * @param container the container holding the elements
  10510. */
  10511. addFromContainer(container: AbstractScene): void;
  10512. /**
  10513. * Removes all the elements in the container from the scene
  10514. * @param container contains the elements to remove
  10515. * @param dispose if the removed element should be disposed (default: false)
  10516. */
  10517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10518. /**
  10519. * Serializes the component data to the specified json object
  10520. * @param serializationObject The object to serialize to
  10521. */
  10522. serialize(serializationObject: any): void;
  10523. }
  10524. /**
  10525. * Strong typing of a Mesh related stage step action
  10526. */
  10527. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10528. /**
  10529. * Strong typing of a Evaluate Sub Mesh related stage step action
  10530. */
  10531. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10532. /**
  10533. * Strong typing of a Active Mesh related stage step action
  10534. */
  10535. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10536. /**
  10537. * Strong typing of a Camera related stage step action
  10538. */
  10539. export type CameraStageAction = (camera: Camera) => void;
  10540. /**
  10541. * Strong typing of a Camera Frame buffer related stage step action
  10542. */
  10543. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10544. /**
  10545. * Strong typing of a Render Target related stage step action
  10546. */
  10547. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10548. /**
  10549. * Strong typing of a RenderingGroup related stage step action
  10550. */
  10551. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10552. /**
  10553. * Strong typing of a Mesh Render related stage step action
  10554. */
  10555. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10556. /**
  10557. * Strong typing of a simple stage step action
  10558. */
  10559. export type SimpleStageAction = () => void;
  10560. /**
  10561. * Strong typing of a render target action.
  10562. */
  10563. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10564. /**
  10565. * Strong typing of a pointer move action.
  10566. */
  10567. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10568. /**
  10569. * Strong typing of a pointer up/down action.
  10570. */
  10571. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10572. /**
  10573. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10574. * @hidden
  10575. */
  10576. export class Stage<T extends Function> extends Array<{
  10577. index: number;
  10578. component: ISceneComponent;
  10579. action: T;
  10580. }> {
  10581. /**
  10582. * Hide ctor from the rest of the world.
  10583. * @param items The items to add.
  10584. */
  10585. private constructor();
  10586. /**
  10587. * Creates a new Stage.
  10588. * @returns A new instance of a Stage
  10589. */
  10590. static Create<T extends Function>(): Stage<T>;
  10591. /**
  10592. * Registers a step in an ordered way in the targeted stage.
  10593. * @param index Defines the position to register the step in
  10594. * @param component Defines the component attached to the step
  10595. * @param action Defines the action to launch during the step
  10596. */
  10597. registerStep(index: number, component: ISceneComponent, action: T): void;
  10598. /**
  10599. * Clears all the steps from the stage.
  10600. */
  10601. clear(): void;
  10602. }
  10603. }
  10604. declare module BABYLON {
  10605. /**
  10606. * Class used to represent a specific level of detail of a mesh
  10607. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10608. */
  10609. export class MeshLODLevel {
  10610. /** Defines the distance where this level should star being displayed */
  10611. distance: number;
  10612. /** Defines the mesh to use to render this level */
  10613. mesh: Nullable<Mesh>;
  10614. /**
  10615. * Creates a new LOD level
  10616. * @param distance defines the distance where this level should star being displayed
  10617. * @param mesh defines the mesh to use to render this level
  10618. */
  10619. constructor(
  10620. /** Defines the distance where this level should star being displayed */
  10621. distance: number,
  10622. /** Defines the mesh to use to render this level */
  10623. mesh: Nullable<Mesh>);
  10624. }
  10625. }
  10626. declare module BABYLON {
  10627. /**
  10628. * Interface describing all the common properties and methods a shadow light needs to implement.
  10629. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10630. * as well as binding the different shadow properties to the effects.
  10631. */
  10632. export interface IShadowLight extends Light {
  10633. /**
  10634. * The light id in the scene (used in scene.findLighById for instance)
  10635. */
  10636. id: string;
  10637. /**
  10638. * The position the shdow will be casted from.
  10639. */
  10640. position: Vector3;
  10641. /**
  10642. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10643. */
  10644. direction: Vector3;
  10645. /**
  10646. * The transformed position. Position of the light in world space taking parenting in account.
  10647. */
  10648. transformedPosition: Vector3;
  10649. /**
  10650. * The transformed direction. Direction of the light in world space taking parenting in account.
  10651. */
  10652. transformedDirection: Vector3;
  10653. /**
  10654. * The friendly name of the light in the scene.
  10655. */
  10656. name: string;
  10657. /**
  10658. * Defines the shadow projection clipping minimum z value.
  10659. */
  10660. shadowMinZ: number;
  10661. /**
  10662. * Defines the shadow projection clipping maximum z value.
  10663. */
  10664. shadowMaxZ: number;
  10665. /**
  10666. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10667. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10668. */
  10669. computeTransformedInformation(): boolean;
  10670. /**
  10671. * Gets the scene the light belongs to.
  10672. * @returns The scene
  10673. */
  10674. getScene(): Scene;
  10675. /**
  10676. * Callback defining a custom Projection Matrix Builder.
  10677. * This can be used to override the default projection matrix computation.
  10678. */
  10679. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10680. /**
  10681. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10682. * @param matrix The materix to updated with the projection information
  10683. * @param viewMatrix The transform matrix of the light
  10684. * @param renderList The list of mesh to render in the map
  10685. * @returns The current light
  10686. */
  10687. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10688. /**
  10689. * Gets the current depth scale used in ESM.
  10690. * @returns The scale
  10691. */
  10692. getDepthScale(): number;
  10693. /**
  10694. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10695. * @returns true if a cube texture needs to be use
  10696. */
  10697. needCube(): boolean;
  10698. /**
  10699. * Detects if the projection matrix requires to be recomputed this frame.
  10700. * @returns true if it requires to be recomputed otherwise, false.
  10701. */
  10702. needProjectionMatrixCompute(): boolean;
  10703. /**
  10704. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10705. */
  10706. forceProjectionMatrixCompute(): void;
  10707. /**
  10708. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10709. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10710. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10711. */
  10712. getShadowDirection(faceIndex?: number): Vector3;
  10713. /**
  10714. * Gets the minZ used for shadow according to both the scene and the light.
  10715. * @param activeCamera The camera we are returning the min for
  10716. * @returns the depth min z
  10717. */
  10718. getDepthMinZ(activeCamera: Camera): number;
  10719. /**
  10720. * Gets the maxZ used for shadow according to both the scene and the light.
  10721. * @param activeCamera The camera we are returning the max for
  10722. * @returns the depth max z
  10723. */
  10724. getDepthMaxZ(activeCamera: Camera): number;
  10725. }
  10726. /**
  10727. * Base implementation IShadowLight
  10728. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10729. */
  10730. export abstract class ShadowLight extends Light implements IShadowLight {
  10731. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10732. protected _position: Vector3;
  10733. protected _setPosition(value: Vector3): void;
  10734. /**
  10735. * Sets the position the shadow will be casted from. Also use as the light position for both
  10736. * point and spot lights.
  10737. */
  10738. /**
  10739. * Sets the position the shadow will be casted from. Also use as the light position for both
  10740. * point and spot lights.
  10741. */
  10742. position: Vector3;
  10743. protected _direction: Vector3;
  10744. protected _setDirection(value: Vector3): void;
  10745. /**
  10746. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10747. * Also use as the light direction on spot and directional lights.
  10748. */
  10749. /**
  10750. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10751. * Also use as the light direction on spot and directional lights.
  10752. */
  10753. direction: Vector3;
  10754. private _shadowMinZ;
  10755. /**
  10756. * Gets the shadow projection clipping minimum z value.
  10757. */
  10758. /**
  10759. * Sets the shadow projection clipping minimum z value.
  10760. */
  10761. shadowMinZ: number;
  10762. private _shadowMaxZ;
  10763. /**
  10764. * Sets the shadow projection clipping maximum z value.
  10765. */
  10766. /**
  10767. * Gets the shadow projection clipping maximum z value.
  10768. */
  10769. shadowMaxZ: number;
  10770. /**
  10771. * Callback defining a custom Projection Matrix Builder.
  10772. * This can be used to override the default projection matrix computation.
  10773. */
  10774. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10775. /**
  10776. * The transformed position. Position of the light in world space taking parenting in account.
  10777. */
  10778. transformedPosition: Vector3;
  10779. /**
  10780. * The transformed direction. Direction of the light in world space taking parenting in account.
  10781. */
  10782. transformedDirection: Vector3;
  10783. private _needProjectionMatrixCompute;
  10784. /**
  10785. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10786. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10787. */
  10788. computeTransformedInformation(): boolean;
  10789. /**
  10790. * Return the depth scale used for the shadow map.
  10791. * @returns the depth scale.
  10792. */
  10793. getDepthScale(): number;
  10794. /**
  10795. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10796. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10797. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10798. */
  10799. getShadowDirection(faceIndex?: number): Vector3;
  10800. /**
  10801. * Returns the ShadowLight absolute position in the World.
  10802. * @returns the position vector in world space
  10803. */
  10804. getAbsolutePosition(): Vector3;
  10805. /**
  10806. * Sets the ShadowLight direction toward the passed target.
  10807. * @param target The point to target in local space
  10808. * @returns the updated ShadowLight direction
  10809. */
  10810. setDirectionToTarget(target: Vector3): Vector3;
  10811. /**
  10812. * Returns the light rotation in euler definition.
  10813. * @returns the x y z rotation in local space.
  10814. */
  10815. getRotation(): Vector3;
  10816. /**
  10817. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10818. * @returns true if a cube texture needs to be use
  10819. */
  10820. needCube(): boolean;
  10821. /**
  10822. * Detects if the projection matrix requires to be recomputed this frame.
  10823. * @returns true if it requires to be recomputed otherwise, false.
  10824. */
  10825. needProjectionMatrixCompute(): boolean;
  10826. /**
  10827. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10828. */
  10829. forceProjectionMatrixCompute(): void;
  10830. /** @hidden */
  10831. _initCache(): void;
  10832. /** @hidden */
  10833. _isSynchronized(): boolean;
  10834. /**
  10835. * Computes the world matrix of the node
  10836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10837. * @returns the world matrix
  10838. */
  10839. computeWorldMatrix(force?: boolean): Matrix;
  10840. /**
  10841. * Gets the minZ used for shadow according to both the scene and the light.
  10842. * @param activeCamera The camera we are returning the min for
  10843. * @returns the depth min z
  10844. */
  10845. getDepthMinZ(activeCamera: Camera): number;
  10846. /**
  10847. * Gets the maxZ used for shadow according to both the scene and the light.
  10848. * @param activeCamera The camera we are returning the max for
  10849. * @returns the depth max z
  10850. */
  10851. getDepthMaxZ(activeCamera: Camera): number;
  10852. /**
  10853. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10854. * @param matrix The materix to updated with the projection information
  10855. * @param viewMatrix The transform matrix of the light
  10856. * @param renderList The list of mesh to render in the map
  10857. * @returns The current light
  10858. */
  10859. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10860. }
  10861. }
  10862. declare module BABYLON {
  10863. /**
  10864. * "Static Class" containing the most commonly used helper while dealing with material for
  10865. * rendering purpose.
  10866. *
  10867. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10868. *
  10869. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10870. */
  10871. export class MaterialHelper {
  10872. /**
  10873. * Bind the current view position to an effect.
  10874. * @param effect The effect to be bound
  10875. * @param scene The scene the eyes position is used from
  10876. */
  10877. static BindEyePosition(effect: Effect, scene: Scene): void;
  10878. /**
  10879. * Helps preparing the defines values about the UVs in used in the effect.
  10880. * UVs are shared as much as we can accross channels in the shaders.
  10881. * @param texture The texture we are preparing the UVs for
  10882. * @param defines The defines to update
  10883. * @param key The channel key "diffuse", "specular"... used in the shader
  10884. */
  10885. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10886. /**
  10887. * Binds a texture matrix value to its corrsponding uniform
  10888. * @param texture The texture to bind the matrix for
  10889. * @param uniformBuffer The uniform buffer receivin the data
  10890. * @param key The channel key "diffuse", "specular"... used in the shader
  10891. */
  10892. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10893. /**
  10894. * Gets the current status of the fog (should it be enabled?)
  10895. * @param mesh defines the mesh to evaluate for fog support
  10896. * @param scene defines the hosting scene
  10897. * @returns true if fog must be enabled
  10898. */
  10899. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10900. /**
  10901. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10902. * @param mesh defines the current mesh
  10903. * @param scene defines the current scene
  10904. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10905. * @param pointsCloud defines if point cloud rendering has to be turned on
  10906. * @param fogEnabled defines if fog has to be turned on
  10907. * @param alphaTest defines if alpha testing has to be turned on
  10908. * @param defines defines the current list of defines
  10909. */
  10910. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10911. /**
  10912. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10913. * @param scene defines the current scene
  10914. * @param engine defines the current engine
  10915. * @param defines specifies the list of active defines
  10916. * @param useInstances defines if instances have to be turned on
  10917. * @param useClipPlane defines if clip plane have to be turned on
  10918. */
  10919. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10920. /**
  10921. * Prepares the defines for bones
  10922. * @param mesh The mesh containing the geometry data we will draw
  10923. * @param defines The defines to update
  10924. */
  10925. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10926. /**
  10927. * Prepares the defines for morph targets
  10928. * @param mesh The mesh containing the geometry data we will draw
  10929. * @param defines The defines to update
  10930. */
  10931. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10932. /**
  10933. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10934. * @param mesh The mesh containing the geometry data we will draw
  10935. * @param defines The defines to update
  10936. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10937. * @param useBones Precise whether bones should be used or not (override mesh info)
  10938. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10939. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10940. * @returns false if defines are considered not dirty and have not been checked
  10941. */
  10942. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10943. /**
  10944. * Prepares the defines related to multiview
  10945. * @param scene The scene we are intending to draw
  10946. * @param defines The defines to update
  10947. */
  10948. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10949. /**
  10950. * Prepares the defines related to the light information passed in parameter
  10951. * @param scene The scene we are intending to draw
  10952. * @param mesh The mesh the effect is compiling for
  10953. * @param light The light the effect is compiling for
  10954. * @param lightIndex The index of the light
  10955. * @param defines The defines to update
  10956. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10957. * @param state Defines the current state regarding what is needed (normals, etc...)
  10958. */
  10959. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10960. needNormals: boolean;
  10961. needRebuild: boolean;
  10962. shadowEnabled: boolean;
  10963. specularEnabled: boolean;
  10964. lightmapMode: boolean;
  10965. }): void;
  10966. /**
  10967. * Prepares the defines related to the light information passed in parameter
  10968. * @param scene The scene we are intending to draw
  10969. * @param mesh The mesh the effect is compiling for
  10970. * @param defines The defines to update
  10971. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10972. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10973. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10974. * @returns true if normals will be required for the rest of the effect
  10975. */
  10976. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10977. /**
  10978. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10979. * @param lightIndex defines the light index
  10980. * @param uniformsList The uniform list
  10981. * @param samplersList The sampler list
  10982. * @param projectedLightTexture defines if projected texture must be used
  10983. * @param uniformBuffersList defines an optional list of uniform buffers
  10984. */
  10985. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  10986. /**
  10987. * Prepares the uniforms and samplers list to be used in the effect
  10988. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10989. * @param samplersList The sampler list
  10990. * @param defines The defines helping in the list generation
  10991. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10992. */
  10993. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10994. /**
  10995. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10996. * @param defines The defines to update while falling back
  10997. * @param fallbacks The authorized effect fallbacks
  10998. * @param maxSimultaneousLights The maximum number of lights allowed
  10999. * @param rank the current rank of the Effect
  11000. * @returns The newly affected rank
  11001. */
  11002. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11003. private static _TmpMorphInfluencers;
  11004. /**
  11005. * Prepares the list of attributes required for morph targets according to the effect defines.
  11006. * @param attribs The current list of supported attribs
  11007. * @param mesh The mesh to prepare the morph targets attributes for
  11008. * @param influencers The number of influencers
  11009. */
  11010. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11011. /**
  11012. * Prepares the list of attributes required for morph targets according to the effect defines.
  11013. * @param attribs The current list of supported attribs
  11014. * @param mesh The mesh to prepare the morph targets attributes for
  11015. * @param defines The current Defines of the effect
  11016. */
  11017. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11018. /**
  11019. * Prepares the list of attributes required for bones according to the effect defines.
  11020. * @param attribs The current list of supported attribs
  11021. * @param mesh The mesh to prepare the bones attributes for
  11022. * @param defines The current Defines of the effect
  11023. * @param fallbacks The current efffect fallback strategy
  11024. */
  11025. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11026. /**
  11027. * Check and prepare the list of attributes required for instances according to the effect defines.
  11028. * @param attribs The current list of supported attribs
  11029. * @param defines The current MaterialDefines of the effect
  11030. */
  11031. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11032. /**
  11033. * Add the list of attributes required for instances to the attribs array.
  11034. * @param attribs The current list of supported attribs
  11035. */
  11036. static PushAttributesForInstances(attribs: string[]): void;
  11037. /**
  11038. * Binds the light shadow information to the effect for the given mesh.
  11039. * @param light The light containing the generator
  11040. * @param scene The scene the lights belongs to
  11041. * @param mesh The mesh we are binding the information to render
  11042. * @param lightIndex The light index in the effect used to render the mesh
  11043. * @param effect The effect we are binding the data to
  11044. */
  11045. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11046. /**
  11047. * Binds the light information to the effect.
  11048. * @param light The light containing the generator
  11049. * @param effect The effect we are binding the data to
  11050. * @param lightIndex The light index in the effect used to render
  11051. */
  11052. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11053. /**
  11054. * Binds the lights information from the scene to the effect for the given mesh.
  11055. * @param light Light to bind
  11056. * @param lightIndex Light index
  11057. * @param scene The scene where the light belongs to
  11058. * @param mesh The mesh we are binding the information to render
  11059. * @param effect The effect we are binding the data to
  11060. * @param useSpecular Defines if specular is supported
  11061. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11062. */
  11063. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11064. /**
  11065. * Binds the lights information from the scene to the effect for the given mesh.
  11066. * @param scene The scene the lights belongs to
  11067. * @param mesh The mesh we are binding the information to render
  11068. * @param effect The effect we are binding the data to
  11069. * @param defines The generated defines for the effect
  11070. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11071. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11072. */
  11073. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11074. private static _tempFogColor;
  11075. /**
  11076. * Binds the fog information from the scene to the effect for the given mesh.
  11077. * @param scene The scene the lights belongs to
  11078. * @param mesh The mesh we are binding the information to render
  11079. * @param effect The effect we are binding the data to
  11080. * @param linearSpace Defines if the fog effect is applied in linear space
  11081. */
  11082. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11083. /**
  11084. * Binds the bones information from the mesh to the effect.
  11085. * @param mesh The mesh we are binding the information to render
  11086. * @param effect The effect we are binding the data to
  11087. */
  11088. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11089. /**
  11090. * Binds the morph targets information from the mesh to the effect.
  11091. * @param abstractMesh The mesh we are binding the information to render
  11092. * @param effect The effect we are binding the data to
  11093. */
  11094. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11095. /**
  11096. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11097. * @param defines The generated defines used in the effect
  11098. * @param effect The effect we are binding the data to
  11099. * @param scene The scene we are willing to render with logarithmic scale for
  11100. */
  11101. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11102. /**
  11103. * Binds the clip plane information from the scene to the effect.
  11104. * @param scene The scene the clip plane information are extracted from
  11105. * @param effect The effect we are binding the data to
  11106. */
  11107. static BindClipPlane(effect: Effect, scene: Scene): void;
  11108. }
  11109. }
  11110. declare module BABYLON {
  11111. /** @hidden */
  11112. export var shadowMapPixelShader: {
  11113. name: string;
  11114. shader: string;
  11115. };
  11116. }
  11117. declare module BABYLON {
  11118. /** @hidden */
  11119. export var bonesDeclaration: {
  11120. name: string;
  11121. shader: string;
  11122. };
  11123. }
  11124. declare module BABYLON {
  11125. /** @hidden */
  11126. export var morphTargetsVertexGlobalDeclaration: {
  11127. name: string;
  11128. shader: string;
  11129. };
  11130. }
  11131. declare module BABYLON {
  11132. /** @hidden */
  11133. export var morphTargetsVertexDeclaration: {
  11134. name: string;
  11135. shader: string;
  11136. };
  11137. }
  11138. declare module BABYLON {
  11139. /** @hidden */
  11140. export var instancesDeclaration: {
  11141. name: string;
  11142. shader: string;
  11143. };
  11144. }
  11145. declare module BABYLON {
  11146. /** @hidden */
  11147. export var helperFunctions: {
  11148. name: string;
  11149. shader: string;
  11150. };
  11151. }
  11152. declare module BABYLON {
  11153. /** @hidden */
  11154. export var morphTargetsVertex: {
  11155. name: string;
  11156. shader: string;
  11157. };
  11158. }
  11159. declare module BABYLON {
  11160. /** @hidden */
  11161. export var instancesVertex: {
  11162. name: string;
  11163. shader: string;
  11164. };
  11165. }
  11166. declare module BABYLON {
  11167. /** @hidden */
  11168. export var bonesVertex: {
  11169. name: string;
  11170. shader: string;
  11171. };
  11172. }
  11173. declare module BABYLON {
  11174. /** @hidden */
  11175. export var shadowMapVertexShader: {
  11176. name: string;
  11177. shader: string;
  11178. };
  11179. }
  11180. declare module BABYLON {
  11181. /** @hidden */
  11182. export var depthBoxBlurPixelShader: {
  11183. name: string;
  11184. shader: string;
  11185. };
  11186. }
  11187. declare module BABYLON {
  11188. /**
  11189. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11190. */
  11191. export interface ICustomShaderOptions {
  11192. /**
  11193. * Gets or sets the custom shader name to use
  11194. */
  11195. shaderName: string;
  11196. /**
  11197. * The list of attribute names used in the shader
  11198. */
  11199. attributes?: string[];
  11200. /**
  11201. * The list of unifrom names used in the shader
  11202. */
  11203. uniforms?: string[];
  11204. /**
  11205. * The list of sampler names used in the shader
  11206. */
  11207. samplers?: string[];
  11208. /**
  11209. * The list of defines used in the shader
  11210. */
  11211. defines?: string[];
  11212. }
  11213. /**
  11214. * Interface to implement to create a shadow generator compatible with BJS.
  11215. */
  11216. export interface IShadowGenerator {
  11217. /**
  11218. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11219. * @returns The render target texture if present otherwise, null
  11220. */
  11221. getShadowMap(): Nullable<RenderTargetTexture>;
  11222. /**
  11223. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11224. * @returns The render target texture if the shadow map is present otherwise, null
  11225. */
  11226. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11227. /**
  11228. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11229. * @param subMesh The submesh we want to render in the shadow map
  11230. * @param useInstances Defines wether will draw in the map using instances
  11231. * @returns true if ready otherwise, false
  11232. */
  11233. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11234. /**
  11235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11236. * @param defines Defines of the material we want to update
  11237. * @param lightIndex Index of the light in the enabled light list of the material
  11238. */
  11239. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11240. /**
  11241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11242. * defined in the generator but impacting the effect).
  11243. * It implies the unifroms available on the materials are the standard BJS ones.
  11244. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11245. * @param effect The effect we are binfing the information for
  11246. */
  11247. bindShadowLight(lightIndex: string, effect: Effect): void;
  11248. /**
  11249. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11250. * (eq to shadow prjection matrix * light transform matrix)
  11251. * @returns The transform matrix used to create the shadow map
  11252. */
  11253. getTransformMatrix(): Matrix;
  11254. /**
  11255. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11256. * Cube and 2D textures for instance.
  11257. */
  11258. recreateShadowMap(): void;
  11259. /**
  11260. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11261. * @param onCompiled Callback triggered at the and of the effects compilation
  11262. * @param options Sets of optional options forcing the compilation with different modes
  11263. */
  11264. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11265. useInstances: boolean;
  11266. }>): void;
  11267. /**
  11268. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11269. * @param options Sets of optional options forcing the compilation with different modes
  11270. * @returns A promise that resolves when the compilation completes
  11271. */
  11272. forceCompilationAsync(options?: Partial<{
  11273. useInstances: boolean;
  11274. }>): Promise<void>;
  11275. /**
  11276. * Serializes the shadow generator setup to a json object.
  11277. * @returns The serialized JSON object
  11278. */
  11279. serialize(): any;
  11280. /**
  11281. * Disposes the Shadow map and related Textures and effects.
  11282. */
  11283. dispose(): void;
  11284. }
  11285. /**
  11286. * Default implementation IShadowGenerator.
  11287. * This is the main object responsible of generating shadows in the framework.
  11288. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11289. */
  11290. export class ShadowGenerator implements IShadowGenerator {
  11291. /**
  11292. * Shadow generator mode None: no filtering applied.
  11293. */
  11294. static readonly FILTER_NONE: number;
  11295. /**
  11296. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11297. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11298. */
  11299. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11300. /**
  11301. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11302. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11303. */
  11304. static readonly FILTER_POISSONSAMPLING: number;
  11305. /**
  11306. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11307. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11308. */
  11309. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11310. /**
  11311. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11312. * edge artifacts on steep falloff.
  11313. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11314. */
  11315. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11316. /**
  11317. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11318. * edge artifacts on steep falloff.
  11319. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11320. */
  11321. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11322. /**
  11323. * Shadow generator mode PCF: Percentage Closer Filtering
  11324. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11325. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11326. */
  11327. static readonly FILTER_PCF: number;
  11328. /**
  11329. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11330. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11331. * Contact Hardening
  11332. */
  11333. static readonly FILTER_PCSS: number;
  11334. /**
  11335. * Reserved for PCF and PCSS
  11336. * Highest Quality.
  11337. *
  11338. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11339. *
  11340. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11341. */
  11342. static readonly QUALITY_HIGH: number;
  11343. /**
  11344. * Reserved for PCF and PCSS
  11345. * Good tradeoff for quality/perf cross devices
  11346. *
  11347. * Execute PCF on a 3*3 kernel.
  11348. *
  11349. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11350. */
  11351. static readonly QUALITY_MEDIUM: number;
  11352. /**
  11353. * Reserved for PCF and PCSS
  11354. * The lowest quality but the fastest.
  11355. *
  11356. * Execute PCF on a 1*1 kernel.
  11357. *
  11358. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11359. */
  11360. static readonly QUALITY_LOW: number;
  11361. /** Gets or sets the custom shader name to use */
  11362. customShaderOptions: ICustomShaderOptions;
  11363. /**
  11364. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11365. */
  11366. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11367. /**
  11368. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11369. */
  11370. onAfterShadowMapRenderObservable: Observable<Effect>;
  11371. /**
  11372. * Observable triggered before a mesh is rendered in the shadow map.
  11373. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11374. */
  11375. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11376. /**
  11377. * Observable triggered after a mesh is rendered in the shadow map.
  11378. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11379. */
  11380. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11381. private _bias;
  11382. /**
  11383. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11384. */
  11385. /**
  11386. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11387. */
  11388. bias: number;
  11389. private _normalBias;
  11390. /**
  11391. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11392. */
  11393. /**
  11394. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11395. */
  11396. normalBias: number;
  11397. private _blurBoxOffset;
  11398. /**
  11399. * Gets the blur box offset: offset applied during the blur pass.
  11400. * Only useful if useKernelBlur = false
  11401. */
  11402. /**
  11403. * Sets the blur box offset: offset applied during the blur pass.
  11404. * Only useful if useKernelBlur = false
  11405. */
  11406. blurBoxOffset: number;
  11407. private _blurScale;
  11408. /**
  11409. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11410. * 2 means half of the size.
  11411. */
  11412. /**
  11413. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11414. * 2 means half of the size.
  11415. */
  11416. blurScale: number;
  11417. private _blurKernel;
  11418. /**
  11419. * Gets the blur kernel: kernel size of the blur pass.
  11420. * Only useful if useKernelBlur = true
  11421. */
  11422. /**
  11423. * Sets the blur kernel: kernel size of the blur pass.
  11424. * Only useful if useKernelBlur = true
  11425. */
  11426. blurKernel: number;
  11427. private _useKernelBlur;
  11428. /**
  11429. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11430. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11431. */
  11432. /**
  11433. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11435. */
  11436. useKernelBlur: boolean;
  11437. private _depthScale;
  11438. /**
  11439. * Gets the depth scale used in ESM mode.
  11440. */
  11441. /**
  11442. * Sets the depth scale used in ESM mode.
  11443. * This can override the scale stored on the light.
  11444. */
  11445. depthScale: number;
  11446. private _filter;
  11447. /**
  11448. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11449. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11450. */
  11451. /**
  11452. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11453. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11454. */
  11455. filter: number;
  11456. /**
  11457. * Gets if the current filter is set to Poisson Sampling.
  11458. */
  11459. /**
  11460. * Sets the current filter to Poisson Sampling.
  11461. */
  11462. usePoissonSampling: boolean;
  11463. /**
  11464. * Gets if the current filter is set to ESM.
  11465. */
  11466. /**
  11467. * Sets the current filter is to ESM.
  11468. */
  11469. useExponentialShadowMap: boolean;
  11470. /**
  11471. * Gets if the current filter is set to filtered ESM.
  11472. */
  11473. /**
  11474. * Gets if the current filter is set to filtered ESM.
  11475. */
  11476. useBlurExponentialShadowMap: boolean;
  11477. /**
  11478. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11479. * exponential to prevent steep falloff artifacts).
  11480. */
  11481. /**
  11482. * Sets the current filter to "close ESM" (using the inverse of the
  11483. * exponential to prevent steep falloff artifacts).
  11484. */
  11485. useCloseExponentialShadowMap: boolean;
  11486. /**
  11487. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11488. * exponential to prevent steep falloff artifacts).
  11489. */
  11490. /**
  11491. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11492. * exponential to prevent steep falloff artifacts).
  11493. */
  11494. useBlurCloseExponentialShadowMap: boolean;
  11495. /**
  11496. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11497. */
  11498. /**
  11499. * Sets the current filter to "PCF" (percentage closer filtering).
  11500. */
  11501. usePercentageCloserFiltering: boolean;
  11502. private _filteringQuality;
  11503. /**
  11504. * Gets the PCF or PCSS Quality.
  11505. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11506. */
  11507. /**
  11508. * Sets the PCF or PCSS Quality.
  11509. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11510. */
  11511. filteringQuality: number;
  11512. /**
  11513. * Gets if the current filter is set to "PCSS" (contact hardening).
  11514. */
  11515. /**
  11516. * Sets the current filter to "PCSS" (contact hardening).
  11517. */
  11518. useContactHardeningShadow: boolean;
  11519. private _contactHardeningLightSizeUVRatio;
  11520. /**
  11521. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11522. * Using a ratio helps keeping shape stability independently of the map size.
  11523. *
  11524. * It does not account for the light projection as it was having too much
  11525. * instability during the light setup or during light position changes.
  11526. *
  11527. * Only valid if useContactHardeningShadow is true.
  11528. */
  11529. /**
  11530. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11531. * Using a ratio helps keeping shape stability independently of the map size.
  11532. *
  11533. * It does not account for the light projection as it was having too much
  11534. * instability during the light setup or during light position changes.
  11535. *
  11536. * Only valid if useContactHardeningShadow is true.
  11537. */
  11538. contactHardeningLightSizeUVRatio: number;
  11539. private _darkness;
  11540. /** Gets or sets the actual darkness of a shadow */
  11541. darkness: number;
  11542. /**
  11543. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11544. * 0 means strongest and 1 would means no shadow.
  11545. * @returns the darkness.
  11546. */
  11547. getDarkness(): number;
  11548. /**
  11549. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11550. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11551. * @returns the shadow generator allowing fluent coding.
  11552. */
  11553. setDarkness(darkness: number): ShadowGenerator;
  11554. private _transparencyShadow;
  11555. /** Gets or sets the ability to have transparent shadow */
  11556. transparencyShadow: boolean;
  11557. /**
  11558. * Sets the ability to have transparent shadow (boolean).
  11559. * @param transparent True if transparent else False
  11560. * @returns the shadow generator allowing fluent coding
  11561. */
  11562. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11563. private _shadowMap;
  11564. private _shadowMap2;
  11565. /**
  11566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11567. * @returns The render target texture if present otherwise, null
  11568. */
  11569. getShadowMap(): Nullable<RenderTargetTexture>;
  11570. /**
  11571. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11572. * @returns The render target texture if the shadow map is present otherwise, null
  11573. */
  11574. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11575. /**
  11576. * Gets the class name of that object
  11577. * @returns "ShadowGenerator"
  11578. */
  11579. getClassName(): string;
  11580. /**
  11581. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11582. * @param mesh Mesh to add
  11583. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11584. * @returns the Shadow Generator itself
  11585. */
  11586. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11587. /**
  11588. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11589. * @param mesh Mesh to remove
  11590. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11591. * @returns the Shadow Generator itself
  11592. */
  11593. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11594. /**
  11595. * Controls the extent to which the shadows fade out at the edge of the frustum
  11596. * Used only by directionals and spots
  11597. */
  11598. frustumEdgeFalloff: number;
  11599. private _light;
  11600. /**
  11601. * Returns the associated light object.
  11602. * @returns the light generating the shadow
  11603. */
  11604. getLight(): IShadowLight;
  11605. /**
  11606. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11607. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11608. * It might on the other hand introduce peter panning.
  11609. */
  11610. forceBackFacesOnly: boolean;
  11611. private _scene;
  11612. private _lightDirection;
  11613. private _effect;
  11614. private _viewMatrix;
  11615. private _projectionMatrix;
  11616. private _transformMatrix;
  11617. private _cachedPosition;
  11618. private _cachedDirection;
  11619. private _cachedDefines;
  11620. private _currentRenderID;
  11621. private _boxBlurPostprocess;
  11622. private _kernelBlurXPostprocess;
  11623. private _kernelBlurYPostprocess;
  11624. private _blurPostProcesses;
  11625. private _mapSize;
  11626. private _currentFaceIndex;
  11627. private _currentFaceIndexCache;
  11628. private _textureType;
  11629. private _defaultTextureMatrix;
  11630. /** @hidden */
  11631. static _SceneComponentInitialization: (scene: Scene) => void;
  11632. /**
  11633. * Creates a ShadowGenerator object.
  11634. * A ShadowGenerator is the required tool to use the shadows.
  11635. * Each light casting shadows needs to use its own ShadowGenerator.
  11636. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11637. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11638. * @param light The light object generating the shadows.
  11639. * @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.
  11640. */
  11641. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11642. private _initializeGenerator;
  11643. private _initializeShadowMap;
  11644. private _initializeBlurRTTAndPostProcesses;
  11645. private _renderForShadowMap;
  11646. private _renderSubMeshForShadowMap;
  11647. private _applyFilterValues;
  11648. /**
  11649. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11650. * @param onCompiled Callback triggered at the and of the effects compilation
  11651. * @param options Sets of optional options forcing the compilation with different modes
  11652. */
  11653. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11654. useInstances: boolean;
  11655. }>): void;
  11656. /**
  11657. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11658. * @param options Sets of optional options forcing the compilation with different modes
  11659. * @returns A promise that resolves when the compilation completes
  11660. */
  11661. forceCompilationAsync(options?: Partial<{
  11662. useInstances: boolean;
  11663. }>): Promise<void>;
  11664. /**
  11665. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11666. * @param subMesh The submesh we want to render in the shadow map
  11667. * @param useInstances Defines wether will draw in the map using instances
  11668. * @returns true if ready otherwise, false
  11669. */
  11670. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11671. /**
  11672. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11673. * @param defines Defines of the material we want to update
  11674. * @param lightIndex Index of the light in the enabled light list of the material
  11675. */
  11676. prepareDefines(defines: any, lightIndex: number): void;
  11677. /**
  11678. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11679. * defined in the generator but impacting the effect).
  11680. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11681. * @param effect The effect we are binfing the information for
  11682. */
  11683. bindShadowLight(lightIndex: string, effect: Effect): void;
  11684. /**
  11685. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11686. * (eq to shadow prjection matrix * light transform matrix)
  11687. * @returns The transform matrix used to create the shadow map
  11688. */
  11689. getTransformMatrix(): Matrix;
  11690. /**
  11691. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11692. * Cube and 2D textures for instance.
  11693. */
  11694. recreateShadowMap(): void;
  11695. private _disposeBlurPostProcesses;
  11696. private _disposeRTTandPostProcesses;
  11697. /**
  11698. * Disposes the ShadowGenerator.
  11699. * Returns nothing.
  11700. */
  11701. dispose(): void;
  11702. /**
  11703. * Serializes the shadow generator setup to a json object.
  11704. * @returns The serialized JSON object
  11705. */
  11706. serialize(): any;
  11707. /**
  11708. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11709. * @param parsedShadowGenerator The JSON object to parse
  11710. * @param scene The scene to create the shadow map for
  11711. * @returns The parsed shadow generator
  11712. */
  11713. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11714. }
  11715. }
  11716. declare module BABYLON {
  11717. /**
  11718. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11719. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11720. * 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.
  11721. */
  11722. export abstract class Light extends Node {
  11723. /**
  11724. * Falloff Default: light is falling off following the material specification:
  11725. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11726. */
  11727. static readonly FALLOFF_DEFAULT: number;
  11728. /**
  11729. * Falloff Physical: light is falling off following the inverse squared distance law.
  11730. */
  11731. static readonly FALLOFF_PHYSICAL: number;
  11732. /**
  11733. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11734. * to enhance interoperability with other engines.
  11735. */
  11736. static readonly FALLOFF_GLTF: number;
  11737. /**
  11738. * Falloff Standard: light is falling off like in the standard material
  11739. * to enhance interoperability with other materials.
  11740. */
  11741. static readonly FALLOFF_STANDARD: number;
  11742. /**
  11743. * If every light affecting the material is in this lightmapMode,
  11744. * material.lightmapTexture adds or multiplies
  11745. * (depends on material.useLightmapAsShadowmap)
  11746. * after every other light calculations.
  11747. */
  11748. static readonly LIGHTMAP_DEFAULT: number;
  11749. /**
  11750. * material.lightmapTexture as only diffuse lighting from this light
  11751. * adds only specular lighting from this light
  11752. * adds dynamic shadows
  11753. */
  11754. static readonly LIGHTMAP_SPECULAR: number;
  11755. /**
  11756. * material.lightmapTexture as only lighting
  11757. * no light calculation from this light
  11758. * only adds dynamic shadows from this light
  11759. */
  11760. static readonly LIGHTMAP_SHADOWSONLY: number;
  11761. /**
  11762. * Each light type uses the default quantity according to its type:
  11763. * point/spot lights use luminous intensity
  11764. * directional lights use illuminance
  11765. */
  11766. static readonly INTENSITYMODE_AUTOMATIC: number;
  11767. /**
  11768. * lumen (lm)
  11769. */
  11770. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11771. /**
  11772. * candela (lm/sr)
  11773. */
  11774. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11775. /**
  11776. * lux (lm/m^2)
  11777. */
  11778. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11779. /**
  11780. * nit (cd/m^2)
  11781. */
  11782. static readonly INTENSITYMODE_LUMINANCE: number;
  11783. /**
  11784. * Light type const id of the point light.
  11785. */
  11786. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11787. /**
  11788. * Light type const id of the directional light.
  11789. */
  11790. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11791. /**
  11792. * Light type const id of the spot light.
  11793. */
  11794. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11795. /**
  11796. * Light type const id of the hemispheric light.
  11797. */
  11798. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11799. /**
  11800. * Diffuse gives the basic color to an object.
  11801. */
  11802. diffuse: Color3;
  11803. /**
  11804. * Specular produces a highlight color on an object.
  11805. * Note: This is note affecting PBR materials.
  11806. */
  11807. specular: Color3;
  11808. /**
  11809. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11810. * falling off base on range or angle.
  11811. * This can be set to any values in Light.FALLOFF_x.
  11812. *
  11813. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11814. * other types of materials.
  11815. */
  11816. falloffType: number;
  11817. /**
  11818. * Strength of the light.
  11819. * Note: By default it is define in the framework own unit.
  11820. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11821. */
  11822. intensity: number;
  11823. private _range;
  11824. protected _inverseSquaredRange: number;
  11825. /**
  11826. * Defines how far from the source the light is impacting in scene units.
  11827. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11828. */
  11829. /**
  11830. * Defines how far from the source the light is impacting in scene units.
  11831. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11832. */
  11833. range: number;
  11834. /**
  11835. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11836. * of light.
  11837. */
  11838. private _photometricScale;
  11839. private _intensityMode;
  11840. /**
  11841. * Gets the photometric scale used to interpret the intensity.
  11842. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11843. */
  11844. /**
  11845. * Sets the photometric scale used to interpret the intensity.
  11846. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11847. */
  11848. intensityMode: number;
  11849. private _radius;
  11850. /**
  11851. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11852. */
  11853. /**
  11854. * sets the light radius used by PBR Materials to simulate soft area lights.
  11855. */
  11856. radius: number;
  11857. private _renderPriority;
  11858. /**
  11859. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11860. * exceeding the number allowed of the materials.
  11861. */
  11862. renderPriority: number;
  11863. private _shadowEnabled;
  11864. /**
  11865. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11866. * the current shadow generator.
  11867. */
  11868. /**
  11869. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11870. * the current shadow generator.
  11871. */
  11872. shadowEnabled: boolean;
  11873. private _includedOnlyMeshes;
  11874. /**
  11875. * Gets the only meshes impacted by this light.
  11876. */
  11877. /**
  11878. * Sets the only meshes impacted by this light.
  11879. */
  11880. includedOnlyMeshes: AbstractMesh[];
  11881. private _excludedMeshes;
  11882. /**
  11883. * Gets the meshes not impacted by this light.
  11884. */
  11885. /**
  11886. * Sets the meshes not impacted by this light.
  11887. */
  11888. excludedMeshes: AbstractMesh[];
  11889. private _excludeWithLayerMask;
  11890. /**
  11891. * Gets the layer id use to find what meshes are not impacted by the light.
  11892. * Inactive if 0
  11893. */
  11894. /**
  11895. * Sets the layer id use to find what meshes are not impacted by the light.
  11896. * Inactive if 0
  11897. */
  11898. excludeWithLayerMask: number;
  11899. private _includeOnlyWithLayerMask;
  11900. /**
  11901. * Gets the layer id use to find what meshes are impacted by the light.
  11902. * Inactive if 0
  11903. */
  11904. /**
  11905. * Sets the layer id use to find what meshes are impacted by the light.
  11906. * Inactive if 0
  11907. */
  11908. includeOnlyWithLayerMask: number;
  11909. private _lightmapMode;
  11910. /**
  11911. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11912. */
  11913. /**
  11914. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11915. */
  11916. lightmapMode: number;
  11917. /**
  11918. * Shadow generator associted to the light.
  11919. * @hidden Internal use only.
  11920. */
  11921. _shadowGenerator: Nullable<IShadowGenerator>;
  11922. /**
  11923. * @hidden Internal use only.
  11924. */
  11925. _excludedMeshesIds: string[];
  11926. /**
  11927. * @hidden Internal use only.
  11928. */
  11929. _includedOnlyMeshesIds: string[];
  11930. /**
  11931. * The current light unifom buffer.
  11932. * @hidden Internal use only.
  11933. */
  11934. _uniformBuffer: UniformBuffer;
  11935. /**
  11936. * Creates a Light object in the scene.
  11937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11938. * @param name The firendly name of the light
  11939. * @param scene The scene the light belongs too
  11940. */
  11941. constructor(name: string, scene: Scene);
  11942. protected abstract _buildUniformLayout(): void;
  11943. /**
  11944. * Sets the passed Effect "effect" with the Light information.
  11945. * @param effect The effect to update
  11946. * @param lightIndex The index of the light in the effect to update
  11947. * @returns The light
  11948. */
  11949. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11950. /**
  11951. * Returns the string "Light".
  11952. * @returns the class name
  11953. */
  11954. getClassName(): string;
  11955. /** @hidden */
  11956. readonly _isLight: boolean;
  11957. /**
  11958. * Converts the light information to a readable string for debug purpose.
  11959. * @param fullDetails Supports for multiple levels of logging within scene loading
  11960. * @returns the human readable light info
  11961. */
  11962. toString(fullDetails?: boolean): string;
  11963. /** @hidden */
  11964. protected _syncParentEnabledState(): void;
  11965. /**
  11966. * Set the enabled state of this node.
  11967. * @param value - the new enabled state
  11968. */
  11969. setEnabled(value: boolean): void;
  11970. /**
  11971. * Returns the Light associated shadow generator if any.
  11972. * @return the associated shadow generator.
  11973. */
  11974. getShadowGenerator(): Nullable<IShadowGenerator>;
  11975. /**
  11976. * Returns a Vector3, the absolute light position in the World.
  11977. * @returns the world space position of the light
  11978. */
  11979. getAbsolutePosition(): Vector3;
  11980. /**
  11981. * Specifies if the light will affect the passed mesh.
  11982. * @param mesh The mesh to test against the light
  11983. * @return true the mesh is affected otherwise, false.
  11984. */
  11985. canAffectMesh(mesh: AbstractMesh): boolean;
  11986. /**
  11987. * Sort function to order lights for rendering.
  11988. * @param a First Light object to compare to second.
  11989. * @param b Second Light object to compare first.
  11990. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11991. */
  11992. static CompareLightsPriority(a: Light, b: Light): number;
  11993. /**
  11994. * Releases resources associated with this node.
  11995. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11996. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11997. */
  11998. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11999. /**
  12000. * Returns the light type ID (integer).
  12001. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12002. */
  12003. getTypeID(): number;
  12004. /**
  12005. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12006. * @returns the scaled intensity in intensity mode unit
  12007. */
  12008. getScaledIntensity(): number;
  12009. /**
  12010. * Returns a new Light object, named "name", from the current one.
  12011. * @param name The name of the cloned light
  12012. * @returns the new created light
  12013. */
  12014. clone(name: string): Nullable<Light>;
  12015. /**
  12016. * Serializes the current light into a Serialization object.
  12017. * @returns the serialized object.
  12018. */
  12019. serialize(): any;
  12020. /**
  12021. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12022. * This new light is named "name" and added to the passed scene.
  12023. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12024. * @param name The friendly name of the light
  12025. * @param scene The scene the new light will belong to
  12026. * @returns the constructor function
  12027. */
  12028. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12029. /**
  12030. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12031. * @param parsedLight The JSON representation of the light
  12032. * @param scene The scene to create the parsed light in
  12033. * @returns the created light after parsing
  12034. */
  12035. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12036. private _hookArrayForExcluded;
  12037. private _hookArrayForIncludedOnly;
  12038. private _resyncMeshes;
  12039. /**
  12040. * Forces the meshes to update their light related information in their rendering used effects
  12041. * @hidden Internal Use Only
  12042. */
  12043. _markMeshesAsLightDirty(): void;
  12044. /**
  12045. * Recomputes the cached photometric scale if needed.
  12046. */
  12047. private _computePhotometricScale;
  12048. /**
  12049. * Returns the Photometric Scale according to the light type and intensity mode.
  12050. */
  12051. private _getPhotometricScale;
  12052. /**
  12053. * Reorder the light in the scene according to their defined priority.
  12054. * @hidden Internal Use Only
  12055. */
  12056. _reorderLightsInScene(): void;
  12057. /**
  12058. * Prepares the list of defines specific to the light type.
  12059. * @param defines the list of defines
  12060. * @param lightIndex defines the index of the light for the effect
  12061. */
  12062. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12063. }
  12064. }
  12065. declare module BABYLON {
  12066. /**
  12067. * Creates an instance based on a source mesh.
  12068. */
  12069. export class InstancedMesh extends AbstractMesh {
  12070. private _sourceMesh;
  12071. private _currentLOD;
  12072. /** @hidden */
  12073. _indexInSourceMeshInstanceArray: number;
  12074. constructor(name: string, source: Mesh);
  12075. /**
  12076. * Returns the string "InstancedMesh".
  12077. */
  12078. getClassName(): string;
  12079. /** Gets the list of lights affecting that mesh */
  12080. readonly lightSources: Light[];
  12081. _resyncLightSources(): void;
  12082. _resyncLighSource(light: Light): void;
  12083. _removeLightSource(light: Light): void;
  12084. /**
  12085. * If the source mesh receives shadows
  12086. */
  12087. readonly receiveShadows: boolean;
  12088. /**
  12089. * The material of the source mesh
  12090. */
  12091. readonly material: Nullable<Material>;
  12092. /**
  12093. * Visibility of the source mesh
  12094. */
  12095. readonly visibility: number;
  12096. /**
  12097. * Skeleton of the source mesh
  12098. */
  12099. readonly skeleton: Nullable<Skeleton>;
  12100. /**
  12101. * Rendering ground id of the source mesh
  12102. */
  12103. renderingGroupId: number;
  12104. /**
  12105. * Returns the total number of vertices (integer).
  12106. */
  12107. getTotalVertices(): number;
  12108. /**
  12109. * Returns a positive integer : the total number of indices in this mesh geometry.
  12110. * @returns the numner of indices or zero if the mesh has no geometry.
  12111. */
  12112. getTotalIndices(): number;
  12113. /**
  12114. * The source mesh of the instance
  12115. */
  12116. readonly sourceMesh: Mesh;
  12117. /**
  12118. * Is this node ready to be used/rendered
  12119. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12120. * @return {boolean} is it ready
  12121. */
  12122. isReady(completeCheck?: boolean): boolean;
  12123. /**
  12124. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12125. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12126. * @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.
  12127. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12128. */
  12129. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12130. /**
  12131. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12132. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12133. * The `data` are either a numeric array either a Float32Array.
  12134. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12135. * 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).
  12136. * Note that a new underlying VertexBuffer object is created each call.
  12137. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12138. *
  12139. * Possible `kind` values :
  12140. * - VertexBuffer.PositionKind
  12141. * - VertexBuffer.UVKind
  12142. * - VertexBuffer.UV2Kind
  12143. * - VertexBuffer.UV3Kind
  12144. * - VertexBuffer.UV4Kind
  12145. * - VertexBuffer.UV5Kind
  12146. * - VertexBuffer.UV6Kind
  12147. * - VertexBuffer.ColorKind
  12148. * - VertexBuffer.MatricesIndicesKind
  12149. * - VertexBuffer.MatricesIndicesExtraKind
  12150. * - VertexBuffer.MatricesWeightsKind
  12151. * - VertexBuffer.MatricesWeightsExtraKind
  12152. *
  12153. * Returns the Mesh.
  12154. */
  12155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12156. /**
  12157. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12158. * If the mesh has no geometry, it is simply returned as it is.
  12159. * The `data` are either a numeric array either a Float32Array.
  12160. * No new underlying VertexBuffer object is created.
  12161. * 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.
  12162. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12163. *
  12164. * Possible `kind` values :
  12165. * - VertexBuffer.PositionKind
  12166. * - VertexBuffer.UVKind
  12167. * - VertexBuffer.UV2Kind
  12168. * - VertexBuffer.UV3Kind
  12169. * - VertexBuffer.UV4Kind
  12170. * - VertexBuffer.UV5Kind
  12171. * - VertexBuffer.UV6Kind
  12172. * - VertexBuffer.ColorKind
  12173. * - VertexBuffer.MatricesIndicesKind
  12174. * - VertexBuffer.MatricesIndicesExtraKind
  12175. * - VertexBuffer.MatricesWeightsKind
  12176. * - VertexBuffer.MatricesWeightsExtraKind
  12177. *
  12178. * Returns the Mesh.
  12179. */
  12180. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12181. /**
  12182. * Sets the mesh indices.
  12183. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12184. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12185. * This method creates a new index buffer each call.
  12186. * Returns the Mesh.
  12187. */
  12188. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12189. /**
  12190. * Boolean : True if the mesh owns the requested kind of data.
  12191. */
  12192. isVerticesDataPresent(kind: string): boolean;
  12193. /**
  12194. * Returns an array of indices (IndicesArray).
  12195. */
  12196. getIndices(): Nullable<IndicesArray>;
  12197. readonly _positions: Nullable<Vector3[]>;
  12198. /**
  12199. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12200. * This means the mesh underlying bounding box and sphere are recomputed.
  12201. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12202. * @returns the current mesh
  12203. */
  12204. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12205. /** @hidden */
  12206. _preActivate(): InstancedMesh;
  12207. /** @hidden */
  12208. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12209. /** @hidden */
  12210. _postActivate(): void;
  12211. getWorldMatrix(): Matrix;
  12212. readonly isAnInstance: boolean;
  12213. /**
  12214. * Returns the current associated LOD AbstractMesh.
  12215. */
  12216. getLOD(camera: Camera): AbstractMesh;
  12217. /** @hidden */
  12218. _syncSubMeshes(): InstancedMesh;
  12219. /** @hidden */
  12220. _generatePointsArray(): boolean;
  12221. /**
  12222. * Creates a new InstancedMesh from the current mesh.
  12223. * - name (string) : the cloned mesh name
  12224. * - newParent (optional Node) : the optional Node to parent the clone to.
  12225. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12226. *
  12227. * Returns the clone.
  12228. */
  12229. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12230. /**
  12231. * Disposes the InstancedMesh.
  12232. * Returns nothing.
  12233. */
  12234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * Defines the options associated with the creation of a shader material.
  12240. */
  12241. export interface IShaderMaterialOptions {
  12242. /**
  12243. * Does the material work in alpha blend mode
  12244. */
  12245. needAlphaBlending: boolean;
  12246. /**
  12247. * Does the material work in alpha test mode
  12248. */
  12249. needAlphaTesting: boolean;
  12250. /**
  12251. * The list of attribute names used in the shader
  12252. */
  12253. attributes: string[];
  12254. /**
  12255. * The list of unifrom names used in the shader
  12256. */
  12257. uniforms: string[];
  12258. /**
  12259. * The list of UBO names used in the shader
  12260. */
  12261. uniformBuffers: string[];
  12262. /**
  12263. * The list of sampler names used in the shader
  12264. */
  12265. samplers: string[];
  12266. /**
  12267. * The list of defines used in the shader
  12268. */
  12269. defines: string[];
  12270. }
  12271. /**
  12272. * 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.
  12273. *
  12274. * This returned material effects how the mesh will look based on the code in the shaders.
  12275. *
  12276. * @see http://doc.babylonjs.com/how_to/shader_material
  12277. */
  12278. export class ShaderMaterial extends Material {
  12279. private _shaderPath;
  12280. private _options;
  12281. private _textures;
  12282. private _textureArrays;
  12283. private _floats;
  12284. private _ints;
  12285. private _floatsArrays;
  12286. private _colors3;
  12287. private _colors3Arrays;
  12288. private _colors4;
  12289. private _colors4Arrays;
  12290. private _vectors2;
  12291. private _vectors3;
  12292. private _vectors4;
  12293. private _matrices;
  12294. private _matrices3x3;
  12295. private _matrices2x2;
  12296. private _vectors2Arrays;
  12297. private _vectors3Arrays;
  12298. private _vectors4Arrays;
  12299. private _cachedWorldViewMatrix;
  12300. private _cachedWorldViewProjectionMatrix;
  12301. private _renderId;
  12302. /**
  12303. * Instantiate a new shader material.
  12304. * 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.
  12305. * This returned material effects how the mesh will look based on the code in the shaders.
  12306. * @see http://doc.babylonjs.com/how_to/shader_material
  12307. * @param name Define the name of the material in the scene
  12308. * @param scene Define the scene the material belongs to
  12309. * @param shaderPath Defines the route to the shader code in one of three ways:
  12310. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12311. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12312. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12313. * @param options Define the options used to create the shader
  12314. */
  12315. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12316. /**
  12317. * Gets the options used to compile the shader.
  12318. * They can be modified to trigger a new compilation
  12319. */
  12320. readonly options: IShaderMaterialOptions;
  12321. /**
  12322. * Gets the current class name of the material e.g. "ShaderMaterial"
  12323. * Mainly use in serialization.
  12324. * @returns the class name
  12325. */
  12326. getClassName(): string;
  12327. /**
  12328. * Specifies if the material will require alpha blending
  12329. * @returns a boolean specifying if alpha blending is needed
  12330. */
  12331. needAlphaBlending(): boolean;
  12332. /**
  12333. * Specifies if this material should be rendered in alpha test mode
  12334. * @returns a boolean specifying if an alpha test is needed.
  12335. */
  12336. needAlphaTesting(): boolean;
  12337. private _checkUniform;
  12338. /**
  12339. * Set a texture in the shader.
  12340. * @param name Define the name of the uniform samplers as defined in the shader
  12341. * @param texture Define the texture to bind to this sampler
  12342. * @return the material itself allowing "fluent" like uniform updates
  12343. */
  12344. setTexture(name: string, texture: Texture): ShaderMaterial;
  12345. /**
  12346. * Set a texture array in the shader.
  12347. * @param name Define the name of the uniform sampler array as defined in the shader
  12348. * @param textures Define the list of textures to bind to this sampler
  12349. * @return the material itself allowing "fluent" like uniform updates
  12350. */
  12351. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12352. /**
  12353. * Set a float in the shader.
  12354. * @param name Define the name of the uniform as defined in the shader
  12355. * @param value Define the value to give to the uniform
  12356. * @return the material itself allowing "fluent" like uniform updates
  12357. */
  12358. setFloat(name: string, value: number): ShaderMaterial;
  12359. /**
  12360. * Set a int in the shader.
  12361. * @param name Define the name of the uniform as defined in the shader
  12362. * @param value Define the value to give to the uniform
  12363. * @return the material itself allowing "fluent" like uniform updates
  12364. */
  12365. setInt(name: string, value: number): ShaderMaterial;
  12366. /**
  12367. * Set an array of floats in the shader.
  12368. * @param name Define the name of the uniform as defined in the shader
  12369. * @param value Define the value to give to the uniform
  12370. * @return the material itself allowing "fluent" like uniform updates
  12371. */
  12372. setFloats(name: string, value: number[]): ShaderMaterial;
  12373. /**
  12374. * Set a vec3 in the shader from a Color3.
  12375. * @param name Define the name of the uniform as defined in the shader
  12376. * @param value Define the value to give to the uniform
  12377. * @return the material itself allowing "fluent" like uniform updates
  12378. */
  12379. setColor3(name: string, value: Color3): ShaderMaterial;
  12380. /**
  12381. * Set a vec3 array in the shader from a Color3 array.
  12382. * @param name Define the name of the uniform as defined in the shader
  12383. * @param value Define the value to give to the uniform
  12384. * @return the material itself allowing "fluent" like uniform updates
  12385. */
  12386. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12387. /**
  12388. * Set a vec4 in the shader from a Color4.
  12389. * @param name Define the name of the uniform as defined in the shader
  12390. * @param value Define the value to give to the uniform
  12391. * @return the material itself allowing "fluent" like uniform updates
  12392. */
  12393. setColor4(name: string, value: Color4): ShaderMaterial;
  12394. /**
  12395. * Set a vec4 array in the shader from a Color4 array.
  12396. * @param name Define the name of the uniform as defined in the shader
  12397. * @param value Define the value to give to the uniform
  12398. * @return the material itself allowing "fluent" like uniform updates
  12399. */
  12400. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12401. /**
  12402. * Set a vec2 in the shader from a Vector2.
  12403. * @param name Define the name of the uniform as defined in the shader
  12404. * @param value Define the value to give to the uniform
  12405. * @return the material itself allowing "fluent" like uniform updates
  12406. */
  12407. setVector2(name: string, value: Vector2): ShaderMaterial;
  12408. /**
  12409. * Set a vec3 in the shader from a Vector3.
  12410. * @param name Define the name of the uniform as defined in the shader
  12411. * @param value Define the value to give to the uniform
  12412. * @return the material itself allowing "fluent" like uniform updates
  12413. */
  12414. setVector3(name: string, value: Vector3): ShaderMaterial;
  12415. /**
  12416. * Set a vec4 in the shader from a Vector4.
  12417. * @param name Define the name of the uniform as defined in the shader
  12418. * @param value Define the value to give to the uniform
  12419. * @return the material itself allowing "fluent" like uniform updates
  12420. */
  12421. setVector4(name: string, value: Vector4): ShaderMaterial;
  12422. /**
  12423. * Set a mat4 in the shader from a Matrix.
  12424. * @param name Define the name of the uniform as defined in the shader
  12425. * @param value Define the value to give to the uniform
  12426. * @return the material itself allowing "fluent" like uniform updates
  12427. */
  12428. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12429. /**
  12430. * Set a mat3 in the shader from a Float32Array.
  12431. * @param name Define the name of the uniform as defined in the shader
  12432. * @param value Define the value to give to the uniform
  12433. * @return the material itself allowing "fluent" like uniform updates
  12434. */
  12435. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12436. /**
  12437. * Set a mat2 in the shader from a Float32Array.
  12438. * @param name Define the name of the uniform as defined in the shader
  12439. * @param value Define the value to give to the uniform
  12440. * @return the material itself allowing "fluent" like uniform updates
  12441. */
  12442. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12443. /**
  12444. * Set a vec2 array in the shader from a number array.
  12445. * @param name Define the name of the uniform as defined in the shader
  12446. * @param value Define the value to give to the uniform
  12447. * @return the material itself allowing "fluent" like uniform updates
  12448. */
  12449. setArray2(name: string, value: number[]): ShaderMaterial;
  12450. /**
  12451. * Set a vec3 array in the shader from a number array.
  12452. * @param name Define the name of the uniform as defined in the shader
  12453. * @param value Define the value to give to the uniform
  12454. * @return the material itself allowing "fluent" like uniform updates
  12455. */
  12456. setArray3(name: string, value: number[]): ShaderMaterial;
  12457. /**
  12458. * Set a vec4 array in the shader from a number array.
  12459. * @param name Define the name of the uniform as defined in the shader
  12460. * @param value Define the value to give to the uniform
  12461. * @return the material itself allowing "fluent" like uniform updates
  12462. */
  12463. setArray4(name: string, value: number[]): ShaderMaterial;
  12464. private _checkCache;
  12465. /**
  12466. * Specifies that the submesh is ready to be used
  12467. * @param mesh defines the mesh to check
  12468. * @param subMesh defines which submesh to check
  12469. * @param useInstances specifies that instances should be used
  12470. * @returns a boolean indicating that the submesh is ready or not
  12471. */
  12472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12473. /**
  12474. * Checks if the material is ready to render the requested mesh
  12475. * @param mesh Define the mesh to render
  12476. * @param useInstances Define whether or not the material is used with instances
  12477. * @returns true if ready, otherwise false
  12478. */
  12479. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12480. /**
  12481. * Binds the world matrix to the material
  12482. * @param world defines the world transformation matrix
  12483. */
  12484. bindOnlyWorldMatrix(world: Matrix): void;
  12485. /**
  12486. * Binds the material to the mesh
  12487. * @param world defines the world transformation matrix
  12488. * @param mesh defines the mesh to bind the material to
  12489. */
  12490. bind(world: Matrix, mesh?: Mesh): void;
  12491. /**
  12492. * Gets the active textures from the material
  12493. * @returns an array of textures
  12494. */
  12495. getActiveTextures(): BaseTexture[];
  12496. /**
  12497. * Specifies if the material uses a texture
  12498. * @param texture defines the texture to check against the material
  12499. * @returns a boolean specifying if the material uses the texture
  12500. */
  12501. hasTexture(texture: BaseTexture): boolean;
  12502. /**
  12503. * Makes a duplicate of the material, and gives it a new name
  12504. * @param name defines the new name for the duplicated material
  12505. * @returns the cloned material
  12506. */
  12507. clone(name: string): ShaderMaterial;
  12508. /**
  12509. * Disposes the material
  12510. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12511. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12512. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12513. */
  12514. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12515. /**
  12516. * Serializes this material in a JSON representation
  12517. * @returns the serialized material object
  12518. */
  12519. serialize(): any;
  12520. /**
  12521. * Creates a shader material from parsed shader material data
  12522. * @param source defines the JSON represnetation of the material
  12523. * @param scene defines the hosting scene
  12524. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12525. * @returns a new material
  12526. */
  12527. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12528. }
  12529. }
  12530. declare module BABYLON {
  12531. /** @hidden */
  12532. export var clipPlaneFragmentDeclaration: {
  12533. name: string;
  12534. shader: string;
  12535. };
  12536. }
  12537. declare module BABYLON {
  12538. /** @hidden */
  12539. export var clipPlaneFragment: {
  12540. name: string;
  12541. shader: string;
  12542. };
  12543. }
  12544. declare module BABYLON {
  12545. /** @hidden */
  12546. export var colorPixelShader: {
  12547. name: string;
  12548. shader: string;
  12549. };
  12550. }
  12551. declare module BABYLON {
  12552. /** @hidden */
  12553. export var clipPlaneVertexDeclaration: {
  12554. name: string;
  12555. shader: string;
  12556. };
  12557. }
  12558. declare module BABYLON {
  12559. /** @hidden */
  12560. export var clipPlaneVertex: {
  12561. name: string;
  12562. shader: string;
  12563. };
  12564. }
  12565. declare module BABYLON {
  12566. /** @hidden */
  12567. export var colorVertexShader: {
  12568. name: string;
  12569. shader: string;
  12570. };
  12571. }
  12572. declare module BABYLON {
  12573. /**
  12574. * Line mesh
  12575. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12576. */
  12577. export class LinesMesh extends Mesh {
  12578. /**
  12579. * If vertex color should be applied to the mesh
  12580. */
  12581. readonly useVertexColor?: boolean | undefined;
  12582. /**
  12583. * If vertex alpha should be applied to the mesh
  12584. */
  12585. readonly useVertexAlpha?: boolean | undefined;
  12586. /**
  12587. * Color of the line (Default: White)
  12588. */
  12589. color: Color3;
  12590. /**
  12591. * Alpha of the line (Default: 1)
  12592. */
  12593. alpha: number;
  12594. /**
  12595. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12596. * This margin is expressed in world space coordinates, so its value may vary.
  12597. * Default value is 0.1
  12598. */
  12599. intersectionThreshold: number;
  12600. private _colorShader;
  12601. private color4;
  12602. /**
  12603. * Creates a new LinesMesh
  12604. * @param name defines the name
  12605. * @param scene defines the hosting scene
  12606. * @param parent defines the parent mesh if any
  12607. * @param source defines the optional source LinesMesh used to clone data from
  12608. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12609. * When false, achieved by calling a clone(), also passing False.
  12610. * This will make creation of children, recursive.
  12611. * @param useVertexColor defines if this LinesMesh supports vertex color
  12612. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12613. */
  12614. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12615. /**
  12616. * If vertex color should be applied to the mesh
  12617. */
  12618. useVertexColor?: boolean | undefined,
  12619. /**
  12620. * If vertex alpha should be applied to the mesh
  12621. */
  12622. useVertexAlpha?: boolean | undefined);
  12623. private _addClipPlaneDefine;
  12624. private _removeClipPlaneDefine;
  12625. isReady(): boolean;
  12626. /**
  12627. * Returns the string "LineMesh"
  12628. */
  12629. getClassName(): string;
  12630. /**
  12631. * @hidden
  12632. */
  12633. /**
  12634. * @hidden
  12635. */
  12636. material: Material;
  12637. /**
  12638. * @hidden
  12639. */
  12640. readonly checkCollisions: boolean;
  12641. /** @hidden */
  12642. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12643. /** @hidden */
  12644. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12645. /**
  12646. * Disposes of the line mesh
  12647. * @param doNotRecurse If children should be disposed
  12648. */
  12649. dispose(doNotRecurse?: boolean): void;
  12650. /**
  12651. * Returns a new LineMesh object cloned from the current one.
  12652. */
  12653. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12654. /**
  12655. * Creates a new InstancedLinesMesh object from the mesh model.
  12656. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12657. * @param name defines the name of the new instance
  12658. * @returns a new InstancedLinesMesh
  12659. */
  12660. createInstance(name: string): InstancedLinesMesh;
  12661. }
  12662. /**
  12663. * Creates an instance based on a source LinesMesh
  12664. */
  12665. export class InstancedLinesMesh extends InstancedMesh {
  12666. /**
  12667. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12668. * This margin is expressed in world space coordinates, so its value may vary.
  12669. * Initilized with the intersectionThreshold value of the source LinesMesh
  12670. */
  12671. intersectionThreshold: number;
  12672. constructor(name: string, source: LinesMesh);
  12673. /**
  12674. * Returns the string "InstancedLinesMesh".
  12675. */
  12676. getClassName(): string;
  12677. }
  12678. }
  12679. declare module BABYLON {
  12680. /**
  12681. * Mesh representing the gorund
  12682. */
  12683. export class GroundMesh extends Mesh {
  12684. /** If octree should be generated */
  12685. generateOctree: boolean;
  12686. private _heightQuads;
  12687. /** @hidden */
  12688. _subdivisionsX: number;
  12689. /** @hidden */
  12690. _subdivisionsY: number;
  12691. /** @hidden */
  12692. _width: number;
  12693. /** @hidden */
  12694. _height: number;
  12695. /** @hidden */
  12696. _minX: number;
  12697. /** @hidden */
  12698. _maxX: number;
  12699. /** @hidden */
  12700. _minZ: number;
  12701. /** @hidden */
  12702. _maxZ: number;
  12703. constructor(name: string, scene: Scene);
  12704. /**
  12705. * "GroundMesh"
  12706. * @returns "GroundMesh"
  12707. */
  12708. getClassName(): string;
  12709. /**
  12710. * The minimum of x and y subdivisions
  12711. */
  12712. readonly subdivisions: number;
  12713. /**
  12714. * X subdivisions
  12715. */
  12716. readonly subdivisionsX: number;
  12717. /**
  12718. * Y subdivisions
  12719. */
  12720. readonly subdivisionsY: number;
  12721. /**
  12722. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12723. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12724. * @param chunksCount the number of subdivisions for x and y
  12725. * @param octreeBlocksSize (Default: 32)
  12726. */
  12727. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12728. /**
  12729. * Returns a height (y) value in the Worl system :
  12730. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12731. * @param x x coordinate
  12732. * @param z z coordinate
  12733. * @returns the ground y position if (x, z) are outside the ground surface.
  12734. */
  12735. getHeightAtCoordinates(x: number, z: number): number;
  12736. /**
  12737. * Returns a normalized vector (Vector3) orthogonal to the ground
  12738. * at the ground coordinates (x, z) expressed in the World system.
  12739. * @param x x coordinate
  12740. * @param z z coordinate
  12741. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12742. */
  12743. getNormalAtCoordinates(x: number, z: number): Vector3;
  12744. /**
  12745. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12746. * at the ground coordinates (x, z) expressed in the World system.
  12747. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12748. * @param x x coordinate
  12749. * @param z z coordinate
  12750. * @param ref vector to store the result
  12751. * @returns the GroundMesh.
  12752. */
  12753. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12754. /**
  12755. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12756. * if the ground has been updated.
  12757. * This can be used in the render loop.
  12758. * @returns the GroundMesh.
  12759. */
  12760. updateCoordinateHeights(): GroundMesh;
  12761. private _getFacetAt;
  12762. private _initHeightQuads;
  12763. private _computeHeightQuads;
  12764. /**
  12765. * Serializes this ground mesh
  12766. * @param serializationObject object to write serialization to
  12767. */
  12768. serialize(serializationObject: any): void;
  12769. /**
  12770. * Parses a serialized ground mesh
  12771. * @param parsedMesh the serialized mesh
  12772. * @param scene the scene to create the ground mesh in
  12773. * @returns the created ground mesh
  12774. */
  12775. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12776. }
  12777. }
  12778. declare module BABYLON {
  12779. /**
  12780. * Interface for Physics-Joint data
  12781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12782. */
  12783. export interface PhysicsJointData {
  12784. /**
  12785. * The main pivot of the joint
  12786. */
  12787. mainPivot?: Vector3;
  12788. /**
  12789. * The connected pivot of the joint
  12790. */
  12791. connectedPivot?: Vector3;
  12792. /**
  12793. * The main axis of the joint
  12794. */
  12795. mainAxis?: Vector3;
  12796. /**
  12797. * The connected axis of the joint
  12798. */
  12799. connectedAxis?: Vector3;
  12800. /**
  12801. * The collision of the joint
  12802. */
  12803. collision?: boolean;
  12804. /**
  12805. * Native Oimo/Cannon/Energy data
  12806. */
  12807. nativeParams?: any;
  12808. }
  12809. /**
  12810. * This is a holder class for the physics joint created by the physics plugin
  12811. * It holds a set of functions to control the underlying joint
  12812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12813. */
  12814. export class PhysicsJoint {
  12815. /**
  12816. * The type of the physics joint
  12817. */
  12818. type: number;
  12819. /**
  12820. * The data for the physics joint
  12821. */
  12822. jointData: PhysicsJointData;
  12823. private _physicsJoint;
  12824. protected _physicsPlugin: IPhysicsEnginePlugin;
  12825. /**
  12826. * Initializes the physics joint
  12827. * @param type The type of the physics joint
  12828. * @param jointData The data for the physics joint
  12829. */
  12830. constructor(
  12831. /**
  12832. * The type of the physics joint
  12833. */
  12834. type: number,
  12835. /**
  12836. * The data for the physics joint
  12837. */
  12838. jointData: PhysicsJointData);
  12839. /**
  12840. * Gets the physics joint
  12841. */
  12842. /**
  12843. * Sets the physics joint
  12844. */
  12845. physicsJoint: any;
  12846. /**
  12847. * Sets the physics plugin
  12848. */
  12849. physicsPlugin: IPhysicsEnginePlugin;
  12850. /**
  12851. * Execute a function that is physics-plugin specific.
  12852. * @param {Function} func the function that will be executed.
  12853. * It accepts two parameters: the physics world and the physics joint
  12854. */
  12855. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12856. /**
  12857. * Distance-Joint type
  12858. */
  12859. static DistanceJoint: number;
  12860. /**
  12861. * Hinge-Joint type
  12862. */
  12863. static HingeJoint: number;
  12864. /**
  12865. * Ball-and-Socket joint type
  12866. */
  12867. static BallAndSocketJoint: number;
  12868. /**
  12869. * Wheel-Joint type
  12870. */
  12871. static WheelJoint: number;
  12872. /**
  12873. * Slider-Joint type
  12874. */
  12875. static SliderJoint: number;
  12876. /**
  12877. * Prismatic-Joint type
  12878. */
  12879. static PrismaticJoint: number;
  12880. /**
  12881. * Universal-Joint type
  12882. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12883. */
  12884. static UniversalJoint: number;
  12885. /**
  12886. * Hinge-Joint 2 type
  12887. */
  12888. static Hinge2Joint: number;
  12889. /**
  12890. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12891. */
  12892. static PointToPointJoint: number;
  12893. /**
  12894. * Spring-Joint type
  12895. */
  12896. static SpringJoint: number;
  12897. /**
  12898. * Lock-Joint type
  12899. */
  12900. static LockJoint: number;
  12901. }
  12902. /**
  12903. * A class representing a physics distance joint
  12904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12905. */
  12906. export class DistanceJoint extends PhysicsJoint {
  12907. /**
  12908. *
  12909. * @param jointData The data for the Distance-Joint
  12910. */
  12911. constructor(jointData: DistanceJointData);
  12912. /**
  12913. * Update the predefined distance.
  12914. * @param maxDistance The maximum preferred distance
  12915. * @param minDistance The minimum preferred distance
  12916. */
  12917. updateDistance(maxDistance: number, minDistance?: number): void;
  12918. }
  12919. /**
  12920. * Represents a Motor-Enabled Joint
  12921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12922. */
  12923. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12924. /**
  12925. * Initializes the Motor-Enabled Joint
  12926. * @param type The type of the joint
  12927. * @param jointData The physica joint data for the joint
  12928. */
  12929. constructor(type: number, jointData: PhysicsJointData);
  12930. /**
  12931. * Set the motor values.
  12932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12933. * @param force the force to apply
  12934. * @param maxForce max force for this motor.
  12935. */
  12936. setMotor(force?: number, maxForce?: number): void;
  12937. /**
  12938. * Set the motor's limits.
  12939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12940. * @param upperLimit The upper limit of the motor
  12941. * @param lowerLimit The lower limit of the motor
  12942. */
  12943. setLimit(upperLimit: number, lowerLimit?: number): void;
  12944. }
  12945. /**
  12946. * This class represents a single physics Hinge-Joint
  12947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12948. */
  12949. export class HingeJoint extends MotorEnabledJoint {
  12950. /**
  12951. * Initializes the Hinge-Joint
  12952. * @param jointData The joint data for the Hinge-Joint
  12953. */
  12954. constructor(jointData: PhysicsJointData);
  12955. /**
  12956. * Set the motor values.
  12957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12958. * @param {number} force the force to apply
  12959. * @param {number} maxForce max force for this motor.
  12960. */
  12961. setMotor(force?: number, maxForce?: number): void;
  12962. /**
  12963. * Set the motor's limits.
  12964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12965. * @param upperLimit The upper limit of the motor
  12966. * @param lowerLimit The lower limit of the motor
  12967. */
  12968. setLimit(upperLimit: number, lowerLimit?: number): void;
  12969. }
  12970. /**
  12971. * This class represents a dual hinge physics joint (same as wheel joint)
  12972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12973. */
  12974. export class Hinge2Joint extends MotorEnabledJoint {
  12975. /**
  12976. * Initializes the Hinge2-Joint
  12977. * @param jointData The joint data for the Hinge2-Joint
  12978. */
  12979. constructor(jointData: PhysicsJointData);
  12980. /**
  12981. * Set the motor values.
  12982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12983. * @param {number} targetSpeed the speed the motor is to reach
  12984. * @param {number} maxForce max force for this motor.
  12985. * @param {motorIndex} the motor's index, 0 or 1.
  12986. */
  12987. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  12988. /**
  12989. * Set the motor limits.
  12990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12991. * @param {number} upperLimit the upper limit
  12992. * @param {number} lowerLimit lower limit
  12993. * @param {motorIndex} the motor's index, 0 or 1.
  12994. */
  12995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  12996. }
  12997. /**
  12998. * Interface for a motor enabled joint
  12999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13000. */
  13001. export interface IMotorEnabledJoint {
  13002. /**
  13003. * Physics joint
  13004. */
  13005. physicsJoint: any;
  13006. /**
  13007. * Sets the motor of the motor-enabled joint
  13008. * @param force The force of the motor
  13009. * @param maxForce The maximum force of the motor
  13010. * @param motorIndex The index of the motor
  13011. */
  13012. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13013. /**
  13014. * Sets the limit of the motor
  13015. * @param upperLimit The upper limit of the motor
  13016. * @param lowerLimit The lower limit of the motor
  13017. * @param motorIndex The index of the motor
  13018. */
  13019. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13020. }
  13021. /**
  13022. * Joint data for a Distance-Joint
  13023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13024. */
  13025. export interface DistanceJointData extends PhysicsJointData {
  13026. /**
  13027. * Max distance the 2 joint objects can be apart
  13028. */
  13029. maxDistance: number;
  13030. }
  13031. /**
  13032. * Joint data from a spring joint
  13033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13034. */
  13035. export interface SpringJointData extends PhysicsJointData {
  13036. /**
  13037. * Length of the spring
  13038. */
  13039. length: number;
  13040. /**
  13041. * Stiffness of the spring
  13042. */
  13043. stiffness: number;
  13044. /**
  13045. * Damping of the spring
  13046. */
  13047. damping: number;
  13048. /** this callback will be called when applying the force to the impostors. */
  13049. forceApplicationCallback: () => void;
  13050. }
  13051. }
  13052. declare module BABYLON {
  13053. /**
  13054. * Holds the data for the raycast result
  13055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13056. */
  13057. export class PhysicsRaycastResult {
  13058. private _hasHit;
  13059. private _hitDistance;
  13060. private _hitNormalWorld;
  13061. private _hitPointWorld;
  13062. private _rayFromWorld;
  13063. private _rayToWorld;
  13064. /**
  13065. * Gets if there was a hit
  13066. */
  13067. readonly hasHit: boolean;
  13068. /**
  13069. * Gets the distance from the hit
  13070. */
  13071. readonly hitDistance: number;
  13072. /**
  13073. * Gets the hit normal/direction in the world
  13074. */
  13075. readonly hitNormalWorld: Vector3;
  13076. /**
  13077. * Gets the hit point in the world
  13078. */
  13079. readonly hitPointWorld: Vector3;
  13080. /**
  13081. * Gets the ray "start point" of the ray in the world
  13082. */
  13083. readonly rayFromWorld: Vector3;
  13084. /**
  13085. * Gets the ray "end point" of the ray in the world
  13086. */
  13087. readonly rayToWorld: Vector3;
  13088. /**
  13089. * Sets the hit data (normal & point in world space)
  13090. * @param hitNormalWorld defines the normal in world space
  13091. * @param hitPointWorld defines the point in world space
  13092. */
  13093. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13094. /**
  13095. * Sets the distance from the start point to the hit point
  13096. * @param distance
  13097. */
  13098. setHitDistance(distance: number): void;
  13099. /**
  13100. * Calculates the distance manually
  13101. */
  13102. calculateHitDistance(): void;
  13103. /**
  13104. * Resets all the values to default
  13105. * @param from The from point on world space
  13106. * @param to The to point on world space
  13107. */
  13108. reset(from?: Vector3, to?: Vector3): void;
  13109. }
  13110. /**
  13111. * Interface for the size containing width and height
  13112. */
  13113. interface IXYZ {
  13114. /**
  13115. * X
  13116. */
  13117. x: number;
  13118. /**
  13119. * Y
  13120. */
  13121. y: number;
  13122. /**
  13123. * Z
  13124. */
  13125. z: number;
  13126. }
  13127. }
  13128. declare module BABYLON {
  13129. /**
  13130. * Interface used to describe a physics joint
  13131. */
  13132. export interface PhysicsImpostorJoint {
  13133. /** Defines the main impostor to which the joint is linked */
  13134. mainImpostor: PhysicsImpostor;
  13135. /** Defines the impostor that is connected to the main impostor using this joint */
  13136. connectedImpostor: PhysicsImpostor;
  13137. /** Defines the joint itself */
  13138. joint: PhysicsJoint;
  13139. }
  13140. /** @hidden */
  13141. export interface IPhysicsEnginePlugin {
  13142. world: any;
  13143. name: string;
  13144. setGravity(gravity: Vector3): void;
  13145. setTimeStep(timeStep: number): void;
  13146. getTimeStep(): number;
  13147. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13148. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13149. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13150. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13151. removePhysicsBody(impostor: PhysicsImpostor): void;
  13152. generateJoint(joint: PhysicsImpostorJoint): void;
  13153. removeJoint(joint: PhysicsImpostorJoint): void;
  13154. isSupported(): boolean;
  13155. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13156. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13158. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13159. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13160. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13161. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13162. getBodyMass(impostor: PhysicsImpostor): number;
  13163. getBodyFriction(impostor: PhysicsImpostor): number;
  13164. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13165. getBodyRestitution(impostor: PhysicsImpostor): number;
  13166. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13167. getBodyPressure?(impostor: PhysicsImpostor): number;
  13168. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13169. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13170. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13171. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13172. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13173. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13174. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13175. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13176. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13177. sleepBody(impostor: PhysicsImpostor): void;
  13178. wakeUpBody(impostor: PhysicsImpostor): void;
  13179. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13180. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13181. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13182. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13183. getRadius(impostor: PhysicsImpostor): number;
  13184. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13185. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13186. dispose(): void;
  13187. }
  13188. /**
  13189. * Interface used to define a physics engine
  13190. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13191. */
  13192. export interface IPhysicsEngine {
  13193. /**
  13194. * Gets the gravity vector used by the simulation
  13195. */
  13196. gravity: Vector3;
  13197. /**
  13198. * Sets the gravity vector used by the simulation
  13199. * @param gravity defines the gravity vector to use
  13200. */
  13201. setGravity(gravity: Vector3): void;
  13202. /**
  13203. * Set the time step of the physics engine.
  13204. * Default is 1/60.
  13205. * To slow it down, enter 1/600 for example.
  13206. * To speed it up, 1/30
  13207. * @param newTimeStep the new timestep to apply to this world.
  13208. */
  13209. setTimeStep(newTimeStep: number): void;
  13210. /**
  13211. * Get the time step of the physics engine.
  13212. * @returns the current time step
  13213. */
  13214. getTimeStep(): number;
  13215. /**
  13216. * Release all resources
  13217. */
  13218. dispose(): void;
  13219. /**
  13220. * Gets the name of the current physics plugin
  13221. * @returns the name of the plugin
  13222. */
  13223. getPhysicsPluginName(): string;
  13224. /**
  13225. * Adding a new impostor for the impostor tracking.
  13226. * This will be done by the impostor itself.
  13227. * @param impostor the impostor to add
  13228. */
  13229. addImpostor(impostor: PhysicsImpostor): void;
  13230. /**
  13231. * Remove an impostor from the engine.
  13232. * This impostor and its mesh will not longer be updated by the physics engine.
  13233. * @param impostor the impostor to remove
  13234. */
  13235. removeImpostor(impostor: PhysicsImpostor): void;
  13236. /**
  13237. * Add a joint to the physics engine
  13238. * @param mainImpostor defines the main impostor to which the joint is added.
  13239. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13240. * @param joint defines the joint that will connect both impostors.
  13241. */
  13242. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13243. /**
  13244. * Removes a joint from the simulation
  13245. * @param mainImpostor defines the impostor used with the joint
  13246. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13247. * @param joint defines the joint to remove
  13248. */
  13249. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13250. /**
  13251. * Gets the current plugin used to run the simulation
  13252. * @returns current plugin
  13253. */
  13254. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13255. /**
  13256. * Gets the list of physic impostors
  13257. * @returns an array of PhysicsImpostor
  13258. */
  13259. getImpostors(): Array<PhysicsImpostor>;
  13260. /**
  13261. * Gets the impostor for a physics enabled object
  13262. * @param object defines the object impersonated by the impostor
  13263. * @returns the PhysicsImpostor or null if not found
  13264. */
  13265. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13266. /**
  13267. * Gets the impostor for a physics body object
  13268. * @param body defines physics body used by the impostor
  13269. * @returns the PhysicsImpostor or null if not found
  13270. */
  13271. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13272. /**
  13273. * Does a raycast in the physics world
  13274. * @param from when should the ray start?
  13275. * @param to when should the ray end?
  13276. * @returns PhysicsRaycastResult
  13277. */
  13278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13279. /**
  13280. * Called by the scene. No need to call it.
  13281. * @param delta defines the timespam between frames
  13282. */
  13283. _step(delta: number): void;
  13284. }
  13285. }
  13286. declare module BABYLON {
  13287. /**
  13288. * The interface for the physics imposter parameters
  13289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13290. */
  13291. export interface PhysicsImpostorParameters {
  13292. /**
  13293. * The mass of the physics imposter
  13294. */
  13295. mass: number;
  13296. /**
  13297. * The friction of the physics imposter
  13298. */
  13299. friction?: number;
  13300. /**
  13301. * The coefficient of restitution of the physics imposter
  13302. */
  13303. restitution?: number;
  13304. /**
  13305. * The native options of the physics imposter
  13306. */
  13307. nativeOptions?: any;
  13308. /**
  13309. * Specifies if the parent should be ignored
  13310. */
  13311. ignoreParent?: boolean;
  13312. /**
  13313. * Specifies if bi-directional transformations should be disabled
  13314. */
  13315. disableBidirectionalTransformation?: boolean;
  13316. /**
  13317. * The pressure inside the physics imposter, soft object only
  13318. */
  13319. pressure?: number;
  13320. /**
  13321. * The stiffness the physics imposter, soft object only
  13322. */
  13323. stiffness?: number;
  13324. /**
  13325. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13326. */
  13327. velocityIterations?: number;
  13328. /**
  13329. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13330. */
  13331. positionIterations?: number;
  13332. /**
  13333. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13334. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13335. * Add to fix multiple points
  13336. */
  13337. fixedPoints?: number;
  13338. /**
  13339. * The collision margin around a soft object
  13340. */
  13341. margin?: number;
  13342. /**
  13343. * The collision margin around a soft object
  13344. */
  13345. damping?: number;
  13346. /**
  13347. * The path for a rope based on an extrusion
  13348. */
  13349. path?: any;
  13350. /**
  13351. * The shape of an extrusion used for a rope based on an extrusion
  13352. */
  13353. shape?: any;
  13354. }
  13355. /**
  13356. * Interface for a physics-enabled object
  13357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13358. */
  13359. export interface IPhysicsEnabledObject {
  13360. /**
  13361. * The position of the physics-enabled object
  13362. */
  13363. position: Vector3;
  13364. /**
  13365. * The rotation of the physics-enabled object
  13366. */
  13367. rotationQuaternion: Nullable<Quaternion>;
  13368. /**
  13369. * The scale of the physics-enabled object
  13370. */
  13371. scaling: Vector3;
  13372. /**
  13373. * The rotation of the physics-enabled object
  13374. */
  13375. rotation?: Vector3;
  13376. /**
  13377. * The parent of the physics-enabled object
  13378. */
  13379. parent?: any;
  13380. /**
  13381. * The bounding info of the physics-enabled object
  13382. * @returns The bounding info of the physics-enabled object
  13383. */
  13384. getBoundingInfo(): BoundingInfo;
  13385. /**
  13386. * Computes the world matrix
  13387. * @param force Specifies if the world matrix should be computed by force
  13388. * @returns A world matrix
  13389. */
  13390. computeWorldMatrix(force: boolean): Matrix;
  13391. /**
  13392. * Gets the world matrix
  13393. * @returns A world matrix
  13394. */
  13395. getWorldMatrix?(): Matrix;
  13396. /**
  13397. * Gets the child meshes
  13398. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13399. * @returns An array of abstract meshes
  13400. */
  13401. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13402. /**
  13403. * Gets the vertex data
  13404. * @param kind The type of vertex data
  13405. * @returns A nullable array of numbers, or a float32 array
  13406. */
  13407. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13408. /**
  13409. * Gets the indices from the mesh
  13410. * @returns A nullable array of index arrays
  13411. */
  13412. getIndices?(): Nullable<IndicesArray>;
  13413. /**
  13414. * Gets the scene from the mesh
  13415. * @returns the indices array or null
  13416. */
  13417. getScene?(): Scene;
  13418. /**
  13419. * Gets the absolute position from the mesh
  13420. * @returns the absolute position
  13421. */
  13422. getAbsolutePosition(): Vector3;
  13423. /**
  13424. * Gets the absolute pivot point from the mesh
  13425. * @returns the absolute pivot point
  13426. */
  13427. getAbsolutePivotPoint(): Vector3;
  13428. /**
  13429. * Rotates the mesh
  13430. * @param axis The axis of rotation
  13431. * @param amount The amount of rotation
  13432. * @param space The space of the rotation
  13433. * @returns The rotation transform node
  13434. */
  13435. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13436. /**
  13437. * Translates the mesh
  13438. * @param axis The axis of translation
  13439. * @param distance The distance of translation
  13440. * @param space The space of the translation
  13441. * @returns The transform node
  13442. */
  13443. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13444. /**
  13445. * Sets the absolute position of the mesh
  13446. * @param absolutePosition The absolute position of the mesh
  13447. * @returns The transform node
  13448. */
  13449. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13450. /**
  13451. * Gets the class name of the mesh
  13452. * @returns The class name
  13453. */
  13454. getClassName(): string;
  13455. }
  13456. /**
  13457. * Represents a physics imposter
  13458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13459. */
  13460. export class PhysicsImpostor {
  13461. /**
  13462. * The physics-enabled object used as the physics imposter
  13463. */
  13464. object: IPhysicsEnabledObject;
  13465. /**
  13466. * The type of the physics imposter
  13467. */
  13468. type: number;
  13469. private _options;
  13470. private _scene?;
  13471. /**
  13472. * The default object size of the imposter
  13473. */
  13474. static DEFAULT_OBJECT_SIZE: Vector3;
  13475. /**
  13476. * The identity quaternion of the imposter
  13477. */
  13478. static IDENTITY_QUATERNION: Quaternion;
  13479. /** @hidden */
  13480. _pluginData: any;
  13481. private _physicsEngine;
  13482. private _physicsBody;
  13483. private _bodyUpdateRequired;
  13484. private _onBeforePhysicsStepCallbacks;
  13485. private _onAfterPhysicsStepCallbacks;
  13486. /** @hidden */
  13487. _onPhysicsCollideCallbacks: Array<{
  13488. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13489. otherImpostors: Array<PhysicsImpostor>;
  13490. }>;
  13491. private _deltaPosition;
  13492. private _deltaRotation;
  13493. private _deltaRotationConjugated;
  13494. /** @hidden */
  13495. _isFromLine: boolean;
  13496. private _parent;
  13497. private _isDisposed;
  13498. private static _tmpVecs;
  13499. private static _tmpQuat;
  13500. /**
  13501. * Specifies if the physics imposter is disposed
  13502. */
  13503. readonly isDisposed: boolean;
  13504. /**
  13505. * Gets the mass of the physics imposter
  13506. */
  13507. mass: number;
  13508. /**
  13509. * Gets the coefficient of friction
  13510. */
  13511. /**
  13512. * Sets the coefficient of friction
  13513. */
  13514. friction: number;
  13515. /**
  13516. * Gets the coefficient of restitution
  13517. */
  13518. /**
  13519. * Sets the coefficient of restitution
  13520. */
  13521. restitution: number;
  13522. /**
  13523. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13524. */
  13525. /**
  13526. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13527. */
  13528. pressure: number;
  13529. /**
  13530. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13531. */
  13532. /**
  13533. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13534. */
  13535. stiffness: number;
  13536. /**
  13537. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13538. */
  13539. /**
  13540. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13541. */
  13542. velocityIterations: number;
  13543. /**
  13544. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13545. */
  13546. /**
  13547. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13548. */
  13549. positionIterations: number;
  13550. /**
  13551. * The unique id of the physics imposter
  13552. * set by the physics engine when adding this impostor to the array
  13553. */
  13554. uniqueId: number;
  13555. /**
  13556. * @hidden
  13557. */
  13558. soft: boolean;
  13559. /**
  13560. * @hidden
  13561. */
  13562. segments: number;
  13563. private _joints;
  13564. /**
  13565. * Initializes the physics imposter
  13566. * @param object The physics-enabled object used as the physics imposter
  13567. * @param type The type of the physics imposter
  13568. * @param _options The options for the physics imposter
  13569. * @param _scene The Babylon scene
  13570. */
  13571. constructor(
  13572. /**
  13573. * The physics-enabled object used as the physics imposter
  13574. */
  13575. object: IPhysicsEnabledObject,
  13576. /**
  13577. * The type of the physics imposter
  13578. */
  13579. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13580. /**
  13581. * This function will completly initialize this impostor.
  13582. * It will create a new body - but only if this mesh has no parent.
  13583. * If it has, this impostor will not be used other than to define the impostor
  13584. * of the child mesh.
  13585. * @hidden
  13586. */
  13587. _init(): void;
  13588. private _getPhysicsParent;
  13589. /**
  13590. * Should a new body be generated.
  13591. * @returns boolean specifying if body initialization is required
  13592. */
  13593. isBodyInitRequired(): boolean;
  13594. /**
  13595. * Sets the updated scaling
  13596. * @param updated Specifies if the scaling is updated
  13597. */
  13598. setScalingUpdated(): void;
  13599. /**
  13600. * Force a regeneration of this or the parent's impostor's body.
  13601. * Use under cautious - This will remove all joints already implemented.
  13602. */
  13603. forceUpdate(): void;
  13604. /**
  13605. * Gets the body that holds this impostor. Either its own, or its parent.
  13606. */
  13607. /**
  13608. * Set the physics body. Used mainly by the physics engine/plugin
  13609. */
  13610. physicsBody: any;
  13611. /**
  13612. * Get the parent of the physics imposter
  13613. * @returns Physics imposter or null
  13614. */
  13615. /**
  13616. * Sets the parent of the physics imposter
  13617. */
  13618. parent: Nullable<PhysicsImpostor>;
  13619. /**
  13620. * Resets the update flags
  13621. */
  13622. resetUpdateFlags(): void;
  13623. /**
  13624. * Gets the object extend size
  13625. * @returns the object extend size
  13626. */
  13627. getObjectExtendSize(): Vector3;
  13628. /**
  13629. * Gets the object center
  13630. * @returns The object center
  13631. */
  13632. getObjectCenter(): Vector3;
  13633. /**
  13634. * Get a specific parametes from the options parameter
  13635. * @param paramName The object parameter name
  13636. * @returns The object parameter
  13637. */
  13638. getParam(paramName: string): any;
  13639. /**
  13640. * Sets a specific parameter in the options given to the physics plugin
  13641. * @param paramName The parameter name
  13642. * @param value The value of the parameter
  13643. */
  13644. setParam(paramName: string, value: number): void;
  13645. /**
  13646. * Specifically change the body's mass option. Won't recreate the physics body object
  13647. * @param mass The mass of the physics imposter
  13648. */
  13649. setMass(mass: number): void;
  13650. /**
  13651. * Gets the linear velocity
  13652. * @returns linear velocity or null
  13653. */
  13654. getLinearVelocity(): Nullable<Vector3>;
  13655. /**
  13656. * Sets the linear velocity
  13657. * @param velocity linear velocity or null
  13658. */
  13659. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13660. /**
  13661. * Gets the angular velocity
  13662. * @returns angular velocity or null
  13663. */
  13664. getAngularVelocity(): Nullable<Vector3>;
  13665. /**
  13666. * Sets the angular velocity
  13667. * @param velocity The velocity or null
  13668. */
  13669. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13670. /**
  13671. * Execute a function with the physics plugin native code
  13672. * Provide a function the will have two variables - the world object and the physics body object
  13673. * @param func The function to execute with the physics plugin native code
  13674. */
  13675. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13676. /**
  13677. * Register a function that will be executed before the physics world is stepping forward
  13678. * @param func The function to execute before the physics world is stepped forward
  13679. */
  13680. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13681. /**
  13682. * Unregister a function that will be executed before the physics world is stepping forward
  13683. * @param func The function to execute before the physics world is stepped forward
  13684. */
  13685. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13686. /**
  13687. * Register a function that will be executed after the physics step
  13688. * @param func The function to execute after physics step
  13689. */
  13690. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13691. /**
  13692. * Unregisters a function that will be executed after the physics step
  13693. * @param func The function to execute after physics step
  13694. */
  13695. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13696. /**
  13697. * register a function that will be executed when this impostor collides against a different body
  13698. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13699. * @param func Callback that is executed on collision
  13700. */
  13701. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13702. /**
  13703. * Unregisters the physics imposter on contact
  13704. * @param collideAgainst The physics object to collide against
  13705. * @param func Callback to execute on collision
  13706. */
  13707. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13708. private _tmpQuat;
  13709. private _tmpQuat2;
  13710. /**
  13711. * Get the parent rotation
  13712. * @returns The parent rotation
  13713. */
  13714. getParentsRotation(): Quaternion;
  13715. /**
  13716. * this function is executed by the physics engine.
  13717. */
  13718. beforeStep: () => void;
  13719. /**
  13720. * this function is executed by the physics engine
  13721. */
  13722. afterStep: () => void;
  13723. /**
  13724. * Legacy collision detection event support
  13725. */
  13726. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13727. /**
  13728. * event and body object due to cannon's event-based architecture.
  13729. */
  13730. onCollide: (e: {
  13731. body: any;
  13732. }) => void;
  13733. /**
  13734. * Apply a force
  13735. * @param force The force to apply
  13736. * @param contactPoint The contact point for the force
  13737. * @returns The physics imposter
  13738. */
  13739. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13740. /**
  13741. * Apply an impulse
  13742. * @param force The impulse force
  13743. * @param contactPoint The contact point for the impulse force
  13744. * @returns The physics imposter
  13745. */
  13746. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13747. /**
  13748. * A help function to create a joint
  13749. * @param otherImpostor A physics imposter used to create a joint
  13750. * @param jointType The type of joint
  13751. * @param jointData The data for the joint
  13752. * @returns The physics imposter
  13753. */
  13754. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13755. /**
  13756. * Add a joint to this impostor with a different impostor
  13757. * @param otherImpostor A physics imposter used to add a joint
  13758. * @param joint The joint to add
  13759. * @returns The physics imposter
  13760. */
  13761. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13762. /**
  13763. * Add an anchor to a cloth impostor
  13764. * @param otherImpostor rigid impostor to anchor to
  13765. * @param width ratio across width from 0 to 1
  13766. * @param height ratio up height from 0 to 1
  13767. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13768. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13769. * @returns impostor the soft imposter
  13770. */
  13771. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13772. /**
  13773. * Add a hook to a rope impostor
  13774. * @param otherImpostor rigid impostor to anchor to
  13775. * @param length ratio across rope from 0 to 1
  13776. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13777. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13778. * @returns impostor the rope imposter
  13779. */
  13780. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13781. /**
  13782. * Will keep this body still, in a sleep mode.
  13783. * @returns the physics imposter
  13784. */
  13785. sleep(): PhysicsImpostor;
  13786. /**
  13787. * Wake the body up.
  13788. * @returns The physics imposter
  13789. */
  13790. wakeUp(): PhysicsImpostor;
  13791. /**
  13792. * Clones the physics imposter
  13793. * @param newObject The physics imposter clones to this physics-enabled object
  13794. * @returns A nullable physics imposter
  13795. */
  13796. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13797. /**
  13798. * Disposes the physics imposter
  13799. */
  13800. dispose(): void;
  13801. /**
  13802. * Sets the delta position
  13803. * @param position The delta position amount
  13804. */
  13805. setDeltaPosition(position: Vector3): void;
  13806. /**
  13807. * Sets the delta rotation
  13808. * @param rotation The delta rotation amount
  13809. */
  13810. setDeltaRotation(rotation: Quaternion): void;
  13811. /**
  13812. * Gets the box size of the physics imposter and stores the result in the input parameter
  13813. * @param result Stores the box size
  13814. * @returns The physics imposter
  13815. */
  13816. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13817. /**
  13818. * Gets the radius of the physics imposter
  13819. * @returns Radius of the physics imposter
  13820. */
  13821. getRadius(): number;
  13822. /**
  13823. * Sync a bone with this impostor
  13824. * @param bone The bone to sync to the impostor.
  13825. * @param boneMesh The mesh that the bone is influencing.
  13826. * @param jointPivot The pivot of the joint / bone in local space.
  13827. * @param distToJoint Optional distance from the impostor to the joint.
  13828. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13829. */
  13830. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13831. /**
  13832. * Sync impostor to a bone
  13833. * @param bone The bone that the impostor will be synced to.
  13834. * @param boneMesh The mesh that the bone is influencing.
  13835. * @param jointPivot The pivot of the joint / bone in local space.
  13836. * @param distToJoint Optional distance from the impostor to the joint.
  13837. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13838. * @param boneAxis Optional vector3 axis the bone is aligned with
  13839. */
  13840. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13841. /**
  13842. * No-Imposter type
  13843. */
  13844. static NoImpostor: number;
  13845. /**
  13846. * Sphere-Imposter type
  13847. */
  13848. static SphereImpostor: number;
  13849. /**
  13850. * Box-Imposter type
  13851. */
  13852. static BoxImpostor: number;
  13853. /**
  13854. * Plane-Imposter type
  13855. */
  13856. static PlaneImpostor: number;
  13857. /**
  13858. * Mesh-imposter type
  13859. */
  13860. static MeshImpostor: number;
  13861. /**
  13862. * Capsule-Impostor type (Ammo.js plugin only)
  13863. */
  13864. static CapsuleImpostor: number;
  13865. /**
  13866. * Cylinder-Imposter type
  13867. */
  13868. static CylinderImpostor: number;
  13869. /**
  13870. * Particle-Imposter type
  13871. */
  13872. static ParticleImpostor: number;
  13873. /**
  13874. * Heightmap-Imposter type
  13875. */
  13876. static HeightmapImpostor: number;
  13877. /**
  13878. * ConvexHull-Impostor type (Ammo.js plugin only)
  13879. */
  13880. static ConvexHullImpostor: number;
  13881. /**
  13882. * Rope-Imposter type
  13883. */
  13884. static RopeImpostor: number;
  13885. /**
  13886. * Cloth-Imposter type
  13887. */
  13888. static ClothImpostor: number;
  13889. /**
  13890. * Softbody-Imposter type
  13891. */
  13892. static SoftbodyImpostor: number;
  13893. }
  13894. }
  13895. declare module BABYLON {
  13896. /**
  13897. * @hidden
  13898. **/
  13899. export class _CreationDataStorage {
  13900. closePath?: boolean;
  13901. closeArray?: boolean;
  13902. idx: number[];
  13903. dashSize: number;
  13904. gapSize: number;
  13905. path3D: Path3D;
  13906. pathArray: Vector3[][];
  13907. arc: number;
  13908. radius: number;
  13909. cap: number;
  13910. tessellation: number;
  13911. }
  13912. /**
  13913. * @hidden
  13914. **/
  13915. class _InstanceDataStorage {
  13916. visibleInstances: any;
  13917. batchCache: _InstancesBatch;
  13918. instancesBufferSize: number;
  13919. instancesBuffer: Nullable<Buffer>;
  13920. instancesData: Float32Array;
  13921. overridenInstanceCount: number;
  13922. isFrozen: boolean;
  13923. previousBatch: Nullable<_InstancesBatch>;
  13924. hardwareInstancedRendering: boolean;
  13925. sideOrientation: number;
  13926. }
  13927. /**
  13928. * @hidden
  13929. **/
  13930. export class _InstancesBatch {
  13931. mustReturn: boolean;
  13932. visibleInstances: Nullable<InstancedMesh[]>[];
  13933. renderSelf: boolean[];
  13934. hardwareInstancedRendering: boolean[];
  13935. }
  13936. /**
  13937. * Class used to represent renderable models
  13938. */
  13939. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13940. /**
  13941. * Mesh side orientation : usually the external or front surface
  13942. */
  13943. static readonly FRONTSIDE: number;
  13944. /**
  13945. * Mesh side orientation : usually the internal or back surface
  13946. */
  13947. static readonly BACKSIDE: number;
  13948. /**
  13949. * Mesh side orientation : both internal and external or front and back surfaces
  13950. */
  13951. static readonly DOUBLESIDE: number;
  13952. /**
  13953. * Mesh side orientation : by default, `FRONTSIDE`
  13954. */
  13955. static readonly DEFAULTSIDE: number;
  13956. /**
  13957. * Mesh cap setting : no cap
  13958. */
  13959. static readonly NO_CAP: number;
  13960. /**
  13961. * Mesh cap setting : one cap at the beginning of the mesh
  13962. */
  13963. static readonly CAP_START: number;
  13964. /**
  13965. * Mesh cap setting : one cap at the end of the mesh
  13966. */
  13967. static readonly CAP_END: number;
  13968. /**
  13969. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13970. */
  13971. static readonly CAP_ALL: number;
  13972. /**
  13973. * Mesh pattern setting : no flip or rotate
  13974. */
  13975. static readonly NO_FLIP: number;
  13976. /**
  13977. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  13978. */
  13979. static readonly FLIP_TILE: number;
  13980. /**
  13981. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  13982. */
  13983. static readonly ROTATE_TILE: number;
  13984. /**
  13985. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  13986. */
  13987. static readonly FLIP_ROW: number;
  13988. /**
  13989. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  13990. */
  13991. static readonly ROTATE_ROW: number;
  13992. /**
  13993. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  13994. */
  13995. static readonly FLIP_N_ROTATE_TILE: number;
  13996. /**
  13997. * Mesh pattern setting : rotate pattern and rotate
  13998. */
  13999. static readonly FLIP_N_ROTATE_ROW: number;
  14000. /**
  14001. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14002. */
  14003. static readonly CENTER: number;
  14004. /**
  14005. * Mesh tile positioning : part tiles on left
  14006. */
  14007. static readonly LEFT: number;
  14008. /**
  14009. * Mesh tile positioning : part tiles on right
  14010. */
  14011. static readonly RIGHT: number;
  14012. /**
  14013. * Mesh tile positioning : part tiles on top
  14014. */
  14015. static readonly TOP: number;
  14016. /**
  14017. * Mesh tile positioning : part tiles on bottom
  14018. */
  14019. static readonly BOTTOM: number;
  14020. /**
  14021. * Gets the default side orientation.
  14022. * @param orientation the orientation to value to attempt to get
  14023. * @returns the default orientation
  14024. * @hidden
  14025. */
  14026. static _GetDefaultSideOrientation(orientation?: number): number;
  14027. private _internalMeshDataInfo;
  14028. /**
  14029. * An event triggered before rendering the mesh
  14030. */
  14031. readonly onBeforeRenderObservable: Observable<Mesh>;
  14032. /**
  14033. * An event triggered before binding the mesh
  14034. */
  14035. readonly onBeforeBindObservable: Observable<Mesh>;
  14036. /**
  14037. * An event triggered after rendering the mesh
  14038. */
  14039. readonly onAfterRenderObservable: Observable<Mesh>;
  14040. /**
  14041. * An event triggered before drawing the mesh
  14042. */
  14043. readonly onBeforeDrawObservable: Observable<Mesh>;
  14044. private _onBeforeDrawObserver;
  14045. /**
  14046. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14047. */
  14048. onBeforeDraw: () => void;
  14049. /**
  14050. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14051. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14052. */
  14053. delayLoadState: number;
  14054. /**
  14055. * Gets the list of instances created from this mesh
  14056. * it is not supposed to be modified manually.
  14057. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14058. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14059. */
  14060. instances: InstancedMesh[];
  14061. /**
  14062. * Gets the file containing delay loading data for this mesh
  14063. */
  14064. delayLoadingFile: string;
  14065. /** @hidden */
  14066. _binaryInfo: any;
  14067. /**
  14068. * User defined function used to change how LOD level selection is done
  14069. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14070. */
  14071. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14072. /**
  14073. * Gets or sets the morph target manager
  14074. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14075. */
  14076. morphTargetManager: Nullable<MorphTargetManager>;
  14077. /** @hidden */
  14078. _creationDataStorage: Nullable<_CreationDataStorage>;
  14079. /** @hidden */
  14080. _geometry: Nullable<Geometry>;
  14081. /** @hidden */
  14082. _delayInfo: Array<string>;
  14083. /** @hidden */
  14084. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14085. /** @hidden */
  14086. _instanceDataStorage: _InstanceDataStorage;
  14087. private _effectiveMaterial;
  14088. /** @hidden */
  14089. _shouldGenerateFlatShading: boolean;
  14090. /** @hidden */
  14091. _originalBuilderSideOrientation: number;
  14092. /**
  14093. * Use this property to change the original side orientation defined at construction time
  14094. */
  14095. overrideMaterialSideOrientation: Nullable<number>;
  14096. /**
  14097. * Gets the source mesh (the one used to clone this one from)
  14098. */
  14099. readonly source: Nullable<Mesh>;
  14100. /**
  14101. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14102. */
  14103. isUnIndexed: boolean;
  14104. /**
  14105. * @constructor
  14106. * @param name The value used by scene.getMeshByName() to do a lookup.
  14107. * @param scene The scene to add this mesh to.
  14108. * @param parent The parent of this mesh, if it has one
  14109. * @param source An optional Mesh from which geometry is shared, cloned.
  14110. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14111. * When false, achieved by calling a clone(), also passing False.
  14112. * This will make creation of children, recursive.
  14113. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14114. */
  14115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14116. /**
  14117. * Gets the class name
  14118. * @returns the string "Mesh".
  14119. */
  14120. getClassName(): string;
  14121. /** @hidden */
  14122. readonly _isMesh: boolean;
  14123. /**
  14124. * Returns a description of this mesh
  14125. * @param fullDetails define if full details about this mesh must be used
  14126. * @returns a descriptive string representing this mesh
  14127. */
  14128. toString(fullDetails?: boolean): string;
  14129. /** @hidden */
  14130. _unBindEffect(): void;
  14131. /**
  14132. * Gets a boolean indicating if this mesh has LOD
  14133. */
  14134. readonly hasLODLevels: boolean;
  14135. /**
  14136. * Gets the list of MeshLODLevel associated with the current mesh
  14137. * @returns an array of MeshLODLevel
  14138. */
  14139. getLODLevels(): MeshLODLevel[];
  14140. private _sortLODLevels;
  14141. /**
  14142. * Add a mesh as LOD level triggered at the given distance.
  14143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14144. * @param distance The distance from the center of the object to show this level
  14145. * @param mesh The mesh to be added as LOD level (can be null)
  14146. * @return This mesh (for chaining)
  14147. */
  14148. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14149. /**
  14150. * Returns the LOD level mesh at the passed distance or null if not found.
  14151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14152. * @param distance The distance from the center of the object to show this level
  14153. * @returns a Mesh or `null`
  14154. */
  14155. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14156. /**
  14157. * Remove a mesh from the LOD array
  14158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14159. * @param mesh defines the mesh to be removed
  14160. * @return This mesh (for chaining)
  14161. */
  14162. removeLODLevel(mesh: Mesh): Mesh;
  14163. /**
  14164. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14165. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14166. * @param camera defines the camera to use to compute distance
  14167. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14168. * @return This mesh (for chaining)
  14169. */
  14170. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14171. /**
  14172. * Gets the mesh internal Geometry object
  14173. */
  14174. readonly geometry: Nullable<Geometry>;
  14175. /**
  14176. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14177. * @returns the total number of vertices
  14178. */
  14179. getTotalVertices(): number;
  14180. /**
  14181. * Returns the content of an associated vertex buffer
  14182. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14183. * - VertexBuffer.PositionKind
  14184. * - VertexBuffer.UVKind
  14185. * - VertexBuffer.UV2Kind
  14186. * - VertexBuffer.UV3Kind
  14187. * - VertexBuffer.UV4Kind
  14188. * - VertexBuffer.UV5Kind
  14189. * - VertexBuffer.UV6Kind
  14190. * - VertexBuffer.ColorKind
  14191. * - VertexBuffer.MatricesIndicesKind
  14192. * - VertexBuffer.MatricesIndicesExtraKind
  14193. * - VertexBuffer.MatricesWeightsKind
  14194. * - VertexBuffer.MatricesWeightsExtraKind
  14195. * @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
  14196. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14197. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14198. */
  14199. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14200. /**
  14201. * Returns the mesh VertexBuffer object from the requested `kind`
  14202. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14203. * - VertexBuffer.PositionKind
  14204. * - VertexBuffer.NormalKind
  14205. * - VertexBuffer.UVKind
  14206. * - VertexBuffer.UV2Kind
  14207. * - VertexBuffer.UV3Kind
  14208. * - VertexBuffer.UV4Kind
  14209. * - VertexBuffer.UV5Kind
  14210. * - VertexBuffer.UV6Kind
  14211. * - VertexBuffer.ColorKind
  14212. * - VertexBuffer.MatricesIndicesKind
  14213. * - VertexBuffer.MatricesIndicesExtraKind
  14214. * - VertexBuffer.MatricesWeightsKind
  14215. * - VertexBuffer.MatricesWeightsExtraKind
  14216. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14217. */
  14218. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14219. /**
  14220. * Tests if a specific vertex buffer is associated with this mesh
  14221. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14222. * - VertexBuffer.PositionKind
  14223. * - VertexBuffer.NormalKind
  14224. * - VertexBuffer.UVKind
  14225. * - VertexBuffer.UV2Kind
  14226. * - VertexBuffer.UV3Kind
  14227. * - VertexBuffer.UV4Kind
  14228. * - VertexBuffer.UV5Kind
  14229. * - VertexBuffer.UV6Kind
  14230. * - VertexBuffer.ColorKind
  14231. * - VertexBuffer.MatricesIndicesKind
  14232. * - VertexBuffer.MatricesIndicesExtraKind
  14233. * - VertexBuffer.MatricesWeightsKind
  14234. * - VertexBuffer.MatricesWeightsExtraKind
  14235. * @returns a boolean
  14236. */
  14237. isVerticesDataPresent(kind: string): boolean;
  14238. /**
  14239. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14240. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14241. * - VertexBuffer.PositionKind
  14242. * - VertexBuffer.UVKind
  14243. * - VertexBuffer.UV2Kind
  14244. * - VertexBuffer.UV3Kind
  14245. * - VertexBuffer.UV4Kind
  14246. * - VertexBuffer.UV5Kind
  14247. * - VertexBuffer.UV6Kind
  14248. * - VertexBuffer.ColorKind
  14249. * - VertexBuffer.MatricesIndicesKind
  14250. * - VertexBuffer.MatricesIndicesExtraKind
  14251. * - VertexBuffer.MatricesWeightsKind
  14252. * - VertexBuffer.MatricesWeightsExtraKind
  14253. * @returns a boolean
  14254. */
  14255. isVertexBufferUpdatable(kind: string): boolean;
  14256. /**
  14257. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14258. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14259. * - VertexBuffer.PositionKind
  14260. * - VertexBuffer.NormalKind
  14261. * - VertexBuffer.UVKind
  14262. * - VertexBuffer.UV2Kind
  14263. * - VertexBuffer.UV3Kind
  14264. * - VertexBuffer.UV4Kind
  14265. * - VertexBuffer.UV5Kind
  14266. * - VertexBuffer.UV6Kind
  14267. * - VertexBuffer.ColorKind
  14268. * - VertexBuffer.MatricesIndicesKind
  14269. * - VertexBuffer.MatricesIndicesExtraKind
  14270. * - VertexBuffer.MatricesWeightsKind
  14271. * - VertexBuffer.MatricesWeightsExtraKind
  14272. * @returns an array of strings
  14273. */
  14274. getVerticesDataKinds(): string[];
  14275. /**
  14276. * Returns a positive integer : the total number of indices in this mesh geometry.
  14277. * @returns the numner of indices or zero if the mesh has no geometry.
  14278. */
  14279. getTotalIndices(): number;
  14280. /**
  14281. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14282. * @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.
  14283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14284. * @returns the indices array or an empty array if the mesh has no geometry
  14285. */
  14286. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14287. readonly isBlocked: boolean;
  14288. /**
  14289. * Determine if the current mesh is ready to be rendered
  14290. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14291. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14292. * @returns true if all associated assets are ready (material, textures, shaders)
  14293. */
  14294. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14295. /**
  14296. * 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.
  14297. */
  14298. readonly areNormalsFrozen: boolean;
  14299. /**
  14300. * 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.
  14301. * @returns the current mesh
  14302. */
  14303. freezeNormals(): Mesh;
  14304. /**
  14305. * 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
  14306. * @returns the current mesh
  14307. */
  14308. unfreezeNormals(): Mesh;
  14309. /**
  14310. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14311. */
  14312. overridenInstanceCount: number;
  14313. /** @hidden */
  14314. _preActivate(): Mesh;
  14315. /** @hidden */
  14316. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14317. /** @hidden */
  14318. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14319. /**
  14320. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14321. * This means the mesh underlying bounding box and sphere are recomputed.
  14322. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14323. * @returns the current mesh
  14324. */
  14325. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14326. /** @hidden */
  14327. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14328. /**
  14329. * This function will subdivide the mesh into multiple submeshes
  14330. * @param count defines the expected number of submeshes
  14331. */
  14332. subdivide(count: number): void;
  14333. /**
  14334. * Copy a FloatArray into a specific associated vertex buffer
  14335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14336. * - VertexBuffer.PositionKind
  14337. * - VertexBuffer.UVKind
  14338. * - VertexBuffer.UV2Kind
  14339. * - VertexBuffer.UV3Kind
  14340. * - VertexBuffer.UV4Kind
  14341. * - VertexBuffer.UV5Kind
  14342. * - VertexBuffer.UV6Kind
  14343. * - VertexBuffer.ColorKind
  14344. * - VertexBuffer.MatricesIndicesKind
  14345. * - VertexBuffer.MatricesIndicesExtraKind
  14346. * - VertexBuffer.MatricesWeightsKind
  14347. * - VertexBuffer.MatricesWeightsExtraKind
  14348. * @param data defines the data source
  14349. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14350. * @param stride defines the data stride size (can be null)
  14351. * @returns the current mesh
  14352. */
  14353. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14354. /**
  14355. * Flags an associated vertex buffer as updatable
  14356. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14357. * - VertexBuffer.PositionKind
  14358. * - VertexBuffer.UVKind
  14359. * - VertexBuffer.UV2Kind
  14360. * - VertexBuffer.UV3Kind
  14361. * - VertexBuffer.UV4Kind
  14362. * - VertexBuffer.UV5Kind
  14363. * - VertexBuffer.UV6Kind
  14364. * - VertexBuffer.ColorKind
  14365. * - VertexBuffer.MatricesIndicesKind
  14366. * - VertexBuffer.MatricesIndicesExtraKind
  14367. * - VertexBuffer.MatricesWeightsKind
  14368. * - VertexBuffer.MatricesWeightsExtraKind
  14369. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14370. */
  14371. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14372. /**
  14373. * Sets the mesh global Vertex Buffer
  14374. * @param buffer defines the buffer to use
  14375. * @returns the current mesh
  14376. */
  14377. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14378. /**
  14379. * Update a specific associated vertex buffer
  14380. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14381. * - VertexBuffer.PositionKind
  14382. * - VertexBuffer.UVKind
  14383. * - VertexBuffer.UV2Kind
  14384. * - VertexBuffer.UV3Kind
  14385. * - VertexBuffer.UV4Kind
  14386. * - VertexBuffer.UV5Kind
  14387. * - VertexBuffer.UV6Kind
  14388. * - VertexBuffer.ColorKind
  14389. * - VertexBuffer.MatricesIndicesKind
  14390. * - VertexBuffer.MatricesIndicesExtraKind
  14391. * - VertexBuffer.MatricesWeightsKind
  14392. * - VertexBuffer.MatricesWeightsExtraKind
  14393. * @param data defines the data source
  14394. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14395. * @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)
  14396. * @returns the current mesh
  14397. */
  14398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14399. /**
  14400. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14401. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14402. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14403. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14404. * @returns the current mesh
  14405. */
  14406. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14407. /**
  14408. * Creates a un-shared specific occurence of the geometry for the mesh.
  14409. * @returns the current mesh
  14410. */
  14411. makeGeometryUnique(): Mesh;
  14412. /**
  14413. * Set the index buffer of this mesh
  14414. * @param indices defines the source data
  14415. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14416. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14417. * @returns the current mesh
  14418. */
  14419. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14420. /**
  14421. * Update the current index buffer
  14422. * @param indices defines the source data
  14423. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14424. * @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)
  14425. * @returns the current mesh
  14426. */
  14427. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14428. /**
  14429. * Invert the geometry to move from a right handed system to a left handed one.
  14430. * @returns the current mesh
  14431. */
  14432. toLeftHanded(): Mesh;
  14433. /** @hidden */
  14434. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14435. /** @hidden */
  14436. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14437. /**
  14438. * Registers for this mesh a javascript function called just before the rendering process
  14439. * @param func defines the function to call before rendering this mesh
  14440. * @returns the current mesh
  14441. */
  14442. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14443. /**
  14444. * Disposes a previously registered javascript function called before the rendering
  14445. * @param func defines the function to remove
  14446. * @returns the current mesh
  14447. */
  14448. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14449. /**
  14450. * Registers for this mesh a javascript function called just after the rendering is complete
  14451. * @param func defines the function to call after rendering this mesh
  14452. * @returns the current mesh
  14453. */
  14454. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14455. /**
  14456. * Disposes a previously registered javascript function called after the rendering.
  14457. * @param func defines the function to remove
  14458. * @returns the current mesh
  14459. */
  14460. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14461. /** @hidden */
  14462. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14463. /** @hidden */
  14464. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14465. /** @hidden */
  14466. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14467. /** @hidden */
  14468. _rebuild(): void;
  14469. /** @hidden */
  14470. _freeze(): void;
  14471. /** @hidden */
  14472. _unFreeze(): void;
  14473. /**
  14474. * 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
  14475. * @param subMesh defines the subMesh to render
  14476. * @param enableAlphaMode defines if alpha mode can be changed
  14477. * @returns the current mesh
  14478. */
  14479. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14480. private _onBeforeDraw;
  14481. /**
  14482. * Renormalize the mesh and patch it up if there are no weights
  14483. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14484. * However in the case of zero weights then we set just a single influence to 1.
  14485. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14486. */
  14487. cleanMatrixWeights(): void;
  14488. private normalizeSkinFourWeights;
  14489. private normalizeSkinWeightsAndExtra;
  14490. /**
  14491. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14492. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14493. * the user know there was an issue with importing the mesh
  14494. * @returns a validation object with skinned, valid and report string
  14495. */
  14496. validateSkinning(): {
  14497. skinned: boolean;
  14498. valid: boolean;
  14499. report: string;
  14500. };
  14501. /** @hidden */
  14502. _checkDelayState(): Mesh;
  14503. private _queueLoad;
  14504. /**
  14505. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14506. * A mesh is in the frustum if its bounding box intersects the frustum
  14507. * @param frustumPlanes defines the frustum to test
  14508. * @returns true if the mesh is in the frustum planes
  14509. */
  14510. isInFrustum(frustumPlanes: Plane[]): boolean;
  14511. /**
  14512. * Sets the mesh material by the material or multiMaterial `id` property
  14513. * @param id is a string identifying the material or the multiMaterial
  14514. * @returns the current mesh
  14515. */
  14516. setMaterialByID(id: string): Mesh;
  14517. /**
  14518. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14519. * @returns an array of IAnimatable
  14520. */
  14521. getAnimatables(): IAnimatable[];
  14522. /**
  14523. * Modifies the mesh geometry according to the passed transformation matrix.
  14524. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14525. * The mesh normals are modified using the same transformation.
  14526. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14527. * @param transform defines the transform matrix to use
  14528. * @see http://doc.babylonjs.com/resources/baking_transformations
  14529. * @returns the current mesh
  14530. */
  14531. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14532. /**
  14533. * Modifies the mesh geometry according to its own current World Matrix.
  14534. * The mesh World Matrix is then reset.
  14535. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14536. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14537. * @see http://doc.babylonjs.com/resources/baking_transformations
  14538. * @returns the current mesh
  14539. */
  14540. bakeCurrentTransformIntoVertices(): Mesh;
  14541. /** @hidden */
  14542. readonly _positions: Nullable<Vector3[]>;
  14543. /** @hidden */
  14544. _resetPointsArrayCache(): Mesh;
  14545. /** @hidden */
  14546. _generatePointsArray(): boolean;
  14547. /**
  14548. * Returns a new Mesh object generated from the current mesh properties.
  14549. * This method must not get confused with createInstance()
  14550. * @param name is a string, the name given to the new mesh
  14551. * @param newParent can be any Node object (default `null`)
  14552. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14553. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14554. * @returns a new mesh
  14555. */
  14556. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14557. /**
  14558. * Releases resources associated with this mesh.
  14559. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14560. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14561. */
  14562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14563. /**
  14564. * Modifies the mesh geometry according to a displacement map.
  14565. * 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.
  14566. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14567. * @param url is a string, the URL from the image file is to be downloaded.
  14568. * @param minHeight is the lower limit of the displacement.
  14569. * @param maxHeight is the upper limit of the displacement.
  14570. * @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.
  14571. * @param uvOffset is an optional vector2 used to offset UV.
  14572. * @param uvScale is an optional vector2 used to scale UV.
  14573. * @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.
  14574. * @returns the Mesh.
  14575. */
  14576. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14577. /**
  14578. * Modifies the mesh geometry according to a displacementMap buffer.
  14579. * 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.
  14580. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14581. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14582. * @param heightMapWidth is the width of the buffer image.
  14583. * @param heightMapHeight is the height of the buffer image.
  14584. * @param minHeight is the lower limit of the displacement.
  14585. * @param maxHeight is the upper limit of the displacement.
  14586. * @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.
  14587. * @param uvOffset is an optional vector2 used to offset UV.
  14588. * @param uvScale is an optional vector2 used to scale UV.
  14589. * @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.
  14590. * @returns the Mesh.
  14591. */
  14592. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14593. /**
  14594. * Modify the mesh to get a flat shading rendering.
  14595. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14596. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14597. * @returns current mesh
  14598. */
  14599. convertToFlatShadedMesh(): Mesh;
  14600. /**
  14601. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14602. * In other words, more vertices, no more indices and a single bigger VBO.
  14603. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14604. * @returns current mesh
  14605. */
  14606. convertToUnIndexedMesh(): Mesh;
  14607. /**
  14608. * Inverses facet orientations.
  14609. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14610. * @param flipNormals will also inverts the normals
  14611. * @returns current mesh
  14612. */
  14613. flipFaces(flipNormals?: boolean): Mesh;
  14614. /**
  14615. * Increase the number of facets and hence vertices in a mesh
  14616. * Vertex normals are interpolated from existing vertex normals
  14617. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14618. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14619. */
  14620. increaseVertices(numberPerEdge: number): void;
  14621. /**
  14622. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14623. * This will undo any application of covertToFlatShadedMesh
  14624. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14625. */
  14626. forceSharedVertices(): void;
  14627. /** @hidden */
  14628. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14629. /** @hidden */
  14630. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14631. /**
  14632. * Creates a new InstancedMesh object from the mesh model.
  14633. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14634. * @param name defines the name of the new instance
  14635. * @returns a new InstancedMesh
  14636. */
  14637. createInstance(name: string): InstancedMesh;
  14638. /**
  14639. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14640. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14641. * @returns the current mesh
  14642. */
  14643. synchronizeInstances(): Mesh;
  14644. /**
  14645. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14646. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14647. * This should be used together with the simplification to avoid disappearing triangles.
  14648. * @param successCallback an optional success callback to be called after the optimization finished.
  14649. * @returns the current mesh
  14650. */
  14651. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14652. /**
  14653. * Serialize current mesh
  14654. * @param serializationObject defines the object which will receive the serialization data
  14655. */
  14656. serialize(serializationObject: any): void;
  14657. /** @hidden */
  14658. _syncGeometryWithMorphTargetManager(): void;
  14659. /** @hidden */
  14660. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14661. /**
  14662. * Returns a new Mesh object parsed from the source provided.
  14663. * @param parsedMesh is the source
  14664. * @param scene defines the hosting scene
  14665. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14666. * @returns a new Mesh
  14667. */
  14668. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14669. /**
  14670. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14671. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14672. * @param name defines the name of the mesh to create
  14673. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14674. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14675. * @param closePath creates a seam between the first and the last points of each path of the path array
  14676. * @param offset is taken in account only if the `pathArray` is containing a single path
  14677. * @param scene defines the hosting scene
  14678. * @param updatable defines if the mesh must be flagged as updatable
  14679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14680. * @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)
  14681. * @returns a new Mesh
  14682. */
  14683. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14684. /**
  14685. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14686. * @param name defines the name of the mesh to create
  14687. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14688. * @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
  14689. * @param scene defines the hosting scene
  14690. * @param updatable defines if the mesh must be flagged as updatable
  14691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14692. * @returns a new Mesh
  14693. */
  14694. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14695. /**
  14696. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14697. * @param name defines the name of the mesh to create
  14698. * @param size sets the size (float) of each box side (default 1)
  14699. * @param scene defines the hosting scene
  14700. * @param updatable defines if the mesh must be flagged as updatable
  14701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14702. * @returns a new Mesh
  14703. */
  14704. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14705. /**
  14706. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14707. * @param name defines the name of the mesh to create
  14708. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14709. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14710. * @param scene defines the hosting scene
  14711. * @param updatable defines if the mesh must be flagged as updatable
  14712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14713. * @returns a new Mesh
  14714. */
  14715. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14716. /**
  14717. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14718. * @param name defines the name of the mesh to create
  14719. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14720. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14721. * @param scene defines the hosting scene
  14722. * @returns a new Mesh
  14723. */
  14724. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14725. /**
  14726. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14727. * @param name defines the name of the mesh to create
  14728. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14729. * @param diameterTop set the top cap diameter (floats, default 1)
  14730. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14731. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14732. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14733. * @param scene defines the hosting scene
  14734. * @param updatable defines if the mesh must be flagged as updatable
  14735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14736. * @returns a new Mesh
  14737. */
  14738. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14739. /**
  14740. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14741. * @param name defines the name of the mesh to create
  14742. * @param diameter sets the diameter size (float) of the torus (default 1)
  14743. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14744. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14745. * @param scene defines the hosting scene
  14746. * @param updatable defines if the mesh must be flagged as updatable
  14747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14748. * @returns a new Mesh
  14749. */
  14750. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14751. /**
  14752. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14753. * @param name defines the name of the mesh to create
  14754. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14755. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14756. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14757. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14758. * @param p the number of windings on X axis (positive integers, default 2)
  14759. * @param q the number of windings on Y axis (positive integers, default 3)
  14760. * @param scene defines the hosting scene
  14761. * @param updatable defines if the mesh must be flagged as updatable
  14762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14763. * @returns a new Mesh
  14764. */
  14765. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14766. /**
  14767. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14768. * @param name defines the name of the mesh to create
  14769. * @param points is an array successive Vector3
  14770. * @param scene defines the hosting scene
  14771. * @param updatable defines if the mesh must be flagged as updatable
  14772. * @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).
  14773. * @returns a new Mesh
  14774. */
  14775. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14776. /**
  14777. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14778. * @param name defines the name of the mesh to create
  14779. * @param points is an array successive Vector3
  14780. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14781. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14782. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14783. * @param scene defines the hosting scene
  14784. * @param updatable defines if the mesh must be flagged as updatable
  14785. * @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)
  14786. * @returns a new Mesh
  14787. */
  14788. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14789. /**
  14790. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14791. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14792. * 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.
  14793. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14794. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14795. * Remember you can only change the shape positions, not their number when updating a polygon.
  14796. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14797. * @param name defines the name of the mesh to create
  14798. * @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
  14799. * @param scene defines the hosting scene
  14800. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14801. * @param updatable defines if the mesh must be flagged as updatable
  14802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14803. * @param earcutInjection can be used to inject your own earcut reference
  14804. * @returns a new Mesh
  14805. */
  14806. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14807. /**
  14808. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14809. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14810. * @param name defines the name of the mesh to create
  14811. * @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
  14812. * @param depth defines the height of extrusion
  14813. * @param scene defines the hosting scene
  14814. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14815. * @param updatable defines if the mesh must be flagged as updatable
  14816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14817. * @param earcutInjection can be used to inject your own earcut reference
  14818. * @returns a new Mesh
  14819. */
  14820. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14821. /**
  14822. * Creates an extruded shape mesh.
  14823. * 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
  14824. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14825. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14826. * @param name defines the name of the mesh to create
  14827. * @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
  14828. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14829. * @param scale is the value to scale the shape
  14830. * @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
  14831. * @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
  14832. * @param scene defines the hosting scene
  14833. * @param updatable defines if the mesh must be flagged as updatable
  14834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14835. * @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)
  14836. * @returns a new Mesh
  14837. */
  14838. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14839. /**
  14840. * Creates an custom extruded shape mesh.
  14841. * The custom extrusion is a parametric shape.
  14842. * It has no predefined shape. Its final shape will depend on the input parameters.
  14843. * Please consider using the same method from the MeshBuilder class instead
  14844. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14845. * @param name defines the name of the mesh to create
  14846. * @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
  14847. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14848. * @param scaleFunction is a custom Javascript function called on each path point
  14849. * @param rotationFunction is a custom Javascript function called on each path point
  14850. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14851. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14852. * @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
  14853. * @param scene defines the hosting scene
  14854. * @param updatable defines if the mesh must be flagged as updatable
  14855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14856. * @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)
  14857. * @returns a new Mesh
  14858. */
  14859. 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;
  14860. /**
  14861. * Creates lathe mesh.
  14862. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14863. * Please consider using the same method from the MeshBuilder class instead
  14864. * @param name defines the name of the mesh to create
  14865. * @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
  14866. * @param radius is the radius value of the lathe
  14867. * @param tessellation is the side number of the lathe.
  14868. * @param scene defines the hosting scene
  14869. * @param updatable defines if the mesh must be flagged as updatable
  14870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14871. * @returns a new Mesh
  14872. */
  14873. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14874. /**
  14875. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14876. * @param name defines the name of the mesh to create
  14877. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14878. * @param scene defines the hosting scene
  14879. * @param updatable defines if the mesh must be flagged as updatable
  14880. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14881. * @returns a new Mesh
  14882. */
  14883. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14884. /**
  14885. * Creates a ground mesh.
  14886. * Please consider using the same method from the MeshBuilder class instead
  14887. * @param name defines the name of the mesh to create
  14888. * @param width set the width of the ground
  14889. * @param height set the height of the ground
  14890. * @param subdivisions sets the number of subdivisions per side
  14891. * @param scene defines the hosting scene
  14892. * @param updatable defines if the mesh must be flagged as updatable
  14893. * @returns a new Mesh
  14894. */
  14895. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14896. /**
  14897. * Creates a tiled ground mesh.
  14898. * Please consider using the same method from the MeshBuilder class instead
  14899. * @param name defines the name of the mesh to create
  14900. * @param xmin set the ground minimum X coordinate
  14901. * @param zmin set the ground minimum Y coordinate
  14902. * @param xmax set the ground maximum X coordinate
  14903. * @param zmax set the ground maximum Z coordinate
  14904. * @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
  14905. * @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
  14906. * @param scene defines the hosting scene
  14907. * @param updatable defines if the mesh must be flagged as updatable
  14908. * @returns a new Mesh
  14909. */
  14910. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14911. w: number;
  14912. h: number;
  14913. }, precision: {
  14914. w: number;
  14915. h: number;
  14916. }, scene: Scene, updatable?: boolean): Mesh;
  14917. /**
  14918. * Creates a ground mesh from a height map.
  14919. * Please consider using the same method from the MeshBuilder class instead
  14920. * @see http://doc.babylonjs.com/babylon101/height_map
  14921. * @param name defines the name of the mesh to create
  14922. * @param url sets the URL of the height map image resource
  14923. * @param width set the ground width size
  14924. * @param height set the ground height size
  14925. * @param subdivisions sets the number of subdivision per side
  14926. * @param minHeight is the minimum altitude on the ground
  14927. * @param maxHeight is the maximum altitude on the ground
  14928. * @param scene defines the hosting scene
  14929. * @param updatable defines if the mesh must be flagged as updatable
  14930. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14931. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14932. * @returns a new Mesh
  14933. */
  14934. 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;
  14935. /**
  14936. * Creates a tube mesh.
  14937. * The tube is a parametric shape.
  14938. * It has no predefined shape. Its final shape will depend on the input parameters.
  14939. * Please consider using the same method from the MeshBuilder class instead
  14940. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14941. * @param name defines the name of the mesh to create
  14942. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14943. * @param radius sets the tube radius size
  14944. * @param tessellation is the number of sides on the tubular surface
  14945. * @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
  14946. * @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
  14947. * @param scene defines the hosting scene
  14948. * @param updatable defines if the mesh must be flagged as updatable
  14949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14950. * @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)
  14951. * @returns a new Mesh
  14952. */
  14953. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14954. (i: number, distance: number): number;
  14955. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14956. /**
  14957. * Creates a polyhedron mesh.
  14958. * Please consider using the same method from the MeshBuilder class instead.
  14959. * * 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
  14960. * * The parameter `size` (positive float, default 1) sets the polygon size
  14961. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14962. * * 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`
  14963. * * 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
  14964. * * 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)`)
  14965. * * 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
  14966. * * 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
  14967. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14968. * * 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
  14969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14970. * @param name defines the name of the mesh to create
  14971. * @param options defines the options used to create the mesh
  14972. * @param scene defines the hosting scene
  14973. * @returns a new Mesh
  14974. */
  14975. static CreatePolyhedron(name: string, options: {
  14976. type?: number;
  14977. size?: number;
  14978. sizeX?: number;
  14979. sizeY?: number;
  14980. sizeZ?: number;
  14981. custom?: any;
  14982. faceUV?: Vector4[];
  14983. faceColors?: Color4[];
  14984. updatable?: boolean;
  14985. sideOrientation?: number;
  14986. }, scene: Scene): Mesh;
  14987. /**
  14988. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  14989. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  14990. * * 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`)
  14991. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  14992. * * 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
  14993. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14994. * * 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
  14995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14996. * @param name defines the name of the mesh
  14997. * @param options defines the options used to create the mesh
  14998. * @param scene defines the hosting scene
  14999. * @returns a new Mesh
  15000. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15001. */
  15002. static CreateIcoSphere(name: string, options: {
  15003. radius?: number;
  15004. flat?: boolean;
  15005. subdivisions?: number;
  15006. sideOrientation?: number;
  15007. updatable?: boolean;
  15008. }, scene: Scene): Mesh;
  15009. /**
  15010. * Creates a decal mesh.
  15011. * Please consider using the same method from the MeshBuilder class instead.
  15012. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15013. * @param name defines the name of the mesh
  15014. * @param sourceMesh defines the mesh receiving the decal
  15015. * @param position sets the position of the decal in world coordinates
  15016. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15017. * @param size sets the decal scaling
  15018. * @param angle sets the angle to rotate the decal
  15019. * @returns a new Mesh
  15020. */
  15021. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15022. /**
  15023. * Prepare internal position array for software CPU skinning
  15024. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15025. */
  15026. setPositionsForCPUSkinning(): Float32Array;
  15027. /**
  15028. * Prepare internal normal array for software CPU skinning
  15029. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15030. */
  15031. setNormalsForCPUSkinning(): Float32Array;
  15032. /**
  15033. * Updates the vertex buffer by applying transformation from the bones
  15034. * @param skeleton defines the skeleton to apply to current mesh
  15035. * @returns the current mesh
  15036. */
  15037. applySkeleton(skeleton: Skeleton): Mesh;
  15038. /**
  15039. * 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
  15040. * @param meshes defines the list of meshes to scan
  15041. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15042. */
  15043. static MinMax(meshes: AbstractMesh[]): {
  15044. min: Vector3;
  15045. max: Vector3;
  15046. };
  15047. /**
  15048. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15049. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15050. * @returns a vector3
  15051. */
  15052. static Center(meshesOrMinMaxVector: {
  15053. min: Vector3;
  15054. max: Vector3;
  15055. } | AbstractMesh[]): Vector3;
  15056. /**
  15057. * Merge the array of meshes into a single mesh for performance reasons.
  15058. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15059. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15060. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15061. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15062. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15063. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15064. * @returns a new mesh
  15065. */
  15066. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15067. /** @hidden */
  15068. addInstance(instance: InstancedMesh): void;
  15069. /** @hidden */
  15070. removeInstance(instance: InstancedMesh): void;
  15071. }
  15072. }
  15073. declare module BABYLON {
  15074. /**
  15075. * Interface used to define Action
  15076. */
  15077. export interface IAction {
  15078. /**
  15079. * Trigger for the action
  15080. */
  15081. trigger: number;
  15082. /** Options of the trigger */
  15083. triggerOptions: any;
  15084. /**
  15085. * Gets the trigger parameters
  15086. * @returns the trigger parameters
  15087. */
  15088. getTriggerParameter(): any;
  15089. /**
  15090. * Internal only - executes current action event
  15091. * @hidden
  15092. */
  15093. _executeCurrent(evt?: ActionEvent): void;
  15094. /**
  15095. * Serialize placeholder for child classes
  15096. * @param parent of child
  15097. * @returns the serialized object
  15098. */
  15099. serialize(parent: any): any;
  15100. /**
  15101. * Internal only
  15102. * @hidden
  15103. */
  15104. _prepare(): void;
  15105. /**
  15106. * Internal only - manager for action
  15107. * @hidden
  15108. */
  15109. _actionManager: AbstractActionManager;
  15110. /**
  15111. * Adds action to chain of actions, may be a DoNothingAction
  15112. * @param action defines the next action to execute
  15113. * @returns The action passed in
  15114. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15115. */
  15116. then(action: IAction): IAction;
  15117. }
  15118. /**
  15119. * The action to be carried out following a trigger
  15120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15121. */
  15122. export class Action implements IAction {
  15123. /** the trigger, with or without parameters, for the action */
  15124. triggerOptions: any;
  15125. /**
  15126. * Trigger for the action
  15127. */
  15128. trigger: number;
  15129. /**
  15130. * Internal only - manager for action
  15131. * @hidden
  15132. */
  15133. _actionManager: ActionManager;
  15134. private _nextActiveAction;
  15135. private _child;
  15136. private _condition?;
  15137. private _triggerParameter;
  15138. /**
  15139. * An event triggered prior to action being executed.
  15140. */
  15141. onBeforeExecuteObservable: Observable<Action>;
  15142. /**
  15143. * Creates a new Action
  15144. * @param triggerOptions the trigger, with or without parameters, for the action
  15145. * @param condition an optional determinant of action
  15146. */
  15147. constructor(
  15148. /** the trigger, with or without parameters, for the action */
  15149. triggerOptions: any, condition?: Condition);
  15150. /**
  15151. * Internal only
  15152. * @hidden
  15153. */
  15154. _prepare(): void;
  15155. /**
  15156. * Gets the trigger parameters
  15157. * @returns the trigger parameters
  15158. */
  15159. getTriggerParameter(): any;
  15160. /**
  15161. * Internal only - executes current action event
  15162. * @hidden
  15163. */
  15164. _executeCurrent(evt?: ActionEvent): void;
  15165. /**
  15166. * Execute placeholder for child classes
  15167. * @param evt optional action event
  15168. */
  15169. execute(evt?: ActionEvent): void;
  15170. /**
  15171. * Skips to next active action
  15172. */
  15173. skipToNextActiveAction(): void;
  15174. /**
  15175. * Adds action to chain of actions, may be a DoNothingAction
  15176. * @param action defines the next action to execute
  15177. * @returns The action passed in
  15178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15179. */
  15180. then(action: Action): Action;
  15181. /**
  15182. * Internal only
  15183. * @hidden
  15184. */
  15185. _getProperty(propertyPath: string): string;
  15186. /**
  15187. * Internal only
  15188. * @hidden
  15189. */
  15190. _getEffectiveTarget(target: any, propertyPath: string): any;
  15191. /**
  15192. * Serialize placeholder for child classes
  15193. * @param parent of child
  15194. * @returns the serialized object
  15195. */
  15196. serialize(parent: any): any;
  15197. /**
  15198. * Internal only called by serialize
  15199. * @hidden
  15200. */
  15201. protected _serialize(serializedAction: any, parent?: any): any;
  15202. /**
  15203. * Internal only
  15204. * @hidden
  15205. */
  15206. static _SerializeValueAsString: (value: any) => string;
  15207. /**
  15208. * Internal only
  15209. * @hidden
  15210. */
  15211. static _GetTargetProperty: (target: Scene | Node) => {
  15212. name: string;
  15213. targetType: string;
  15214. value: string;
  15215. };
  15216. }
  15217. }
  15218. declare module BABYLON {
  15219. /**
  15220. * A Condition applied to an Action
  15221. */
  15222. export class Condition {
  15223. /**
  15224. * Internal only - manager for action
  15225. * @hidden
  15226. */
  15227. _actionManager: ActionManager;
  15228. /**
  15229. * Internal only
  15230. * @hidden
  15231. */
  15232. _evaluationId: number;
  15233. /**
  15234. * Internal only
  15235. * @hidden
  15236. */
  15237. _currentResult: boolean;
  15238. /**
  15239. * Creates a new Condition
  15240. * @param actionManager the manager of the action the condition is applied to
  15241. */
  15242. constructor(actionManager: ActionManager);
  15243. /**
  15244. * Check if the current condition is valid
  15245. * @returns a boolean
  15246. */
  15247. isValid(): boolean;
  15248. /**
  15249. * Internal only
  15250. * @hidden
  15251. */
  15252. _getProperty(propertyPath: string): string;
  15253. /**
  15254. * Internal only
  15255. * @hidden
  15256. */
  15257. _getEffectiveTarget(target: any, propertyPath: string): any;
  15258. /**
  15259. * Serialize placeholder for child classes
  15260. * @returns the serialized object
  15261. */
  15262. serialize(): any;
  15263. /**
  15264. * Internal only
  15265. * @hidden
  15266. */
  15267. protected _serialize(serializedCondition: any): any;
  15268. }
  15269. /**
  15270. * Defines specific conditional operators as extensions of Condition
  15271. */
  15272. export class ValueCondition extends Condition {
  15273. /** path to specify the property of the target the conditional operator uses */
  15274. propertyPath: string;
  15275. /** the value compared by the conditional operator against the current value of the property */
  15276. value: any;
  15277. /** the conditional operator, default ValueCondition.IsEqual */
  15278. operator: number;
  15279. /**
  15280. * Internal only
  15281. * @hidden
  15282. */
  15283. private static _IsEqual;
  15284. /**
  15285. * Internal only
  15286. * @hidden
  15287. */
  15288. private static _IsDifferent;
  15289. /**
  15290. * Internal only
  15291. * @hidden
  15292. */
  15293. private static _IsGreater;
  15294. /**
  15295. * Internal only
  15296. * @hidden
  15297. */
  15298. private static _IsLesser;
  15299. /**
  15300. * returns the number for IsEqual
  15301. */
  15302. static readonly IsEqual: number;
  15303. /**
  15304. * Returns the number for IsDifferent
  15305. */
  15306. static readonly IsDifferent: number;
  15307. /**
  15308. * Returns the number for IsGreater
  15309. */
  15310. static readonly IsGreater: number;
  15311. /**
  15312. * Returns the number for IsLesser
  15313. */
  15314. static readonly IsLesser: number;
  15315. /**
  15316. * Internal only The action manager for the condition
  15317. * @hidden
  15318. */
  15319. _actionManager: ActionManager;
  15320. /**
  15321. * Internal only
  15322. * @hidden
  15323. */
  15324. private _target;
  15325. /**
  15326. * Internal only
  15327. * @hidden
  15328. */
  15329. private _effectiveTarget;
  15330. /**
  15331. * Internal only
  15332. * @hidden
  15333. */
  15334. private _property;
  15335. /**
  15336. * Creates a new ValueCondition
  15337. * @param actionManager manager for the action the condition applies to
  15338. * @param target for the action
  15339. * @param propertyPath path to specify the property of the target the conditional operator uses
  15340. * @param value the value compared by the conditional operator against the current value of the property
  15341. * @param operator the conditional operator, default ValueCondition.IsEqual
  15342. */
  15343. constructor(actionManager: ActionManager, target: any,
  15344. /** path to specify the property of the target the conditional operator uses */
  15345. propertyPath: string,
  15346. /** the value compared by the conditional operator against the current value of the property */
  15347. value: any,
  15348. /** the conditional operator, default ValueCondition.IsEqual */
  15349. operator?: number);
  15350. /**
  15351. * Compares the given value with the property value for the specified conditional operator
  15352. * @returns the result of the comparison
  15353. */
  15354. isValid(): boolean;
  15355. /**
  15356. * Serialize the ValueCondition into a JSON compatible object
  15357. * @returns serialization object
  15358. */
  15359. serialize(): any;
  15360. /**
  15361. * Gets the name of the conditional operator for the ValueCondition
  15362. * @param operator the conditional operator
  15363. * @returns the name
  15364. */
  15365. static GetOperatorName(operator: number): string;
  15366. }
  15367. /**
  15368. * Defines a predicate condition as an extension of Condition
  15369. */
  15370. export class PredicateCondition extends Condition {
  15371. /** defines the predicate function used to validate the condition */
  15372. predicate: () => boolean;
  15373. /**
  15374. * Internal only - manager for action
  15375. * @hidden
  15376. */
  15377. _actionManager: ActionManager;
  15378. /**
  15379. * Creates a new PredicateCondition
  15380. * @param actionManager manager for the action the condition applies to
  15381. * @param predicate defines the predicate function used to validate the condition
  15382. */
  15383. constructor(actionManager: ActionManager,
  15384. /** defines the predicate function used to validate the condition */
  15385. predicate: () => boolean);
  15386. /**
  15387. * @returns the validity of the predicate condition
  15388. */
  15389. isValid(): boolean;
  15390. }
  15391. /**
  15392. * Defines a state condition as an extension of Condition
  15393. */
  15394. export class StateCondition extends Condition {
  15395. /** Value to compare with target state */
  15396. value: string;
  15397. /**
  15398. * Internal only - manager for action
  15399. * @hidden
  15400. */
  15401. _actionManager: ActionManager;
  15402. /**
  15403. * Internal only
  15404. * @hidden
  15405. */
  15406. private _target;
  15407. /**
  15408. * Creates a new StateCondition
  15409. * @param actionManager manager for the action the condition applies to
  15410. * @param target of the condition
  15411. * @param value to compare with target state
  15412. */
  15413. constructor(actionManager: ActionManager, target: any,
  15414. /** Value to compare with target state */
  15415. value: string);
  15416. /**
  15417. * Gets a boolean indicating if the current condition is met
  15418. * @returns the validity of the state
  15419. */
  15420. isValid(): boolean;
  15421. /**
  15422. * Serialize the StateCondition into a JSON compatible object
  15423. * @returns serialization object
  15424. */
  15425. serialize(): any;
  15426. }
  15427. }
  15428. declare module BABYLON {
  15429. /**
  15430. * This defines an action responsible to toggle a boolean once triggered.
  15431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15432. */
  15433. export class SwitchBooleanAction extends Action {
  15434. /**
  15435. * The path to the boolean property in the target object
  15436. */
  15437. propertyPath: string;
  15438. private _target;
  15439. private _effectiveTarget;
  15440. private _property;
  15441. /**
  15442. * Instantiate the action
  15443. * @param triggerOptions defines the trigger options
  15444. * @param target defines the object containing the boolean
  15445. * @param propertyPath defines the path to the boolean property in the target object
  15446. * @param condition defines the trigger related conditions
  15447. */
  15448. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15449. /** @hidden */
  15450. _prepare(): void;
  15451. /**
  15452. * Execute the action toggle the boolean value.
  15453. */
  15454. execute(): void;
  15455. /**
  15456. * Serializes the actions and its related information.
  15457. * @param parent defines the object to serialize in
  15458. * @returns the serialized object
  15459. */
  15460. serialize(parent: any): any;
  15461. }
  15462. /**
  15463. * This defines an action responsible to set a the state field of the target
  15464. * to a desired value once triggered.
  15465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15466. */
  15467. export class SetStateAction extends Action {
  15468. /**
  15469. * The value to store in the state field.
  15470. */
  15471. value: string;
  15472. private _target;
  15473. /**
  15474. * Instantiate the action
  15475. * @param triggerOptions defines the trigger options
  15476. * @param target defines the object containing the state property
  15477. * @param value defines the value to store in the state field
  15478. * @param condition defines the trigger related conditions
  15479. */
  15480. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15481. /**
  15482. * Execute the action and store the value on the target state property.
  15483. */
  15484. execute(): void;
  15485. /**
  15486. * Serializes the actions and its related information.
  15487. * @param parent defines the object to serialize in
  15488. * @returns the serialized object
  15489. */
  15490. serialize(parent: any): any;
  15491. }
  15492. /**
  15493. * This defines an action responsible to set a property of the target
  15494. * to a desired value once triggered.
  15495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15496. */
  15497. export class SetValueAction extends Action {
  15498. /**
  15499. * The path of the property to set in the target.
  15500. */
  15501. propertyPath: string;
  15502. /**
  15503. * The value to set in the property
  15504. */
  15505. value: any;
  15506. private _target;
  15507. private _effectiveTarget;
  15508. private _property;
  15509. /**
  15510. * Instantiate the action
  15511. * @param triggerOptions defines the trigger options
  15512. * @param target defines the object containing the property
  15513. * @param propertyPath defines the path of the property to set in the target
  15514. * @param value defines the value to set in the property
  15515. * @param condition defines the trigger related conditions
  15516. */
  15517. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15518. /** @hidden */
  15519. _prepare(): void;
  15520. /**
  15521. * Execute the action and set the targetted property to the desired value.
  15522. */
  15523. execute(): void;
  15524. /**
  15525. * Serializes the actions and its related information.
  15526. * @param parent defines the object to serialize in
  15527. * @returns the serialized object
  15528. */
  15529. serialize(parent: any): any;
  15530. }
  15531. /**
  15532. * This defines an action responsible to increment the target value
  15533. * to a desired value once triggered.
  15534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15535. */
  15536. export class IncrementValueAction extends Action {
  15537. /**
  15538. * The path of the property to increment in the target.
  15539. */
  15540. propertyPath: string;
  15541. /**
  15542. * The value we should increment the property by.
  15543. */
  15544. value: any;
  15545. private _target;
  15546. private _effectiveTarget;
  15547. private _property;
  15548. /**
  15549. * Instantiate the action
  15550. * @param triggerOptions defines the trigger options
  15551. * @param target defines the object containing the property
  15552. * @param propertyPath defines the path of the property to increment in the target
  15553. * @param value defines the value value we should increment the property by
  15554. * @param condition defines the trigger related conditions
  15555. */
  15556. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15557. /** @hidden */
  15558. _prepare(): void;
  15559. /**
  15560. * Execute the action and increment the target of the value amount.
  15561. */
  15562. execute(): void;
  15563. /**
  15564. * Serializes the actions and its related information.
  15565. * @param parent defines the object to serialize in
  15566. * @returns the serialized object
  15567. */
  15568. serialize(parent: any): any;
  15569. }
  15570. /**
  15571. * This defines an action responsible to start an animation once triggered.
  15572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15573. */
  15574. export class PlayAnimationAction extends Action {
  15575. /**
  15576. * Where the animation should start (animation frame)
  15577. */
  15578. from: number;
  15579. /**
  15580. * Where the animation should stop (animation frame)
  15581. */
  15582. to: number;
  15583. /**
  15584. * Define if the animation should loop or stop after the first play.
  15585. */
  15586. loop?: boolean;
  15587. private _target;
  15588. /**
  15589. * Instantiate the action
  15590. * @param triggerOptions defines the trigger options
  15591. * @param target defines the target animation or animation name
  15592. * @param from defines from where the animation should start (animation frame)
  15593. * @param end defines where the animation should stop (animation frame)
  15594. * @param loop defines if the animation should loop or stop after the first play
  15595. * @param condition defines the trigger related conditions
  15596. */
  15597. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15598. /** @hidden */
  15599. _prepare(): void;
  15600. /**
  15601. * Execute the action and play the animation.
  15602. */
  15603. execute(): void;
  15604. /**
  15605. * Serializes the actions and its related information.
  15606. * @param parent defines the object to serialize in
  15607. * @returns the serialized object
  15608. */
  15609. serialize(parent: any): any;
  15610. }
  15611. /**
  15612. * This defines an action responsible to stop an animation once triggered.
  15613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15614. */
  15615. export class StopAnimationAction extends Action {
  15616. private _target;
  15617. /**
  15618. * Instantiate the action
  15619. * @param triggerOptions defines the trigger options
  15620. * @param target defines the target animation or animation name
  15621. * @param condition defines the trigger related conditions
  15622. */
  15623. constructor(triggerOptions: any, target: any, condition?: Condition);
  15624. /** @hidden */
  15625. _prepare(): void;
  15626. /**
  15627. * Execute the action and stop the animation.
  15628. */
  15629. execute(): void;
  15630. /**
  15631. * Serializes the actions and its related information.
  15632. * @param parent defines the object to serialize in
  15633. * @returns the serialized object
  15634. */
  15635. serialize(parent: any): any;
  15636. }
  15637. /**
  15638. * This defines an action responsible that does nothing once triggered.
  15639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15640. */
  15641. export class DoNothingAction extends Action {
  15642. /**
  15643. * Instantiate the action
  15644. * @param triggerOptions defines the trigger options
  15645. * @param condition defines the trigger related conditions
  15646. */
  15647. constructor(triggerOptions?: any, condition?: Condition);
  15648. /**
  15649. * Execute the action and do nothing.
  15650. */
  15651. execute(): void;
  15652. /**
  15653. * Serializes the actions and its related information.
  15654. * @param parent defines the object to serialize in
  15655. * @returns the serialized object
  15656. */
  15657. serialize(parent: any): any;
  15658. }
  15659. /**
  15660. * This defines an action responsible to trigger several actions once triggered.
  15661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15662. */
  15663. export class CombineAction extends Action {
  15664. /**
  15665. * The list of aggregated animations to run.
  15666. */
  15667. children: Action[];
  15668. /**
  15669. * Instantiate the action
  15670. * @param triggerOptions defines the trigger options
  15671. * @param children defines the list of aggregated animations to run
  15672. * @param condition defines the trigger related conditions
  15673. */
  15674. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15675. /** @hidden */
  15676. _prepare(): void;
  15677. /**
  15678. * Execute the action and executes all the aggregated actions.
  15679. */
  15680. execute(evt: ActionEvent): void;
  15681. /**
  15682. * Serializes the actions and its related information.
  15683. * @param parent defines the object to serialize in
  15684. * @returns the serialized object
  15685. */
  15686. serialize(parent: any): any;
  15687. }
  15688. /**
  15689. * This defines an action responsible to run code (external event) once triggered.
  15690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15691. */
  15692. export class ExecuteCodeAction extends Action {
  15693. /**
  15694. * The callback function to run.
  15695. */
  15696. func: (evt: ActionEvent) => void;
  15697. /**
  15698. * Instantiate the action
  15699. * @param triggerOptions defines the trigger options
  15700. * @param func defines the callback function to run
  15701. * @param condition defines the trigger related conditions
  15702. */
  15703. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15704. /**
  15705. * Execute the action and run the attached code.
  15706. */
  15707. execute(evt: ActionEvent): void;
  15708. }
  15709. /**
  15710. * This defines an action responsible to set the parent property of the target once triggered.
  15711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15712. */
  15713. export class SetParentAction extends Action {
  15714. private _parent;
  15715. private _target;
  15716. /**
  15717. * Instantiate the action
  15718. * @param triggerOptions defines the trigger options
  15719. * @param target defines the target containing the parent property
  15720. * @param parent defines from where the animation should start (animation frame)
  15721. * @param condition defines the trigger related conditions
  15722. */
  15723. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15724. /** @hidden */
  15725. _prepare(): void;
  15726. /**
  15727. * Execute the action and set the parent property.
  15728. */
  15729. execute(): void;
  15730. /**
  15731. * Serializes the actions and its related information.
  15732. * @param parent defines the object to serialize in
  15733. * @returns the serialized object
  15734. */
  15735. serialize(parent: any): any;
  15736. }
  15737. }
  15738. declare module BABYLON {
  15739. /**
  15740. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15741. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15743. */
  15744. export class ActionManager extends AbstractActionManager {
  15745. /**
  15746. * Nothing
  15747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15748. */
  15749. static readonly NothingTrigger: number;
  15750. /**
  15751. * On pick
  15752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15753. */
  15754. static readonly OnPickTrigger: number;
  15755. /**
  15756. * On left pick
  15757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15758. */
  15759. static readonly OnLeftPickTrigger: number;
  15760. /**
  15761. * On right pick
  15762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15763. */
  15764. static readonly OnRightPickTrigger: number;
  15765. /**
  15766. * On center pick
  15767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15768. */
  15769. static readonly OnCenterPickTrigger: number;
  15770. /**
  15771. * On pick down
  15772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15773. */
  15774. static readonly OnPickDownTrigger: number;
  15775. /**
  15776. * On double pick
  15777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15778. */
  15779. static readonly OnDoublePickTrigger: number;
  15780. /**
  15781. * On pick up
  15782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15783. */
  15784. static readonly OnPickUpTrigger: number;
  15785. /**
  15786. * On pick out.
  15787. * This trigger will only be raised if you also declared a OnPickDown
  15788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15789. */
  15790. static readonly OnPickOutTrigger: number;
  15791. /**
  15792. * On long press
  15793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15794. */
  15795. static readonly OnLongPressTrigger: number;
  15796. /**
  15797. * On pointer over
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15799. */
  15800. static readonly OnPointerOverTrigger: number;
  15801. /**
  15802. * On pointer out
  15803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15804. */
  15805. static readonly OnPointerOutTrigger: number;
  15806. /**
  15807. * On every frame
  15808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15809. */
  15810. static readonly OnEveryFrameTrigger: number;
  15811. /**
  15812. * On intersection enter
  15813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15814. */
  15815. static readonly OnIntersectionEnterTrigger: number;
  15816. /**
  15817. * On intersection exit
  15818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15819. */
  15820. static readonly OnIntersectionExitTrigger: number;
  15821. /**
  15822. * On key down
  15823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15824. */
  15825. static readonly OnKeyDownTrigger: number;
  15826. /**
  15827. * On key up
  15828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15829. */
  15830. static readonly OnKeyUpTrigger: number;
  15831. private _scene;
  15832. /**
  15833. * Creates a new action manager
  15834. * @param scene defines the hosting scene
  15835. */
  15836. constructor(scene: Scene);
  15837. /**
  15838. * Releases all associated resources
  15839. */
  15840. dispose(): void;
  15841. /**
  15842. * Gets hosting scene
  15843. * @returns the hosting scene
  15844. */
  15845. getScene(): Scene;
  15846. /**
  15847. * Does this action manager handles actions of any of the given triggers
  15848. * @param triggers defines the triggers to be tested
  15849. * @return a boolean indicating whether one (or more) of the triggers is handled
  15850. */
  15851. hasSpecificTriggers(triggers: number[]): boolean;
  15852. /**
  15853. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15854. * speed.
  15855. * @param triggerA defines the trigger to be tested
  15856. * @param triggerB defines the trigger to be tested
  15857. * @return a boolean indicating whether one (or more) of the triggers is handled
  15858. */
  15859. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15860. /**
  15861. * Does this action manager handles actions of a given trigger
  15862. * @param trigger defines the trigger to be tested
  15863. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15864. * @return whether the trigger is handled
  15865. */
  15866. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15867. /**
  15868. * Does this action manager has pointer triggers
  15869. */
  15870. readonly hasPointerTriggers: boolean;
  15871. /**
  15872. * Does this action manager has pick triggers
  15873. */
  15874. readonly hasPickTriggers: boolean;
  15875. /**
  15876. * Registers an action to this action manager
  15877. * @param action defines the action to be registered
  15878. * @return the action amended (prepared) after registration
  15879. */
  15880. registerAction(action: IAction): Nullable<IAction>;
  15881. /**
  15882. * Unregisters an action to this action manager
  15883. * @param action defines the action to be unregistered
  15884. * @return a boolean indicating whether the action has been unregistered
  15885. */
  15886. unregisterAction(action: IAction): Boolean;
  15887. /**
  15888. * Process a specific trigger
  15889. * @param trigger defines the trigger to process
  15890. * @param evt defines the event details to be processed
  15891. */
  15892. processTrigger(trigger: number, evt?: IActionEvent): void;
  15893. /** @hidden */
  15894. _getEffectiveTarget(target: any, propertyPath: string): any;
  15895. /** @hidden */
  15896. _getProperty(propertyPath: string): string;
  15897. /**
  15898. * Serialize this manager to a JSON object
  15899. * @param name defines the property name to store this manager
  15900. * @returns a JSON representation of this manager
  15901. */
  15902. serialize(name: string): any;
  15903. /**
  15904. * Creates a new ActionManager from a JSON data
  15905. * @param parsedActions defines the JSON data to read from
  15906. * @param object defines the hosting mesh
  15907. * @param scene defines the hosting scene
  15908. */
  15909. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15910. /**
  15911. * Get a trigger name by index
  15912. * @param trigger defines the trigger index
  15913. * @returns a trigger name
  15914. */
  15915. static GetTriggerName(trigger: number): string;
  15916. }
  15917. }
  15918. declare module BABYLON {
  15919. /**
  15920. * Class representing a ray with position and direction
  15921. */
  15922. export class Ray {
  15923. /** origin point */
  15924. origin: Vector3;
  15925. /** direction */
  15926. direction: Vector3;
  15927. /** length of the ray */
  15928. length: number;
  15929. private static readonly TmpVector3;
  15930. private _tmpRay;
  15931. /**
  15932. * Creates a new ray
  15933. * @param origin origin point
  15934. * @param direction direction
  15935. * @param length length of the ray
  15936. */
  15937. constructor(
  15938. /** origin point */
  15939. origin: Vector3,
  15940. /** direction */
  15941. direction: Vector3,
  15942. /** length of the ray */
  15943. length?: number);
  15944. /**
  15945. * Checks if the ray intersects a box
  15946. * @param minimum bound of the box
  15947. * @param maximum bound of the box
  15948. * @param intersectionTreshold extra extend to be added to the box in all direction
  15949. * @returns if the box was hit
  15950. */
  15951. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15952. /**
  15953. * Checks if the ray intersects a box
  15954. * @param box the bounding box to check
  15955. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15956. * @returns if the box was hit
  15957. */
  15958. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15959. /**
  15960. * If the ray hits a sphere
  15961. * @param sphere the bounding sphere to check
  15962. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15963. * @returns true if it hits the sphere
  15964. */
  15965. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15966. /**
  15967. * If the ray hits a triange
  15968. * @param vertex0 triangle vertex
  15969. * @param vertex1 triangle vertex
  15970. * @param vertex2 triangle vertex
  15971. * @returns intersection information if hit
  15972. */
  15973. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15974. /**
  15975. * Checks if ray intersects a plane
  15976. * @param plane the plane to check
  15977. * @returns the distance away it was hit
  15978. */
  15979. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  15980. /**
  15981. * Checks if ray intersects a mesh
  15982. * @param mesh the mesh to check
  15983. * @param fastCheck if only the bounding box should checked
  15984. * @returns picking info of the intersecton
  15985. */
  15986. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  15987. /**
  15988. * Checks if ray intersects a mesh
  15989. * @param meshes the meshes to check
  15990. * @param fastCheck if only the bounding box should checked
  15991. * @param results array to store result in
  15992. * @returns Array of picking infos
  15993. */
  15994. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  15995. private _comparePickingInfo;
  15996. private static smallnum;
  15997. private static rayl;
  15998. /**
  15999. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16000. * @param sega the first point of the segment to test the intersection against
  16001. * @param segb the second point of the segment to test the intersection against
  16002. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16003. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16004. */
  16005. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16006. /**
  16007. * Update the ray from viewport position
  16008. * @param x position
  16009. * @param y y position
  16010. * @param viewportWidth viewport width
  16011. * @param viewportHeight viewport height
  16012. * @param world world matrix
  16013. * @param view view matrix
  16014. * @param projection projection matrix
  16015. * @returns this ray updated
  16016. */
  16017. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16018. /**
  16019. * Creates a ray with origin and direction of 0,0,0
  16020. * @returns the new ray
  16021. */
  16022. static Zero(): Ray;
  16023. /**
  16024. * Creates a new ray from screen space and viewport
  16025. * @param x position
  16026. * @param y y position
  16027. * @param viewportWidth viewport width
  16028. * @param viewportHeight viewport height
  16029. * @param world world matrix
  16030. * @param view view matrix
  16031. * @param projection projection matrix
  16032. * @returns new ray
  16033. */
  16034. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16035. /**
  16036. * 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
  16037. * transformed to the given world matrix.
  16038. * @param origin The origin point
  16039. * @param end The end point
  16040. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16041. * @returns the new ray
  16042. */
  16043. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16044. /**
  16045. * Transforms a ray by a matrix
  16046. * @param ray ray to transform
  16047. * @param matrix matrix to apply
  16048. * @returns the resulting new ray
  16049. */
  16050. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16051. /**
  16052. * Transforms a ray by a matrix
  16053. * @param ray ray to transform
  16054. * @param matrix matrix to apply
  16055. * @param result ray to store result in
  16056. */
  16057. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16058. /**
  16059. * Unproject a ray from screen space to object space
  16060. * @param sourceX defines the screen space x coordinate to use
  16061. * @param sourceY defines the screen space y coordinate to use
  16062. * @param viewportWidth defines the current width of the viewport
  16063. * @param viewportHeight defines the current height of the viewport
  16064. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16065. * @param view defines the view matrix to use
  16066. * @param projection defines the projection matrix to use
  16067. */
  16068. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16069. }
  16070. /**
  16071. * Type used to define predicate used to select faces when a mesh intersection is detected
  16072. */
  16073. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16074. interface Scene {
  16075. /** @hidden */
  16076. _tempPickingRay: Nullable<Ray>;
  16077. /** @hidden */
  16078. _cachedRayForTransform: Ray;
  16079. /** @hidden */
  16080. _pickWithRayInverseMatrix: Matrix;
  16081. /** @hidden */
  16082. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16083. /** @hidden */
  16084. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16085. }
  16086. }
  16087. declare module BABYLON {
  16088. interface Scene {
  16089. /** @hidden */
  16090. _pointerOverSprite: Nullable<Sprite>;
  16091. /** @hidden */
  16092. _pickedDownSprite: Nullable<Sprite>;
  16093. /** @hidden */
  16094. _tempSpritePickingRay: Nullable<Ray>;
  16095. /**
  16096. * All of the sprite managers added to this scene
  16097. * @see http://doc.babylonjs.com/babylon101/sprites
  16098. */
  16099. spriteManagers: Array<ISpriteManager>;
  16100. /**
  16101. * An event triggered when sprites rendering is about to start
  16102. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16103. */
  16104. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16105. /**
  16106. * An event triggered when sprites rendering is done
  16107. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16108. */
  16109. onAfterSpritesRenderingObservable: Observable<Scene>;
  16110. /** @hidden */
  16111. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16112. /** Launch a ray to try to pick a sprite in the scene
  16113. * @param x position on screen
  16114. * @param y position on screen
  16115. * @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
  16116. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16117. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16118. * @returns a PickingInfo
  16119. */
  16120. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16121. /** Use the given ray to pick a sprite in the scene
  16122. * @param ray The ray (in world space) to use to pick meshes
  16123. * @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
  16124. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16126. * @returns a PickingInfo
  16127. */
  16128. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16129. /**
  16130. * Force the sprite under the pointer
  16131. * @param sprite defines the sprite to use
  16132. */
  16133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16134. /**
  16135. * Gets the sprite under the pointer
  16136. * @returns a Sprite or null if no sprite is under the pointer
  16137. */
  16138. getPointerOverSprite(): Nullable<Sprite>;
  16139. }
  16140. /**
  16141. * Defines the sprite scene component responsible to manage sprites
  16142. * in a given scene.
  16143. */
  16144. export class SpriteSceneComponent implements ISceneComponent {
  16145. /**
  16146. * The component name helpfull to identify the component in the list of scene components.
  16147. */
  16148. readonly name: string;
  16149. /**
  16150. * The scene the component belongs to.
  16151. */
  16152. scene: Scene;
  16153. /** @hidden */
  16154. private _spritePredicate;
  16155. /**
  16156. * Creates a new instance of the component for the given scene
  16157. * @param scene Defines the scene to register the component in
  16158. */
  16159. constructor(scene: Scene);
  16160. /**
  16161. * Registers the component in a given scene
  16162. */
  16163. register(): void;
  16164. /**
  16165. * Rebuilds the elements related to this component in case of
  16166. * context lost for instance.
  16167. */
  16168. rebuild(): void;
  16169. /**
  16170. * Disposes the component and the associated ressources.
  16171. */
  16172. dispose(): void;
  16173. private _pickSpriteButKeepRay;
  16174. private _pointerMove;
  16175. private _pointerDown;
  16176. private _pointerUp;
  16177. }
  16178. }
  16179. declare module BABYLON {
  16180. /** @hidden */
  16181. export var fogFragmentDeclaration: {
  16182. name: string;
  16183. shader: string;
  16184. };
  16185. }
  16186. declare module BABYLON {
  16187. /** @hidden */
  16188. export var fogFragment: {
  16189. name: string;
  16190. shader: string;
  16191. };
  16192. }
  16193. declare module BABYLON {
  16194. /** @hidden */
  16195. export var spritesPixelShader: {
  16196. name: string;
  16197. shader: string;
  16198. };
  16199. }
  16200. declare module BABYLON {
  16201. /** @hidden */
  16202. export var fogVertexDeclaration: {
  16203. name: string;
  16204. shader: string;
  16205. };
  16206. }
  16207. declare module BABYLON {
  16208. /** @hidden */
  16209. export var spritesVertexShader: {
  16210. name: string;
  16211. shader: string;
  16212. };
  16213. }
  16214. declare module BABYLON {
  16215. /**
  16216. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16217. */
  16218. export interface ISpriteManager extends IDisposable {
  16219. /**
  16220. * Restricts the camera to viewing objects with the same layerMask.
  16221. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16222. */
  16223. layerMask: number;
  16224. /**
  16225. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16226. */
  16227. isPickable: boolean;
  16228. /**
  16229. * Specifies the rendering group id for this mesh (0 by default)
  16230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16231. */
  16232. renderingGroupId: number;
  16233. /**
  16234. * Defines the list of sprites managed by the manager.
  16235. */
  16236. sprites: Array<Sprite>;
  16237. /**
  16238. * Tests the intersection of a sprite with a specific ray.
  16239. * @param ray The ray we are sending to test the collision
  16240. * @param camera The camera space we are sending rays in
  16241. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16242. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16243. * @returns picking info or null.
  16244. */
  16245. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16246. /**
  16247. * Renders the list of sprites on screen.
  16248. */
  16249. render(): void;
  16250. }
  16251. /**
  16252. * Class used to manage multiple sprites on the same spritesheet
  16253. * @see http://doc.babylonjs.com/babylon101/sprites
  16254. */
  16255. export class SpriteManager implements ISpriteManager {
  16256. /** defines the manager's name */
  16257. name: string;
  16258. /** Gets the list of sprites */
  16259. sprites: Sprite[];
  16260. /** Gets or sets the rendering group id (0 by default) */
  16261. renderingGroupId: number;
  16262. /** Gets or sets camera layer mask */
  16263. layerMask: number;
  16264. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16265. fogEnabled: boolean;
  16266. /** Gets or sets a boolean indicating if the sprites are pickable */
  16267. isPickable: boolean;
  16268. /** Defines the default width of a cell in the spritesheet */
  16269. cellWidth: number;
  16270. /** Defines the default height of a cell in the spritesheet */
  16271. cellHeight: number;
  16272. /**
  16273. * An event triggered when the manager is disposed.
  16274. */
  16275. onDisposeObservable: Observable<SpriteManager>;
  16276. private _onDisposeObserver;
  16277. /**
  16278. * Callback called when the manager is disposed
  16279. */
  16280. onDispose: () => void;
  16281. private _capacity;
  16282. private _spriteTexture;
  16283. private _epsilon;
  16284. private _scene;
  16285. private _vertexData;
  16286. private _buffer;
  16287. private _vertexBuffers;
  16288. private _indexBuffer;
  16289. private _effectBase;
  16290. private _effectFog;
  16291. /**
  16292. * Gets or sets the spritesheet texture
  16293. */
  16294. texture: Texture;
  16295. /**
  16296. * Creates a new sprite manager
  16297. * @param name defines the manager's name
  16298. * @param imgUrl defines the sprite sheet url
  16299. * @param capacity defines the maximum allowed number of sprites
  16300. * @param cellSize defines the size of a sprite cell
  16301. * @param scene defines the hosting scene
  16302. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16303. * @param samplingMode defines the smapling mode to use with spritesheet
  16304. */
  16305. constructor(
  16306. /** defines the manager's name */
  16307. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16308. private _appendSpriteVertex;
  16309. /**
  16310. * Intersects the sprites with a ray
  16311. * @param ray defines the ray to intersect with
  16312. * @param camera defines the current active camera
  16313. * @param predicate defines a predicate used to select candidate sprites
  16314. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16315. * @returns null if no hit or a PickingInfo
  16316. */
  16317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16318. /**
  16319. * Render all child sprites
  16320. */
  16321. render(): void;
  16322. /**
  16323. * Release associated resources
  16324. */
  16325. dispose(): void;
  16326. }
  16327. }
  16328. declare module BABYLON {
  16329. /**
  16330. * Class used to represent a sprite
  16331. * @see http://doc.babylonjs.com/babylon101/sprites
  16332. */
  16333. export class Sprite {
  16334. /** defines the name */
  16335. name: string;
  16336. /** Gets or sets the current world position */
  16337. position: Vector3;
  16338. /** Gets or sets the main color */
  16339. color: Color4;
  16340. /** Gets or sets the width */
  16341. width: number;
  16342. /** Gets or sets the height */
  16343. height: number;
  16344. /** Gets or sets rotation angle */
  16345. angle: number;
  16346. /** Gets or sets the cell index in the sprite sheet */
  16347. cellIndex: number;
  16348. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16349. invertU: number;
  16350. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16351. invertV: number;
  16352. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16353. disposeWhenFinishedAnimating: boolean;
  16354. /** Gets the list of attached animations */
  16355. animations: Animation[];
  16356. /** Gets or sets a boolean indicating if the sprite can be picked */
  16357. isPickable: boolean;
  16358. /**
  16359. * Gets or sets the associated action manager
  16360. */
  16361. actionManager: Nullable<ActionManager>;
  16362. private _animationStarted;
  16363. private _loopAnimation;
  16364. private _fromIndex;
  16365. private _toIndex;
  16366. private _delay;
  16367. private _direction;
  16368. private _manager;
  16369. private _time;
  16370. private _onAnimationEnd;
  16371. /**
  16372. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16373. */
  16374. isVisible: boolean;
  16375. /**
  16376. * Gets or sets the sprite size
  16377. */
  16378. size: number;
  16379. /**
  16380. * Creates a new Sprite
  16381. * @param name defines the name
  16382. * @param manager defines the manager
  16383. */
  16384. constructor(
  16385. /** defines the name */
  16386. name: string, manager: ISpriteManager);
  16387. /**
  16388. * Starts an animation
  16389. * @param from defines the initial key
  16390. * @param to defines the end key
  16391. * @param loop defines if the animation must loop
  16392. * @param delay defines the start delay (in ms)
  16393. * @param onAnimationEnd defines a callback to call when animation ends
  16394. */
  16395. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16396. /** Stops current animation (if any) */
  16397. stopAnimation(): void;
  16398. /** @hidden */
  16399. _animate(deltaTime: number): void;
  16400. /** Release associated resources */
  16401. dispose(): void;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. /**
  16406. * Information about the result of picking within a scene
  16407. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16408. */
  16409. export class PickingInfo {
  16410. /** @hidden */
  16411. _pickingUnavailable: boolean;
  16412. /**
  16413. * If the pick collided with an object
  16414. */
  16415. hit: boolean;
  16416. /**
  16417. * Distance away where the pick collided
  16418. */
  16419. distance: number;
  16420. /**
  16421. * The location of pick collision
  16422. */
  16423. pickedPoint: Nullable<Vector3>;
  16424. /**
  16425. * The mesh corresponding the the pick collision
  16426. */
  16427. pickedMesh: Nullable<AbstractMesh>;
  16428. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16429. bu: number;
  16430. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16431. bv: number;
  16432. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16433. faceId: number;
  16434. /** Id of the the submesh that was picked */
  16435. subMeshId: number;
  16436. /** If a sprite was picked, this will be the sprite the pick collided with */
  16437. pickedSprite: Nullable<Sprite>;
  16438. /**
  16439. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16440. */
  16441. originMesh: Nullable<AbstractMesh>;
  16442. /**
  16443. * The ray that was used to perform the picking.
  16444. */
  16445. ray: Nullable<Ray>;
  16446. /**
  16447. * Gets the normal correspodning to the face the pick collided with
  16448. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16449. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16450. * @returns The normal correspodning to the face the pick collided with
  16451. */
  16452. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16453. /**
  16454. * Gets the texture coordinates of where the pick occured
  16455. * @returns the vector containing the coordnates of the texture
  16456. */
  16457. getTextureCoordinates(): Nullable<Vector2>;
  16458. }
  16459. }
  16460. declare module BABYLON {
  16461. /**
  16462. * Gather the list of pointer event types as constants.
  16463. */
  16464. export class PointerEventTypes {
  16465. /**
  16466. * 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.
  16467. */
  16468. static readonly POINTERDOWN: number;
  16469. /**
  16470. * The pointerup event is fired when a pointer is no longer active.
  16471. */
  16472. static readonly POINTERUP: number;
  16473. /**
  16474. * The pointermove event is fired when a pointer changes coordinates.
  16475. */
  16476. static readonly POINTERMOVE: number;
  16477. /**
  16478. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16479. */
  16480. static readonly POINTERWHEEL: number;
  16481. /**
  16482. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16483. */
  16484. static readonly POINTERPICK: number;
  16485. /**
  16486. * The pointertap event is fired when a the object has been touched and released without drag.
  16487. */
  16488. static readonly POINTERTAP: number;
  16489. /**
  16490. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16491. */
  16492. static readonly POINTERDOUBLETAP: number;
  16493. }
  16494. /**
  16495. * Base class of pointer info types.
  16496. */
  16497. export class PointerInfoBase {
  16498. /**
  16499. * Defines the type of event (PointerEventTypes)
  16500. */
  16501. type: number;
  16502. /**
  16503. * Defines the related dom event
  16504. */
  16505. event: PointerEvent | MouseWheelEvent;
  16506. /**
  16507. * Instantiates the base class of pointers info.
  16508. * @param type Defines the type of event (PointerEventTypes)
  16509. * @param event Defines the related dom event
  16510. */
  16511. constructor(
  16512. /**
  16513. * Defines the type of event (PointerEventTypes)
  16514. */
  16515. type: number,
  16516. /**
  16517. * Defines the related dom event
  16518. */
  16519. event: PointerEvent | MouseWheelEvent);
  16520. }
  16521. /**
  16522. * This class is used to store pointer related info for the onPrePointerObservable event.
  16523. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16524. */
  16525. export class PointerInfoPre extends PointerInfoBase {
  16526. /**
  16527. * Ray from a pointer if availible (eg. 6dof controller)
  16528. */
  16529. ray: Nullable<Ray>;
  16530. /**
  16531. * Defines the local position of the pointer on the canvas.
  16532. */
  16533. localPosition: Vector2;
  16534. /**
  16535. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16536. */
  16537. skipOnPointerObservable: boolean;
  16538. /**
  16539. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16540. * @param type Defines the type of event (PointerEventTypes)
  16541. * @param event Defines the related dom event
  16542. * @param localX Defines the local x coordinates of the pointer when the event occured
  16543. * @param localY Defines the local y coordinates of the pointer when the event occured
  16544. */
  16545. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16546. }
  16547. /**
  16548. * This type contains all the data related to a pointer event in Babylon.js.
  16549. * 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.
  16550. */
  16551. export class PointerInfo extends PointerInfoBase {
  16552. /**
  16553. * Defines the picking info associated to the info (if any)\
  16554. */
  16555. pickInfo: Nullable<PickingInfo>;
  16556. /**
  16557. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16558. * @param type Defines the type of event (PointerEventTypes)
  16559. * @param event Defines the related dom event
  16560. * @param pickInfo Defines the picking info associated to the info (if any)\
  16561. */
  16562. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16563. /**
  16564. * Defines the picking info associated to the info (if any)\
  16565. */
  16566. pickInfo: Nullable<PickingInfo>);
  16567. }
  16568. /**
  16569. * Data relating to a touch event on the screen.
  16570. */
  16571. export interface PointerTouch {
  16572. /**
  16573. * X coordinate of touch.
  16574. */
  16575. x: number;
  16576. /**
  16577. * Y coordinate of touch.
  16578. */
  16579. y: number;
  16580. /**
  16581. * Id of touch. Unique for each finger.
  16582. */
  16583. pointerId: number;
  16584. /**
  16585. * Event type passed from DOM.
  16586. */
  16587. type: any;
  16588. }
  16589. }
  16590. declare module BABYLON {
  16591. /**
  16592. * Manage the mouse inputs to control the movement of a free camera.
  16593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16594. */
  16595. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16596. /**
  16597. * Define if touch is enabled in the mouse input
  16598. */
  16599. touchEnabled: boolean;
  16600. /**
  16601. * Defines the camera the input is attached to.
  16602. */
  16603. camera: FreeCamera;
  16604. /**
  16605. * Defines the buttons associated with the input to handle camera move.
  16606. */
  16607. buttons: number[];
  16608. /**
  16609. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16610. */
  16611. angularSensibility: number;
  16612. private _pointerInput;
  16613. private _onMouseMove;
  16614. private _observer;
  16615. private previousPosition;
  16616. /**
  16617. * Observable for when a pointer move event occurs containing the move offset
  16618. */
  16619. onPointerMovedObservable: Observable<{
  16620. offsetX: number;
  16621. offsetY: number;
  16622. }>;
  16623. /**
  16624. * @hidden
  16625. * If the camera should be rotated automatically based on pointer movement
  16626. */
  16627. _allowCameraRotation: boolean;
  16628. /**
  16629. * Manage the mouse inputs to control the movement of a free camera.
  16630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16631. * @param touchEnabled Defines if touch is enabled or not
  16632. */
  16633. constructor(
  16634. /**
  16635. * Define if touch is enabled in the mouse input
  16636. */
  16637. touchEnabled?: boolean);
  16638. /**
  16639. * Attach the input controls to a specific dom element to get the input from.
  16640. * @param element Defines the element the controls should be listened from
  16641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16642. */
  16643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16644. /**
  16645. * Called on JS contextmenu event.
  16646. * Override this method to provide functionality.
  16647. */
  16648. protected onContextMenu(evt: PointerEvent): void;
  16649. /**
  16650. * Detach the current controls from the specified dom element.
  16651. * @param element Defines the element to stop listening the inputs from
  16652. */
  16653. detachControl(element: Nullable<HTMLElement>): void;
  16654. /**
  16655. * Gets the class name of the current intput.
  16656. * @returns the class name
  16657. */
  16658. getClassName(): string;
  16659. /**
  16660. * Get the friendly name associated with the input class.
  16661. * @returns the input friendly name
  16662. */
  16663. getSimpleName(): string;
  16664. }
  16665. }
  16666. declare module BABYLON {
  16667. /**
  16668. * Manage the touch inputs to control the movement of a free camera.
  16669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16670. */
  16671. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16672. /**
  16673. * Defines the camera the input is attached to.
  16674. */
  16675. camera: FreeCamera;
  16676. /**
  16677. * Defines the touch sensibility for rotation.
  16678. * The higher the faster.
  16679. */
  16680. touchAngularSensibility: number;
  16681. /**
  16682. * Defines the touch sensibility for move.
  16683. * The higher the faster.
  16684. */
  16685. touchMoveSensibility: number;
  16686. private _offsetX;
  16687. private _offsetY;
  16688. private _pointerPressed;
  16689. private _pointerInput;
  16690. private _observer;
  16691. private _onLostFocus;
  16692. /**
  16693. * Attach the input controls to a specific dom element to get the input from.
  16694. * @param element Defines the element the controls should be listened from
  16695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16696. */
  16697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16698. /**
  16699. * Detach the current controls from the specified dom element.
  16700. * @param element Defines the element to stop listening the inputs from
  16701. */
  16702. detachControl(element: Nullable<HTMLElement>): void;
  16703. /**
  16704. * Update the current camera state depending on the inputs that have been used this frame.
  16705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16706. */
  16707. checkInputs(): void;
  16708. /**
  16709. * Gets the class name of the current intput.
  16710. * @returns the class name
  16711. */
  16712. getClassName(): string;
  16713. /**
  16714. * Get the friendly name associated with the input class.
  16715. * @returns the input friendly name
  16716. */
  16717. getSimpleName(): string;
  16718. }
  16719. }
  16720. declare module BABYLON {
  16721. /**
  16722. * Default Inputs manager for the FreeCamera.
  16723. * It groups all the default supported inputs for ease of use.
  16724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16725. */
  16726. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16727. /**
  16728. * @hidden
  16729. */
  16730. _mouseInput: Nullable<FreeCameraMouseInput>;
  16731. /**
  16732. * Instantiates a new FreeCameraInputsManager.
  16733. * @param camera Defines the camera the inputs belong to
  16734. */
  16735. constructor(camera: FreeCamera);
  16736. /**
  16737. * Add keyboard input support to the input manager.
  16738. * @returns the current input manager
  16739. */
  16740. addKeyboard(): FreeCameraInputsManager;
  16741. /**
  16742. * Add mouse input support to the input manager.
  16743. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16744. * @returns the current input manager
  16745. */
  16746. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16747. /**
  16748. * Removes the mouse input support from the manager
  16749. * @returns the current input manager
  16750. */
  16751. removeMouse(): FreeCameraInputsManager;
  16752. /**
  16753. * Add touch input support to the input manager.
  16754. * @returns the current input manager
  16755. */
  16756. addTouch(): FreeCameraInputsManager;
  16757. /**
  16758. * Remove all attached input methods from a camera
  16759. */
  16760. clear(): void;
  16761. }
  16762. }
  16763. declare module BABYLON {
  16764. /**
  16765. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16766. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16767. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16768. */
  16769. export class FreeCamera extends TargetCamera {
  16770. /**
  16771. * Define the collision ellipsoid of the camera.
  16772. * This is helpful to simulate a camera body like the player body around the camera
  16773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16774. */
  16775. ellipsoid: Vector3;
  16776. /**
  16777. * Define an offset for the position of the ellipsoid around the camera.
  16778. * This can be helpful to determine the center of the body near the gravity center of the body
  16779. * instead of its head.
  16780. */
  16781. ellipsoidOffset: Vector3;
  16782. /**
  16783. * Enable or disable collisions of the camera with the rest of the scene objects.
  16784. */
  16785. checkCollisions: boolean;
  16786. /**
  16787. * Enable or disable gravity on the camera.
  16788. */
  16789. applyGravity: boolean;
  16790. /**
  16791. * Define the input manager associated to the camera.
  16792. */
  16793. inputs: FreeCameraInputsManager;
  16794. /**
  16795. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16796. * Higher values reduce sensitivity.
  16797. */
  16798. /**
  16799. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16800. * Higher values reduce sensitivity.
  16801. */
  16802. angularSensibility: number;
  16803. /**
  16804. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16805. */
  16806. keysUp: number[];
  16807. /**
  16808. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16809. */
  16810. keysDown: number[];
  16811. /**
  16812. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16813. */
  16814. keysLeft: number[];
  16815. /**
  16816. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16817. */
  16818. keysRight: number[];
  16819. /**
  16820. * Event raised when the camera collide with a mesh in the scene.
  16821. */
  16822. onCollide: (collidedMesh: AbstractMesh) => void;
  16823. private _collider;
  16824. private _needMoveForGravity;
  16825. private _oldPosition;
  16826. private _diffPosition;
  16827. private _newPosition;
  16828. /** @hidden */
  16829. _localDirection: Vector3;
  16830. /** @hidden */
  16831. _transformedDirection: Vector3;
  16832. /**
  16833. * Instantiates a Free Camera.
  16834. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16835. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16836. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16837. * @param name Define the name of the camera in the scene
  16838. * @param position Define the start position of the camera in the scene
  16839. * @param scene Define the scene the camera belongs to
  16840. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16841. */
  16842. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16843. /**
  16844. * Attached controls to the current camera.
  16845. * @param element Defines the element the controls should be listened from
  16846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16847. */
  16848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16849. /**
  16850. * Detach the current controls from the camera.
  16851. * The camera will stop reacting to inputs.
  16852. * @param element Defines the element to stop listening the inputs from
  16853. */
  16854. detachControl(element: HTMLElement): void;
  16855. private _collisionMask;
  16856. /**
  16857. * Define a collision mask to limit the list of object the camera can collide with
  16858. */
  16859. collisionMask: number;
  16860. /** @hidden */
  16861. _collideWithWorld(displacement: Vector3): void;
  16862. private _onCollisionPositionChange;
  16863. /** @hidden */
  16864. _checkInputs(): void;
  16865. /** @hidden */
  16866. _decideIfNeedsToMove(): boolean;
  16867. /** @hidden */
  16868. _updatePosition(): void;
  16869. /**
  16870. * Destroy the camera and release the current resources hold by it.
  16871. */
  16872. dispose(): void;
  16873. /**
  16874. * Gets the current object class name.
  16875. * @return the class name
  16876. */
  16877. getClassName(): string;
  16878. }
  16879. }
  16880. declare module BABYLON {
  16881. /**
  16882. * Represents a gamepad control stick position
  16883. */
  16884. export class StickValues {
  16885. /**
  16886. * The x component of the control stick
  16887. */
  16888. x: number;
  16889. /**
  16890. * The y component of the control stick
  16891. */
  16892. y: number;
  16893. /**
  16894. * Initializes the gamepad x and y control stick values
  16895. * @param x The x component of the gamepad control stick value
  16896. * @param y The y component of the gamepad control stick value
  16897. */
  16898. constructor(
  16899. /**
  16900. * The x component of the control stick
  16901. */
  16902. x: number,
  16903. /**
  16904. * The y component of the control stick
  16905. */
  16906. y: number);
  16907. }
  16908. /**
  16909. * An interface which manages callbacks for gamepad button changes
  16910. */
  16911. export interface GamepadButtonChanges {
  16912. /**
  16913. * Called when a gamepad has been changed
  16914. */
  16915. changed: boolean;
  16916. /**
  16917. * Called when a gamepad press event has been triggered
  16918. */
  16919. pressChanged: boolean;
  16920. /**
  16921. * Called when a touch event has been triggered
  16922. */
  16923. touchChanged: boolean;
  16924. /**
  16925. * Called when a value has changed
  16926. */
  16927. valueChanged: boolean;
  16928. }
  16929. /**
  16930. * Represents a gamepad
  16931. */
  16932. export class Gamepad {
  16933. /**
  16934. * The id of the gamepad
  16935. */
  16936. id: string;
  16937. /**
  16938. * The index of the gamepad
  16939. */
  16940. index: number;
  16941. /**
  16942. * The browser gamepad
  16943. */
  16944. browserGamepad: any;
  16945. /**
  16946. * Specifies what type of gamepad this represents
  16947. */
  16948. type: number;
  16949. private _leftStick;
  16950. private _rightStick;
  16951. /** @hidden */
  16952. _isConnected: boolean;
  16953. private _leftStickAxisX;
  16954. private _leftStickAxisY;
  16955. private _rightStickAxisX;
  16956. private _rightStickAxisY;
  16957. /**
  16958. * Triggered when the left control stick has been changed
  16959. */
  16960. private _onleftstickchanged;
  16961. /**
  16962. * Triggered when the right control stick has been changed
  16963. */
  16964. private _onrightstickchanged;
  16965. /**
  16966. * Represents a gamepad controller
  16967. */
  16968. static GAMEPAD: number;
  16969. /**
  16970. * Represents a generic controller
  16971. */
  16972. static GENERIC: number;
  16973. /**
  16974. * Represents an XBox controller
  16975. */
  16976. static XBOX: number;
  16977. /**
  16978. * Represents a pose-enabled controller
  16979. */
  16980. static POSE_ENABLED: number;
  16981. /**
  16982. * Specifies whether the left control stick should be Y-inverted
  16983. */
  16984. protected _invertLeftStickY: boolean;
  16985. /**
  16986. * Specifies if the gamepad has been connected
  16987. */
  16988. readonly isConnected: boolean;
  16989. /**
  16990. * Initializes the gamepad
  16991. * @param id The id of the gamepad
  16992. * @param index The index of the gamepad
  16993. * @param browserGamepad The browser gamepad
  16994. * @param leftStickX The x component of the left joystick
  16995. * @param leftStickY The y component of the left joystick
  16996. * @param rightStickX The x component of the right joystick
  16997. * @param rightStickY The y component of the right joystick
  16998. */
  16999. constructor(
  17000. /**
  17001. * The id of the gamepad
  17002. */
  17003. id: string,
  17004. /**
  17005. * The index of the gamepad
  17006. */
  17007. index: number,
  17008. /**
  17009. * The browser gamepad
  17010. */
  17011. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17012. /**
  17013. * Callback triggered when the left joystick has changed
  17014. * @param callback
  17015. */
  17016. onleftstickchanged(callback: (values: StickValues) => void): void;
  17017. /**
  17018. * Callback triggered when the right joystick has changed
  17019. * @param callback
  17020. */
  17021. onrightstickchanged(callback: (values: StickValues) => void): void;
  17022. /**
  17023. * Gets the left joystick
  17024. */
  17025. /**
  17026. * Sets the left joystick values
  17027. */
  17028. leftStick: StickValues;
  17029. /**
  17030. * Gets the right joystick
  17031. */
  17032. /**
  17033. * Sets the right joystick value
  17034. */
  17035. rightStick: StickValues;
  17036. /**
  17037. * Updates the gamepad joystick positions
  17038. */
  17039. update(): void;
  17040. /**
  17041. * Disposes the gamepad
  17042. */
  17043. dispose(): void;
  17044. }
  17045. /**
  17046. * Represents a generic gamepad
  17047. */
  17048. export class GenericPad extends Gamepad {
  17049. private _buttons;
  17050. private _onbuttondown;
  17051. private _onbuttonup;
  17052. /**
  17053. * Observable triggered when a button has been pressed
  17054. */
  17055. onButtonDownObservable: Observable<number>;
  17056. /**
  17057. * Observable triggered when a button has been released
  17058. */
  17059. onButtonUpObservable: Observable<number>;
  17060. /**
  17061. * Callback triggered when a button has been pressed
  17062. * @param callback Called when a button has been pressed
  17063. */
  17064. onbuttondown(callback: (buttonPressed: number) => void): void;
  17065. /**
  17066. * Callback triggered when a button has been released
  17067. * @param callback Called when a button has been released
  17068. */
  17069. onbuttonup(callback: (buttonReleased: number) => void): void;
  17070. /**
  17071. * Initializes the generic gamepad
  17072. * @param id The id of the generic gamepad
  17073. * @param index The index of the generic gamepad
  17074. * @param browserGamepad The browser gamepad
  17075. */
  17076. constructor(id: string, index: number, browserGamepad: any);
  17077. private _setButtonValue;
  17078. /**
  17079. * Updates the generic gamepad
  17080. */
  17081. update(): void;
  17082. /**
  17083. * Disposes the generic gamepad
  17084. */
  17085. dispose(): void;
  17086. }
  17087. }
  17088. declare module BABYLON {
  17089. /**
  17090. * Defines the types of pose enabled controllers that are supported
  17091. */
  17092. export enum PoseEnabledControllerType {
  17093. /**
  17094. * HTC Vive
  17095. */
  17096. VIVE = 0,
  17097. /**
  17098. * Oculus Rift
  17099. */
  17100. OCULUS = 1,
  17101. /**
  17102. * Windows mixed reality
  17103. */
  17104. WINDOWS = 2,
  17105. /**
  17106. * Samsung gear VR
  17107. */
  17108. GEAR_VR = 3,
  17109. /**
  17110. * Google Daydream
  17111. */
  17112. DAYDREAM = 4,
  17113. /**
  17114. * Generic
  17115. */
  17116. GENERIC = 5
  17117. }
  17118. /**
  17119. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17120. */
  17121. export interface MutableGamepadButton {
  17122. /**
  17123. * Value of the button/trigger
  17124. */
  17125. value: number;
  17126. /**
  17127. * If the button/trigger is currently touched
  17128. */
  17129. touched: boolean;
  17130. /**
  17131. * If the button/trigger is currently pressed
  17132. */
  17133. pressed: boolean;
  17134. }
  17135. /**
  17136. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17137. * @hidden
  17138. */
  17139. export interface ExtendedGamepadButton extends GamepadButton {
  17140. /**
  17141. * If the button/trigger is currently pressed
  17142. */
  17143. readonly pressed: boolean;
  17144. /**
  17145. * If the button/trigger is currently touched
  17146. */
  17147. readonly touched: boolean;
  17148. /**
  17149. * Value of the button/trigger
  17150. */
  17151. readonly value: number;
  17152. }
  17153. /** @hidden */
  17154. export interface _GamePadFactory {
  17155. /**
  17156. * Returns wether or not the current gamepad can be created for this type of controller.
  17157. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17158. * @returns true if it can be created, otherwise false
  17159. */
  17160. canCreate(gamepadInfo: any): boolean;
  17161. /**
  17162. * Creates a new instance of the Gamepad.
  17163. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17164. * @returns the new gamepad instance
  17165. */
  17166. create(gamepadInfo: any): Gamepad;
  17167. }
  17168. /**
  17169. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17170. */
  17171. export class PoseEnabledControllerHelper {
  17172. /** @hidden */
  17173. static _ControllerFactories: _GamePadFactory[];
  17174. /** @hidden */
  17175. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17176. /**
  17177. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17178. * @param vrGamepad the gamepad to initialized
  17179. * @returns a vr controller of the type the gamepad identified as
  17180. */
  17181. static InitiateController(vrGamepad: any): Gamepad;
  17182. }
  17183. /**
  17184. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17185. */
  17186. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17187. private _deviceRoomPosition;
  17188. private _deviceRoomRotationQuaternion;
  17189. /**
  17190. * The device position in babylon space
  17191. */
  17192. devicePosition: Vector3;
  17193. /**
  17194. * The device rotation in babylon space
  17195. */
  17196. deviceRotationQuaternion: Quaternion;
  17197. /**
  17198. * The scale factor of the device in babylon space
  17199. */
  17200. deviceScaleFactor: number;
  17201. /**
  17202. * (Likely devicePosition should be used instead) The device position in its room space
  17203. */
  17204. position: Vector3;
  17205. /**
  17206. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17207. */
  17208. rotationQuaternion: Quaternion;
  17209. /**
  17210. * The type of controller (Eg. Windows mixed reality)
  17211. */
  17212. controllerType: PoseEnabledControllerType;
  17213. protected _calculatedPosition: Vector3;
  17214. private _calculatedRotation;
  17215. /**
  17216. * The raw pose from the device
  17217. */
  17218. rawPose: DevicePose;
  17219. private _trackPosition;
  17220. private _maxRotationDistFromHeadset;
  17221. private _draggedRoomRotation;
  17222. /**
  17223. * @hidden
  17224. */
  17225. _disableTrackPosition(fixedPosition: Vector3): void;
  17226. /**
  17227. * Internal, the mesh attached to the controller
  17228. * @hidden
  17229. */
  17230. _mesh: Nullable<AbstractMesh>;
  17231. private _poseControlledCamera;
  17232. private _leftHandSystemQuaternion;
  17233. /**
  17234. * Internal, matrix used to convert room space to babylon space
  17235. * @hidden
  17236. */
  17237. _deviceToWorld: Matrix;
  17238. /**
  17239. * Node to be used when casting a ray from the controller
  17240. * @hidden
  17241. */
  17242. _pointingPoseNode: Nullable<TransformNode>;
  17243. /**
  17244. * Name of the child mesh that can be used to cast a ray from the controller
  17245. */
  17246. static readonly POINTING_POSE: string;
  17247. /**
  17248. * Creates a new PoseEnabledController from a gamepad
  17249. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17250. */
  17251. constructor(browserGamepad: any);
  17252. private _workingMatrix;
  17253. /**
  17254. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17255. */
  17256. update(): void;
  17257. /**
  17258. * Updates only the pose device and mesh without doing any button event checking
  17259. */
  17260. protected _updatePoseAndMesh(): void;
  17261. /**
  17262. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17263. * @param poseData raw pose fromthe device
  17264. */
  17265. updateFromDevice(poseData: DevicePose): void;
  17266. /**
  17267. * @hidden
  17268. */
  17269. _meshAttachedObservable: Observable<AbstractMesh>;
  17270. /**
  17271. * Attaches a mesh to the controller
  17272. * @param mesh the mesh to be attached
  17273. */
  17274. attachToMesh(mesh: AbstractMesh): void;
  17275. /**
  17276. * Attaches the controllers mesh to a camera
  17277. * @param camera the camera the mesh should be attached to
  17278. */
  17279. attachToPoseControlledCamera(camera: TargetCamera): void;
  17280. /**
  17281. * Disposes of the controller
  17282. */
  17283. dispose(): void;
  17284. /**
  17285. * The mesh that is attached to the controller
  17286. */
  17287. readonly mesh: Nullable<AbstractMesh>;
  17288. /**
  17289. * Gets the ray of the controller in the direction the controller is pointing
  17290. * @param length the length the resulting ray should be
  17291. * @returns a ray in the direction the controller is pointing
  17292. */
  17293. getForwardRay(length?: number): Ray;
  17294. }
  17295. }
  17296. declare module BABYLON {
  17297. /**
  17298. * Defines the WebVRController object that represents controllers tracked in 3D space
  17299. */
  17300. export abstract class WebVRController extends PoseEnabledController {
  17301. /**
  17302. * Internal, the default controller model for the controller
  17303. */
  17304. protected _defaultModel: AbstractMesh;
  17305. /**
  17306. * Fired when the trigger state has changed
  17307. */
  17308. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17309. /**
  17310. * Fired when the main button state has changed
  17311. */
  17312. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17313. /**
  17314. * Fired when the secondary button state has changed
  17315. */
  17316. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17317. /**
  17318. * Fired when the pad state has changed
  17319. */
  17320. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17321. /**
  17322. * Fired when controllers stick values have changed
  17323. */
  17324. onPadValuesChangedObservable: Observable<StickValues>;
  17325. /**
  17326. * Array of button availible on the controller
  17327. */
  17328. protected _buttons: Array<MutableGamepadButton>;
  17329. private _onButtonStateChange;
  17330. /**
  17331. * Fired when a controller button's state has changed
  17332. * @param callback the callback containing the button that was modified
  17333. */
  17334. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17335. /**
  17336. * X and Y axis corresponding to the controllers joystick
  17337. */
  17338. pad: StickValues;
  17339. /**
  17340. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17341. */
  17342. hand: string;
  17343. /**
  17344. * The default controller model for the controller
  17345. */
  17346. readonly defaultModel: AbstractMesh;
  17347. /**
  17348. * Creates a new WebVRController from a gamepad
  17349. * @param vrGamepad the gamepad that the WebVRController should be created from
  17350. */
  17351. constructor(vrGamepad: any);
  17352. /**
  17353. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17354. */
  17355. update(): void;
  17356. /**
  17357. * Function to be called when a button is modified
  17358. */
  17359. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17360. /**
  17361. * Loads a mesh and attaches it to the controller
  17362. * @param scene the scene the mesh should be added to
  17363. * @param meshLoaded callback for when the mesh has been loaded
  17364. */
  17365. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17366. private _setButtonValue;
  17367. private _changes;
  17368. private _checkChanges;
  17369. /**
  17370. * Disposes of th webVRCOntroller
  17371. */
  17372. dispose(): void;
  17373. }
  17374. }
  17375. declare module BABYLON {
  17376. /**
  17377. * The HemisphericLight simulates the ambient environment light,
  17378. * so the passed direction is the light reflection direction, not the incoming direction.
  17379. */
  17380. export class HemisphericLight extends Light {
  17381. /**
  17382. * The groundColor is the light in the opposite direction to the one specified during creation.
  17383. * 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.
  17384. */
  17385. groundColor: Color3;
  17386. /**
  17387. * The light reflection direction, not the incoming direction.
  17388. */
  17389. direction: Vector3;
  17390. /**
  17391. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17392. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17393. * The HemisphericLight can't cast shadows.
  17394. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17395. * @param name The friendly name of the light
  17396. * @param direction The direction of the light reflection
  17397. * @param scene The scene the light belongs to
  17398. */
  17399. constructor(name: string, direction: Vector3, scene: Scene);
  17400. protected _buildUniformLayout(): void;
  17401. /**
  17402. * Returns the string "HemisphericLight".
  17403. * @return The class name
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17408. * Returns the updated direction.
  17409. * @param target The target the direction should point to
  17410. * @return The computed direction
  17411. */
  17412. setDirectionToTarget(target: Vector3): Vector3;
  17413. /**
  17414. * Returns the shadow generator associated to the light.
  17415. * @returns Always null for hemispheric lights because it does not support shadows.
  17416. */
  17417. getShadowGenerator(): Nullable<IShadowGenerator>;
  17418. /**
  17419. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17420. * @param effect The effect to update
  17421. * @param lightIndex The index of the light in the effect to update
  17422. * @returns The hemispheric light
  17423. */
  17424. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17425. /**
  17426. * Computes the world matrix of the node
  17427. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17428. * @param useWasUpdatedFlag defines a reserved property
  17429. * @returns the world matrix
  17430. */
  17431. computeWorldMatrix(): Matrix;
  17432. /**
  17433. * Returns the integer 3.
  17434. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17435. */
  17436. getTypeID(): number;
  17437. /**
  17438. * Prepares the list of defines specific to the light type.
  17439. * @param defines the list of defines
  17440. * @param lightIndex defines the index of the light for the effect
  17441. */
  17442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17443. }
  17444. }
  17445. declare module BABYLON {
  17446. /** @hidden */
  17447. export var vrMultiviewToSingleviewPixelShader: {
  17448. name: string;
  17449. shader: string;
  17450. };
  17451. }
  17452. declare module BABYLON {
  17453. /**
  17454. * Renders to multiple views with a single draw call
  17455. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17456. */
  17457. export class MultiviewRenderTarget extends RenderTargetTexture {
  17458. /**
  17459. * Creates a multiview render target
  17460. * @param scene scene used with the render target
  17461. * @param size the size of the render target (used for each view)
  17462. */
  17463. constructor(scene: Scene, size?: number | {
  17464. width: number;
  17465. height: number;
  17466. } | {
  17467. ratio: number;
  17468. });
  17469. /**
  17470. * @hidden
  17471. * @param faceIndex the face index, if its a cube texture
  17472. */
  17473. _bindFrameBuffer(faceIndex?: number): void;
  17474. /**
  17475. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17476. * @returns the view count
  17477. */
  17478. getViewCount(): number;
  17479. }
  17480. }
  17481. declare module BABYLON {
  17482. interface Engine {
  17483. /**
  17484. * Creates a new multiview render target
  17485. * @param width defines the width of the texture
  17486. * @param height defines the height of the texture
  17487. * @returns the created multiview texture
  17488. */
  17489. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17490. /**
  17491. * Binds a multiview framebuffer to be drawn to
  17492. * @param multiviewTexture texture to bind
  17493. */
  17494. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17495. }
  17496. interface Camera {
  17497. /**
  17498. * @hidden
  17499. * 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)
  17500. */
  17501. _useMultiviewToSingleView: boolean;
  17502. /**
  17503. * @hidden
  17504. * 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)
  17505. */
  17506. _multiviewTexture: Nullable<RenderTargetTexture>;
  17507. /**
  17508. * @hidden
  17509. * ensures the multiview texture of the camera exists and has the specified width/height
  17510. * @param width height to set on the multiview texture
  17511. * @param height width to set on the multiview texture
  17512. */
  17513. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17514. }
  17515. interface Scene {
  17516. /** @hidden */
  17517. _transformMatrixR: Matrix;
  17518. /** @hidden */
  17519. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17520. /** @hidden */
  17521. _createMultiviewUbo(): void;
  17522. /** @hidden */
  17523. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17524. /** @hidden */
  17525. _renderMultiviewToSingleView(camera: Camera): void;
  17526. }
  17527. }
  17528. declare module BABYLON {
  17529. /**
  17530. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17531. * This will not be used for webXR as it supports displaying texture arrays directly
  17532. */
  17533. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17534. /**
  17535. * Initializes a VRMultiviewToSingleview
  17536. * @param name name of the post process
  17537. * @param camera camera to be applied to
  17538. * @param scaleFactor scaling factor to the size of the output texture
  17539. */
  17540. constructor(name: string, camera: Camera, scaleFactor: number);
  17541. }
  17542. }
  17543. declare module BABYLON {
  17544. interface Engine {
  17545. /** @hidden */
  17546. _vrDisplay: any;
  17547. /** @hidden */
  17548. _vrSupported: boolean;
  17549. /** @hidden */
  17550. _oldSize: Size;
  17551. /** @hidden */
  17552. _oldHardwareScaleFactor: number;
  17553. /** @hidden */
  17554. _vrExclusivePointerMode: boolean;
  17555. /** @hidden */
  17556. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17557. /** @hidden */
  17558. _onVRDisplayPointerRestricted: () => void;
  17559. /** @hidden */
  17560. _onVRDisplayPointerUnrestricted: () => void;
  17561. /** @hidden */
  17562. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17563. /** @hidden */
  17564. _onVrDisplayDisconnect: Nullable<() => void>;
  17565. /** @hidden */
  17566. _onVrDisplayPresentChange: Nullable<() => void>;
  17567. /**
  17568. * Observable signaled when VR display mode changes
  17569. */
  17570. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17571. /**
  17572. * Observable signaled when VR request present is complete
  17573. */
  17574. onVRRequestPresentComplete: Observable<boolean>;
  17575. /**
  17576. * Observable signaled when VR request present starts
  17577. */
  17578. onVRRequestPresentStart: Observable<Engine>;
  17579. /**
  17580. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17581. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17582. */
  17583. isInVRExclusivePointerMode: boolean;
  17584. /**
  17585. * Gets a boolean indicating if a webVR device was detected
  17586. * @returns true if a webVR device was detected
  17587. */
  17588. isVRDevicePresent(): boolean;
  17589. /**
  17590. * Gets the current webVR device
  17591. * @returns the current webVR device (or null)
  17592. */
  17593. getVRDevice(): any;
  17594. /**
  17595. * Initializes a webVR display and starts listening to display change events
  17596. * The onVRDisplayChangedObservable will be notified upon these changes
  17597. * @returns A promise containing a VRDisplay and if vr is supported
  17598. */
  17599. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17600. /** @hidden */
  17601. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17602. /**
  17603. * Call this function to switch to webVR mode
  17604. * Will do nothing if webVR is not supported or if there is no webVR device
  17605. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17606. */
  17607. enableVR(): void;
  17608. /** @hidden */
  17609. _onVRFullScreenTriggered(): void;
  17610. }
  17611. }
  17612. declare module BABYLON {
  17613. /**
  17614. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17615. * IMPORTANT!! The data is right-hand data.
  17616. * @export
  17617. * @interface DevicePose
  17618. */
  17619. export interface DevicePose {
  17620. /**
  17621. * The position of the device, values in array are [x,y,z].
  17622. */
  17623. readonly position: Nullable<Float32Array>;
  17624. /**
  17625. * The linearVelocity of the device, values in array are [x,y,z].
  17626. */
  17627. readonly linearVelocity: Nullable<Float32Array>;
  17628. /**
  17629. * The linearAcceleration of the device, values in array are [x,y,z].
  17630. */
  17631. readonly linearAcceleration: Nullable<Float32Array>;
  17632. /**
  17633. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17634. */
  17635. readonly orientation: Nullable<Float32Array>;
  17636. /**
  17637. * The angularVelocity of the device, values in array are [x,y,z].
  17638. */
  17639. readonly angularVelocity: Nullable<Float32Array>;
  17640. /**
  17641. * The angularAcceleration of the device, values in array are [x,y,z].
  17642. */
  17643. readonly angularAcceleration: Nullable<Float32Array>;
  17644. }
  17645. /**
  17646. * Interface representing a pose controlled object in Babylon.
  17647. * A pose controlled object has both regular pose values as well as pose values
  17648. * from an external device such as a VR head mounted display
  17649. */
  17650. export interface PoseControlled {
  17651. /**
  17652. * The position of the object in babylon space.
  17653. */
  17654. position: Vector3;
  17655. /**
  17656. * The rotation quaternion of the object in babylon space.
  17657. */
  17658. rotationQuaternion: Quaternion;
  17659. /**
  17660. * The position of the device in babylon space.
  17661. */
  17662. devicePosition?: Vector3;
  17663. /**
  17664. * The rotation quaternion of the device in babylon space.
  17665. */
  17666. deviceRotationQuaternion: Quaternion;
  17667. /**
  17668. * The raw pose coming from the device.
  17669. */
  17670. rawPose: Nullable<DevicePose>;
  17671. /**
  17672. * The scale of the device to be used when translating from device space to babylon space.
  17673. */
  17674. deviceScaleFactor: number;
  17675. /**
  17676. * Updates the poseControlled values based on the input device pose.
  17677. * @param poseData the pose data to update the object with
  17678. */
  17679. updateFromDevice(poseData: DevicePose): void;
  17680. }
  17681. /**
  17682. * Set of options to customize the webVRCamera
  17683. */
  17684. export interface WebVROptions {
  17685. /**
  17686. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17687. */
  17688. trackPosition?: boolean;
  17689. /**
  17690. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17691. */
  17692. positionScale?: number;
  17693. /**
  17694. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17695. */
  17696. displayName?: string;
  17697. /**
  17698. * Should the native controller meshes be initialized. (default: true)
  17699. */
  17700. controllerMeshes?: boolean;
  17701. /**
  17702. * Creating a default HemiLight only on controllers. (default: true)
  17703. */
  17704. defaultLightingOnControllers?: boolean;
  17705. /**
  17706. * If you don't want to use the default VR button of the helper. (default: false)
  17707. */
  17708. useCustomVRButton?: boolean;
  17709. /**
  17710. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17711. */
  17712. customVRButton?: HTMLButtonElement;
  17713. /**
  17714. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17715. */
  17716. rayLength?: number;
  17717. /**
  17718. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17719. */
  17720. defaultHeight?: number;
  17721. /**
  17722. * If multiview should be used if availible (default: false)
  17723. */
  17724. useMultiview?: boolean;
  17725. }
  17726. /**
  17727. * This represents a WebVR camera.
  17728. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17729. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17730. */
  17731. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17732. private webVROptions;
  17733. /**
  17734. * @hidden
  17735. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17736. */
  17737. _vrDevice: any;
  17738. /**
  17739. * The rawPose of the vrDevice.
  17740. */
  17741. rawPose: Nullable<DevicePose>;
  17742. private _onVREnabled;
  17743. private _specsVersion;
  17744. private _attached;
  17745. private _frameData;
  17746. protected _descendants: Array<Node>;
  17747. private _deviceRoomPosition;
  17748. /** @hidden */
  17749. _deviceRoomRotationQuaternion: Quaternion;
  17750. private _standingMatrix;
  17751. /**
  17752. * Represents device position in babylon space.
  17753. */
  17754. devicePosition: Vector3;
  17755. /**
  17756. * Represents device rotation in babylon space.
  17757. */
  17758. deviceRotationQuaternion: Quaternion;
  17759. /**
  17760. * The scale of the device to be used when translating from device space to babylon space.
  17761. */
  17762. deviceScaleFactor: number;
  17763. private _deviceToWorld;
  17764. private _worldToDevice;
  17765. /**
  17766. * References to the webVR controllers for the vrDevice.
  17767. */
  17768. controllers: Array<WebVRController>;
  17769. /**
  17770. * Emits an event when a controller is attached.
  17771. */
  17772. onControllersAttachedObservable: Observable<WebVRController[]>;
  17773. /**
  17774. * Emits an event when a controller's mesh has been loaded;
  17775. */
  17776. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17777. /**
  17778. * Emits an event when the HMD's pose has been updated.
  17779. */
  17780. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17781. private _poseSet;
  17782. /**
  17783. * If the rig cameras be used as parent instead of this camera.
  17784. */
  17785. rigParenting: boolean;
  17786. private _lightOnControllers;
  17787. private _defaultHeight?;
  17788. /**
  17789. * Instantiates a WebVRFreeCamera.
  17790. * @param name The name of the WebVRFreeCamera
  17791. * @param position The starting anchor position for the camera
  17792. * @param scene The scene the camera belongs to
  17793. * @param webVROptions a set of customizable options for the webVRCamera
  17794. */
  17795. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17796. /**
  17797. * Gets the device distance from the ground in meters.
  17798. * @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.
  17799. */
  17800. deviceDistanceToRoomGround(): number;
  17801. /**
  17802. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17803. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17804. */
  17805. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17806. /**
  17807. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17808. * @returns A promise with a boolean set to if the standing matrix is supported.
  17809. */
  17810. useStandingMatrixAsync(): Promise<boolean>;
  17811. /**
  17812. * Disposes the camera
  17813. */
  17814. dispose(): void;
  17815. /**
  17816. * Gets a vrController by name.
  17817. * @param name The name of the controller to retreive
  17818. * @returns the controller matching the name specified or null if not found
  17819. */
  17820. getControllerByName(name: string): Nullable<WebVRController>;
  17821. private _leftController;
  17822. /**
  17823. * The controller corresponding to the users left hand.
  17824. */
  17825. readonly leftController: Nullable<WebVRController>;
  17826. private _rightController;
  17827. /**
  17828. * The controller corresponding to the users right hand.
  17829. */
  17830. readonly rightController: Nullable<WebVRController>;
  17831. /**
  17832. * Casts a ray forward from the vrCamera's gaze.
  17833. * @param length Length of the ray (default: 100)
  17834. * @returns the ray corresponding to the gaze
  17835. */
  17836. getForwardRay(length?: number): Ray;
  17837. /**
  17838. * @hidden
  17839. * Updates the camera based on device's frame data
  17840. */
  17841. _checkInputs(): void;
  17842. /**
  17843. * Updates the poseControlled values based on the input device pose.
  17844. * @param poseData Pose coming from the device
  17845. */
  17846. updateFromDevice(poseData: DevicePose): void;
  17847. private _htmlElementAttached;
  17848. private _detachIfAttached;
  17849. /**
  17850. * WebVR's attach control will start broadcasting frames to the device.
  17851. * Note that in certain browsers (chrome for example) this function must be called
  17852. * within a user-interaction callback. Example:
  17853. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17854. *
  17855. * @param element html element to attach the vrDevice to
  17856. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17857. */
  17858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17859. /**
  17860. * Detaches the camera from the html element and disables VR
  17861. *
  17862. * @param element html element to detach from
  17863. */
  17864. detachControl(element: HTMLElement): void;
  17865. /**
  17866. * @returns the name of this class
  17867. */
  17868. getClassName(): string;
  17869. /**
  17870. * Calls resetPose on the vrDisplay
  17871. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17872. */
  17873. resetToCurrentRotation(): void;
  17874. /**
  17875. * @hidden
  17876. * Updates the rig cameras (left and right eye)
  17877. */
  17878. _updateRigCameras(): void;
  17879. private _workingVector;
  17880. private _oneVector;
  17881. private _workingMatrix;
  17882. private updateCacheCalled;
  17883. private _correctPositionIfNotTrackPosition;
  17884. /**
  17885. * @hidden
  17886. * Updates the cached values of the camera
  17887. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17888. */
  17889. _updateCache(ignoreParentClass?: boolean): void;
  17890. /**
  17891. * @hidden
  17892. * Get current device position in babylon world
  17893. */
  17894. _computeDevicePosition(): void;
  17895. /**
  17896. * Updates the current device position and rotation in the babylon world
  17897. */
  17898. update(): void;
  17899. /**
  17900. * @hidden
  17901. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17902. * @returns an identity matrix
  17903. */
  17904. _getViewMatrix(): Matrix;
  17905. private _tmpMatrix;
  17906. /**
  17907. * This function is called by the two RIG cameras.
  17908. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17909. * @hidden
  17910. */
  17911. _getWebVRViewMatrix(): Matrix;
  17912. /** @hidden */
  17913. _getWebVRProjectionMatrix(): Matrix;
  17914. private _onGamepadConnectedObserver;
  17915. private _onGamepadDisconnectedObserver;
  17916. private _updateCacheWhenTrackingDisabledObserver;
  17917. /**
  17918. * Initializes the controllers and their meshes
  17919. */
  17920. initControllers(): void;
  17921. }
  17922. }
  17923. declare module BABYLON {
  17924. /**
  17925. * Size options for a post process
  17926. */
  17927. export type PostProcessOptions = {
  17928. width: number;
  17929. height: number;
  17930. };
  17931. /**
  17932. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17933. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17934. */
  17935. export class PostProcess {
  17936. /** Name of the PostProcess. */
  17937. name: string;
  17938. /**
  17939. * Gets or sets the unique id of the post process
  17940. */
  17941. uniqueId: number;
  17942. /**
  17943. * Width of the texture to apply the post process on
  17944. */
  17945. width: number;
  17946. /**
  17947. * Height of the texture to apply the post process on
  17948. */
  17949. height: number;
  17950. /**
  17951. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17952. * @hidden
  17953. */
  17954. _outputTexture: Nullable<InternalTexture>;
  17955. /**
  17956. * Sampling mode used by the shader
  17957. * See https://doc.babylonjs.com/classes/3.1/texture
  17958. */
  17959. renderTargetSamplingMode: number;
  17960. /**
  17961. * Clear color to use when screen clearing
  17962. */
  17963. clearColor: Color4;
  17964. /**
  17965. * If the buffer needs to be cleared before applying the post process. (default: true)
  17966. * Should be set to false if shader will overwrite all previous pixels.
  17967. */
  17968. autoClear: boolean;
  17969. /**
  17970. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  17971. */
  17972. alphaMode: number;
  17973. /**
  17974. * Sets the setAlphaBlendConstants of the babylon engine
  17975. */
  17976. alphaConstants: Color4;
  17977. /**
  17978. * Animations to be used for the post processing
  17979. */
  17980. animations: Animation[];
  17981. /**
  17982. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  17983. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  17984. */
  17985. enablePixelPerfectMode: boolean;
  17986. /**
  17987. * Force the postprocess to be applied without taking in account viewport
  17988. */
  17989. forceFullscreenViewport: boolean;
  17990. /**
  17991. * List of inspectable custom properties (used by the Inspector)
  17992. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17993. */
  17994. inspectableCustomProperties: IInspectable[];
  17995. /**
  17996. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  17997. *
  17998. * | Value | Type | Description |
  17999. * | ----- | ----------------------------------- | ----------- |
  18000. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18001. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18002. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18003. *
  18004. */
  18005. scaleMode: number;
  18006. /**
  18007. * Force textures to be a power of two (default: false)
  18008. */
  18009. alwaysForcePOT: boolean;
  18010. private _samples;
  18011. /**
  18012. * Number of sample textures (default: 1)
  18013. */
  18014. samples: number;
  18015. /**
  18016. * Modify the scale of the post process to be the same as the viewport (default: false)
  18017. */
  18018. adaptScaleToCurrentViewport: boolean;
  18019. private _camera;
  18020. private _scene;
  18021. private _engine;
  18022. private _options;
  18023. private _reusable;
  18024. private _textureType;
  18025. /**
  18026. * Smart array of input and output textures for the post process.
  18027. * @hidden
  18028. */
  18029. _textures: SmartArray<InternalTexture>;
  18030. /**
  18031. * The index in _textures that corresponds to the output texture.
  18032. * @hidden
  18033. */
  18034. _currentRenderTextureInd: number;
  18035. private _effect;
  18036. private _samplers;
  18037. private _fragmentUrl;
  18038. private _vertexUrl;
  18039. private _parameters;
  18040. private _scaleRatio;
  18041. protected _indexParameters: any;
  18042. private _shareOutputWithPostProcess;
  18043. private _texelSize;
  18044. private _forcedOutputTexture;
  18045. /**
  18046. * Returns the fragment url or shader name used in the post process.
  18047. * @returns the fragment url or name in the shader store.
  18048. */
  18049. getEffectName(): string;
  18050. /**
  18051. * An event triggered when the postprocess is activated.
  18052. */
  18053. onActivateObservable: Observable<Camera>;
  18054. private _onActivateObserver;
  18055. /**
  18056. * A function that is added to the onActivateObservable
  18057. */
  18058. onActivate: Nullable<(camera: Camera) => void>;
  18059. /**
  18060. * An event triggered when the postprocess changes its size.
  18061. */
  18062. onSizeChangedObservable: Observable<PostProcess>;
  18063. private _onSizeChangedObserver;
  18064. /**
  18065. * A function that is added to the onSizeChangedObservable
  18066. */
  18067. onSizeChanged: (postProcess: PostProcess) => void;
  18068. /**
  18069. * An event triggered when the postprocess applies its effect.
  18070. */
  18071. onApplyObservable: Observable<Effect>;
  18072. private _onApplyObserver;
  18073. /**
  18074. * A function that is added to the onApplyObservable
  18075. */
  18076. onApply: (effect: Effect) => void;
  18077. /**
  18078. * An event triggered before rendering the postprocess
  18079. */
  18080. onBeforeRenderObservable: Observable<Effect>;
  18081. private _onBeforeRenderObserver;
  18082. /**
  18083. * A function that is added to the onBeforeRenderObservable
  18084. */
  18085. onBeforeRender: (effect: Effect) => void;
  18086. /**
  18087. * An event triggered after rendering the postprocess
  18088. */
  18089. onAfterRenderObservable: Observable<Effect>;
  18090. private _onAfterRenderObserver;
  18091. /**
  18092. * A function that is added to the onAfterRenderObservable
  18093. */
  18094. onAfterRender: (efect: Effect) => void;
  18095. /**
  18096. * 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
  18097. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18098. */
  18099. inputTexture: InternalTexture;
  18100. /**
  18101. * Gets the camera which post process is applied to.
  18102. * @returns The camera the post process is applied to.
  18103. */
  18104. getCamera(): Camera;
  18105. /**
  18106. * Gets the texel size of the postprocess.
  18107. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18108. */
  18109. readonly texelSize: Vector2;
  18110. /**
  18111. * Creates a new instance PostProcess
  18112. * @param name The name of the PostProcess.
  18113. * @param fragmentUrl The url of the fragment shader to be used.
  18114. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18115. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18116. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18117. * @param camera The camera to apply the render pass to.
  18118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18119. * @param engine The engine which the post process will be applied. (default: current engine)
  18120. * @param reusable If the post process can be reused on the same frame. (default: false)
  18121. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18122. * @param textureType Type of textures used when performing the post process. (default: 0)
  18123. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18124. * @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
  18125. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18126. */
  18127. constructor(
  18128. /** Name of the PostProcess. */
  18129. 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);
  18130. /**
  18131. * Gets a string idenfifying the name of the class
  18132. * @returns "PostProcess" string
  18133. */
  18134. getClassName(): string;
  18135. /**
  18136. * Gets the engine which this post process belongs to.
  18137. * @returns The engine the post process was enabled with.
  18138. */
  18139. getEngine(): Engine;
  18140. /**
  18141. * The effect that is created when initializing the post process.
  18142. * @returns The created effect corresponding the the postprocess.
  18143. */
  18144. getEffect(): Effect;
  18145. /**
  18146. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18147. * @param postProcess The post process to share the output with.
  18148. * @returns This post process.
  18149. */
  18150. shareOutputWith(postProcess: PostProcess): PostProcess;
  18151. /**
  18152. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18153. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18154. */
  18155. useOwnOutput(): void;
  18156. /**
  18157. * Updates the effect with the current post process compile time values and recompiles the shader.
  18158. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18159. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18160. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18161. * @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
  18162. * @param onCompiled Called when the shader has been compiled.
  18163. * @param onError Called if there is an error when compiling a shader.
  18164. */
  18165. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18166. /**
  18167. * The post process is reusable if it can be used multiple times within one frame.
  18168. * @returns If the post process is reusable
  18169. */
  18170. isReusable(): boolean;
  18171. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18172. markTextureDirty(): void;
  18173. /**
  18174. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18175. * 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.
  18176. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18177. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18178. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18179. * @returns The target texture that was bound to be written to.
  18180. */
  18181. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18182. /**
  18183. * If the post process is supported.
  18184. */
  18185. readonly isSupported: boolean;
  18186. /**
  18187. * The aspect ratio of the output texture.
  18188. */
  18189. readonly aspectRatio: number;
  18190. /**
  18191. * Get a value indicating if the post-process is ready to be used
  18192. * @returns true if the post-process is ready (shader is compiled)
  18193. */
  18194. isReady(): boolean;
  18195. /**
  18196. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18197. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18198. */
  18199. apply(): Nullable<Effect>;
  18200. private _disposeTextures;
  18201. /**
  18202. * Disposes the post process.
  18203. * @param camera The camera to dispose the post process on.
  18204. */
  18205. dispose(camera?: Camera): void;
  18206. }
  18207. }
  18208. declare module BABYLON {
  18209. /** @hidden */
  18210. export var kernelBlurVaryingDeclaration: {
  18211. name: string;
  18212. shader: string;
  18213. };
  18214. }
  18215. declare module BABYLON {
  18216. /** @hidden */
  18217. export var kernelBlurFragment: {
  18218. name: string;
  18219. shader: string;
  18220. };
  18221. }
  18222. declare module BABYLON {
  18223. /** @hidden */
  18224. export var kernelBlurFragment2: {
  18225. name: string;
  18226. shader: string;
  18227. };
  18228. }
  18229. declare module BABYLON {
  18230. /** @hidden */
  18231. export var kernelBlurPixelShader: {
  18232. name: string;
  18233. shader: string;
  18234. };
  18235. }
  18236. declare module BABYLON {
  18237. /** @hidden */
  18238. export var kernelBlurVertex: {
  18239. name: string;
  18240. shader: string;
  18241. };
  18242. }
  18243. declare module BABYLON {
  18244. /** @hidden */
  18245. export var kernelBlurVertexShader: {
  18246. name: string;
  18247. shader: string;
  18248. };
  18249. }
  18250. declare module BABYLON {
  18251. /**
  18252. * The Blur Post Process which blurs an image based on a kernel and direction.
  18253. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18254. */
  18255. export class BlurPostProcess extends PostProcess {
  18256. /** The direction in which to blur the image. */
  18257. direction: Vector2;
  18258. private blockCompilation;
  18259. protected _kernel: number;
  18260. protected _idealKernel: number;
  18261. protected _packedFloat: boolean;
  18262. private _staticDefines;
  18263. /**
  18264. * Sets the length in pixels of the blur sample region
  18265. */
  18266. /**
  18267. * Gets the length in pixels of the blur sample region
  18268. */
  18269. kernel: number;
  18270. /**
  18271. * Sets wether or not the blur needs to unpack/repack floats
  18272. */
  18273. /**
  18274. * Gets wether or not the blur is unpacking/repacking floats
  18275. */
  18276. packedFloat: boolean;
  18277. /**
  18278. * Creates a new instance BlurPostProcess
  18279. * @param name The name of the effect.
  18280. * @param direction The direction in which to blur the image.
  18281. * @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.
  18282. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18283. * @param camera The camera to apply the render pass to.
  18284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18285. * @param engine The engine which the post process will be applied. (default: current engine)
  18286. * @param reusable If the post process can be reused on the same frame. (default: false)
  18287. * @param textureType Type of textures used when performing the post process. (default: 0)
  18288. * @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)
  18289. */
  18290. constructor(name: string,
  18291. /** The direction in which to blur the image. */
  18292. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18293. /**
  18294. * Updates the effect with the current post process compile time values and recompiles the shader.
  18295. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18296. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18297. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18298. * @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
  18299. * @param onCompiled Called when the shader has been compiled.
  18300. * @param onError Called if there is an error when compiling a shader.
  18301. */
  18302. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18303. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18304. /**
  18305. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18306. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18307. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18308. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18309. * The gaps between physical kernels are compensated for in the weighting of the samples
  18310. * @param idealKernel Ideal blur kernel.
  18311. * @return Nearest best kernel.
  18312. */
  18313. protected _nearestBestKernel(idealKernel: number): number;
  18314. /**
  18315. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18316. * @param x The point on the Gaussian distribution to sample.
  18317. * @return the value of the Gaussian function at x.
  18318. */
  18319. protected _gaussianWeight(x: number): number;
  18320. /**
  18321. * Generates a string that can be used as a floating point number in GLSL.
  18322. * @param x Value to print.
  18323. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18324. * @return GLSL float string.
  18325. */
  18326. protected _glslFloat(x: number, decimalFigures?: number): string;
  18327. }
  18328. }
  18329. declare module BABYLON {
  18330. /**
  18331. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18332. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18333. * You can then easily use it as a reflectionTexture on a flat surface.
  18334. * In case the surface is not a plane, please consider relying on reflection probes.
  18335. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18336. */
  18337. export class MirrorTexture extends RenderTargetTexture {
  18338. private scene;
  18339. /**
  18340. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18341. * 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.
  18342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18343. */
  18344. mirrorPlane: Plane;
  18345. /**
  18346. * Define the blur ratio used to blur the reflection if needed.
  18347. */
  18348. blurRatio: number;
  18349. /**
  18350. * Define the adaptive blur kernel used to blur the reflection if needed.
  18351. * This will autocompute the closest best match for the `blurKernel`
  18352. */
  18353. adaptiveBlurKernel: number;
  18354. /**
  18355. * Define the blur kernel used to blur the reflection if needed.
  18356. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18357. */
  18358. blurKernel: number;
  18359. /**
  18360. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18361. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18362. */
  18363. blurKernelX: number;
  18364. /**
  18365. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18366. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18367. */
  18368. blurKernelY: number;
  18369. private _autoComputeBlurKernel;
  18370. protected _onRatioRescale(): void;
  18371. private _updateGammaSpace;
  18372. private _imageProcessingConfigChangeObserver;
  18373. private _transformMatrix;
  18374. private _mirrorMatrix;
  18375. private _savedViewMatrix;
  18376. private _blurX;
  18377. private _blurY;
  18378. private _adaptiveBlurKernel;
  18379. private _blurKernelX;
  18380. private _blurKernelY;
  18381. private _blurRatio;
  18382. /**
  18383. * Instantiates a Mirror Texture.
  18384. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18385. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18386. * You can then easily use it as a reflectionTexture on a flat surface.
  18387. * In case the surface is not a plane, please consider relying on reflection probes.
  18388. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18389. * @param name
  18390. * @param size
  18391. * @param scene
  18392. * @param generateMipMaps
  18393. * @param type
  18394. * @param samplingMode
  18395. * @param generateDepthBuffer
  18396. */
  18397. constructor(name: string, size: number | {
  18398. width: number;
  18399. height: number;
  18400. } | {
  18401. ratio: number;
  18402. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18403. private _preparePostProcesses;
  18404. /**
  18405. * Clone the mirror texture.
  18406. * @returns the cloned texture
  18407. */
  18408. clone(): MirrorTexture;
  18409. /**
  18410. * Serialize the texture to a JSON representation you could use in Parse later on
  18411. * @returns the serialized JSON representation
  18412. */
  18413. serialize(): any;
  18414. /**
  18415. * Dispose the texture and release its associated resources.
  18416. */
  18417. dispose(): void;
  18418. }
  18419. }
  18420. declare module BABYLON {
  18421. /**
  18422. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18423. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18424. */
  18425. export class Texture extends BaseTexture {
  18426. /** @hidden */
  18427. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18428. /** @hidden */
  18429. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18430. /** @hidden */
  18431. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18432. /** nearest is mag = nearest and min = nearest and mip = linear */
  18433. static readonly NEAREST_SAMPLINGMODE: number;
  18434. /** nearest is mag = nearest and min = nearest and mip = linear */
  18435. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18436. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18437. static readonly BILINEAR_SAMPLINGMODE: number;
  18438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18439. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18440. /** Trilinear is mag = linear and min = linear and mip = linear */
  18441. static readonly TRILINEAR_SAMPLINGMODE: number;
  18442. /** Trilinear is mag = linear and min = linear and mip = linear */
  18443. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18444. /** mag = nearest and min = nearest and mip = nearest */
  18445. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18446. /** mag = nearest and min = linear and mip = nearest */
  18447. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18448. /** mag = nearest and min = linear and mip = linear */
  18449. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18450. /** mag = nearest and min = linear and mip = none */
  18451. static readonly NEAREST_LINEAR: number;
  18452. /** mag = nearest and min = nearest and mip = none */
  18453. static readonly NEAREST_NEAREST: number;
  18454. /** mag = linear and min = nearest and mip = nearest */
  18455. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18456. /** mag = linear and min = nearest and mip = linear */
  18457. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18458. /** mag = linear and min = linear and mip = none */
  18459. static readonly LINEAR_LINEAR: number;
  18460. /** mag = linear and min = nearest and mip = none */
  18461. static readonly LINEAR_NEAREST: number;
  18462. /** Explicit coordinates mode */
  18463. static readonly EXPLICIT_MODE: number;
  18464. /** Spherical coordinates mode */
  18465. static readonly SPHERICAL_MODE: number;
  18466. /** Planar coordinates mode */
  18467. static readonly PLANAR_MODE: number;
  18468. /** Cubic coordinates mode */
  18469. static readonly CUBIC_MODE: number;
  18470. /** Projection coordinates mode */
  18471. static readonly PROJECTION_MODE: number;
  18472. /** Inverse Cubic coordinates mode */
  18473. static readonly SKYBOX_MODE: number;
  18474. /** Inverse Cubic coordinates mode */
  18475. static readonly INVCUBIC_MODE: number;
  18476. /** Equirectangular coordinates mode */
  18477. static readonly EQUIRECTANGULAR_MODE: number;
  18478. /** Equirectangular Fixed coordinates mode */
  18479. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18480. /** Equirectangular Fixed Mirrored coordinates mode */
  18481. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18482. /** Texture is not repeating outside of 0..1 UVs */
  18483. static readonly CLAMP_ADDRESSMODE: number;
  18484. /** Texture is repeating outside of 0..1 UVs */
  18485. static readonly WRAP_ADDRESSMODE: number;
  18486. /** Texture is repeating and mirrored */
  18487. static readonly MIRROR_ADDRESSMODE: number;
  18488. /**
  18489. * 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
  18490. */
  18491. static UseSerializedUrlIfAny: boolean;
  18492. /**
  18493. * Define the url of the texture.
  18494. */
  18495. url: Nullable<string>;
  18496. /**
  18497. * Define an offset on the texture to offset the u coordinates of the UVs
  18498. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18499. */
  18500. uOffset: number;
  18501. /**
  18502. * Define an offset on the texture to offset the v coordinates of the UVs
  18503. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18504. */
  18505. vOffset: number;
  18506. /**
  18507. * Define an offset on the texture to scale the u coordinates of the UVs
  18508. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18509. */
  18510. uScale: number;
  18511. /**
  18512. * Define an offset on the texture to scale the v coordinates of the UVs
  18513. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18514. */
  18515. vScale: number;
  18516. /**
  18517. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18518. * @see http://doc.babylonjs.com/how_to/more_materials
  18519. */
  18520. uAng: number;
  18521. /**
  18522. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18523. * @see http://doc.babylonjs.com/how_to/more_materials
  18524. */
  18525. vAng: number;
  18526. /**
  18527. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18528. * @see http://doc.babylonjs.com/how_to/more_materials
  18529. */
  18530. wAng: number;
  18531. /**
  18532. * Defines the center of rotation (U)
  18533. */
  18534. uRotationCenter: number;
  18535. /**
  18536. * Defines the center of rotation (V)
  18537. */
  18538. vRotationCenter: number;
  18539. /**
  18540. * Defines the center of rotation (W)
  18541. */
  18542. wRotationCenter: number;
  18543. /**
  18544. * Are mip maps generated for this texture or not.
  18545. */
  18546. readonly noMipmap: boolean;
  18547. /**
  18548. * List of inspectable custom properties (used by the Inspector)
  18549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18550. */
  18551. inspectableCustomProperties: Nullable<IInspectable[]>;
  18552. private _noMipmap;
  18553. /** @hidden */
  18554. _invertY: boolean;
  18555. private _rowGenerationMatrix;
  18556. private _cachedTextureMatrix;
  18557. private _projectionModeMatrix;
  18558. private _t0;
  18559. private _t1;
  18560. private _t2;
  18561. private _cachedUOffset;
  18562. private _cachedVOffset;
  18563. private _cachedUScale;
  18564. private _cachedVScale;
  18565. private _cachedUAng;
  18566. private _cachedVAng;
  18567. private _cachedWAng;
  18568. private _cachedProjectionMatrixId;
  18569. private _cachedCoordinatesMode;
  18570. /** @hidden */
  18571. protected _initialSamplingMode: number;
  18572. /** @hidden */
  18573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18574. private _deleteBuffer;
  18575. protected _format: Nullable<number>;
  18576. private _delayedOnLoad;
  18577. private _delayedOnError;
  18578. /**
  18579. * Observable triggered once the texture has been loaded.
  18580. */
  18581. onLoadObservable: Observable<Texture>;
  18582. protected _isBlocking: boolean;
  18583. /**
  18584. * Is the texture preventing material to render while loading.
  18585. * If false, a default texture will be used instead of the loading one during the preparation step.
  18586. */
  18587. isBlocking: boolean;
  18588. /**
  18589. * Get the current sampling mode associated with the texture.
  18590. */
  18591. readonly samplingMode: number;
  18592. /**
  18593. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18594. */
  18595. readonly invertY: boolean;
  18596. /**
  18597. * Instantiates a new texture.
  18598. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18599. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18600. * @param url define the url of the picture to load as a texture
  18601. * @param scene define the scene the texture will belong to
  18602. * @param noMipmap define if the texture will require mip maps or not
  18603. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18604. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18605. * @param onLoad define a callback triggered when the texture has been loaded
  18606. * @param onError define a callback triggered when an error occurred during the loading session
  18607. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18608. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18609. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18610. */
  18611. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18612. /**
  18613. * Update the url (and optional buffer) of this texture if url was null during construction.
  18614. * @param url the url of the texture
  18615. * @param buffer the buffer of the texture (defaults to null)
  18616. * @param onLoad callback called when the texture is loaded (defaults to null)
  18617. */
  18618. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18619. /**
  18620. * Finish the loading sequence of a texture flagged as delayed load.
  18621. * @hidden
  18622. */
  18623. delayLoad(): void;
  18624. private _prepareRowForTextureGeneration;
  18625. /**
  18626. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18627. * @returns the transform matrix of the texture.
  18628. */
  18629. getTextureMatrix(): Matrix;
  18630. /**
  18631. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18632. * @returns The reflection texture transform
  18633. */
  18634. getReflectionTextureMatrix(): Matrix;
  18635. /**
  18636. * Clones the texture.
  18637. * @returns the cloned texture
  18638. */
  18639. clone(): Texture;
  18640. /**
  18641. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18642. * @returns The JSON representation of the texture
  18643. */
  18644. serialize(): any;
  18645. /**
  18646. * Get the current class name of the texture useful for serialization or dynamic coding.
  18647. * @returns "Texture"
  18648. */
  18649. getClassName(): string;
  18650. /**
  18651. * Dispose the texture and release its associated resources.
  18652. */
  18653. dispose(): void;
  18654. /**
  18655. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18656. * @param parsedTexture Define the JSON representation of the texture
  18657. * @param scene Define the scene the parsed texture should be instantiated in
  18658. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18659. * @returns The parsed texture if successful
  18660. */
  18661. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18662. /**
  18663. * Creates a texture from its base 64 representation.
  18664. * @param data Define the base64 payload without the data: prefix
  18665. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18666. * @param scene Define the scene the texture should belong to
  18667. * @param noMipmap Forces the texture to not create mip map information if true
  18668. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18669. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18670. * @param onLoad define a callback triggered when the texture has been loaded
  18671. * @param onError define a callback triggered when an error occurred during the loading session
  18672. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18673. * @returns the created texture
  18674. */
  18675. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18676. /**
  18677. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18678. * @param data Define the base64 payload without the data: prefix
  18679. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18680. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18681. * @param scene Define the scene the texture should belong to
  18682. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18683. * @param noMipmap Forces the texture to not create mip map information if true
  18684. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18685. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18686. * @param onLoad define a callback triggered when the texture has been loaded
  18687. * @param onError define a callback triggered when an error occurred during the loading session
  18688. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18689. * @returns the created texture
  18690. */
  18691. 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;
  18692. }
  18693. }
  18694. declare module BABYLON {
  18695. /**
  18696. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18697. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18698. */
  18699. export class PostProcessManager {
  18700. private _scene;
  18701. private _indexBuffer;
  18702. private _vertexBuffers;
  18703. /**
  18704. * Creates a new instance PostProcess
  18705. * @param scene The scene that the post process is associated with.
  18706. */
  18707. constructor(scene: Scene);
  18708. private _prepareBuffers;
  18709. private _buildIndexBuffer;
  18710. /**
  18711. * Rebuilds the vertex buffers of the manager.
  18712. * @hidden
  18713. */
  18714. _rebuild(): void;
  18715. /**
  18716. * Prepares a frame to be run through a post process.
  18717. * @param sourceTexture The input texture to the post procesess. (default: null)
  18718. * @param postProcesses An array of post processes to be run. (default: null)
  18719. * @returns True if the post processes were able to be run.
  18720. * @hidden
  18721. */
  18722. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18723. /**
  18724. * Manually render a set of post processes to a texture.
  18725. * @param postProcesses An array of post processes to be run.
  18726. * @param targetTexture The target texture to render to.
  18727. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18728. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18729. * @param lodLevel defines which lod of the texture to render to
  18730. */
  18731. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18732. /**
  18733. * Finalize the result of the output of the postprocesses.
  18734. * @param doNotPresent If true the result will not be displayed to the screen.
  18735. * @param targetTexture The target texture to render to.
  18736. * @param faceIndex The index of the face to bind the target texture to.
  18737. * @param postProcesses The array of post processes to render.
  18738. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18739. * @hidden
  18740. */
  18741. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18742. /**
  18743. * Disposes of the post process manager.
  18744. */
  18745. dispose(): void;
  18746. }
  18747. }
  18748. declare module BABYLON {
  18749. interface AbstractScene {
  18750. /**
  18751. * The list of procedural textures added to the scene
  18752. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18753. */
  18754. proceduralTextures: Array<ProceduralTexture>;
  18755. }
  18756. /**
  18757. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18758. * in a given scene.
  18759. */
  18760. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18761. /**
  18762. * The component name helpfull to identify the component in the list of scene components.
  18763. */
  18764. readonly name: string;
  18765. /**
  18766. * The scene the component belongs to.
  18767. */
  18768. scene: Scene;
  18769. /**
  18770. * Creates a new instance of the component for the given scene
  18771. * @param scene Defines the scene to register the component in
  18772. */
  18773. constructor(scene: Scene);
  18774. /**
  18775. * Registers the component in a given scene
  18776. */
  18777. register(): void;
  18778. /**
  18779. * Rebuilds the elements related to this component in case of
  18780. * context lost for instance.
  18781. */
  18782. rebuild(): void;
  18783. /**
  18784. * Disposes the component and the associated ressources.
  18785. */
  18786. dispose(): void;
  18787. private _beforeClear;
  18788. }
  18789. }
  18790. declare module BABYLON {
  18791. interface Engine {
  18792. /**
  18793. * Creates a new render target cube texture
  18794. * @param size defines the size of the texture
  18795. * @param options defines the options used to create the texture
  18796. * @returns a new render target cube texture stored in an InternalTexture
  18797. */
  18798. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18799. }
  18800. }
  18801. declare module BABYLON {
  18802. /** @hidden */
  18803. export var proceduralVertexShader: {
  18804. name: string;
  18805. shader: string;
  18806. };
  18807. }
  18808. declare module BABYLON {
  18809. /**
  18810. * 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.
  18811. * This is the base class of any Procedural texture and contains most of the shareable code.
  18812. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18813. */
  18814. export class ProceduralTexture extends Texture {
  18815. isCube: boolean;
  18816. /**
  18817. * Define if the texture is enabled or not (disabled texture will not render)
  18818. */
  18819. isEnabled: boolean;
  18820. /**
  18821. * Define if the texture must be cleared before rendering (default is true)
  18822. */
  18823. autoClear: boolean;
  18824. /**
  18825. * Callback called when the texture is generated
  18826. */
  18827. onGenerated: () => void;
  18828. /**
  18829. * Event raised when the texture is generated
  18830. */
  18831. onGeneratedObservable: Observable<ProceduralTexture>;
  18832. /** @hidden */
  18833. _generateMipMaps: boolean;
  18834. /** @hidden **/
  18835. _effect: Effect;
  18836. /** @hidden */
  18837. _textures: {
  18838. [key: string]: Texture;
  18839. };
  18840. private _size;
  18841. private _currentRefreshId;
  18842. private _refreshRate;
  18843. private _vertexBuffers;
  18844. private _indexBuffer;
  18845. private _uniforms;
  18846. private _samplers;
  18847. private _fragment;
  18848. private _floats;
  18849. private _ints;
  18850. private _floatsArrays;
  18851. private _colors3;
  18852. private _colors4;
  18853. private _vectors2;
  18854. private _vectors3;
  18855. private _matrices;
  18856. private _fallbackTexture;
  18857. private _fallbackTextureUsed;
  18858. private _engine;
  18859. private _cachedDefines;
  18860. private _contentUpdateId;
  18861. private _contentData;
  18862. /**
  18863. * Instantiates a new procedural texture.
  18864. * 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.
  18865. * This is the base class of any Procedural texture and contains most of the shareable code.
  18866. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18867. * @param name Define the name of the texture
  18868. * @param size Define the size of the texture to create
  18869. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18870. * @param scene Define the scene the texture belongs to
  18871. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18872. * @param generateMipMaps Define if the texture should creates mip maps or not
  18873. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18874. */
  18875. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18876. /**
  18877. * The effect that is created when initializing the post process.
  18878. * @returns The created effect corresponding the the postprocess.
  18879. */
  18880. getEffect(): Effect;
  18881. /**
  18882. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18883. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18884. */
  18885. getContent(): Nullable<ArrayBufferView>;
  18886. private _createIndexBuffer;
  18887. /** @hidden */
  18888. _rebuild(): void;
  18889. /**
  18890. * Resets the texture in order to recreate its associated resources.
  18891. * This can be called in case of context loss
  18892. */
  18893. reset(): void;
  18894. protected _getDefines(): string;
  18895. /**
  18896. * Is the texture ready to be used ? (rendered at least once)
  18897. * @returns true if ready, otherwise, false.
  18898. */
  18899. isReady(): boolean;
  18900. /**
  18901. * Resets the refresh counter of the texture and start bak from scratch.
  18902. * Could be useful to regenerate the texture if it is setup to render only once.
  18903. */
  18904. resetRefreshCounter(): void;
  18905. /**
  18906. * Set the fragment shader to use in order to render the texture.
  18907. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18908. */
  18909. setFragment(fragment: any): void;
  18910. /**
  18911. * Define the refresh rate of the texture or the rendering frequency.
  18912. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18913. */
  18914. refreshRate: number;
  18915. /** @hidden */
  18916. _shouldRender(): boolean;
  18917. /**
  18918. * Get the size the texture is rendering at.
  18919. * @returns the size (texture is always squared)
  18920. */
  18921. getRenderSize(): number;
  18922. /**
  18923. * Resize the texture to new value.
  18924. * @param size Define the new size the texture should have
  18925. * @param generateMipMaps Define whether the new texture should create mip maps
  18926. */
  18927. resize(size: number, generateMipMaps: boolean): void;
  18928. private _checkUniform;
  18929. /**
  18930. * Set a texture in the shader program used to render.
  18931. * @param name Define the name of the uniform samplers as defined in the shader
  18932. * @param texture Define the texture to bind to this sampler
  18933. * @return the texture itself allowing "fluent" like uniform updates
  18934. */
  18935. setTexture(name: string, texture: Texture): ProceduralTexture;
  18936. /**
  18937. * Set a float in the shader.
  18938. * @param name Define the name of the uniform as defined in the shader
  18939. * @param value Define the value to give to the uniform
  18940. * @return the texture itself allowing "fluent" like uniform updates
  18941. */
  18942. setFloat(name: string, value: number): ProceduralTexture;
  18943. /**
  18944. * Set a int in the shader.
  18945. * @param name Define the name of the uniform as defined in the shader
  18946. * @param value Define the value to give to the uniform
  18947. * @return the texture itself allowing "fluent" like uniform updates
  18948. */
  18949. setInt(name: string, value: number): ProceduralTexture;
  18950. /**
  18951. * Set an array of floats in the shader.
  18952. * @param name Define the name of the uniform as defined in the shader
  18953. * @param value Define the value to give to the uniform
  18954. * @return the texture itself allowing "fluent" like uniform updates
  18955. */
  18956. setFloats(name: string, value: number[]): ProceduralTexture;
  18957. /**
  18958. * Set a vec3 in the shader from a Color3.
  18959. * @param name Define the name of the uniform as defined in the shader
  18960. * @param value Define the value to give to the uniform
  18961. * @return the texture itself allowing "fluent" like uniform updates
  18962. */
  18963. setColor3(name: string, value: Color3): ProceduralTexture;
  18964. /**
  18965. * Set a vec4 in the shader from a Color4.
  18966. * @param name Define the name of the uniform as defined in the shader
  18967. * @param value Define the value to give to the uniform
  18968. * @return the texture itself allowing "fluent" like uniform updates
  18969. */
  18970. setColor4(name: string, value: Color4): ProceduralTexture;
  18971. /**
  18972. * Set a vec2 in the shader from a Vector2.
  18973. * @param name Define the name of the uniform as defined in the shader
  18974. * @param value Define the value to give to the uniform
  18975. * @return the texture itself allowing "fluent" like uniform updates
  18976. */
  18977. setVector2(name: string, value: Vector2): ProceduralTexture;
  18978. /**
  18979. * Set a vec3 in the shader from a Vector3.
  18980. * @param name Define the name of the uniform as defined in the shader
  18981. * @param value Define the value to give to the uniform
  18982. * @return the texture itself allowing "fluent" like uniform updates
  18983. */
  18984. setVector3(name: string, value: Vector3): ProceduralTexture;
  18985. /**
  18986. * Set a mat4 in the shader from a MAtrix.
  18987. * @param name Define the name of the uniform as defined in the shader
  18988. * @param value Define the value to give to the uniform
  18989. * @return the texture itself allowing "fluent" like uniform updates
  18990. */
  18991. setMatrix(name: string, value: Matrix): ProceduralTexture;
  18992. /**
  18993. * Render the texture to its associated render target.
  18994. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  18995. */
  18996. render(useCameraPostProcess?: boolean): void;
  18997. /**
  18998. * Clone the texture.
  18999. * @returns the cloned texture
  19000. */
  19001. clone(): ProceduralTexture;
  19002. /**
  19003. * Dispose the texture and release its asoociated resources.
  19004. */
  19005. dispose(): void;
  19006. }
  19007. }
  19008. declare module BABYLON {
  19009. /**
  19010. * This represents the base class for particle system in Babylon.
  19011. * 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.
  19012. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19013. * @example https://doc.babylonjs.com/babylon101/particles
  19014. */
  19015. export class BaseParticleSystem {
  19016. /**
  19017. * Source color is added to the destination color without alpha affecting the result
  19018. */
  19019. static BLENDMODE_ONEONE: number;
  19020. /**
  19021. * Blend current color and particle color using particle’s alpha
  19022. */
  19023. static BLENDMODE_STANDARD: number;
  19024. /**
  19025. * Add current color and particle color multiplied by particle’s alpha
  19026. */
  19027. static BLENDMODE_ADD: number;
  19028. /**
  19029. * Multiply current color with particle color
  19030. */
  19031. static BLENDMODE_MULTIPLY: number;
  19032. /**
  19033. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19034. */
  19035. static BLENDMODE_MULTIPLYADD: number;
  19036. /**
  19037. * List of animations used by the particle system.
  19038. */
  19039. animations: Animation[];
  19040. /**
  19041. * The id of the Particle system.
  19042. */
  19043. id: string;
  19044. /**
  19045. * The friendly name of the Particle system.
  19046. */
  19047. name: string;
  19048. /**
  19049. * The rendering group used by the Particle system to chose when to render.
  19050. */
  19051. renderingGroupId: number;
  19052. /**
  19053. * The emitter represents the Mesh or position we are attaching the particle system to.
  19054. */
  19055. emitter: Nullable<AbstractMesh | Vector3>;
  19056. /**
  19057. * The maximum number of particles to emit per frame
  19058. */
  19059. emitRate: number;
  19060. /**
  19061. * If you want to launch only a few particles at once, that can be done, as well.
  19062. */
  19063. manualEmitCount: number;
  19064. /**
  19065. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19066. */
  19067. updateSpeed: number;
  19068. /**
  19069. * The amount of time the particle system is running (depends of the overall update speed).
  19070. */
  19071. targetStopDuration: number;
  19072. /**
  19073. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19074. */
  19075. disposeOnStop: boolean;
  19076. /**
  19077. * Minimum power of emitting particles.
  19078. */
  19079. minEmitPower: number;
  19080. /**
  19081. * Maximum power of emitting particles.
  19082. */
  19083. maxEmitPower: number;
  19084. /**
  19085. * Minimum life time of emitting particles.
  19086. */
  19087. minLifeTime: number;
  19088. /**
  19089. * Maximum life time of emitting particles.
  19090. */
  19091. maxLifeTime: number;
  19092. /**
  19093. * Minimum Size of emitting particles.
  19094. */
  19095. minSize: number;
  19096. /**
  19097. * Maximum Size of emitting particles.
  19098. */
  19099. maxSize: number;
  19100. /**
  19101. * Minimum scale of emitting particles on X axis.
  19102. */
  19103. minScaleX: number;
  19104. /**
  19105. * Maximum scale of emitting particles on X axis.
  19106. */
  19107. maxScaleX: number;
  19108. /**
  19109. * Minimum scale of emitting particles on Y axis.
  19110. */
  19111. minScaleY: number;
  19112. /**
  19113. * Maximum scale of emitting particles on Y axis.
  19114. */
  19115. maxScaleY: number;
  19116. /**
  19117. * Gets or sets the minimal initial rotation in radians.
  19118. */
  19119. minInitialRotation: number;
  19120. /**
  19121. * Gets or sets the maximal initial rotation in radians.
  19122. */
  19123. maxInitialRotation: number;
  19124. /**
  19125. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19126. */
  19127. minAngularSpeed: number;
  19128. /**
  19129. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19130. */
  19131. maxAngularSpeed: number;
  19132. /**
  19133. * The texture used to render each particle. (this can be a spritesheet)
  19134. */
  19135. particleTexture: Nullable<Texture>;
  19136. /**
  19137. * The layer mask we are rendering the particles through.
  19138. */
  19139. layerMask: number;
  19140. /**
  19141. * This can help using your own shader to render the particle system.
  19142. * The according effect will be created
  19143. */
  19144. customShader: any;
  19145. /**
  19146. * By default particle system starts as soon as they are created. This prevents the
  19147. * automatic start to happen and let you decide when to start emitting particles.
  19148. */
  19149. preventAutoStart: boolean;
  19150. private _noiseTexture;
  19151. /**
  19152. * Gets or sets a texture used to add random noise to particle positions
  19153. */
  19154. noiseTexture: Nullable<ProceduralTexture>;
  19155. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19156. noiseStrength: Vector3;
  19157. /**
  19158. * Callback triggered when the particle animation is ending.
  19159. */
  19160. onAnimationEnd: Nullable<() => void>;
  19161. /**
  19162. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19163. */
  19164. blendMode: number;
  19165. /**
  19166. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19167. * to override the particles.
  19168. */
  19169. forceDepthWrite: boolean;
  19170. /** 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 */
  19171. preWarmCycles: number;
  19172. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19173. preWarmStepOffset: number;
  19174. /**
  19175. * 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)
  19176. */
  19177. spriteCellChangeSpeed: number;
  19178. /**
  19179. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19180. */
  19181. startSpriteCellID: number;
  19182. /**
  19183. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19184. */
  19185. endSpriteCellID: number;
  19186. /**
  19187. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19188. */
  19189. spriteCellWidth: number;
  19190. /**
  19191. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19192. */
  19193. spriteCellHeight: number;
  19194. /**
  19195. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19196. */
  19197. spriteRandomStartCell: boolean;
  19198. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19199. translationPivot: Vector2;
  19200. /** @hidden */
  19201. protected _isAnimationSheetEnabled: boolean;
  19202. /**
  19203. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19204. */
  19205. beginAnimationOnStart: boolean;
  19206. /**
  19207. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19208. */
  19209. beginAnimationFrom: number;
  19210. /**
  19211. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19212. */
  19213. beginAnimationTo: number;
  19214. /**
  19215. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19216. */
  19217. beginAnimationLoop: boolean;
  19218. /**
  19219. * Gets or sets a world offset applied to all particles
  19220. */
  19221. worldOffset: Vector3;
  19222. /**
  19223. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19224. */
  19225. isAnimationSheetEnabled: boolean;
  19226. /**
  19227. * Get hosting scene
  19228. * @returns the scene
  19229. */
  19230. getScene(): Scene;
  19231. /**
  19232. * You can use gravity if you want to give an orientation to your particles.
  19233. */
  19234. gravity: Vector3;
  19235. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19236. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19237. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19238. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19239. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19240. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19241. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19242. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19243. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19244. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19245. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19246. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19247. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19248. /**
  19249. * Defines the delay in milliseconds before starting the system (0 by default)
  19250. */
  19251. startDelay: number;
  19252. /**
  19253. * Gets the current list of drag gradients.
  19254. * You must use addDragGradient and removeDragGradient to udpate this list
  19255. * @returns the list of drag gradients
  19256. */
  19257. getDragGradients(): Nullable<Array<FactorGradient>>;
  19258. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19259. limitVelocityDamping: number;
  19260. /**
  19261. * Gets the current list of limit velocity gradients.
  19262. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19263. * @returns the list of limit velocity gradients
  19264. */
  19265. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Gets the current list of color gradients.
  19268. * You must use addColorGradient and removeColorGradient to udpate this list
  19269. * @returns the list of color gradients
  19270. */
  19271. getColorGradients(): Nullable<Array<ColorGradient>>;
  19272. /**
  19273. * Gets the current list of size gradients.
  19274. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19275. * @returns the list of size gradients
  19276. */
  19277. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19278. /**
  19279. * Gets the current list of color remap gradients.
  19280. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19281. * @returns the list of color remap gradients
  19282. */
  19283. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19284. /**
  19285. * Gets the current list of alpha remap gradients.
  19286. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19287. * @returns the list of alpha remap gradients
  19288. */
  19289. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19290. /**
  19291. * Gets the current list of life time gradients.
  19292. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19293. * @returns the list of life time gradients
  19294. */
  19295. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19296. /**
  19297. * Gets the current list of angular speed gradients.
  19298. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19299. * @returns the list of angular speed gradients
  19300. */
  19301. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19302. /**
  19303. * Gets the current list of velocity gradients.
  19304. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19305. * @returns the list of velocity gradients
  19306. */
  19307. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19308. /**
  19309. * Gets the current list of start size gradients.
  19310. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19311. * @returns the list of start size gradients
  19312. */
  19313. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19314. /**
  19315. * Gets the current list of emit rate gradients.
  19316. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19317. * @returns the list of emit rate gradients
  19318. */
  19319. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19320. /**
  19321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19322. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19323. */
  19324. direction1: Vector3;
  19325. /**
  19326. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19327. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19328. */
  19329. direction2: Vector3;
  19330. /**
  19331. * 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.
  19332. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19333. */
  19334. minEmitBox: Vector3;
  19335. /**
  19336. * 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.
  19337. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19338. */
  19339. maxEmitBox: Vector3;
  19340. /**
  19341. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19342. */
  19343. color1: Color4;
  19344. /**
  19345. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19346. */
  19347. color2: Color4;
  19348. /**
  19349. * Color the particle will have at the end of its lifetime
  19350. */
  19351. colorDead: Color4;
  19352. /**
  19353. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19354. */
  19355. textureMask: Color4;
  19356. /**
  19357. * The particle emitter type defines the emitter used by the particle system.
  19358. * It can be for example box, sphere, or cone...
  19359. */
  19360. particleEmitterType: IParticleEmitterType;
  19361. /** @hidden */
  19362. _isSubEmitter: boolean;
  19363. /**
  19364. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19365. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19366. */
  19367. billboardMode: number;
  19368. protected _isBillboardBased: boolean;
  19369. /**
  19370. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19371. */
  19372. isBillboardBased: boolean;
  19373. /**
  19374. * The scene the particle system belongs to.
  19375. */
  19376. protected _scene: Scene;
  19377. /**
  19378. * Local cache of defines for image processing.
  19379. */
  19380. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19381. /**
  19382. * Default configuration related to image processing available in the standard Material.
  19383. */
  19384. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19385. /**
  19386. * Gets the image processing configuration used either in this material.
  19387. */
  19388. /**
  19389. * Sets the Default image processing configuration used either in the this material.
  19390. *
  19391. * If sets to null, the scene one is in use.
  19392. */
  19393. imageProcessingConfiguration: ImageProcessingConfiguration;
  19394. /**
  19395. * Attaches a new image processing configuration to the Standard Material.
  19396. * @param configuration
  19397. */
  19398. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19399. /** @hidden */
  19400. protected _reset(): void;
  19401. /** @hidden */
  19402. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19403. /**
  19404. * Instantiates a particle system.
  19405. * 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.
  19406. * @param name The name of the particle system
  19407. */
  19408. constructor(name: string);
  19409. /**
  19410. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19413. * @returns the emitter
  19414. */
  19415. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19416. /**
  19417. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19418. * @param radius The radius of the hemisphere to emit from
  19419. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19420. * @returns the emitter
  19421. */
  19422. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19423. /**
  19424. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19425. * @param radius The radius of the sphere to emit from
  19426. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19427. * @returns the emitter
  19428. */
  19429. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19430. /**
  19431. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19432. * @param radius The radius of the sphere to emit from
  19433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19435. * @returns the emitter
  19436. */
  19437. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19438. /**
  19439. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19440. * @param radius The radius of the emission cylinder
  19441. * @param height The height of the emission cylinder
  19442. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19443. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19444. * @returns the emitter
  19445. */
  19446. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19447. /**
  19448. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19449. * @param radius The radius of the cylinder to emit from
  19450. * @param height The height of the emission cylinder
  19451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19454. * @returns the emitter
  19455. */
  19456. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19457. /**
  19458. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19459. * @param radius The radius of the cone to emit from
  19460. * @param angle The base angle of the cone
  19461. * @returns the emitter
  19462. */
  19463. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19464. /**
  19465. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19468. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19469. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19470. * @returns the emitter
  19471. */
  19472. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19473. }
  19474. }
  19475. declare module BABYLON {
  19476. /**
  19477. * Type of sub emitter
  19478. */
  19479. export enum SubEmitterType {
  19480. /**
  19481. * Attached to the particle over it's lifetime
  19482. */
  19483. ATTACHED = 0,
  19484. /**
  19485. * Created when the particle dies
  19486. */
  19487. END = 1
  19488. }
  19489. /**
  19490. * Sub emitter class used to emit particles from an existing particle
  19491. */
  19492. export class SubEmitter {
  19493. /**
  19494. * the particle system to be used by the sub emitter
  19495. */
  19496. particleSystem: ParticleSystem;
  19497. /**
  19498. * Type of the submitter (Default: END)
  19499. */
  19500. type: SubEmitterType;
  19501. /**
  19502. * 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)
  19503. * Note: This only is supported when using an emitter of type Mesh
  19504. */
  19505. inheritDirection: boolean;
  19506. /**
  19507. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19508. */
  19509. inheritedVelocityAmount: number;
  19510. /**
  19511. * Creates a sub emitter
  19512. * @param particleSystem the particle system to be used by the sub emitter
  19513. */
  19514. constructor(
  19515. /**
  19516. * the particle system to be used by the sub emitter
  19517. */
  19518. particleSystem: ParticleSystem);
  19519. /**
  19520. * Clones the sub emitter
  19521. * @returns the cloned sub emitter
  19522. */
  19523. clone(): SubEmitter;
  19524. /**
  19525. * Serialize current object to a JSON object
  19526. * @returns the serialized object
  19527. */
  19528. serialize(): any;
  19529. /** @hidden */
  19530. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19531. /**
  19532. * Creates a new SubEmitter from a serialized JSON version
  19533. * @param serializationObject defines the JSON object to read from
  19534. * @param scene defines the hosting scene
  19535. * @param rootUrl defines the rootUrl for data loading
  19536. * @returns a new SubEmitter
  19537. */
  19538. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19539. /** Release associated resources */
  19540. dispose(): void;
  19541. }
  19542. }
  19543. declare module BABYLON {
  19544. /** @hidden */
  19545. export var imageProcessingDeclaration: {
  19546. name: string;
  19547. shader: string;
  19548. };
  19549. }
  19550. declare module BABYLON {
  19551. /** @hidden */
  19552. export var imageProcessingFunctions: {
  19553. name: string;
  19554. shader: string;
  19555. };
  19556. }
  19557. declare module BABYLON {
  19558. /** @hidden */
  19559. export var particlesPixelShader: {
  19560. name: string;
  19561. shader: string;
  19562. };
  19563. }
  19564. declare module BABYLON {
  19565. /** @hidden */
  19566. export var particlesVertexShader: {
  19567. name: string;
  19568. shader: string;
  19569. };
  19570. }
  19571. declare module BABYLON {
  19572. /**
  19573. * This represents a particle system in Babylon.
  19574. * 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.
  19575. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19576. * @example https://doc.babylonjs.com/babylon101/particles
  19577. */
  19578. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19579. /**
  19580. * Billboard mode will only apply to Y axis
  19581. */
  19582. static readonly BILLBOARDMODE_Y: number;
  19583. /**
  19584. * Billboard mode will apply to all axes
  19585. */
  19586. static readonly BILLBOARDMODE_ALL: number;
  19587. /**
  19588. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19589. */
  19590. static readonly BILLBOARDMODE_STRETCHED: number;
  19591. /**
  19592. * This function can be defined to provide custom update for active particles.
  19593. * This function will be called instead of regular update (age, position, color, etc.).
  19594. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19595. */
  19596. updateFunction: (particles: Particle[]) => void;
  19597. private _emitterWorldMatrix;
  19598. /**
  19599. * This function can be defined to specify initial direction for every new particle.
  19600. * It by default use the emitterType defined function
  19601. */
  19602. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19603. /**
  19604. * This function can be defined to specify initial position for every new particle.
  19605. * It by default use the emitterType defined function
  19606. */
  19607. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19608. /**
  19609. * @hidden
  19610. */
  19611. _inheritedVelocityOffset: Vector3;
  19612. /**
  19613. * An event triggered when the system is disposed
  19614. */
  19615. onDisposeObservable: Observable<ParticleSystem>;
  19616. private _onDisposeObserver;
  19617. /**
  19618. * Sets a callback that will be triggered when the system is disposed
  19619. */
  19620. onDispose: () => void;
  19621. private _particles;
  19622. private _epsilon;
  19623. private _capacity;
  19624. private _stockParticles;
  19625. private _newPartsExcess;
  19626. private _vertexData;
  19627. private _vertexBuffer;
  19628. private _vertexBuffers;
  19629. private _spriteBuffer;
  19630. private _indexBuffer;
  19631. private _effect;
  19632. private _customEffect;
  19633. private _cachedDefines;
  19634. private _scaledColorStep;
  19635. private _colorDiff;
  19636. private _scaledDirection;
  19637. private _scaledGravity;
  19638. private _currentRenderId;
  19639. private _alive;
  19640. private _useInstancing;
  19641. private _started;
  19642. private _stopped;
  19643. private _actualFrame;
  19644. private _scaledUpdateSpeed;
  19645. private _vertexBufferSize;
  19646. /** @hidden */
  19647. _currentEmitRateGradient: Nullable<FactorGradient>;
  19648. /** @hidden */
  19649. _currentEmitRate1: number;
  19650. /** @hidden */
  19651. _currentEmitRate2: number;
  19652. /** @hidden */
  19653. _currentStartSizeGradient: Nullable<FactorGradient>;
  19654. /** @hidden */
  19655. _currentStartSize1: number;
  19656. /** @hidden */
  19657. _currentStartSize2: number;
  19658. private readonly _rawTextureWidth;
  19659. private _rampGradientsTexture;
  19660. private _useRampGradients;
  19661. /** Gets or sets a boolean indicating that ramp gradients must be used
  19662. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19663. */
  19664. useRampGradients: boolean;
  19665. /**
  19666. * 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.
  19667. * 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: [])
  19668. */
  19669. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19670. private _subEmitters;
  19671. /**
  19672. * @hidden
  19673. * If the particle systems emitter should be disposed when the particle system is disposed
  19674. */
  19675. _disposeEmitterOnDispose: boolean;
  19676. /**
  19677. * The current active Sub-systems, this property is used by the root particle system only.
  19678. */
  19679. activeSubSystems: Array<ParticleSystem>;
  19680. private _rootParticleSystem;
  19681. /**
  19682. * Gets the current list of active particles
  19683. */
  19684. readonly particles: Particle[];
  19685. /**
  19686. * Returns the string "ParticleSystem"
  19687. * @returns a string containing the class name
  19688. */
  19689. getClassName(): string;
  19690. /**
  19691. * Instantiates a particle system.
  19692. * 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.
  19693. * @param name The name of the particle system
  19694. * @param capacity The max number of particles alive at the same time
  19695. * @param scene The scene the particle system belongs to
  19696. * @param customEffect a custom effect used to change the way particles are rendered by default
  19697. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19698. * @param epsilon Offset used to render the particles
  19699. */
  19700. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19701. private _addFactorGradient;
  19702. private _removeFactorGradient;
  19703. /**
  19704. * Adds a new life time gradient
  19705. * @param gradient defines the gradient to use (between 0 and 1)
  19706. * @param factor defines the life time factor to affect to the specified gradient
  19707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19708. * @returns the current particle system
  19709. */
  19710. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19711. /**
  19712. * Remove a specific life time gradient
  19713. * @param gradient defines the gradient to remove
  19714. * @returns the current particle system
  19715. */
  19716. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19717. /**
  19718. * Adds a new size gradient
  19719. * @param gradient defines the gradient to use (between 0 and 1)
  19720. * @param factor defines the size factor to affect to the specified gradient
  19721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19722. * @returns the current particle system
  19723. */
  19724. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19725. /**
  19726. * Remove a specific size gradient
  19727. * @param gradient defines the gradient to remove
  19728. * @returns the current particle system
  19729. */
  19730. removeSizeGradient(gradient: number): IParticleSystem;
  19731. /**
  19732. * Adds a new color remap gradient
  19733. * @param gradient defines the gradient to use (between 0 and 1)
  19734. * @param min defines the color remap minimal range
  19735. * @param max defines the color remap maximal range
  19736. * @returns the current particle system
  19737. */
  19738. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19739. /**
  19740. * Remove a specific color remap gradient
  19741. * @param gradient defines the gradient to remove
  19742. * @returns the current particle system
  19743. */
  19744. removeColorRemapGradient(gradient: number): IParticleSystem;
  19745. /**
  19746. * Adds a new alpha remap gradient
  19747. * @param gradient defines the gradient to use (between 0 and 1)
  19748. * @param min defines the alpha remap minimal range
  19749. * @param max defines the alpha remap maximal range
  19750. * @returns the current particle system
  19751. */
  19752. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19753. /**
  19754. * Remove a specific alpha remap gradient
  19755. * @param gradient defines the gradient to remove
  19756. * @returns the current particle system
  19757. */
  19758. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19759. /**
  19760. * Adds a new angular speed gradient
  19761. * @param gradient defines the gradient to use (between 0 and 1)
  19762. * @param factor defines the angular speed to affect to the specified gradient
  19763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19764. * @returns the current particle system
  19765. */
  19766. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19767. /**
  19768. * Remove a specific angular speed gradient
  19769. * @param gradient defines the gradient to remove
  19770. * @returns the current particle system
  19771. */
  19772. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19773. /**
  19774. * Adds a new velocity gradient
  19775. * @param gradient defines the gradient to use (between 0 and 1)
  19776. * @param factor defines the velocity to affect to the specified gradient
  19777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19778. * @returns the current particle system
  19779. */
  19780. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19781. /**
  19782. * Remove a specific velocity gradient
  19783. * @param gradient defines the gradient to remove
  19784. * @returns the current particle system
  19785. */
  19786. removeVelocityGradient(gradient: number): IParticleSystem;
  19787. /**
  19788. * Adds a new limit velocity gradient
  19789. * @param gradient defines the gradient to use (between 0 and 1)
  19790. * @param factor defines the limit velocity value to affect to the specified gradient
  19791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19792. * @returns the current particle system
  19793. */
  19794. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19795. /**
  19796. * Remove a specific limit velocity gradient
  19797. * @param gradient defines the gradient to remove
  19798. * @returns the current particle system
  19799. */
  19800. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19801. /**
  19802. * Adds a new drag gradient
  19803. * @param gradient defines the gradient to use (between 0 and 1)
  19804. * @param factor defines the drag value to affect to the specified gradient
  19805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19806. * @returns the current particle system
  19807. */
  19808. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19809. /**
  19810. * Remove a specific drag gradient
  19811. * @param gradient defines the gradient to remove
  19812. * @returns the current particle system
  19813. */
  19814. removeDragGradient(gradient: number): IParticleSystem;
  19815. /**
  19816. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19817. * @param gradient defines the gradient to use (between 0 and 1)
  19818. * @param factor defines the emit rate value to affect to the specified gradient
  19819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19820. * @returns the current particle system
  19821. */
  19822. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19823. /**
  19824. * Remove a specific emit rate gradient
  19825. * @param gradient defines the gradient to remove
  19826. * @returns the current particle system
  19827. */
  19828. removeEmitRateGradient(gradient: number): IParticleSystem;
  19829. /**
  19830. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19831. * @param gradient defines the gradient to use (between 0 and 1)
  19832. * @param factor defines the start size value to affect to the specified gradient
  19833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19834. * @returns the current particle system
  19835. */
  19836. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19837. /**
  19838. * Remove a specific start size gradient
  19839. * @param gradient defines the gradient to remove
  19840. * @returns the current particle system
  19841. */
  19842. removeStartSizeGradient(gradient: number): IParticleSystem;
  19843. private _createRampGradientTexture;
  19844. /**
  19845. * Gets the current list of ramp gradients.
  19846. * You must use addRampGradient and removeRampGradient to udpate this list
  19847. * @returns the list of ramp gradients
  19848. */
  19849. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19850. /**
  19851. * Adds a new ramp gradient used to remap particle colors
  19852. * @param gradient defines the gradient to use (between 0 and 1)
  19853. * @param color defines the color to affect to the specified gradient
  19854. * @returns the current particle system
  19855. */
  19856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19857. /**
  19858. * Remove a specific ramp gradient
  19859. * @param gradient defines the gradient to remove
  19860. * @returns the current particle system
  19861. */
  19862. removeRampGradient(gradient: number): ParticleSystem;
  19863. /**
  19864. * Adds a new color gradient
  19865. * @param gradient defines the gradient to use (between 0 and 1)
  19866. * @param color1 defines the color to affect to the specified gradient
  19867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19868. * @returns this particle system
  19869. */
  19870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19871. /**
  19872. * Remove a specific color gradient
  19873. * @param gradient defines the gradient to remove
  19874. * @returns this particle system
  19875. */
  19876. removeColorGradient(gradient: number): IParticleSystem;
  19877. private _fetchR;
  19878. protected _reset(): void;
  19879. private _resetEffect;
  19880. private _createVertexBuffers;
  19881. private _createIndexBuffer;
  19882. /**
  19883. * Gets the maximum number of particles active at the same time.
  19884. * @returns The max number of active particles.
  19885. */
  19886. getCapacity(): number;
  19887. /**
  19888. * Gets whether there are still active particles in the system.
  19889. * @returns True if it is alive, otherwise false.
  19890. */
  19891. isAlive(): boolean;
  19892. /**
  19893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19894. * @returns True if it has been started, otherwise false.
  19895. */
  19896. isStarted(): boolean;
  19897. private _prepareSubEmitterInternalArray;
  19898. /**
  19899. * Starts the particle system and begins to emit
  19900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19901. */
  19902. start(delay?: number): void;
  19903. /**
  19904. * Stops the particle system.
  19905. * @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.
  19906. */
  19907. stop(stopSubEmitters?: boolean): void;
  19908. /**
  19909. * Remove all active particles
  19910. */
  19911. reset(): void;
  19912. /**
  19913. * @hidden (for internal use only)
  19914. */
  19915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19916. /**
  19917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19918. * Its lifetime will start back at 0.
  19919. */
  19920. recycleParticle: (particle: Particle) => void;
  19921. private _stopSubEmitters;
  19922. private _createParticle;
  19923. private _removeFromRoot;
  19924. private _emitFromParticle;
  19925. private _update;
  19926. /** @hidden */
  19927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19928. /** @hidden */
  19929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19930. /** @hidden */
  19931. private _getEffect;
  19932. /**
  19933. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19934. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19935. */
  19936. animate(preWarmOnly?: boolean): void;
  19937. private _appendParticleVertices;
  19938. /**
  19939. * Rebuilds the particle system.
  19940. */
  19941. rebuild(): void;
  19942. /**
  19943. * Is this system ready to be used/rendered
  19944. * @return true if the system is ready
  19945. */
  19946. isReady(): boolean;
  19947. private _render;
  19948. /**
  19949. * Renders the particle system in its current state.
  19950. * @returns the current number of particles
  19951. */
  19952. render(): number;
  19953. /**
  19954. * Disposes the particle system and free the associated resources
  19955. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19956. */
  19957. dispose(disposeTexture?: boolean): void;
  19958. /**
  19959. * Clones the particle system.
  19960. * @param name The name of the cloned object
  19961. * @param newEmitter The new emitter to use
  19962. * @returns the cloned particle system
  19963. */
  19964. clone(name: string, newEmitter: any): ParticleSystem;
  19965. /**
  19966. * Serializes the particle system to a JSON object.
  19967. * @returns the JSON object
  19968. */
  19969. serialize(): any;
  19970. /** @hidden */
  19971. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  19972. /** @hidden */
  19973. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  19974. /**
  19975. * Parses a JSON object to create a particle system.
  19976. * @param parsedParticleSystem The JSON object to parse
  19977. * @param scene The scene to create the particle system in
  19978. * @param rootUrl The root url to use to load external dependencies like texture
  19979. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  19980. * @returns the Parsed particle system
  19981. */
  19982. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  19983. }
  19984. }
  19985. declare module BABYLON {
  19986. /**
  19987. * A particle represents one of the element emitted by a particle system.
  19988. * This is mainly define by its coordinates, direction, velocity and age.
  19989. */
  19990. export class Particle {
  19991. /**
  19992. * The particle system the particle belongs to.
  19993. */
  19994. particleSystem: ParticleSystem;
  19995. private static _Count;
  19996. /**
  19997. * Unique ID of the particle
  19998. */
  19999. id: number;
  20000. /**
  20001. * The world position of the particle in the scene.
  20002. */
  20003. position: Vector3;
  20004. /**
  20005. * The world direction of the particle in the scene.
  20006. */
  20007. direction: Vector3;
  20008. /**
  20009. * The color of the particle.
  20010. */
  20011. color: Color4;
  20012. /**
  20013. * The color change of the particle per step.
  20014. */
  20015. colorStep: Color4;
  20016. /**
  20017. * Defines how long will the life of the particle be.
  20018. */
  20019. lifeTime: number;
  20020. /**
  20021. * The current age of the particle.
  20022. */
  20023. age: number;
  20024. /**
  20025. * The current size of the particle.
  20026. */
  20027. size: number;
  20028. /**
  20029. * The current scale of the particle.
  20030. */
  20031. scale: Vector2;
  20032. /**
  20033. * The current angle of the particle.
  20034. */
  20035. angle: number;
  20036. /**
  20037. * Defines how fast is the angle changing.
  20038. */
  20039. angularSpeed: number;
  20040. /**
  20041. * Defines the cell index used by the particle to be rendered from a sprite.
  20042. */
  20043. cellIndex: number;
  20044. /**
  20045. * The information required to support color remapping
  20046. */
  20047. remapData: Vector4;
  20048. /** @hidden */
  20049. _randomCellOffset?: number;
  20050. /** @hidden */
  20051. _initialDirection: Nullable<Vector3>;
  20052. /** @hidden */
  20053. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20054. /** @hidden */
  20055. _initialStartSpriteCellID: number;
  20056. /** @hidden */
  20057. _initialEndSpriteCellID: number;
  20058. /** @hidden */
  20059. _currentColorGradient: Nullable<ColorGradient>;
  20060. /** @hidden */
  20061. _currentColor1: Color4;
  20062. /** @hidden */
  20063. _currentColor2: Color4;
  20064. /** @hidden */
  20065. _currentSizeGradient: Nullable<FactorGradient>;
  20066. /** @hidden */
  20067. _currentSize1: number;
  20068. /** @hidden */
  20069. _currentSize2: number;
  20070. /** @hidden */
  20071. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20072. /** @hidden */
  20073. _currentAngularSpeed1: number;
  20074. /** @hidden */
  20075. _currentAngularSpeed2: number;
  20076. /** @hidden */
  20077. _currentVelocityGradient: Nullable<FactorGradient>;
  20078. /** @hidden */
  20079. _currentVelocity1: number;
  20080. /** @hidden */
  20081. _currentVelocity2: number;
  20082. /** @hidden */
  20083. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20084. /** @hidden */
  20085. _currentLimitVelocity1: number;
  20086. /** @hidden */
  20087. _currentLimitVelocity2: number;
  20088. /** @hidden */
  20089. _currentDragGradient: Nullable<FactorGradient>;
  20090. /** @hidden */
  20091. _currentDrag1: number;
  20092. /** @hidden */
  20093. _currentDrag2: number;
  20094. /** @hidden */
  20095. _randomNoiseCoordinates1: Vector3;
  20096. /** @hidden */
  20097. _randomNoiseCoordinates2: Vector3;
  20098. /**
  20099. * Creates a new instance Particle
  20100. * @param particleSystem the particle system the particle belongs to
  20101. */
  20102. constructor(
  20103. /**
  20104. * The particle system the particle belongs to.
  20105. */
  20106. particleSystem: ParticleSystem);
  20107. private updateCellInfoFromSystem;
  20108. /**
  20109. * Defines how the sprite cell index is updated for the particle
  20110. */
  20111. updateCellIndex(): void;
  20112. /** @hidden */
  20113. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20114. /** @hidden */
  20115. _inheritParticleInfoToSubEmitters(): void;
  20116. /** @hidden */
  20117. _reset(): void;
  20118. /**
  20119. * Copy the properties of particle to another one.
  20120. * @param other the particle to copy the information to.
  20121. */
  20122. copyTo(other: Particle): void;
  20123. }
  20124. }
  20125. declare module BABYLON {
  20126. /**
  20127. * Particle emitter represents a volume emitting particles.
  20128. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20129. */
  20130. export interface IParticleEmitterType {
  20131. /**
  20132. * Called by the particle System when the direction is computed for the created particle.
  20133. * @param worldMatrix is the world matrix of the particle system
  20134. * @param directionToUpdate is the direction vector to update with the result
  20135. * @param particle is the particle we are computed the direction for
  20136. */
  20137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20138. /**
  20139. * Called by the particle System when the position is computed for the created particle.
  20140. * @param worldMatrix is the world matrix of the particle system
  20141. * @param positionToUpdate is the position vector to update with the result
  20142. * @param particle is the particle we are computed the position for
  20143. */
  20144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20145. /**
  20146. * Clones the current emitter and returns a copy of it
  20147. * @returns the new emitter
  20148. */
  20149. clone(): IParticleEmitterType;
  20150. /**
  20151. * Called by the GPUParticleSystem to setup the update shader
  20152. * @param effect defines the update shader
  20153. */
  20154. applyToShader(effect: Effect): void;
  20155. /**
  20156. * Returns a string to use to update the GPU particles update shader
  20157. * @returns the effect defines string
  20158. */
  20159. getEffectDefines(): string;
  20160. /**
  20161. * Returns a string representing the class name
  20162. * @returns a string containing the class name
  20163. */
  20164. getClassName(): string;
  20165. /**
  20166. * Serializes the particle system to a JSON object.
  20167. * @returns the JSON object
  20168. */
  20169. serialize(): any;
  20170. /**
  20171. * Parse properties from a JSON object
  20172. * @param serializationObject defines the JSON object
  20173. */
  20174. parse(serializationObject: any): void;
  20175. }
  20176. }
  20177. declare module BABYLON {
  20178. /**
  20179. * Particle emitter emitting particles from the inside of a box.
  20180. * It emits the particles randomly between 2 given directions.
  20181. */
  20182. export class BoxParticleEmitter implements IParticleEmitterType {
  20183. /**
  20184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20185. */
  20186. direction1: Vector3;
  20187. /**
  20188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20189. */
  20190. direction2: Vector3;
  20191. /**
  20192. * 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.
  20193. */
  20194. minEmitBox: Vector3;
  20195. /**
  20196. * 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.
  20197. */
  20198. maxEmitBox: Vector3;
  20199. /**
  20200. * Creates a new instance BoxParticleEmitter
  20201. */
  20202. constructor();
  20203. /**
  20204. * Called by the particle System when the direction is computed for the created particle.
  20205. * @param worldMatrix is the world matrix of the particle system
  20206. * @param directionToUpdate is the direction vector to update with the result
  20207. * @param particle is the particle we are computed the direction for
  20208. */
  20209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20210. /**
  20211. * Called by the particle System when the position is computed for the created particle.
  20212. * @param worldMatrix is the world matrix of the particle system
  20213. * @param positionToUpdate is the position vector to update with the result
  20214. * @param particle is the particle we are computed the position for
  20215. */
  20216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20217. /**
  20218. * Clones the current emitter and returns a copy of it
  20219. * @returns the new emitter
  20220. */
  20221. clone(): BoxParticleEmitter;
  20222. /**
  20223. * Called by the GPUParticleSystem to setup the update shader
  20224. * @param effect defines the update shader
  20225. */
  20226. applyToShader(effect: Effect): void;
  20227. /**
  20228. * Returns a string to use to update the GPU particles update shader
  20229. * @returns a string containng the defines string
  20230. */
  20231. getEffectDefines(): string;
  20232. /**
  20233. * Returns the string "BoxParticleEmitter"
  20234. * @returns a string containing the class name
  20235. */
  20236. getClassName(): string;
  20237. /**
  20238. * Serializes the particle system to a JSON object.
  20239. * @returns the JSON object
  20240. */
  20241. serialize(): any;
  20242. /**
  20243. * Parse properties from a JSON object
  20244. * @param serializationObject defines the JSON object
  20245. */
  20246. parse(serializationObject: any): void;
  20247. }
  20248. }
  20249. declare module BABYLON {
  20250. /**
  20251. * Particle emitter emitting particles from the inside of a cone.
  20252. * It emits the particles alongside the cone volume from the base to the particle.
  20253. * The emission direction might be randomized.
  20254. */
  20255. export class ConeParticleEmitter implements IParticleEmitterType {
  20256. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20257. directionRandomizer: number;
  20258. private _radius;
  20259. private _angle;
  20260. private _height;
  20261. /**
  20262. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20263. */
  20264. radiusRange: number;
  20265. /**
  20266. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20267. */
  20268. heightRange: number;
  20269. /**
  20270. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20271. */
  20272. emitFromSpawnPointOnly: boolean;
  20273. /**
  20274. * Gets or sets the radius of the emission cone
  20275. */
  20276. radius: number;
  20277. /**
  20278. * Gets or sets the angle of the emission cone
  20279. */
  20280. angle: number;
  20281. private _buildHeight;
  20282. /**
  20283. * Creates a new instance ConeParticleEmitter
  20284. * @param radius the radius of the emission cone (1 by default)
  20285. * @param angle the cone base angle (PI by default)
  20286. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20287. */
  20288. constructor(radius?: number, angle?: number,
  20289. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20290. directionRandomizer?: number);
  20291. /**
  20292. * Called by the particle System when the direction is computed for the created particle.
  20293. * @param worldMatrix is the world matrix of the particle system
  20294. * @param directionToUpdate is the direction vector to update with the result
  20295. * @param particle is the particle we are computed the direction for
  20296. */
  20297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20298. /**
  20299. * Called by the particle System when the position is computed for the created particle.
  20300. * @param worldMatrix is the world matrix of the particle system
  20301. * @param positionToUpdate is the position vector to update with the result
  20302. * @param particle is the particle we are computed the position for
  20303. */
  20304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20305. /**
  20306. * Clones the current emitter and returns a copy of it
  20307. * @returns the new emitter
  20308. */
  20309. clone(): ConeParticleEmitter;
  20310. /**
  20311. * Called by the GPUParticleSystem to setup the update shader
  20312. * @param effect defines the update shader
  20313. */
  20314. applyToShader(effect: Effect): void;
  20315. /**
  20316. * Returns a string to use to update the GPU particles update shader
  20317. * @returns a string containng the defines string
  20318. */
  20319. getEffectDefines(): string;
  20320. /**
  20321. * Returns the string "ConeParticleEmitter"
  20322. * @returns a string containing the class name
  20323. */
  20324. getClassName(): string;
  20325. /**
  20326. * Serializes the particle system to a JSON object.
  20327. * @returns the JSON object
  20328. */
  20329. serialize(): any;
  20330. /**
  20331. * Parse properties from a JSON object
  20332. * @param serializationObject defines the JSON object
  20333. */
  20334. parse(serializationObject: any): void;
  20335. }
  20336. }
  20337. declare module BABYLON {
  20338. /**
  20339. * Particle emitter emitting particles from the inside of a cylinder.
  20340. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20341. */
  20342. export class CylinderParticleEmitter implements IParticleEmitterType {
  20343. /**
  20344. * The radius of the emission cylinder.
  20345. */
  20346. radius: number;
  20347. /**
  20348. * The height of the emission cylinder.
  20349. */
  20350. height: number;
  20351. /**
  20352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20353. */
  20354. radiusRange: number;
  20355. /**
  20356. * How much to randomize the particle direction [0-1].
  20357. */
  20358. directionRandomizer: number;
  20359. /**
  20360. * Creates a new instance CylinderParticleEmitter
  20361. * @param radius the radius of the emission cylinder (1 by default)
  20362. * @param height the height of the emission cylinder (1 by default)
  20363. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20364. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20365. */
  20366. constructor(
  20367. /**
  20368. * The radius of the emission cylinder.
  20369. */
  20370. radius?: number,
  20371. /**
  20372. * The height of the emission cylinder.
  20373. */
  20374. height?: number,
  20375. /**
  20376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20377. */
  20378. radiusRange?: number,
  20379. /**
  20380. * How much to randomize the particle direction [0-1].
  20381. */
  20382. directionRandomizer?: number);
  20383. /**
  20384. * Called by the particle System when the direction is computed for the created particle.
  20385. * @param worldMatrix is the world matrix of the particle system
  20386. * @param directionToUpdate is the direction vector to update with the result
  20387. * @param particle is the particle we are computed the direction for
  20388. */
  20389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20390. /**
  20391. * Called by the particle System when the position is computed for the created particle.
  20392. * @param worldMatrix is the world matrix of the particle system
  20393. * @param positionToUpdate is the position vector to update with the result
  20394. * @param particle is the particle we are computed the position for
  20395. */
  20396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20397. /**
  20398. * Clones the current emitter and returns a copy of it
  20399. * @returns the new emitter
  20400. */
  20401. clone(): CylinderParticleEmitter;
  20402. /**
  20403. * Called by the GPUParticleSystem to setup the update shader
  20404. * @param effect defines the update shader
  20405. */
  20406. applyToShader(effect: Effect): void;
  20407. /**
  20408. * Returns a string to use to update the GPU particles update shader
  20409. * @returns a string containng the defines string
  20410. */
  20411. getEffectDefines(): string;
  20412. /**
  20413. * Returns the string "CylinderParticleEmitter"
  20414. * @returns a string containing the class name
  20415. */
  20416. getClassName(): string;
  20417. /**
  20418. * Serializes the particle system to a JSON object.
  20419. * @returns the JSON object
  20420. */
  20421. serialize(): any;
  20422. /**
  20423. * Parse properties from a JSON object
  20424. * @param serializationObject defines the JSON object
  20425. */
  20426. parse(serializationObject: any): void;
  20427. }
  20428. /**
  20429. * Particle emitter emitting particles from the inside of a cylinder.
  20430. * It emits the particles randomly between two vectors.
  20431. */
  20432. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20433. /**
  20434. * The min limit of the emission direction.
  20435. */
  20436. direction1: Vector3;
  20437. /**
  20438. * The max limit of the emission direction.
  20439. */
  20440. direction2: Vector3;
  20441. /**
  20442. * Creates a new instance CylinderDirectedParticleEmitter
  20443. * @param radius the radius of the emission cylinder (1 by default)
  20444. * @param height the height of the emission cylinder (1 by default)
  20445. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20446. * @param direction1 the min limit of the emission direction (up vector by default)
  20447. * @param direction2 the max limit of the emission direction (up vector by default)
  20448. */
  20449. constructor(radius?: number, height?: number, radiusRange?: number,
  20450. /**
  20451. * The min limit of the emission direction.
  20452. */
  20453. direction1?: Vector3,
  20454. /**
  20455. * The max limit of the emission direction.
  20456. */
  20457. direction2?: Vector3);
  20458. /**
  20459. * Called by the particle System when the direction is computed for the created particle.
  20460. * @param worldMatrix is the world matrix of the particle system
  20461. * @param directionToUpdate is the direction vector to update with the result
  20462. * @param particle is the particle we are computed the direction for
  20463. */
  20464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20465. /**
  20466. * Clones the current emitter and returns a copy of it
  20467. * @returns the new emitter
  20468. */
  20469. clone(): CylinderDirectedParticleEmitter;
  20470. /**
  20471. * Called by the GPUParticleSystem to setup the update shader
  20472. * @param effect defines the update shader
  20473. */
  20474. applyToShader(effect: Effect): void;
  20475. /**
  20476. * Returns a string to use to update the GPU particles update shader
  20477. * @returns a string containng the defines string
  20478. */
  20479. getEffectDefines(): string;
  20480. /**
  20481. * Returns the string "CylinderDirectedParticleEmitter"
  20482. * @returns a string containing the class name
  20483. */
  20484. getClassName(): string;
  20485. /**
  20486. * Serializes the particle system to a JSON object.
  20487. * @returns the JSON object
  20488. */
  20489. serialize(): any;
  20490. /**
  20491. * Parse properties from a JSON object
  20492. * @param serializationObject defines the JSON object
  20493. */
  20494. parse(serializationObject: any): void;
  20495. }
  20496. }
  20497. declare module BABYLON {
  20498. /**
  20499. * Particle emitter emitting particles from the inside of a hemisphere.
  20500. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20501. */
  20502. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20503. /**
  20504. * The radius of the emission hemisphere.
  20505. */
  20506. radius: number;
  20507. /**
  20508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20509. */
  20510. radiusRange: number;
  20511. /**
  20512. * How much to randomize the particle direction [0-1].
  20513. */
  20514. directionRandomizer: number;
  20515. /**
  20516. * Creates a new instance HemisphericParticleEmitter
  20517. * @param radius the radius of the emission hemisphere (1 by default)
  20518. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20519. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20520. */
  20521. constructor(
  20522. /**
  20523. * The radius of the emission hemisphere.
  20524. */
  20525. radius?: number,
  20526. /**
  20527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20528. */
  20529. radiusRange?: number,
  20530. /**
  20531. * How much to randomize the particle direction [0-1].
  20532. */
  20533. directionRandomizer?: number);
  20534. /**
  20535. * Called by the particle System when the direction is computed for the created particle.
  20536. * @param worldMatrix is the world matrix of the particle system
  20537. * @param directionToUpdate is the direction vector to update with the result
  20538. * @param particle is the particle we are computed the direction for
  20539. */
  20540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20541. /**
  20542. * Called by the particle System when the position is computed for the created particle.
  20543. * @param worldMatrix is the world matrix of the particle system
  20544. * @param positionToUpdate is the position vector to update with the result
  20545. * @param particle is the particle we are computed the position for
  20546. */
  20547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20548. /**
  20549. * Clones the current emitter and returns a copy of it
  20550. * @returns the new emitter
  20551. */
  20552. clone(): HemisphericParticleEmitter;
  20553. /**
  20554. * Called by the GPUParticleSystem to setup the update shader
  20555. * @param effect defines the update shader
  20556. */
  20557. applyToShader(effect: Effect): void;
  20558. /**
  20559. * Returns a string to use to update the GPU particles update shader
  20560. * @returns a string containng the defines string
  20561. */
  20562. getEffectDefines(): string;
  20563. /**
  20564. * Returns the string "HemisphericParticleEmitter"
  20565. * @returns a string containing the class name
  20566. */
  20567. getClassName(): string;
  20568. /**
  20569. * Serializes the particle system to a JSON object.
  20570. * @returns the JSON object
  20571. */
  20572. serialize(): any;
  20573. /**
  20574. * Parse properties from a JSON object
  20575. * @param serializationObject defines the JSON object
  20576. */
  20577. parse(serializationObject: any): void;
  20578. }
  20579. }
  20580. declare module BABYLON {
  20581. /**
  20582. * Particle emitter emitting particles from a point.
  20583. * It emits the particles randomly between 2 given directions.
  20584. */
  20585. export class PointParticleEmitter implements IParticleEmitterType {
  20586. /**
  20587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20588. */
  20589. direction1: Vector3;
  20590. /**
  20591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20592. */
  20593. direction2: Vector3;
  20594. /**
  20595. * Creates a new instance PointParticleEmitter
  20596. */
  20597. constructor();
  20598. /**
  20599. * Called by the particle System when the direction is computed for the created particle.
  20600. * @param worldMatrix is the world matrix of the particle system
  20601. * @param directionToUpdate is the direction vector to update with the result
  20602. * @param particle is the particle we are computed the direction for
  20603. */
  20604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20605. /**
  20606. * Called by the particle System when the position is computed for the created particle.
  20607. * @param worldMatrix is the world matrix of the particle system
  20608. * @param positionToUpdate is the position vector to update with the result
  20609. * @param particle is the particle we are computed the position for
  20610. */
  20611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20612. /**
  20613. * Clones the current emitter and returns a copy of it
  20614. * @returns the new emitter
  20615. */
  20616. clone(): PointParticleEmitter;
  20617. /**
  20618. * Called by the GPUParticleSystem to setup the update shader
  20619. * @param effect defines the update shader
  20620. */
  20621. applyToShader(effect: Effect): void;
  20622. /**
  20623. * Returns a string to use to update the GPU particles update shader
  20624. * @returns a string containng the defines string
  20625. */
  20626. getEffectDefines(): string;
  20627. /**
  20628. * Returns the string "PointParticleEmitter"
  20629. * @returns a string containing the class name
  20630. */
  20631. getClassName(): string;
  20632. /**
  20633. * Serializes the particle system to a JSON object.
  20634. * @returns the JSON object
  20635. */
  20636. serialize(): any;
  20637. /**
  20638. * Parse properties from a JSON object
  20639. * @param serializationObject defines the JSON object
  20640. */
  20641. parse(serializationObject: any): void;
  20642. }
  20643. }
  20644. declare module BABYLON {
  20645. /**
  20646. * Particle emitter emitting particles from the inside of a sphere.
  20647. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20648. */
  20649. export class SphereParticleEmitter implements IParticleEmitterType {
  20650. /**
  20651. * The radius of the emission sphere.
  20652. */
  20653. radius: number;
  20654. /**
  20655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20656. */
  20657. radiusRange: number;
  20658. /**
  20659. * How much to randomize the particle direction [0-1].
  20660. */
  20661. directionRandomizer: number;
  20662. /**
  20663. * Creates a new instance SphereParticleEmitter
  20664. * @param radius the radius of the emission sphere (1 by default)
  20665. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20666. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20667. */
  20668. constructor(
  20669. /**
  20670. * The radius of the emission sphere.
  20671. */
  20672. radius?: number,
  20673. /**
  20674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20675. */
  20676. radiusRange?: number,
  20677. /**
  20678. * How much to randomize the particle direction [0-1].
  20679. */
  20680. directionRandomizer?: number);
  20681. /**
  20682. * Called by the particle System when the direction is computed for the created particle.
  20683. * @param worldMatrix is the world matrix of the particle system
  20684. * @param directionToUpdate is the direction vector to update with the result
  20685. * @param particle is the particle we are computed the direction for
  20686. */
  20687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20688. /**
  20689. * Called by the particle System when the position is computed for the created particle.
  20690. * @param worldMatrix is the world matrix of the particle system
  20691. * @param positionToUpdate is the position vector to update with the result
  20692. * @param particle is the particle we are computed the position for
  20693. */
  20694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20695. /**
  20696. * Clones the current emitter and returns a copy of it
  20697. * @returns the new emitter
  20698. */
  20699. clone(): SphereParticleEmitter;
  20700. /**
  20701. * Called by the GPUParticleSystem to setup the update shader
  20702. * @param effect defines the update shader
  20703. */
  20704. applyToShader(effect: Effect): void;
  20705. /**
  20706. * Returns a string to use to update the GPU particles update shader
  20707. * @returns a string containng the defines string
  20708. */
  20709. getEffectDefines(): string;
  20710. /**
  20711. * Returns the string "SphereParticleEmitter"
  20712. * @returns a string containing the class name
  20713. */
  20714. getClassName(): string;
  20715. /**
  20716. * Serializes the particle system to a JSON object.
  20717. * @returns the JSON object
  20718. */
  20719. serialize(): any;
  20720. /**
  20721. * Parse properties from a JSON object
  20722. * @param serializationObject defines the JSON object
  20723. */
  20724. parse(serializationObject: any): void;
  20725. }
  20726. /**
  20727. * Particle emitter emitting particles from the inside of a sphere.
  20728. * It emits the particles randomly between two vectors.
  20729. */
  20730. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20731. /**
  20732. * The min limit of the emission direction.
  20733. */
  20734. direction1: Vector3;
  20735. /**
  20736. * The max limit of the emission direction.
  20737. */
  20738. direction2: Vector3;
  20739. /**
  20740. * Creates a new instance SphereDirectedParticleEmitter
  20741. * @param radius the radius of the emission sphere (1 by default)
  20742. * @param direction1 the min limit of the emission direction (up vector by default)
  20743. * @param direction2 the max limit of the emission direction (up vector by default)
  20744. */
  20745. constructor(radius?: number,
  20746. /**
  20747. * The min limit of the emission direction.
  20748. */
  20749. direction1?: Vector3,
  20750. /**
  20751. * The max limit of the emission direction.
  20752. */
  20753. direction2?: Vector3);
  20754. /**
  20755. * Called by the particle System when the direction is computed for the created particle.
  20756. * @param worldMatrix is the world matrix of the particle system
  20757. * @param directionToUpdate is the direction vector to update with the result
  20758. * @param particle is the particle we are computed the direction for
  20759. */
  20760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20761. /**
  20762. * Clones the current emitter and returns a copy of it
  20763. * @returns the new emitter
  20764. */
  20765. clone(): SphereDirectedParticleEmitter;
  20766. /**
  20767. * Called by the GPUParticleSystem to setup the update shader
  20768. * @param effect defines the update shader
  20769. */
  20770. applyToShader(effect: Effect): void;
  20771. /**
  20772. * Returns a string to use to update the GPU particles update shader
  20773. * @returns a string containng the defines string
  20774. */
  20775. getEffectDefines(): string;
  20776. /**
  20777. * Returns the string "SphereDirectedParticleEmitter"
  20778. * @returns a string containing the class name
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Serializes the particle system to a JSON object.
  20783. * @returns the JSON object
  20784. */
  20785. serialize(): any;
  20786. /**
  20787. * Parse properties from a JSON object
  20788. * @param serializationObject defines the JSON object
  20789. */
  20790. parse(serializationObject: any): void;
  20791. }
  20792. }
  20793. declare module BABYLON {
  20794. /**
  20795. * Interface representing a particle system in Babylon.js.
  20796. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20797. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20798. */
  20799. export interface IParticleSystem {
  20800. /**
  20801. * List of animations used by the particle system.
  20802. */
  20803. animations: Animation[];
  20804. /**
  20805. * The id of the Particle system.
  20806. */
  20807. id: string;
  20808. /**
  20809. * The name of the Particle system.
  20810. */
  20811. name: string;
  20812. /**
  20813. * The emitter represents the Mesh or position we are attaching the particle system to.
  20814. */
  20815. emitter: Nullable<AbstractMesh | Vector3>;
  20816. /**
  20817. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20818. */
  20819. isBillboardBased: boolean;
  20820. /**
  20821. * The rendering group used by the Particle system to chose when to render.
  20822. */
  20823. renderingGroupId: number;
  20824. /**
  20825. * The layer mask we are rendering the particles through.
  20826. */
  20827. layerMask: number;
  20828. /**
  20829. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20830. */
  20831. updateSpeed: number;
  20832. /**
  20833. * The amount of time the particle system is running (depends of the overall update speed).
  20834. */
  20835. targetStopDuration: number;
  20836. /**
  20837. * The texture used to render each particle. (this can be a spritesheet)
  20838. */
  20839. particleTexture: Nullable<Texture>;
  20840. /**
  20841. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20842. */
  20843. blendMode: number;
  20844. /**
  20845. * Minimum life time of emitting particles.
  20846. */
  20847. minLifeTime: number;
  20848. /**
  20849. * Maximum life time of emitting particles.
  20850. */
  20851. maxLifeTime: number;
  20852. /**
  20853. * Minimum Size of emitting particles.
  20854. */
  20855. minSize: number;
  20856. /**
  20857. * Maximum Size of emitting particles.
  20858. */
  20859. maxSize: number;
  20860. /**
  20861. * Minimum scale of emitting particles on X axis.
  20862. */
  20863. minScaleX: number;
  20864. /**
  20865. * Maximum scale of emitting particles on X axis.
  20866. */
  20867. maxScaleX: number;
  20868. /**
  20869. * Minimum scale of emitting particles on Y axis.
  20870. */
  20871. minScaleY: number;
  20872. /**
  20873. * Maximum scale of emitting particles on Y axis.
  20874. */
  20875. maxScaleY: number;
  20876. /**
  20877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20878. */
  20879. color1: Color4;
  20880. /**
  20881. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20882. */
  20883. color2: Color4;
  20884. /**
  20885. * Color the particle will have at the end of its lifetime.
  20886. */
  20887. colorDead: Color4;
  20888. /**
  20889. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20890. */
  20891. emitRate: number;
  20892. /**
  20893. * You can use gravity if you want to give an orientation to your particles.
  20894. */
  20895. gravity: Vector3;
  20896. /**
  20897. * Minimum power of emitting particles.
  20898. */
  20899. minEmitPower: number;
  20900. /**
  20901. * Maximum power of emitting particles.
  20902. */
  20903. maxEmitPower: number;
  20904. /**
  20905. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20906. */
  20907. minAngularSpeed: number;
  20908. /**
  20909. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20910. */
  20911. maxAngularSpeed: number;
  20912. /**
  20913. * Gets or sets the minimal initial rotation in radians.
  20914. */
  20915. minInitialRotation: number;
  20916. /**
  20917. * Gets or sets the maximal initial rotation in radians.
  20918. */
  20919. maxInitialRotation: number;
  20920. /**
  20921. * The particle emitter type defines the emitter used by the particle system.
  20922. * It can be for example box, sphere, or cone...
  20923. */
  20924. particleEmitterType: Nullable<IParticleEmitterType>;
  20925. /**
  20926. * Defines the delay in milliseconds before starting the system (0 by default)
  20927. */
  20928. startDelay: number;
  20929. /**
  20930. * 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
  20931. */
  20932. preWarmCycles: number;
  20933. /**
  20934. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20935. */
  20936. preWarmStepOffset: number;
  20937. /**
  20938. * 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)
  20939. */
  20940. spriteCellChangeSpeed: number;
  20941. /**
  20942. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20943. */
  20944. startSpriteCellID: number;
  20945. /**
  20946. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20947. */
  20948. endSpriteCellID: number;
  20949. /**
  20950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20951. */
  20952. spriteCellWidth: number;
  20953. /**
  20954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20955. */
  20956. spriteCellHeight: number;
  20957. /**
  20958. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20959. */
  20960. spriteRandomStartCell: boolean;
  20961. /**
  20962. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20963. */
  20964. isAnimationSheetEnabled: boolean;
  20965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20966. translationPivot: Vector2;
  20967. /**
  20968. * Gets or sets a texture used to add random noise to particle positions
  20969. */
  20970. noiseTexture: Nullable<BaseTexture>;
  20971. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  20972. noiseStrength: Vector3;
  20973. /**
  20974. * Gets or sets the billboard mode to use when isBillboardBased = true.
  20975. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  20976. */
  20977. billboardMode: number;
  20978. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  20979. limitVelocityDamping: number;
  20980. /**
  20981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  20982. */
  20983. beginAnimationOnStart: boolean;
  20984. /**
  20985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  20986. */
  20987. beginAnimationFrom: number;
  20988. /**
  20989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  20990. */
  20991. beginAnimationTo: number;
  20992. /**
  20993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  20994. */
  20995. beginAnimationLoop: boolean;
  20996. /**
  20997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  20998. */
  20999. disposeOnStop: boolean;
  21000. /**
  21001. * Gets the maximum number of particles active at the same time.
  21002. * @returns The max number of active particles.
  21003. */
  21004. getCapacity(): number;
  21005. /**
  21006. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21007. * @returns True if it has been started, otherwise false.
  21008. */
  21009. isStarted(): boolean;
  21010. /**
  21011. * Animates the particle system for this frame.
  21012. */
  21013. animate(): void;
  21014. /**
  21015. * Renders the particle system in its current state.
  21016. * @returns the current number of particles
  21017. */
  21018. render(): number;
  21019. /**
  21020. * Dispose the particle system and frees its associated resources.
  21021. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21022. */
  21023. dispose(disposeTexture?: boolean): void;
  21024. /**
  21025. * Clones the particle system.
  21026. * @param name The name of the cloned object
  21027. * @param newEmitter The new emitter to use
  21028. * @returns the cloned particle system
  21029. */
  21030. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21031. /**
  21032. * Serializes the particle system to a JSON object.
  21033. * @returns the JSON object
  21034. */
  21035. serialize(): any;
  21036. /**
  21037. * Rebuild the particle system
  21038. */
  21039. rebuild(): void;
  21040. /**
  21041. * Starts the particle system and begins to emit
  21042. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21043. */
  21044. start(delay?: number): void;
  21045. /**
  21046. * Stops the particle system.
  21047. */
  21048. stop(): void;
  21049. /**
  21050. * Remove all active particles
  21051. */
  21052. reset(): void;
  21053. /**
  21054. * Is this system ready to be used/rendered
  21055. * @return true if the system is ready
  21056. */
  21057. isReady(): boolean;
  21058. /**
  21059. * Adds a new color gradient
  21060. * @param gradient defines the gradient to use (between 0 and 1)
  21061. * @param color1 defines the color to affect to the specified gradient
  21062. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21063. * @returns the current particle system
  21064. */
  21065. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21066. /**
  21067. * Remove a specific color gradient
  21068. * @param gradient defines the gradient to remove
  21069. * @returns the current particle system
  21070. */
  21071. removeColorGradient(gradient: number): IParticleSystem;
  21072. /**
  21073. * Adds a new size gradient
  21074. * @param gradient defines the gradient to use (between 0 and 1)
  21075. * @param factor defines the size factor to affect to the specified gradient
  21076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21077. * @returns the current particle system
  21078. */
  21079. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21080. /**
  21081. * Remove a specific size gradient
  21082. * @param gradient defines the gradient to remove
  21083. * @returns the current particle system
  21084. */
  21085. removeSizeGradient(gradient: number): IParticleSystem;
  21086. /**
  21087. * Gets the current list of color gradients.
  21088. * You must use addColorGradient and removeColorGradient to udpate this list
  21089. * @returns the list of color gradients
  21090. */
  21091. getColorGradients(): Nullable<Array<ColorGradient>>;
  21092. /**
  21093. * Gets the current list of size gradients.
  21094. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21095. * @returns the list of size gradients
  21096. */
  21097. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21098. /**
  21099. * Gets the current list of angular speed gradients.
  21100. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21101. * @returns the list of angular speed gradients
  21102. */
  21103. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21104. /**
  21105. * Adds a new angular speed gradient
  21106. * @param gradient defines the gradient to use (between 0 and 1)
  21107. * @param factor defines the angular speed to affect to the specified gradient
  21108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21109. * @returns the current particle system
  21110. */
  21111. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21112. /**
  21113. * Remove a specific angular speed gradient
  21114. * @param gradient defines the gradient to remove
  21115. * @returns the current particle system
  21116. */
  21117. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21118. /**
  21119. * Gets the current list of velocity gradients.
  21120. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21121. * @returns the list of velocity gradients
  21122. */
  21123. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21124. /**
  21125. * Adds a new velocity gradient
  21126. * @param gradient defines the gradient to use (between 0 and 1)
  21127. * @param factor defines the velocity to affect to the specified gradient
  21128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21129. * @returns the current particle system
  21130. */
  21131. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21132. /**
  21133. * Remove a specific velocity gradient
  21134. * @param gradient defines the gradient to remove
  21135. * @returns the current particle system
  21136. */
  21137. removeVelocityGradient(gradient: number): IParticleSystem;
  21138. /**
  21139. * Gets the current list of limit velocity gradients.
  21140. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21141. * @returns the list of limit velocity gradients
  21142. */
  21143. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21144. /**
  21145. * Adds a new limit velocity gradient
  21146. * @param gradient defines the gradient to use (between 0 and 1)
  21147. * @param factor defines the limit velocity to affect to the specified gradient
  21148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21149. * @returns the current particle system
  21150. */
  21151. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21152. /**
  21153. * Remove a specific limit velocity gradient
  21154. * @param gradient defines the gradient to remove
  21155. * @returns the current particle system
  21156. */
  21157. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21158. /**
  21159. * Adds a new drag gradient
  21160. * @param gradient defines the gradient to use (between 0 and 1)
  21161. * @param factor defines the drag to affect to the specified gradient
  21162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21163. * @returns the current particle system
  21164. */
  21165. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21166. /**
  21167. * Remove a specific drag gradient
  21168. * @param gradient defines the gradient to remove
  21169. * @returns the current particle system
  21170. */
  21171. removeDragGradient(gradient: number): IParticleSystem;
  21172. /**
  21173. * Gets the current list of drag gradients.
  21174. * You must use addDragGradient and removeDragGradient to udpate this list
  21175. * @returns the list of drag gradients
  21176. */
  21177. getDragGradients(): Nullable<Array<FactorGradient>>;
  21178. /**
  21179. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21180. * @param gradient defines the gradient to use (between 0 and 1)
  21181. * @param factor defines the emit rate to affect to the specified gradient
  21182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21183. * @returns the current particle system
  21184. */
  21185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21186. /**
  21187. * Remove a specific emit rate gradient
  21188. * @param gradient defines the gradient to remove
  21189. * @returns the current particle system
  21190. */
  21191. removeEmitRateGradient(gradient: number): IParticleSystem;
  21192. /**
  21193. * Gets the current list of emit rate gradients.
  21194. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21195. * @returns the list of emit rate gradients
  21196. */
  21197. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21198. /**
  21199. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21200. * @param gradient defines the gradient to use (between 0 and 1)
  21201. * @param factor defines the start size to affect to the specified gradient
  21202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21203. * @returns the current particle system
  21204. */
  21205. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21206. /**
  21207. * Remove a specific start size gradient
  21208. * @param gradient defines the gradient to remove
  21209. * @returns the current particle system
  21210. */
  21211. removeStartSizeGradient(gradient: number): IParticleSystem;
  21212. /**
  21213. * Gets the current list of start size gradients.
  21214. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21215. * @returns the list of start size gradients
  21216. */
  21217. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21218. /**
  21219. * Adds a new life time gradient
  21220. * @param gradient defines the gradient to use (between 0 and 1)
  21221. * @param factor defines the life time factor to affect to the specified gradient
  21222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21223. * @returns the current particle system
  21224. */
  21225. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21226. /**
  21227. * Remove a specific life time gradient
  21228. * @param gradient defines the gradient to remove
  21229. * @returns the current particle system
  21230. */
  21231. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21232. /**
  21233. * Gets the current list of life time gradients.
  21234. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21235. * @returns the list of life time gradients
  21236. */
  21237. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21238. /**
  21239. * Gets the current list of color gradients.
  21240. * You must use addColorGradient and removeColorGradient to udpate this list
  21241. * @returns the list of color gradients
  21242. */
  21243. getColorGradients(): Nullable<Array<ColorGradient>>;
  21244. /**
  21245. * Adds a new ramp gradient used to remap particle colors
  21246. * @param gradient defines the gradient to use (between 0 and 1)
  21247. * @param color defines the color to affect to the specified gradient
  21248. * @returns the current particle system
  21249. */
  21250. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21251. /**
  21252. * Gets the current list of ramp gradients.
  21253. * You must use addRampGradient and removeRampGradient to udpate this list
  21254. * @returns the list of ramp gradients
  21255. */
  21256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21257. /** Gets or sets a boolean indicating that ramp gradients must be used
  21258. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21259. */
  21260. useRampGradients: boolean;
  21261. /**
  21262. * Adds a new color remap gradient
  21263. * @param gradient defines the gradient to use (between 0 and 1)
  21264. * @param min defines the color remap minimal range
  21265. * @param max defines the color remap maximal range
  21266. * @returns the current particle system
  21267. */
  21268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21269. /**
  21270. * Gets the current list of color remap gradients.
  21271. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21272. * @returns the list of color remap gradients
  21273. */
  21274. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21275. /**
  21276. * Adds a new alpha remap gradient
  21277. * @param gradient defines the gradient to use (between 0 and 1)
  21278. * @param min defines the alpha remap minimal range
  21279. * @param max defines the alpha remap maximal range
  21280. * @returns the current particle system
  21281. */
  21282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21283. /**
  21284. * Gets the current list of alpha remap gradients.
  21285. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21286. * @returns the list of alpha remap gradients
  21287. */
  21288. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21289. /**
  21290. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21293. * @returns the emitter
  21294. */
  21295. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21296. /**
  21297. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21298. * @param radius The radius of the hemisphere to emit from
  21299. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21300. * @returns the emitter
  21301. */
  21302. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21303. /**
  21304. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21305. * @param radius The radius of the sphere to emit from
  21306. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21307. * @returns the emitter
  21308. */
  21309. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21310. /**
  21311. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21312. * @param radius The radius of the sphere to emit from
  21313. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21314. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21315. * @returns the emitter
  21316. */
  21317. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21318. /**
  21319. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21320. * @param radius The radius of the emission cylinder
  21321. * @param height The height of the emission cylinder
  21322. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21323. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21324. * @returns the emitter
  21325. */
  21326. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21327. /**
  21328. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21329. * @param radius The radius of the cylinder to emit from
  21330. * @param height The height of the emission cylinder
  21331. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21334. * @returns the emitter
  21335. */
  21336. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21337. /**
  21338. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21339. * @param radius The radius of the cone to emit from
  21340. * @param angle The base angle of the cone
  21341. * @returns the emitter
  21342. */
  21343. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21344. /**
  21345. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21346. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21347. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21348. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21349. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21350. * @returns the emitter
  21351. */
  21352. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21353. /**
  21354. * Get hosting scene
  21355. * @returns the scene
  21356. */
  21357. getScene(): Scene;
  21358. }
  21359. }
  21360. declare module BABYLON {
  21361. /** @hidden */
  21362. export var linePixelShader: {
  21363. name: string;
  21364. shader: string;
  21365. };
  21366. }
  21367. declare module BABYLON {
  21368. /** @hidden */
  21369. export var lineVertexShader: {
  21370. name: string;
  21371. shader: string;
  21372. };
  21373. }
  21374. declare module BABYLON {
  21375. interface AbstractMesh {
  21376. /**
  21377. * Gets the edgesRenderer associated with the mesh
  21378. */
  21379. edgesRenderer: Nullable<EdgesRenderer>;
  21380. }
  21381. interface LinesMesh {
  21382. /**
  21383. * Enables the edge rendering mode on the mesh.
  21384. * This mode makes the mesh edges visible
  21385. * @param epsilon defines the maximal distance between two angles to detect a face
  21386. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21387. * @returns the currentAbstractMesh
  21388. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21389. */
  21390. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21391. }
  21392. interface InstancedLinesMesh {
  21393. /**
  21394. * Enables the edge rendering mode on the mesh.
  21395. * This mode makes the mesh edges visible
  21396. * @param epsilon defines the maximal distance between two angles to detect a face
  21397. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21398. * @returns the current InstancedLinesMesh
  21399. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21400. */
  21401. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21402. }
  21403. /**
  21404. * Defines the minimum contract an Edges renderer should follow.
  21405. */
  21406. export interface IEdgesRenderer extends IDisposable {
  21407. /**
  21408. * Gets or sets a boolean indicating if the edgesRenderer is active
  21409. */
  21410. isEnabled: boolean;
  21411. /**
  21412. * Renders the edges of the attached mesh,
  21413. */
  21414. render(): void;
  21415. /**
  21416. * Checks wether or not the edges renderer is ready to render.
  21417. * @return true if ready, otherwise false.
  21418. */
  21419. isReady(): boolean;
  21420. }
  21421. /**
  21422. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21423. */
  21424. export class EdgesRenderer implements IEdgesRenderer {
  21425. /**
  21426. * Define the size of the edges with an orthographic camera
  21427. */
  21428. edgesWidthScalerForOrthographic: number;
  21429. /**
  21430. * Define the size of the edges with a perspective camera
  21431. */
  21432. edgesWidthScalerForPerspective: number;
  21433. protected _source: AbstractMesh;
  21434. protected _linesPositions: number[];
  21435. protected _linesNormals: number[];
  21436. protected _linesIndices: number[];
  21437. protected _epsilon: number;
  21438. protected _indicesCount: number;
  21439. protected _lineShader: ShaderMaterial;
  21440. protected _ib: DataBuffer;
  21441. protected _buffers: {
  21442. [key: string]: Nullable<VertexBuffer>;
  21443. };
  21444. protected _checkVerticesInsteadOfIndices: boolean;
  21445. private _meshRebuildObserver;
  21446. private _meshDisposeObserver;
  21447. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21448. isEnabled: boolean;
  21449. /**
  21450. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21451. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21452. * @param source Mesh used to create edges
  21453. * @param epsilon sum of angles in adjacency to check for edge
  21454. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21455. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21456. */
  21457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21458. protected _prepareRessources(): void;
  21459. /** @hidden */
  21460. _rebuild(): void;
  21461. /**
  21462. * Releases the required resources for the edges renderer
  21463. */
  21464. dispose(): void;
  21465. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21466. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21467. /**
  21468. * Checks if the pair of p0 and p1 is en edge
  21469. * @param faceIndex
  21470. * @param edge
  21471. * @param faceNormals
  21472. * @param p0
  21473. * @param p1
  21474. * @private
  21475. */
  21476. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21477. /**
  21478. * push line into the position, normal and index buffer
  21479. * @protected
  21480. */
  21481. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21482. /**
  21483. * Generates lines edges from adjacencjes
  21484. * @private
  21485. */
  21486. _generateEdgesLines(): void;
  21487. /**
  21488. * Checks wether or not the edges renderer is ready to render.
  21489. * @return true if ready, otherwise false.
  21490. */
  21491. isReady(): boolean;
  21492. /**
  21493. * Renders the edges of the attached mesh,
  21494. */
  21495. render(): void;
  21496. }
  21497. /**
  21498. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21499. */
  21500. export class LineEdgesRenderer extends EdgesRenderer {
  21501. /**
  21502. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21503. * @param source LineMesh used to generate edges
  21504. * @param epsilon not important (specified angle for edge detection)
  21505. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21506. */
  21507. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21508. /**
  21509. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21510. */
  21511. _generateEdgesLines(): void;
  21512. }
  21513. }
  21514. declare module BABYLON {
  21515. /**
  21516. * This represents the object necessary to create a rendering group.
  21517. * This is exclusively used and created by the rendering manager.
  21518. * To modify the behavior, you use the available helpers in your scene or meshes.
  21519. * @hidden
  21520. */
  21521. export class RenderingGroup {
  21522. index: number;
  21523. private static _zeroVector;
  21524. private _scene;
  21525. private _opaqueSubMeshes;
  21526. private _transparentSubMeshes;
  21527. private _alphaTestSubMeshes;
  21528. private _depthOnlySubMeshes;
  21529. private _particleSystems;
  21530. private _spriteManagers;
  21531. private _opaqueSortCompareFn;
  21532. private _alphaTestSortCompareFn;
  21533. private _transparentSortCompareFn;
  21534. private _renderOpaque;
  21535. private _renderAlphaTest;
  21536. private _renderTransparent;
  21537. /** @hidden */
  21538. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21539. onBeforeTransparentRendering: () => void;
  21540. /**
  21541. * Set the opaque sort comparison function.
  21542. * If null the sub meshes will be render in the order they were created
  21543. */
  21544. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21545. /**
  21546. * Set the alpha test sort comparison function.
  21547. * If null the sub meshes will be render in the order they were created
  21548. */
  21549. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21550. /**
  21551. * Set the transparent sort comparison function.
  21552. * If null the sub meshes will be render in the order they were created
  21553. */
  21554. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21555. /**
  21556. * Creates a new rendering group.
  21557. * @param index The rendering group index
  21558. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21559. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21560. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21561. */
  21562. 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>);
  21563. /**
  21564. * Render all the sub meshes contained in the group.
  21565. * @param customRenderFunction Used to override the default render behaviour of the group.
  21566. * @returns true if rendered some submeshes.
  21567. */
  21568. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21569. /**
  21570. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21571. * @param subMeshes The submeshes to render
  21572. */
  21573. private renderOpaqueSorted;
  21574. /**
  21575. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21576. * @param subMeshes The submeshes to render
  21577. */
  21578. private renderAlphaTestSorted;
  21579. /**
  21580. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21581. * @param subMeshes The submeshes to render
  21582. */
  21583. private renderTransparentSorted;
  21584. /**
  21585. * Renders the submeshes in a specified order.
  21586. * @param subMeshes The submeshes to sort before render
  21587. * @param sortCompareFn The comparison function use to sort
  21588. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21589. * @param transparent Specifies to activate blending if true
  21590. */
  21591. private static renderSorted;
  21592. /**
  21593. * Renders the submeshes in the order they were dispatched (no sort applied).
  21594. * @param subMeshes The submeshes to render
  21595. */
  21596. private static renderUnsorted;
  21597. /**
  21598. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21599. * are rendered back to front if in the same alpha index.
  21600. *
  21601. * @param a The first submesh
  21602. * @param b The second submesh
  21603. * @returns The result of the comparison
  21604. */
  21605. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21606. /**
  21607. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21608. * are rendered back to front.
  21609. *
  21610. * @param a The first submesh
  21611. * @param b The second submesh
  21612. * @returns The result of the comparison
  21613. */
  21614. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21615. /**
  21616. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21617. * are rendered front to back (prevent overdraw).
  21618. *
  21619. * @param a The first submesh
  21620. * @param b The second submesh
  21621. * @returns The result of the comparison
  21622. */
  21623. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21624. /**
  21625. * Resets the different lists of submeshes to prepare a new frame.
  21626. */
  21627. prepare(): void;
  21628. dispose(): void;
  21629. /**
  21630. * Inserts the submesh in its correct queue depending on its material.
  21631. * @param subMesh The submesh to dispatch
  21632. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21633. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21634. */
  21635. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21636. dispatchSprites(spriteManager: ISpriteManager): void;
  21637. dispatchParticles(particleSystem: IParticleSystem): void;
  21638. private _renderParticles;
  21639. private _renderSprites;
  21640. }
  21641. }
  21642. declare module BABYLON {
  21643. /**
  21644. * Interface describing the different options available in the rendering manager
  21645. * regarding Auto Clear between groups.
  21646. */
  21647. export interface IRenderingManagerAutoClearSetup {
  21648. /**
  21649. * Defines whether or not autoclear is enable.
  21650. */
  21651. autoClear: boolean;
  21652. /**
  21653. * Defines whether or not to autoclear the depth buffer.
  21654. */
  21655. depth: boolean;
  21656. /**
  21657. * Defines whether or not to autoclear the stencil buffer.
  21658. */
  21659. stencil: boolean;
  21660. }
  21661. /**
  21662. * This class is used by the onRenderingGroupObservable
  21663. */
  21664. export class RenderingGroupInfo {
  21665. /**
  21666. * The Scene that being rendered
  21667. */
  21668. scene: Scene;
  21669. /**
  21670. * The camera currently used for the rendering pass
  21671. */
  21672. camera: Nullable<Camera>;
  21673. /**
  21674. * The ID of the renderingGroup being processed
  21675. */
  21676. renderingGroupId: number;
  21677. }
  21678. /**
  21679. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21680. * It is enable to manage the different groups as well as the different necessary sort functions.
  21681. * This should not be used directly aside of the few static configurations
  21682. */
  21683. export class RenderingManager {
  21684. /**
  21685. * The max id used for rendering groups (not included)
  21686. */
  21687. static MAX_RENDERINGGROUPS: number;
  21688. /**
  21689. * The min id used for rendering groups (included)
  21690. */
  21691. static MIN_RENDERINGGROUPS: number;
  21692. /**
  21693. * Used to globally prevent autoclearing scenes.
  21694. */
  21695. static AUTOCLEAR: boolean;
  21696. /**
  21697. * @hidden
  21698. */
  21699. _useSceneAutoClearSetup: boolean;
  21700. private _scene;
  21701. private _renderingGroups;
  21702. private _depthStencilBufferAlreadyCleaned;
  21703. private _autoClearDepthStencil;
  21704. private _customOpaqueSortCompareFn;
  21705. private _customAlphaTestSortCompareFn;
  21706. private _customTransparentSortCompareFn;
  21707. private _renderingGroupInfo;
  21708. /**
  21709. * Instantiates a new rendering group for a particular scene
  21710. * @param scene Defines the scene the groups belongs to
  21711. */
  21712. constructor(scene: Scene);
  21713. private _clearDepthStencilBuffer;
  21714. /**
  21715. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21716. * @hidden
  21717. */
  21718. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21719. /**
  21720. * Resets the different information of the group to prepare a new frame
  21721. * @hidden
  21722. */
  21723. reset(): void;
  21724. /**
  21725. * Dispose and release the group and its associated resources.
  21726. * @hidden
  21727. */
  21728. dispose(): void;
  21729. /**
  21730. * Clear the info related to rendering groups preventing retention points during dispose.
  21731. */
  21732. freeRenderingGroups(): void;
  21733. private _prepareRenderingGroup;
  21734. /**
  21735. * Add a sprite manager to the rendering manager in order to render it this frame.
  21736. * @param spriteManager Define the sprite manager to render
  21737. */
  21738. dispatchSprites(spriteManager: ISpriteManager): void;
  21739. /**
  21740. * Add a particle system to the rendering manager in order to render it this frame.
  21741. * @param particleSystem Define the particle system to render
  21742. */
  21743. dispatchParticles(particleSystem: IParticleSystem): void;
  21744. /**
  21745. * Add a submesh to the manager in order to render it this frame
  21746. * @param subMesh The submesh to dispatch
  21747. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21748. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21749. */
  21750. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21751. /**
  21752. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21753. * This allowed control for front to back rendering or reversly depending of the special needs.
  21754. *
  21755. * @param renderingGroupId The rendering group id corresponding to its index
  21756. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21757. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21758. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21759. */
  21760. 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;
  21761. /**
  21762. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21763. *
  21764. * @param renderingGroupId The rendering group id corresponding to its index
  21765. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21766. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21767. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21768. */
  21769. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21770. /**
  21771. * Gets the current auto clear configuration for one rendering group of the rendering
  21772. * manager.
  21773. * @param index the rendering group index to get the information for
  21774. * @returns The auto clear setup for the requested rendering group
  21775. */
  21776. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21777. }
  21778. }
  21779. declare module BABYLON {
  21780. /**
  21781. * This Helps creating a texture that will be created from a camera in your scene.
  21782. * It is basically a dynamic texture that could be used to create special effects for instance.
  21783. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21784. */
  21785. export class RenderTargetTexture extends Texture {
  21786. isCube: boolean;
  21787. /**
  21788. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21789. */
  21790. static readonly REFRESHRATE_RENDER_ONCE: number;
  21791. /**
  21792. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21793. */
  21794. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21795. /**
  21796. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21797. * the central point of your effect and can save a lot of performances.
  21798. */
  21799. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21800. /**
  21801. * Use this predicate to dynamically define the list of mesh you want to render.
  21802. * If set, the renderList property will be overwritten.
  21803. */
  21804. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21805. private _renderList;
  21806. /**
  21807. * Use this list to define the list of mesh you want to render.
  21808. */
  21809. renderList: Nullable<Array<AbstractMesh>>;
  21810. private _hookArray;
  21811. /**
  21812. * Define if particles should be rendered in your texture.
  21813. */
  21814. renderParticles: boolean;
  21815. /**
  21816. * Define if sprites should be rendered in your texture.
  21817. */
  21818. renderSprites: boolean;
  21819. /**
  21820. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21821. */
  21822. coordinatesMode: number;
  21823. /**
  21824. * Define the camera used to render the texture.
  21825. */
  21826. activeCamera: Nullable<Camera>;
  21827. /**
  21828. * Override the render function of the texture with your own one.
  21829. */
  21830. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21831. /**
  21832. * Define if camera post processes should be use while rendering the texture.
  21833. */
  21834. useCameraPostProcesses: boolean;
  21835. /**
  21836. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21837. */
  21838. ignoreCameraViewport: boolean;
  21839. private _postProcessManager;
  21840. private _postProcesses;
  21841. private _resizeObserver;
  21842. /**
  21843. * An event triggered when the texture is unbind.
  21844. */
  21845. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21846. /**
  21847. * An event triggered when the texture is unbind.
  21848. */
  21849. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21850. private _onAfterUnbindObserver;
  21851. /**
  21852. * Set a after unbind callback in the texture.
  21853. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21854. */
  21855. onAfterUnbind: () => void;
  21856. /**
  21857. * An event triggered before rendering the texture
  21858. */
  21859. onBeforeRenderObservable: Observable<number>;
  21860. private _onBeforeRenderObserver;
  21861. /**
  21862. * Set a before render callback in the texture.
  21863. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21864. */
  21865. onBeforeRender: (faceIndex: number) => void;
  21866. /**
  21867. * An event triggered after rendering the texture
  21868. */
  21869. onAfterRenderObservable: Observable<number>;
  21870. private _onAfterRenderObserver;
  21871. /**
  21872. * Set a after render callback in the texture.
  21873. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21874. */
  21875. onAfterRender: (faceIndex: number) => void;
  21876. /**
  21877. * An event triggered after the texture clear
  21878. */
  21879. onClearObservable: Observable<Engine>;
  21880. private _onClearObserver;
  21881. /**
  21882. * Set a clear callback in the texture.
  21883. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21884. */
  21885. onClear: (Engine: Engine) => void;
  21886. /**
  21887. * Define the clear color of the Render Target if it should be different from the scene.
  21888. */
  21889. clearColor: Color4;
  21890. protected _size: number | {
  21891. width: number;
  21892. height: number;
  21893. };
  21894. protected _initialSizeParameter: number | {
  21895. width: number;
  21896. height: number;
  21897. } | {
  21898. ratio: number;
  21899. };
  21900. protected _sizeRatio: Nullable<number>;
  21901. /** @hidden */
  21902. _generateMipMaps: boolean;
  21903. protected _renderingManager: RenderingManager;
  21904. /** @hidden */
  21905. _waitingRenderList: string[];
  21906. protected _doNotChangeAspectRatio: boolean;
  21907. protected _currentRefreshId: number;
  21908. protected _refreshRate: number;
  21909. protected _textureMatrix: Matrix;
  21910. protected _samples: number;
  21911. protected _renderTargetOptions: RenderTargetCreationOptions;
  21912. /**
  21913. * Gets render target creation options that were used.
  21914. */
  21915. readonly renderTargetOptions: RenderTargetCreationOptions;
  21916. protected _engine: Engine;
  21917. protected _onRatioRescale(): void;
  21918. /**
  21919. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21920. * It must define where the camera used to render the texture is set
  21921. */
  21922. boundingBoxPosition: Vector3;
  21923. private _boundingBoxSize;
  21924. /**
  21925. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21926. * When defined, the cubemap will switch to local mode
  21927. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21928. * @example https://www.babylonjs-playground.com/#RNASML
  21929. */
  21930. boundingBoxSize: Vector3;
  21931. /**
  21932. * In case the RTT has been created with a depth texture, get the associated
  21933. * depth texture.
  21934. * Otherwise, return null.
  21935. */
  21936. depthStencilTexture: Nullable<InternalTexture>;
  21937. /**
  21938. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21939. * or used a shadow, depth texture...
  21940. * @param name The friendly name of the texture
  21941. * @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)
  21942. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21943. * @param generateMipMaps True if mip maps need to be generated after render.
  21944. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21945. * @param type The type of the buffer in the RTT (int, half float, float...)
  21946. * @param isCube True if a cube texture needs to be created
  21947. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21948. * @param generateDepthBuffer True to generate a depth buffer
  21949. * @param generateStencilBuffer True to generate a stencil buffer
  21950. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21951. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21952. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21953. */
  21954. constructor(name: string, size: number | {
  21955. width: number;
  21956. height: number;
  21957. } | {
  21958. ratio: number;
  21959. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21960. /**
  21961. * Creates a depth stencil texture.
  21962. * This is only available in WebGL 2 or with the depth texture extension available.
  21963. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21964. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21965. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21966. */
  21967. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21968. private _processSizeParameter;
  21969. /**
  21970. * Define the number of samples to use in case of MSAA.
  21971. * It defaults to one meaning no MSAA has been enabled.
  21972. */
  21973. samples: number;
  21974. /**
  21975. * Resets the refresh counter of the texture and start bak from scratch.
  21976. * Could be useful to regenerate the texture if it is setup to render only once.
  21977. */
  21978. resetRefreshCounter(): void;
  21979. /**
  21980. * Define the refresh rate of the texture or the rendering frequency.
  21981. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21982. */
  21983. refreshRate: number;
  21984. /**
  21985. * Adds a post process to the render target rendering passes.
  21986. * @param postProcess define the post process to add
  21987. */
  21988. addPostProcess(postProcess: PostProcess): void;
  21989. /**
  21990. * Clear all the post processes attached to the render target
  21991. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21992. */
  21993. clearPostProcesses(dispose?: boolean): void;
  21994. /**
  21995. * Remove one of the post process from the list of attached post processes to the texture
  21996. * @param postProcess define the post process to remove from the list
  21997. */
  21998. removePostProcess(postProcess: PostProcess): void;
  21999. /** @hidden */
  22000. _shouldRender(): boolean;
  22001. /**
  22002. * Gets the actual render size of the texture.
  22003. * @returns the width of the render size
  22004. */
  22005. getRenderSize(): number;
  22006. /**
  22007. * Gets the actual render width of the texture.
  22008. * @returns the width of the render size
  22009. */
  22010. getRenderWidth(): number;
  22011. /**
  22012. * Gets the actual render height of the texture.
  22013. * @returns the height of the render size
  22014. */
  22015. getRenderHeight(): number;
  22016. /**
  22017. * Get if the texture can be rescaled or not.
  22018. */
  22019. readonly canRescale: boolean;
  22020. /**
  22021. * Resize the texture using a ratio.
  22022. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22023. */
  22024. scale(ratio: number): void;
  22025. /**
  22026. * Get the texture reflection matrix used to rotate/transform the reflection.
  22027. * @returns the reflection matrix
  22028. */
  22029. getReflectionTextureMatrix(): Matrix;
  22030. /**
  22031. * Resize the texture to a new desired size.
  22032. * Be carrefull as it will recreate all the data in the new texture.
  22033. * @param size Define the new size. It can be:
  22034. * - a number for squared texture,
  22035. * - an object containing { width: number, height: number }
  22036. * - or an object containing a ratio { ratio: number }
  22037. */
  22038. resize(size: number | {
  22039. width: number;
  22040. height: number;
  22041. } | {
  22042. ratio: number;
  22043. }): void;
  22044. /**
  22045. * Renders all the objects from the render list into the texture.
  22046. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22047. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22048. */
  22049. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22050. private _bestReflectionRenderTargetDimension;
  22051. /**
  22052. * @hidden
  22053. * @param faceIndex face index to bind to if this is a cubetexture
  22054. */
  22055. _bindFrameBuffer(faceIndex?: number): void;
  22056. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22057. private renderToTarget;
  22058. /**
  22059. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22060. * This allowed control for front to back rendering or reversly depending of the special needs.
  22061. *
  22062. * @param renderingGroupId The rendering group id corresponding to its index
  22063. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22064. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22065. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22066. */
  22067. 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;
  22068. /**
  22069. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22070. *
  22071. * @param renderingGroupId The rendering group id corresponding to its index
  22072. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22073. */
  22074. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22075. /**
  22076. * Clones the texture.
  22077. * @returns the cloned texture
  22078. */
  22079. clone(): RenderTargetTexture;
  22080. /**
  22081. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22082. * @returns The JSON representation of the texture
  22083. */
  22084. serialize(): any;
  22085. /**
  22086. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22087. */
  22088. disposeFramebufferObjects(): void;
  22089. /**
  22090. * Dispose the texture and release its associated resources.
  22091. */
  22092. dispose(): void;
  22093. /** @hidden */
  22094. _rebuild(): void;
  22095. /**
  22096. * Clear the info related to rendering groups preventing retention point in material dispose.
  22097. */
  22098. freeRenderingGroups(): void;
  22099. /**
  22100. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22101. * @returns the view count
  22102. */
  22103. getViewCount(): number;
  22104. }
  22105. }
  22106. declare module BABYLON {
  22107. /**
  22108. * Base class for the main features of a material in Babylon.js
  22109. */
  22110. export class Material implements IAnimatable {
  22111. /**
  22112. * Returns the triangle fill mode
  22113. */
  22114. static readonly TriangleFillMode: number;
  22115. /**
  22116. * Returns the wireframe mode
  22117. */
  22118. static readonly WireFrameFillMode: number;
  22119. /**
  22120. * Returns the point fill mode
  22121. */
  22122. static readonly PointFillMode: number;
  22123. /**
  22124. * Returns the point list draw mode
  22125. */
  22126. static readonly PointListDrawMode: number;
  22127. /**
  22128. * Returns the line list draw mode
  22129. */
  22130. static readonly LineListDrawMode: number;
  22131. /**
  22132. * Returns the line loop draw mode
  22133. */
  22134. static readonly LineLoopDrawMode: number;
  22135. /**
  22136. * Returns the line strip draw mode
  22137. */
  22138. static readonly LineStripDrawMode: number;
  22139. /**
  22140. * Returns the triangle strip draw mode
  22141. */
  22142. static readonly TriangleStripDrawMode: number;
  22143. /**
  22144. * Returns the triangle fan draw mode
  22145. */
  22146. static readonly TriangleFanDrawMode: number;
  22147. /**
  22148. * Stores the clock-wise side orientation
  22149. */
  22150. static readonly ClockWiseSideOrientation: number;
  22151. /**
  22152. * Stores the counter clock-wise side orientation
  22153. */
  22154. static readonly CounterClockWiseSideOrientation: number;
  22155. /**
  22156. * The dirty texture flag value
  22157. */
  22158. static readonly TextureDirtyFlag: number;
  22159. /**
  22160. * The dirty light flag value
  22161. */
  22162. static readonly LightDirtyFlag: number;
  22163. /**
  22164. * The dirty fresnel flag value
  22165. */
  22166. static readonly FresnelDirtyFlag: number;
  22167. /**
  22168. * The dirty attribute flag value
  22169. */
  22170. static readonly AttributesDirtyFlag: number;
  22171. /**
  22172. * The dirty misc flag value
  22173. */
  22174. static readonly MiscDirtyFlag: number;
  22175. /**
  22176. * The all dirty flag value
  22177. */
  22178. static readonly AllDirtyFlag: number;
  22179. /**
  22180. * The ID of the material
  22181. */
  22182. id: string;
  22183. /**
  22184. * Gets or sets the unique id of the material
  22185. */
  22186. uniqueId: number;
  22187. /**
  22188. * The name of the material
  22189. */
  22190. name: string;
  22191. /**
  22192. * Gets or sets user defined metadata
  22193. */
  22194. metadata: any;
  22195. /**
  22196. * For internal use only. Please do not use.
  22197. */
  22198. reservedDataStore: any;
  22199. /**
  22200. * Specifies if the ready state should be checked on each call
  22201. */
  22202. checkReadyOnEveryCall: boolean;
  22203. /**
  22204. * Specifies if the ready state should be checked once
  22205. */
  22206. checkReadyOnlyOnce: boolean;
  22207. /**
  22208. * The state of the material
  22209. */
  22210. state: string;
  22211. /**
  22212. * The alpha value of the material
  22213. */
  22214. protected _alpha: number;
  22215. /**
  22216. * List of inspectable custom properties (used by the Inspector)
  22217. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22218. */
  22219. inspectableCustomProperties: IInspectable[];
  22220. /**
  22221. * Sets the alpha value of the material
  22222. */
  22223. /**
  22224. * Gets the alpha value of the material
  22225. */
  22226. alpha: number;
  22227. /**
  22228. * Specifies if back face culling is enabled
  22229. */
  22230. protected _backFaceCulling: boolean;
  22231. /**
  22232. * Sets the back-face culling state
  22233. */
  22234. /**
  22235. * Gets the back-face culling state
  22236. */
  22237. backFaceCulling: boolean;
  22238. /**
  22239. * Stores the value for side orientation
  22240. */
  22241. sideOrientation: number;
  22242. /**
  22243. * Callback triggered when the material is compiled
  22244. */
  22245. onCompiled: Nullable<(effect: Effect) => void>;
  22246. /**
  22247. * Callback triggered when an error occurs
  22248. */
  22249. onError: Nullable<(effect: Effect, errors: string) => void>;
  22250. /**
  22251. * Callback triggered to get the render target textures
  22252. */
  22253. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22254. /**
  22255. * Gets a boolean indicating that current material needs to register RTT
  22256. */
  22257. readonly hasRenderTargetTextures: boolean;
  22258. /**
  22259. * Specifies if the material should be serialized
  22260. */
  22261. doNotSerialize: boolean;
  22262. /**
  22263. * @hidden
  22264. */
  22265. _storeEffectOnSubMeshes: boolean;
  22266. /**
  22267. * Stores the animations for the material
  22268. */
  22269. animations: Nullable<Array<Animation>>;
  22270. /**
  22271. * An event triggered when the material is disposed
  22272. */
  22273. onDisposeObservable: Observable<Material>;
  22274. /**
  22275. * An observer which watches for dispose events
  22276. */
  22277. private _onDisposeObserver;
  22278. private _onUnBindObservable;
  22279. /**
  22280. * Called during a dispose event
  22281. */
  22282. onDispose: () => void;
  22283. private _onBindObservable;
  22284. /**
  22285. * An event triggered when the material is bound
  22286. */
  22287. readonly onBindObservable: Observable<AbstractMesh>;
  22288. /**
  22289. * An observer which watches for bind events
  22290. */
  22291. private _onBindObserver;
  22292. /**
  22293. * Called during a bind event
  22294. */
  22295. onBind: (Mesh: AbstractMesh) => void;
  22296. /**
  22297. * An event triggered when the material is unbound
  22298. */
  22299. readonly onUnBindObservable: Observable<Material>;
  22300. /**
  22301. * Stores the value of the alpha mode
  22302. */
  22303. private _alphaMode;
  22304. /**
  22305. * Sets the value of the alpha mode.
  22306. *
  22307. * | Value | Type | Description |
  22308. * | --- | --- | --- |
  22309. * | 0 | ALPHA_DISABLE | |
  22310. * | 1 | ALPHA_ADD | |
  22311. * | 2 | ALPHA_COMBINE | |
  22312. * | 3 | ALPHA_SUBTRACT | |
  22313. * | 4 | ALPHA_MULTIPLY | |
  22314. * | 5 | ALPHA_MAXIMIZED | |
  22315. * | 6 | ALPHA_ONEONE | |
  22316. * | 7 | ALPHA_PREMULTIPLIED | |
  22317. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22318. * | 9 | ALPHA_INTERPOLATE | |
  22319. * | 10 | ALPHA_SCREENMODE | |
  22320. *
  22321. */
  22322. /**
  22323. * Gets the value of the alpha mode
  22324. */
  22325. alphaMode: number;
  22326. /**
  22327. * Stores the state of the need depth pre-pass value
  22328. */
  22329. private _needDepthPrePass;
  22330. /**
  22331. * Sets the need depth pre-pass value
  22332. */
  22333. /**
  22334. * Gets the depth pre-pass value
  22335. */
  22336. needDepthPrePass: boolean;
  22337. /**
  22338. * Specifies if depth writing should be disabled
  22339. */
  22340. disableDepthWrite: boolean;
  22341. /**
  22342. * Specifies if depth writing should be forced
  22343. */
  22344. forceDepthWrite: boolean;
  22345. /**
  22346. * Specifies if there should be a separate pass for culling
  22347. */
  22348. separateCullingPass: boolean;
  22349. /**
  22350. * Stores the state specifing if fog should be enabled
  22351. */
  22352. private _fogEnabled;
  22353. /**
  22354. * Sets the state for enabling fog
  22355. */
  22356. /**
  22357. * Gets the value of the fog enabled state
  22358. */
  22359. fogEnabled: boolean;
  22360. /**
  22361. * Stores the size of points
  22362. */
  22363. pointSize: number;
  22364. /**
  22365. * Stores the z offset value
  22366. */
  22367. zOffset: number;
  22368. /**
  22369. * Gets a value specifying if wireframe mode is enabled
  22370. */
  22371. /**
  22372. * Sets the state of wireframe mode
  22373. */
  22374. wireframe: boolean;
  22375. /**
  22376. * Gets the value specifying if point clouds are enabled
  22377. */
  22378. /**
  22379. * Sets the state of point cloud mode
  22380. */
  22381. pointsCloud: boolean;
  22382. /**
  22383. * Gets the material fill mode
  22384. */
  22385. /**
  22386. * Sets the material fill mode
  22387. */
  22388. fillMode: number;
  22389. /**
  22390. * @hidden
  22391. * Stores the effects for the material
  22392. */
  22393. _effect: Nullable<Effect>;
  22394. /**
  22395. * @hidden
  22396. * Specifies if the material was previously ready
  22397. */
  22398. _wasPreviouslyReady: boolean;
  22399. /**
  22400. * Specifies if uniform buffers should be used
  22401. */
  22402. private _useUBO;
  22403. /**
  22404. * Stores a reference to the scene
  22405. */
  22406. private _scene;
  22407. /**
  22408. * Stores the fill mode state
  22409. */
  22410. private _fillMode;
  22411. /**
  22412. * Specifies if the depth write state should be cached
  22413. */
  22414. private _cachedDepthWriteState;
  22415. /**
  22416. * Stores the uniform buffer
  22417. */
  22418. protected _uniformBuffer: UniformBuffer;
  22419. /** @hidden */
  22420. _indexInSceneMaterialArray: number;
  22421. /** @hidden */
  22422. meshMap: Nullable<{
  22423. [id: string]: AbstractMesh | undefined;
  22424. }>;
  22425. /**
  22426. * Creates a material instance
  22427. * @param name defines the name of the material
  22428. * @param scene defines the scene to reference
  22429. * @param doNotAdd specifies if the material should be added to the scene
  22430. */
  22431. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22432. /**
  22433. * Returns a string representation of the current material
  22434. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22435. * @returns a string with material information
  22436. */
  22437. toString(fullDetails?: boolean): string;
  22438. /**
  22439. * Gets the class name of the material
  22440. * @returns a string with the class name of the material
  22441. */
  22442. getClassName(): string;
  22443. /**
  22444. * Specifies if updates for the material been locked
  22445. */
  22446. readonly isFrozen: boolean;
  22447. /**
  22448. * Locks updates for the material
  22449. */
  22450. freeze(): void;
  22451. /**
  22452. * Unlocks updates for the material
  22453. */
  22454. unfreeze(): void;
  22455. /**
  22456. * Specifies if the material is ready to be used
  22457. * @param mesh defines the mesh to check
  22458. * @param useInstances specifies if instances should be used
  22459. * @returns a boolean indicating if the material is ready to be used
  22460. */
  22461. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22462. /**
  22463. * Specifies that the submesh is ready to be used
  22464. * @param mesh defines the mesh to check
  22465. * @param subMesh defines which submesh to check
  22466. * @param useInstances specifies that instances should be used
  22467. * @returns a boolean indicating that the submesh is ready or not
  22468. */
  22469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22470. /**
  22471. * Returns the material effect
  22472. * @returns the effect associated with the material
  22473. */
  22474. getEffect(): Nullable<Effect>;
  22475. /**
  22476. * Returns the current scene
  22477. * @returns a Scene
  22478. */
  22479. getScene(): Scene;
  22480. /**
  22481. * Specifies if the material will require alpha blending
  22482. * @returns a boolean specifying if alpha blending is needed
  22483. */
  22484. needAlphaBlending(): boolean;
  22485. /**
  22486. * Specifies if the mesh will require alpha blending
  22487. * @param mesh defines the mesh to check
  22488. * @returns a boolean specifying if alpha blending is needed for the mesh
  22489. */
  22490. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22491. /**
  22492. * Specifies if this material should be rendered in alpha test mode
  22493. * @returns a boolean specifying if an alpha test is needed.
  22494. */
  22495. needAlphaTesting(): boolean;
  22496. /**
  22497. * Gets the texture used for the alpha test
  22498. * @returns the texture to use for alpha testing
  22499. */
  22500. getAlphaTestTexture(): Nullable<BaseTexture>;
  22501. /**
  22502. * Marks the material to indicate that it needs to be re-calculated
  22503. */
  22504. markDirty(): void;
  22505. /** @hidden */
  22506. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22507. /**
  22508. * Binds the material to the mesh
  22509. * @param world defines the world transformation matrix
  22510. * @param mesh defines the mesh to bind the material to
  22511. */
  22512. bind(world: Matrix, mesh?: Mesh): void;
  22513. /**
  22514. * Binds the submesh to the material
  22515. * @param world defines the world transformation matrix
  22516. * @param mesh defines the mesh containing the submesh
  22517. * @param subMesh defines the submesh to bind the material to
  22518. */
  22519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22520. /**
  22521. * Binds the world matrix to the material
  22522. * @param world defines the world transformation matrix
  22523. */
  22524. bindOnlyWorldMatrix(world: Matrix): void;
  22525. /**
  22526. * Binds the scene's uniform buffer to the effect.
  22527. * @param effect defines the effect to bind to the scene uniform buffer
  22528. * @param sceneUbo defines the uniform buffer storing scene data
  22529. */
  22530. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22531. /**
  22532. * Binds the view matrix to the effect
  22533. * @param effect defines the effect to bind the view matrix to
  22534. */
  22535. bindView(effect: Effect): void;
  22536. /**
  22537. * Binds the view projection matrix to the effect
  22538. * @param effect defines the effect to bind the view projection matrix to
  22539. */
  22540. bindViewProjection(effect: Effect): void;
  22541. /**
  22542. * Specifies if material alpha testing should be turned on for the mesh
  22543. * @param mesh defines the mesh to check
  22544. */
  22545. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22546. /**
  22547. * Processes to execute after binding the material to a mesh
  22548. * @param mesh defines the rendered mesh
  22549. */
  22550. protected _afterBind(mesh?: Mesh): void;
  22551. /**
  22552. * Unbinds the material from the mesh
  22553. */
  22554. unbind(): void;
  22555. /**
  22556. * Gets the active textures from the material
  22557. * @returns an array of textures
  22558. */
  22559. getActiveTextures(): BaseTexture[];
  22560. /**
  22561. * Specifies if the material uses a texture
  22562. * @param texture defines the texture to check against the material
  22563. * @returns a boolean specifying if the material uses the texture
  22564. */
  22565. hasTexture(texture: BaseTexture): boolean;
  22566. /**
  22567. * Makes a duplicate of the material, and gives it a new name
  22568. * @param name defines the new name for the duplicated material
  22569. * @returns the cloned material
  22570. */
  22571. clone(name: string): Nullable<Material>;
  22572. /**
  22573. * Gets the meshes bound to the material
  22574. * @returns an array of meshes bound to the material
  22575. */
  22576. getBindedMeshes(): AbstractMesh[];
  22577. /**
  22578. * Force shader compilation
  22579. * @param mesh defines the mesh associated with this material
  22580. * @param onCompiled defines a function to execute once the material is compiled
  22581. * @param options defines the options to configure the compilation
  22582. */
  22583. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22584. clipPlane: boolean;
  22585. }>): void;
  22586. /**
  22587. * Force shader compilation
  22588. * @param mesh defines the mesh that will use this material
  22589. * @param options defines additional options for compiling the shaders
  22590. * @returns a promise that resolves when the compilation completes
  22591. */
  22592. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22593. clipPlane: boolean;
  22594. }>): Promise<void>;
  22595. private static readonly _AllDirtyCallBack;
  22596. private static readonly _ImageProcessingDirtyCallBack;
  22597. private static readonly _TextureDirtyCallBack;
  22598. private static readonly _FresnelDirtyCallBack;
  22599. private static readonly _MiscDirtyCallBack;
  22600. private static readonly _LightsDirtyCallBack;
  22601. private static readonly _AttributeDirtyCallBack;
  22602. private static _FresnelAndMiscDirtyCallBack;
  22603. private static _TextureAndMiscDirtyCallBack;
  22604. private static readonly _DirtyCallbackArray;
  22605. private static readonly _RunDirtyCallBacks;
  22606. /**
  22607. * Marks a define in the material to indicate that it needs to be re-computed
  22608. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22609. */
  22610. markAsDirty(flag: number): void;
  22611. /**
  22612. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22613. * @param func defines a function which checks material defines against the submeshes
  22614. */
  22615. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22616. /**
  22617. * Indicates that we need to re-calculated for all submeshes
  22618. */
  22619. protected _markAllSubMeshesAsAllDirty(): void;
  22620. /**
  22621. * Indicates that image processing needs to be re-calculated for all submeshes
  22622. */
  22623. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22624. /**
  22625. * Indicates that textures need to be re-calculated for all submeshes
  22626. */
  22627. protected _markAllSubMeshesAsTexturesDirty(): void;
  22628. /**
  22629. * Indicates that fresnel needs to be re-calculated for all submeshes
  22630. */
  22631. protected _markAllSubMeshesAsFresnelDirty(): void;
  22632. /**
  22633. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22634. */
  22635. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22636. /**
  22637. * Indicates that lights need to be re-calculated for all submeshes
  22638. */
  22639. protected _markAllSubMeshesAsLightsDirty(): void;
  22640. /**
  22641. * Indicates that attributes need to be re-calculated for all submeshes
  22642. */
  22643. protected _markAllSubMeshesAsAttributesDirty(): void;
  22644. /**
  22645. * Indicates that misc needs to be re-calculated for all submeshes
  22646. */
  22647. protected _markAllSubMeshesAsMiscDirty(): void;
  22648. /**
  22649. * Indicates that textures and misc need to be re-calculated for all submeshes
  22650. */
  22651. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22652. /**
  22653. * Disposes the material
  22654. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22655. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22656. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22657. */
  22658. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22659. /** @hidden */
  22660. private releaseVertexArrayObject;
  22661. /**
  22662. * Serializes this material
  22663. * @returns the serialized material object
  22664. */
  22665. serialize(): any;
  22666. /**
  22667. * Creates a material from parsed material data
  22668. * @param parsedMaterial defines parsed material data
  22669. * @param scene defines the hosting scene
  22670. * @param rootUrl defines the root URL to use to load textures
  22671. * @returns a new material
  22672. */
  22673. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22674. }
  22675. }
  22676. declare module BABYLON {
  22677. /**
  22678. * Base class for submeshes
  22679. */
  22680. export class BaseSubMesh {
  22681. /** @hidden */
  22682. _materialDefines: Nullable<MaterialDefines>;
  22683. /** @hidden */
  22684. _materialEffect: Nullable<Effect>;
  22685. /**
  22686. * Gets associated effect
  22687. */
  22688. readonly effect: Nullable<Effect>;
  22689. /**
  22690. * Sets associated effect (effect used to render this submesh)
  22691. * @param effect defines the effect to associate with
  22692. * @param defines defines the set of defines used to compile this effect
  22693. */
  22694. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22695. }
  22696. /**
  22697. * Defines a subdivision inside a mesh
  22698. */
  22699. export class SubMesh extends BaseSubMesh implements ICullable {
  22700. /** the material index to use */
  22701. materialIndex: number;
  22702. /** vertex index start */
  22703. verticesStart: number;
  22704. /** vertices count */
  22705. verticesCount: number;
  22706. /** index start */
  22707. indexStart: number;
  22708. /** indices count */
  22709. indexCount: number;
  22710. /** @hidden */
  22711. _linesIndexCount: number;
  22712. private _mesh;
  22713. private _renderingMesh;
  22714. private _boundingInfo;
  22715. private _linesIndexBuffer;
  22716. /** @hidden */
  22717. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22718. /** @hidden */
  22719. _trianglePlanes: Plane[];
  22720. /** @hidden */
  22721. _lastColliderTransformMatrix: Nullable<Matrix>;
  22722. /** @hidden */
  22723. _renderId: number;
  22724. /** @hidden */
  22725. _alphaIndex: number;
  22726. /** @hidden */
  22727. _distanceToCamera: number;
  22728. /** @hidden */
  22729. _id: number;
  22730. private _currentMaterial;
  22731. /**
  22732. * Add a new submesh to a mesh
  22733. * @param materialIndex defines the material index to use
  22734. * @param verticesStart defines vertex index start
  22735. * @param verticesCount defines vertices count
  22736. * @param indexStart defines index start
  22737. * @param indexCount defines indices count
  22738. * @param mesh defines the parent mesh
  22739. * @param renderingMesh defines an optional rendering mesh
  22740. * @param createBoundingBox defines if bounding box should be created for this submesh
  22741. * @returns the new submesh
  22742. */
  22743. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22744. /**
  22745. * Creates a new submesh
  22746. * @param materialIndex defines the material index to use
  22747. * @param verticesStart defines vertex index start
  22748. * @param verticesCount defines vertices count
  22749. * @param indexStart defines index start
  22750. * @param indexCount defines indices count
  22751. * @param mesh defines the parent mesh
  22752. * @param renderingMesh defines an optional rendering mesh
  22753. * @param createBoundingBox defines if bounding box should be created for this submesh
  22754. */
  22755. constructor(
  22756. /** the material index to use */
  22757. materialIndex: number,
  22758. /** vertex index start */
  22759. verticesStart: number,
  22760. /** vertices count */
  22761. verticesCount: number,
  22762. /** index start */
  22763. indexStart: number,
  22764. /** indices count */
  22765. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22766. /**
  22767. * Returns true if this submesh covers the entire parent mesh
  22768. * @ignorenaming
  22769. */
  22770. readonly IsGlobal: boolean;
  22771. /**
  22772. * Returns the submesh BoudingInfo object
  22773. * @returns current bounding info (or mesh's one if the submesh is global)
  22774. */
  22775. getBoundingInfo(): BoundingInfo;
  22776. /**
  22777. * Sets the submesh BoundingInfo
  22778. * @param boundingInfo defines the new bounding info to use
  22779. * @returns the SubMesh
  22780. */
  22781. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22782. /**
  22783. * Returns the mesh of the current submesh
  22784. * @return the parent mesh
  22785. */
  22786. getMesh(): AbstractMesh;
  22787. /**
  22788. * Returns the rendering mesh of the submesh
  22789. * @returns the rendering mesh (could be different from parent mesh)
  22790. */
  22791. getRenderingMesh(): Mesh;
  22792. /**
  22793. * Returns the submesh material
  22794. * @returns null or the current material
  22795. */
  22796. getMaterial(): Nullable<Material>;
  22797. /**
  22798. * Sets a new updated BoundingInfo object to the submesh
  22799. * @param data defines an optional position array to use to determine the bounding info
  22800. * @returns the SubMesh
  22801. */
  22802. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22803. /** @hidden */
  22804. _checkCollision(collider: Collider): boolean;
  22805. /**
  22806. * Updates the submesh BoundingInfo
  22807. * @param world defines the world matrix to use to update the bounding info
  22808. * @returns the submesh
  22809. */
  22810. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22811. /**
  22812. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22813. * @param frustumPlanes defines the frustum planes
  22814. * @returns true if the submesh is intersecting with the frustum
  22815. */
  22816. isInFrustum(frustumPlanes: Plane[]): boolean;
  22817. /**
  22818. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22819. * @param frustumPlanes defines the frustum planes
  22820. * @returns true if the submesh is inside the frustum
  22821. */
  22822. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22823. /**
  22824. * Renders the submesh
  22825. * @param enableAlphaMode defines if alpha needs to be used
  22826. * @returns the submesh
  22827. */
  22828. render(enableAlphaMode: boolean): SubMesh;
  22829. /**
  22830. * @hidden
  22831. */
  22832. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22833. /**
  22834. * Checks if the submesh intersects with a ray
  22835. * @param ray defines the ray to test
  22836. * @returns true is the passed ray intersects the submesh bounding box
  22837. */
  22838. canIntersects(ray: Ray): boolean;
  22839. /**
  22840. * Intersects current submesh with a ray
  22841. * @param ray defines the ray to test
  22842. * @param positions defines mesh's positions array
  22843. * @param indices defines mesh's indices array
  22844. * @param fastCheck defines if only bounding info should be used
  22845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22846. * @returns intersection info or null if no intersection
  22847. */
  22848. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22849. /** @hidden */
  22850. private _intersectLines;
  22851. /** @hidden */
  22852. private _intersectUnIndexedLines;
  22853. /** @hidden */
  22854. private _intersectTriangles;
  22855. /** @hidden */
  22856. private _intersectUnIndexedTriangles;
  22857. /** @hidden */
  22858. _rebuild(): void;
  22859. /**
  22860. * Creates a new submesh from the passed mesh
  22861. * @param newMesh defines the new hosting mesh
  22862. * @param newRenderingMesh defines an optional rendering mesh
  22863. * @returns the new submesh
  22864. */
  22865. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22866. /**
  22867. * Release associated resources
  22868. */
  22869. dispose(): void;
  22870. /**
  22871. * Gets the class name
  22872. * @returns the string "SubMesh".
  22873. */
  22874. getClassName(): string;
  22875. /**
  22876. * Creates a new submesh from indices data
  22877. * @param materialIndex the index of the main mesh material
  22878. * @param startIndex the index where to start the copy in the mesh indices array
  22879. * @param indexCount the number of indices to copy then from the startIndex
  22880. * @param mesh the main mesh to create the submesh from
  22881. * @param renderingMesh the optional rendering mesh
  22882. * @returns a new submesh
  22883. */
  22884. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22885. }
  22886. }
  22887. declare module BABYLON {
  22888. /**
  22889. * Class used to store geometry data (vertex buffers + index buffer)
  22890. */
  22891. export class Geometry implements IGetSetVerticesData {
  22892. /**
  22893. * Gets or sets the ID of the geometry
  22894. */
  22895. id: string;
  22896. /**
  22897. * Gets or sets the unique ID of the geometry
  22898. */
  22899. uniqueId: number;
  22900. /**
  22901. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22902. */
  22903. delayLoadState: number;
  22904. /**
  22905. * Gets the file containing the data to load when running in delay load state
  22906. */
  22907. delayLoadingFile: Nullable<string>;
  22908. /**
  22909. * Callback called when the geometry is updated
  22910. */
  22911. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22912. private _scene;
  22913. private _engine;
  22914. private _meshes;
  22915. private _totalVertices;
  22916. /** @hidden */
  22917. _indices: IndicesArray;
  22918. /** @hidden */
  22919. _vertexBuffers: {
  22920. [key: string]: VertexBuffer;
  22921. };
  22922. private _isDisposed;
  22923. private _extend;
  22924. private _boundingBias;
  22925. /** @hidden */
  22926. _delayInfo: Array<string>;
  22927. private _indexBuffer;
  22928. private _indexBufferIsUpdatable;
  22929. /** @hidden */
  22930. _boundingInfo: Nullable<BoundingInfo>;
  22931. /** @hidden */
  22932. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22933. /** @hidden */
  22934. _softwareSkinningFrameId: number;
  22935. private _vertexArrayObjects;
  22936. private _updatable;
  22937. /** @hidden */
  22938. _positions: Nullable<Vector3[]>;
  22939. /**
  22940. * 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
  22941. */
  22942. /**
  22943. * 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
  22944. */
  22945. boundingBias: Vector2;
  22946. /**
  22947. * Static function used to attach a new empty geometry to a mesh
  22948. * @param mesh defines the mesh to attach the geometry to
  22949. * @returns the new Geometry
  22950. */
  22951. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22952. /**
  22953. * Creates a new geometry
  22954. * @param id defines the unique ID
  22955. * @param scene defines the hosting scene
  22956. * @param vertexData defines the VertexData used to get geometry data
  22957. * @param updatable defines if geometry must be updatable (false by default)
  22958. * @param mesh defines the mesh that will be associated with the geometry
  22959. */
  22960. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22961. /**
  22962. * Gets the current extend of the geometry
  22963. */
  22964. readonly extend: {
  22965. minimum: Vector3;
  22966. maximum: Vector3;
  22967. };
  22968. /**
  22969. * Gets the hosting scene
  22970. * @returns the hosting Scene
  22971. */
  22972. getScene(): Scene;
  22973. /**
  22974. * Gets the hosting engine
  22975. * @returns the hosting Engine
  22976. */
  22977. getEngine(): Engine;
  22978. /**
  22979. * Defines if the geometry is ready to use
  22980. * @returns true if the geometry is ready to be used
  22981. */
  22982. isReady(): boolean;
  22983. /**
  22984. * Gets a value indicating that the geometry should not be serialized
  22985. */
  22986. readonly doNotSerialize: boolean;
  22987. /** @hidden */
  22988. _rebuild(): void;
  22989. /**
  22990. * Affects all geometry data in one call
  22991. * @param vertexData defines the geometry data
  22992. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22993. */
  22994. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22995. /**
  22996. * Set specific vertex data
  22997. * @param kind defines the data kind (Position, normal, etc...)
  22998. * @param data defines the vertex data to use
  22999. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23000. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23001. */
  23002. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23003. /**
  23004. * Removes a specific vertex data
  23005. * @param kind defines the data kind (Position, normal, etc...)
  23006. */
  23007. removeVerticesData(kind: string): void;
  23008. /**
  23009. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23010. * @param buffer defines the vertex buffer to use
  23011. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23012. */
  23013. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23014. /**
  23015. * Update a specific vertex buffer
  23016. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23017. * It will do nothing if the buffer is not updatable
  23018. * @param kind defines the data kind (Position, normal, etc...)
  23019. * @param data defines the data to use
  23020. * @param offset defines the offset in the target buffer where to store the data
  23021. * @param useBytes set to true if the offset is in bytes
  23022. */
  23023. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23024. /**
  23025. * Update a specific vertex buffer
  23026. * This function will create a new buffer if the current one is not updatable
  23027. * @param kind defines the data kind (Position, normal, etc...)
  23028. * @param data defines the data to use
  23029. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23030. */
  23031. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23032. private _updateBoundingInfo;
  23033. /** @hidden */
  23034. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23035. /**
  23036. * Gets total number of vertices
  23037. * @returns the total number of vertices
  23038. */
  23039. getTotalVertices(): number;
  23040. /**
  23041. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23042. * @param kind defines the data kind (Position, normal, etc...)
  23043. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23044. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23045. * @returns a float array containing vertex data
  23046. */
  23047. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23048. /**
  23049. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23050. * @param kind defines the data kind (Position, normal, etc...)
  23051. * @returns true if the vertex buffer with the specified kind is updatable
  23052. */
  23053. isVertexBufferUpdatable(kind: string): boolean;
  23054. /**
  23055. * Gets a specific vertex buffer
  23056. * @param kind defines the data kind (Position, normal, etc...)
  23057. * @returns a VertexBuffer
  23058. */
  23059. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23060. /**
  23061. * Returns all vertex buffers
  23062. * @return an object holding all vertex buffers indexed by kind
  23063. */
  23064. getVertexBuffers(): Nullable<{
  23065. [key: string]: VertexBuffer;
  23066. }>;
  23067. /**
  23068. * Gets a boolean indicating if specific vertex buffer is present
  23069. * @param kind defines the data kind (Position, normal, etc...)
  23070. * @returns true if data is present
  23071. */
  23072. isVerticesDataPresent(kind: string): boolean;
  23073. /**
  23074. * Gets a list of all attached data kinds (Position, normal, etc...)
  23075. * @returns a list of string containing all kinds
  23076. */
  23077. getVerticesDataKinds(): string[];
  23078. /**
  23079. * Update index buffer
  23080. * @param indices defines the indices to store in the index buffer
  23081. * @param offset defines the offset in the target buffer where to store the data
  23082. * @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)
  23083. */
  23084. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23085. /**
  23086. * Creates a new index buffer
  23087. * @param indices defines the indices to store in the index buffer
  23088. * @param totalVertices defines the total number of vertices (could be null)
  23089. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23090. */
  23091. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23092. /**
  23093. * Return the total number of indices
  23094. * @returns the total number of indices
  23095. */
  23096. getTotalIndices(): number;
  23097. /**
  23098. * Gets the index buffer array
  23099. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23100. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23101. * @returns the index buffer array
  23102. */
  23103. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23104. /**
  23105. * Gets the index buffer
  23106. * @return the index buffer
  23107. */
  23108. getIndexBuffer(): Nullable<DataBuffer>;
  23109. /** @hidden */
  23110. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23111. /**
  23112. * Release the associated resources for a specific mesh
  23113. * @param mesh defines the source mesh
  23114. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23115. */
  23116. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23117. /**
  23118. * Apply current geometry to a given mesh
  23119. * @param mesh defines the mesh to apply geometry to
  23120. */
  23121. applyToMesh(mesh: Mesh): void;
  23122. private _updateExtend;
  23123. private _applyToMesh;
  23124. private notifyUpdate;
  23125. /**
  23126. * Load the geometry if it was flagged as delay loaded
  23127. * @param scene defines the hosting scene
  23128. * @param onLoaded defines a callback called when the geometry is loaded
  23129. */
  23130. load(scene: Scene, onLoaded?: () => void): void;
  23131. private _queueLoad;
  23132. /**
  23133. * Invert the geometry to move from a right handed system to a left handed one.
  23134. */
  23135. toLeftHanded(): void;
  23136. /** @hidden */
  23137. _resetPointsArrayCache(): void;
  23138. /** @hidden */
  23139. _generatePointsArray(): boolean;
  23140. /**
  23141. * Gets a value indicating if the geometry is disposed
  23142. * @returns true if the geometry was disposed
  23143. */
  23144. isDisposed(): boolean;
  23145. private _disposeVertexArrayObjects;
  23146. /**
  23147. * Free all associated resources
  23148. */
  23149. dispose(): void;
  23150. /**
  23151. * Clone the current geometry into a new geometry
  23152. * @param id defines the unique ID of the new geometry
  23153. * @returns a new geometry object
  23154. */
  23155. copy(id: string): Geometry;
  23156. /**
  23157. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23158. * @return a JSON representation of the current geometry data (without the vertices data)
  23159. */
  23160. serialize(): any;
  23161. private toNumberArray;
  23162. /**
  23163. * Serialize all vertices data into a JSON oject
  23164. * @returns a JSON representation of the current geometry data
  23165. */
  23166. serializeVerticeData(): any;
  23167. /**
  23168. * Extracts a clone of a mesh geometry
  23169. * @param mesh defines the source mesh
  23170. * @param id defines the unique ID of the new geometry object
  23171. * @returns the new geometry object
  23172. */
  23173. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23174. /**
  23175. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23176. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23177. * Be aware Math.random() could cause collisions, but:
  23178. * "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"
  23179. * @returns a string containing a new GUID
  23180. */
  23181. static RandomId(): string;
  23182. /** @hidden */
  23183. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23184. private static _CleanMatricesWeights;
  23185. /**
  23186. * Create a new geometry from persisted data (Using .babylon file format)
  23187. * @param parsedVertexData defines the persisted data
  23188. * @param scene defines the hosting scene
  23189. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23190. * @returns the new geometry object
  23191. */
  23192. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23193. }
  23194. }
  23195. declare module BABYLON {
  23196. /**
  23197. * Define an interface for all classes that will get and set the data on vertices
  23198. */
  23199. export interface IGetSetVerticesData {
  23200. /**
  23201. * Gets a boolean indicating if specific vertex data is present
  23202. * @param kind defines the vertex data kind to use
  23203. * @returns true is data kind is present
  23204. */
  23205. isVerticesDataPresent(kind: string): boolean;
  23206. /**
  23207. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23208. * @param kind defines the data kind (Position, normal, etc...)
  23209. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23210. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23211. * @returns a float array containing vertex data
  23212. */
  23213. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23214. /**
  23215. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23216. * @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.
  23217. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23218. * @returns the indices array or an empty array if the mesh has no geometry
  23219. */
  23220. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23221. /**
  23222. * Set specific vertex data
  23223. * @param kind defines the data kind (Position, normal, etc...)
  23224. * @param data defines the vertex data to use
  23225. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23226. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23227. */
  23228. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23229. /**
  23230. * Update a specific associated vertex buffer
  23231. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23232. * - VertexBuffer.PositionKind
  23233. * - VertexBuffer.UVKind
  23234. * - VertexBuffer.UV2Kind
  23235. * - VertexBuffer.UV3Kind
  23236. * - VertexBuffer.UV4Kind
  23237. * - VertexBuffer.UV5Kind
  23238. * - VertexBuffer.UV6Kind
  23239. * - VertexBuffer.ColorKind
  23240. * - VertexBuffer.MatricesIndicesKind
  23241. * - VertexBuffer.MatricesIndicesExtraKind
  23242. * - VertexBuffer.MatricesWeightsKind
  23243. * - VertexBuffer.MatricesWeightsExtraKind
  23244. * @param data defines the data source
  23245. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23246. * @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)
  23247. */
  23248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23249. /**
  23250. * Creates a new index buffer
  23251. * @param indices defines the indices to store in the index buffer
  23252. * @param totalVertices defines the total number of vertices (could be null)
  23253. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23254. */
  23255. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23256. }
  23257. /**
  23258. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23259. */
  23260. export class VertexData {
  23261. /**
  23262. * Mesh side orientation : usually the external or front surface
  23263. */
  23264. static readonly FRONTSIDE: number;
  23265. /**
  23266. * Mesh side orientation : usually the internal or back surface
  23267. */
  23268. static readonly BACKSIDE: number;
  23269. /**
  23270. * Mesh side orientation : both internal and external or front and back surfaces
  23271. */
  23272. static readonly DOUBLESIDE: number;
  23273. /**
  23274. * Mesh side orientation : by default, `FRONTSIDE`
  23275. */
  23276. static readonly DEFAULTSIDE: number;
  23277. /**
  23278. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23279. */
  23280. positions: Nullable<FloatArray>;
  23281. /**
  23282. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23283. */
  23284. normals: Nullable<FloatArray>;
  23285. /**
  23286. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23287. */
  23288. tangents: Nullable<FloatArray>;
  23289. /**
  23290. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23291. */
  23292. uvs: Nullable<FloatArray>;
  23293. /**
  23294. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23295. */
  23296. uvs2: Nullable<FloatArray>;
  23297. /**
  23298. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23299. */
  23300. uvs3: Nullable<FloatArray>;
  23301. /**
  23302. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23303. */
  23304. uvs4: Nullable<FloatArray>;
  23305. /**
  23306. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23307. */
  23308. uvs5: Nullable<FloatArray>;
  23309. /**
  23310. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23311. */
  23312. uvs6: Nullable<FloatArray>;
  23313. /**
  23314. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23315. */
  23316. colors: Nullable<FloatArray>;
  23317. /**
  23318. * 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).
  23319. */
  23320. matricesIndices: Nullable<FloatArray>;
  23321. /**
  23322. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23323. */
  23324. matricesWeights: Nullable<FloatArray>;
  23325. /**
  23326. * An array extending the number of possible indices
  23327. */
  23328. matricesIndicesExtra: Nullable<FloatArray>;
  23329. /**
  23330. * An array extending the number of possible weights when the number of indices is extended
  23331. */
  23332. matricesWeightsExtra: Nullable<FloatArray>;
  23333. /**
  23334. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23335. */
  23336. indices: Nullable<IndicesArray>;
  23337. /**
  23338. * Uses the passed data array to set the set the values for the specified kind of data
  23339. * @param data a linear array of floating numbers
  23340. * @param kind the type of data that is being set, eg positions, colors etc
  23341. */
  23342. set(data: FloatArray, kind: string): void;
  23343. /**
  23344. * Associates the vertexData to the passed Mesh.
  23345. * Sets it as updatable or not (default `false`)
  23346. * @param mesh the mesh the vertexData is applied to
  23347. * @param updatable when used and having the value true allows new data to update the vertexData
  23348. * @returns the VertexData
  23349. */
  23350. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23351. /**
  23352. * Associates the vertexData to the passed Geometry.
  23353. * Sets it as updatable or not (default `false`)
  23354. * @param geometry the geometry the vertexData is applied to
  23355. * @param updatable when used and having the value true allows new data to update the vertexData
  23356. * @returns VertexData
  23357. */
  23358. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23359. /**
  23360. * Updates the associated mesh
  23361. * @param mesh the mesh to be updated
  23362. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23363. * @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
  23364. * @returns VertexData
  23365. */
  23366. updateMesh(mesh: Mesh): VertexData;
  23367. /**
  23368. * Updates the associated geometry
  23369. * @param geometry the geometry to be updated
  23370. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23371. * @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
  23372. * @returns VertexData.
  23373. */
  23374. updateGeometry(geometry: Geometry): VertexData;
  23375. private _applyTo;
  23376. private _update;
  23377. /**
  23378. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23379. * @param matrix the transforming matrix
  23380. * @returns the VertexData
  23381. */
  23382. transform(matrix: Matrix): VertexData;
  23383. /**
  23384. * Merges the passed VertexData into the current one
  23385. * @param other the VertexData to be merged into the current one
  23386. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23387. * @returns the modified VertexData
  23388. */
  23389. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23390. private _mergeElement;
  23391. private _validate;
  23392. /**
  23393. * Serializes the VertexData
  23394. * @returns a serialized object
  23395. */
  23396. serialize(): any;
  23397. /**
  23398. * Extracts the vertexData from a mesh
  23399. * @param mesh the mesh from which to extract the VertexData
  23400. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23401. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23402. * @returns the object VertexData associated to the passed mesh
  23403. */
  23404. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23405. /**
  23406. * Extracts the vertexData from the geometry
  23407. * @param geometry the geometry from which to extract the VertexData
  23408. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23409. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23410. * @returns the object VertexData associated to the passed mesh
  23411. */
  23412. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23413. private static _ExtractFrom;
  23414. /**
  23415. * Creates the VertexData for a Ribbon
  23416. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23417. * * pathArray array of paths, each of which an array of successive Vector3
  23418. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23419. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23420. * * 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
  23421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23422. * * 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)
  23423. * * 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)
  23424. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23425. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23426. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23427. * @returns the VertexData of the ribbon
  23428. */
  23429. static CreateRibbon(options: {
  23430. pathArray: Vector3[][];
  23431. closeArray?: boolean;
  23432. closePath?: boolean;
  23433. offset?: number;
  23434. sideOrientation?: number;
  23435. frontUVs?: Vector4;
  23436. backUVs?: Vector4;
  23437. invertUV?: boolean;
  23438. uvs?: Vector2[];
  23439. colors?: Color4[];
  23440. }): VertexData;
  23441. /**
  23442. * Creates the VertexData for a box
  23443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23444. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23445. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23446. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23447. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23448. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23449. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23451. * * 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)
  23452. * * 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)
  23453. * @returns the VertexData of the box
  23454. */
  23455. static CreateBox(options: {
  23456. size?: number;
  23457. width?: number;
  23458. height?: number;
  23459. depth?: number;
  23460. faceUV?: Vector4[];
  23461. faceColors?: Color4[];
  23462. sideOrientation?: number;
  23463. frontUVs?: Vector4;
  23464. backUVs?: Vector4;
  23465. }): VertexData;
  23466. /**
  23467. * Creates the VertexData for a tiled box
  23468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23469. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23470. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23471. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23473. * @returns the VertexData of the box
  23474. */
  23475. static CreateTiledBox(options: {
  23476. pattern?: number;
  23477. width?: number;
  23478. height?: number;
  23479. depth?: number;
  23480. tileSize?: number;
  23481. tileWidth?: number;
  23482. tileHeight?: number;
  23483. alignHorizontal?: number;
  23484. alignVertical?: number;
  23485. faceUV?: Vector4[];
  23486. faceColors?: Color4[];
  23487. sideOrientation?: number;
  23488. }): VertexData;
  23489. /**
  23490. * Creates the VertexData for a tiled plane
  23491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23492. * * pattern a limited pattern arrangement depending on the number
  23493. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23494. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23495. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the tiled plane
  23500. */
  23501. static CreateTiledPlane(options: {
  23502. pattern?: number;
  23503. tileSize?: number;
  23504. tileWidth?: number;
  23505. tileHeight?: number;
  23506. size?: number;
  23507. width?: number;
  23508. height?: number;
  23509. alignHorizontal?: number;
  23510. alignVertical?: number;
  23511. sideOrientation?: number;
  23512. frontUVs?: Vector4;
  23513. backUVs?: Vector4;
  23514. }): VertexData;
  23515. /**
  23516. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23517. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23518. * * segments sets the number of horizontal strips optional, default 32
  23519. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23520. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23521. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23522. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23523. * * 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
  23524. * * 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
  23525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23526. * * 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)
  23527. * * 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)
  23528. * @returns the VertexData of the ellipsoid
  23529. */
  23530. static CreateSphere(options: {
  23531. segments?: number;
  23532. diameter?: number;
  23533. diameterX?: number;
  23534. diameterY?: number;
  23535. diameterZ?: number;
  23536. arc?: number;
  23537. slice?: number;
  23538. sideOrientation?: number;
  23539. frontUVs?: Vector4;
  23540. backUVs?: Vector4;
  23541. }): VertexData;
  23542. /**
  23543. * Creates the VertexData for a cylinder, cone or prism
  23544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23545. * * height sets the height (y direction) of the cylinder, optional, default 2
  23546. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23547. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23548. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23549. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23550. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23551. * * 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
  23552. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23553. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23554. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23555. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23557. * * 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)
  23558. * * 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)
  23559. * @returns the VertexData of the cylinder, cone or prism
  23560. */
  23561. static CreateCylinder(options: {
  23562. height?: number;
  23563. diameterTop?: number;
  23564. diameterBottom?: number;
  23565. diameter?: number;
  23566. tessellation?: number;
  23567. subdivisions?: number;
  23568. arc?: number;
  23569. faceColors?: Color4[];
  23570. faceUV?: Vector4[];
  23571. hasRings?: boolean;
  23572. enclose?: boolean;
  23573. sideOrientation?: number;
  23574. frontUVs?: Vector4;
  23575. backUVs?: Vector4;
  23576. }): VertexData;
  23577. /**
  23578. * Creates the VertexData for a torus
  23579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23580. * * diameter the diameter of the torus, optional default 1
  23581. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23584. * * 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)
  23585. * * 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)
  23586. * @returns the VertexData of the torus
  23587. */
  23588. static CreateTorus(options: {
  23589. diameter?: number;
  23590. thickness?: number;
  23591. tessellation?: number;
  23592. sideOrientation?: number;
  23593. frontUVs?: Vector4;
  23594. backUVs?: Vector4;
  23595. }): VertexData;
  23596. /**
  23597. * Creates the VertexData of the LineSystem
  23598. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23599. * - lines an array of lines, each line being an array of successive Vector3
  23600. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23601. * @returns the VertexData of the LineSystem
  23602. */
  23603. static CreateLineSystem(options: {
  23604. lines: Vector3[][];
  23605. colors?: Nullable<Color4[][]>;
  23606. }): VertexData;
  23607. /**
  23608. * Create the VertexData for a DashedLines
  23609. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23610. * - points an array successive Vector3
  23611. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23612. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23613. * - dashNb the intended total number of dashes, optional, default 200
  23614. * @returns the VertexData for the DashedLines
  23615. */
  23616. static CreateDashedLines(options: {
  23617. points: Vector3[];
  23618. dashSize?: number;
  23619. gapSize?: number;
  23620. dashNb?: number;
  23621. }): VertexData;
  23622. /**
  23623. * Creates the VertexData for a Ground
  23624. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23625. * - width the width (x direction) of the ground, optional, default 1
  23626. * - height the height (z direction) of the ground, optional, default 1
  23627. * - subdivisions the number of subdivisions per side, optional, default 1
  23628. * @returns the VertexData of the Ground
  23629. */
  23630. static CreateGround(options: {
  23631. width?: number;
  23632. height?: number;
  23633. subdivisions?: number;
  23634. subdivisionsX?: number;
  23635. subdivisionsY?: number;
  23636. }): VertexData;
  23637. /**
  23638. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23639. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23640. * * xmin the ground minimum X coordinate, optional, default -1
  23641. * * zmin the ground minimum Z coordinate, optional, default -1
  23642. * * xmax the ground maximum X coordinate, optional, default 1
  23643. * * zmax the ground maximum Z coordinate, optional, default 1
  23644. * * 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}
  23645. * * 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}
  23646. * @returns the VertexData of the TiledGround
  23647. */
  23648. static CreateTiledGround(options: {
  23649. xmin: number;
  23650. zmin: number;
  23651. xmax: number;
  23652. zmax: number;
  23653. subdivisions?: {
  23654. w: number;
  23655. h: number;
  23656. };
  23657. precision?: {
  23658. w: number;
  23659. h: number;
  23660. };
  23661. }): VertexData;
  23662. /**
  23663. * Creates the VertexData of the Ground designed from a heightmap
  23664. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23665. * * width the width (x direction) of the ground
  23666. * * height the height (z direction) of the ground
  23667. * * subdivisions the number of subdivisions per side
  23668. * * minHeight the minimum altitude on the ground, optional, default 0
  23669. * * maxHeight the maximum altitude on the ground, optional default 1
  23670. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23671. * * buffer the array holding the image color data
  23672. * * bufferWidth the width of image
  23673. * * bufferHeight the height of image
  23674. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23675. * @returns the VertexData of the Ground designed from a heightmap
  23676. */
  23677. static CreateGroundFromHeightMap(options: {
  23678. width: number;
  23679. height: number;
  23680. subdivisions: number;
  23681. minHeight: number;
  23682. maxHeight: number;
  23683. colorFilter: Color3;
  23684. buffer: Uint8Array;
  23685. bufferWidth: number;
  23686. bufferHeight: number;
  23687. alphaFilter: number;
  23688. }): VertexData;
  23689. /**
  23690. * Creates the VertexData for a Plane
  23691. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23692. * * size sets the width and height of the plane to the value of size, optional default 1
  23693. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23694. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23696. * * 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)
  23697. * * 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)
  23698. * @returns the VertexData of the box
  23699. */
  23700. static CreatePlane(options: {
  23701. size?: number;
  23702. width?: number;
  23703. height?: number;
  23704. sideOrientation?: number;
  23705. frontUVs?: Vector4;
  23706. backUVs?: Vector4;
  23707. }): VertexData;
  23708. /**
  23709. * Creates the VertexData of the Disc or regular Polygon
  23710. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23711. * * radius the radius of the disc, optional default 0.5
  23712. * * tessellation the number of polygon sides, optional, default 64
  23713. * * 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
  23714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23715. * * 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)
  23716. * * 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)
  23717. * @returns the VertexData of the box
  23718. */
  23719. static CreateDisc(options: {
  23720. radius?: number;
  23721. tessellation?: number;
  23722. arc?: number;
  23723. sideOrientation?: number;
  23724. frontUVs?: Vector4;
  23725. backUVs?: Vector4;
  23726. }): VertexData;
  23727. /**
  23728. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23729. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23730. * @param polygon a mesh built from polygonTriangulation.build()
  23731. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23732. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23733. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23734. * @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)
  23735. * @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)
  23736. * @returns the VertexData of the Polygon
  23737. */
  23738. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23739. /**
  23740. * Creates the VertexData of the IcoSphere
  23741. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23742. * * radius the radius of the IcoSphere, optional default 1
  23743. * * radiusX allows stretching in the x direction, optional, default radius
  23744. * * radiusY allows stretching in the y direction, optional, default radius
  23745. * * radiusZ allows stretching in the z direction, optional, default radius
  23746. * * flat when true creates a flat shaded mesh, optional, default true
  23747. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23749. * * 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)
  23750. * * 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)
  23751. * @returns the VertexData of the IcoSphere
  23752. */
  23753. static CreateIcoSphere(options: {
  23754. radius?: number;
  23755. radiusX?: number;
  23756. radiusY?: number;
  23757. radiusZ?: number;
  23758. flat?: boolean;
  23759. subdivisions?: number;
  23760. sideOrientation?: number;
  23761. frontUVs?: Vector4;
  23762. backUVs?: Vector4;
  23763. }): VertexData;
  23764. /**
  23765. * Creates the VertexData for a Polyhedron
  23766. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23767. * * type provided types are:
  23768. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23769. * * 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)
  23770. * * size the size of the IcoSphere, optional default 1
  23771. * * sizeX allows stretching in the x direction, optional, default size
  23772. * * sizeY allows stretching in the y direction, optional, default size
  23773. * * sizeZ allows stretching in the z direction, optional, default size
  23774. * * 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
  23775. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23776. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23777. * * flat when true creates a flat shaded mesh, optional, default true
  23778. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23780. * * 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)
  23781. * * 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)
  23782. * @returns the VertexData of the Polyhedron
  23783. */
  23784. static CreatePolyhedron(options: {
  23785. type?: number;
  23786. size?: number;
  23787. sizeX?: number;
  23788. sizeY?: number;
  23789. sizeZ?: number;
  23790. custom?: any;
  23791. faceUV?: Vector4[];
  23792. faceColors?: Color4[];
  23793. flat?: boolean;
  23794. sideOrientation?: number;
  23795. frontUVs?: Vector4;
  23796. backUVs?: Vector4;
  23797. }): VertexData;
  23798. /**
  23799. * Creates the VertexData for a TorusKnot
  23800. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23801. * * radius the radius of the torus knot, optional, default 2
  23802. * * tube the thickness of the tube, optional, default 0.5
  23803. * * radialSegments the number of sides on each tube segments, optional, default 32
  23804. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23805. * * p the number of windings around the z axis, optional, default 2
  23806. * * q the number of windings around the x axis, optional, default 3
  23807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23808. * * 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)
  23809. * * 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)
  23810. * @returns the VertexData of the Torus Knot
  23811. */
  23812. static CreateTorusKnot(options: {
  23813. radius?: number;
  23814. tube?: number;
  23815. radialSegments?: number;
  23816. tubularSegments?: number;
  23817. p?: number;
  23818. q?: number;
  23819. sideOrientation?: number;
  23820. frontUVs?: Vector4;
  23821. backUVs?: Vector4;
  23822. }): VertexData;
  23823. /**
  23824. * Compute normals for given positions and indices
  23825. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23826. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23827. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23828. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23829. * * facetNormals : optional array of facet normals (vector3)
  23830. * * facetPositions : optional array of facet positions (vector3)
  23831. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23832. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23833. * * bInfo : optional bounding info, required for facetPartitioning computation
  23834. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23835. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23836. * * useRightHandedSystem: optional boolean to for right handed system computation
  23837. * * depthSort : optional boolean to enable the facet depth sort computation
  23838. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23839. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23840. */
  23841. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23842. facetNormals?: any;
  23843. facetPositions?: any;
  23844. facetPartitioning?: any;
  23845. ratio?: number;
  23846. bInfo?: any;
  23847. bbSize?: Vector3;
  23848. subDiv?: any;
  23849. useRightHandedSystem?: boolean;
  23850. depthSort?: boolean;
  23851. distanceTo?: Vector3;
  23852. depthSortedFacets?: any;
  23853. }): void;
  23854. /** @hidden */
  23855. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23856. /**
  23857. * Applies VertexData created from the imported parameters to the geometry
  23858. * @param parsedVertexData the parsed data from an imported file
  23859. * @param geometry the geometry to apply the VertexData to
  23860. */
  23861. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23862. }
  23863. }
  23864. declare module BABYLON {
  23865. /**
  23866. * Class containing static functions to help procedurally build meshes
  23867. */
  23868. export class DiscBuilder {
  23869. /**
  23870. * Creates a plane polygonal mesh. By default, this is a disc
  23871. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23872. * * 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
  23873. * * 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
  23874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23875. * * 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
  23876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23877. * @param name defines the name of the mesh
  23878. * @param options defines the options used to create the mesh
  23879. * @param scene defines the hosting scene
  23880. * @returns the plane polygonal mesh
  23881. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23882. */
  23883. static CreateDisc(name: string, options: {
  23884. radius?: number;
  23885. tessellation?: number;
  23886. arc?: number;
  23887. updatable?: boolean;
  23888. sideOrientation?: number;
  23889. frontUVs?: Vector4;
  23890. backUVs?: Vector4;
  23891. }, scene?: Nullable<Scene>): Mesh;
  23892. }
  23893. }
  23894. declare module BABYLON {
  23895. /**
  23896. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23897. *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.
  23898. * The SPS is also a particle system. It provides some methods to manage the particles.
  23899. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23900. *
  23901. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23902. */
  23903. export class SolidParticleSystem implements IDisposable {
  23904. /**
  23905. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23906. * Example : var p = SPS.particles[i];
  23907. */
  23908. particles: SolidParticle[];
  23909. /**
  23910. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23911. */
  23912. nbParticles: number;
  23913. /**
  23914. * If the particles must ever face the camera (default false). Useful for planar particles.
  23915. */
  23916. billboard: boolean;
  23917. /**
  23918. * Recompute normals when adding a shape
  23919. */
  23920. recomputeNormals: boolean;
  23921. /**
  23922. * This a counter ofr your own usage. It's not set by any SPS functions.
  23923. */
  23924. counter: number;
  23925. /**
  23926. * The SPS name. This name is also given to the underlying mesh.
  23927. */
  23928. name: string;
  23929. /**
  23930. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23931. */
  23932. mesh: Mesh;
  23933. /**
  23934. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23935. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23936. */
  23937. vars: any;
  23938. /**
  23939. * This array is populated when the SPS is set as 'pickable'.
  23940. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23941. * Each element of this array is an object `{idx: int, faceId: int}`.
  23942. * `idx` is the picked particle index in the `SPS.particles` array
  23943. * `faceId` is the picked face index counted within this particle.
  23944. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23945. */
  23946. pickedParticles: {
  23947. idx: number;
  23948. faceId: number;
  23949. }[];
  23950. /**
  23951. * This array is populated when `enableDepthSort` is set to true.
  23952. * Each element of this array is an instance of the class DepthSortedParticle.
  23953. */
  23954. depthSortedParticles: DepthSortedParticle[];
  23955. /**
  23956. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23957. * @hidden
  23958. */
  23959. _bSphereOnly: boolean;
  23960. /**
  23961. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23962. * @hidden
  23963. */
  23964. _bSphereRadiusFactor: number;
  23965. private _scene;
  23966. private _positions;
  23967. private _indices;
  23968. private _normals;
  23969. private _colors;
  23970. private _uvs;
  23971. private _indices32;
  23972. private _positions32;
  23973. private _normals32;
  23974. private _fixedNormal32;
  23975. private _colors32;
  23976. private _uvs32;
  23977. private _index;
  23978. private _updatable;
  23979. private _pickable;
  23980. private _isVisibilityBoxLocked;
  23981. private _alwaysVisible;
  23982. private _depthSort;
  23983. private _shapeCounter;
  23984. private _copy;
  23985. private _color;
  23986. private _computeParticleColor;
  23987. private _computeParticleTexture;
  23988. private _computeParticleRotation;
  23989. private _computeParticleVertex;
  23990. private _computeBoundingBox;
  23991. private _depthSortParticles;
  23992. private _camera;
  23993. private _mustUnrotateFixedNormals;
  23994. private _particlesIntersect;
  23995. private _needs32Bits;
  23996. /**
  23997. * Creates a SPS (Solid Particle System) object.
  23998. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23999. * @param scene (Scene) is the scene in which the SPS is added.
  24000. * @param options defines the options of the sps e.g.
  24001. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24002. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24003. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24004. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24005. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24006. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24007. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24008. */
  24009. constructor(name: string, scene: Scene, options?: {
  24010. updatable?: boolean;
  24011. isPickable?: boolean;
  24012. enableDepthSort?: boolean;
  24013. particleIntersection?: boolean;
  24014. boundingSphereOnly?: boolean;
  24015. bSphereRadiusFactor?: number;
  24016. });
  24017. /**
  24018. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24019. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24020. * @returns the created mesh
  24021. */
  24022. buildMesh(): Mesh;
  24023. /**
  24024. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24025. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24026. * Thus the particles generated from `digest()` have their property `position` set yet.
  24027. * @param mesh ( Mesh ) is the mesh to be digested
  24028. * @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
  24029. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24030. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24031. * @returns the current SPS
  24032. */
  24033. digest(mesh: Mesh, options?: {
  24034. facetNb?: number;
  24035. number?: number;
  24036. delta?: number;
  24037. }): SolidParticleSystem;
  24038. private _unrotateFixedNormals;
  24039. private _resetCopy;
  24040. private _meshBuilder;
  24041. private _posToShape;
  24042. private _uvsToShapeUV;
  24043. private _addParticle;
  24044. /**
  24045. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24046. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24047. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24048. * @param nb (positive integer) the number of particles to be created from this model
  24049. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24050. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24051. * @returns the number of shapes in the system
  24052. */
  24053. addShape(mesh: Mesh, nb: number, options?: {
  24054. positionFunction?: any;
  24055. vertexFunction?: any;
  24056. }): number;
  24057. private _rebuildParticle;
  24058. /**
  24059. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24060. * @returns the SPS.
  24061. */
  24062. rebuildMesh(): SolidParticleSystem;
  24063. /**
  24064. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24065. * This method calls `updateParticle()` for each particle of the SPS.
  24066. * For an animated SPS, it is usually called within the render loop.
  24067. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24068. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24069. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24070. * @returns the SPS.
  24071. */
  24072. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24073. /**
  24074. * Disposes the SPS.
  24075. */
  24076. dispose(): void;
  24077. /**
  24078. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24079. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24080. * @returns the SPS.
  24081. */
  24082. refreshVisibleSize(): SolidParticleSystem;
  24083. /**
  24084. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24085. * @param size the size (float) of the visibility box
  24086. * note : this doesn't lock the SPS mesh bounding box.
  24087. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24088. */
  24089. setVisibilityBox(size: number): void;
  24090. /**
  24091. * Gets whether the SPS as always visible or not
  24092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24093. */
  24094. /**
  24095. * Sets the SPS as always visible or not
  24096. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24097. */
  24098. isAlwaysVisible: boolean;
  24099. /**
  24100. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24102. */
  24103. /**
  24104. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24105. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24106. */
  24107. isVisibilityBoxLocked: boolean;
  24108. /**
  24109. * Tells to `setParticles()` to compute the particle rotations or not.
  24110. * Default value : true. The SPS is faster when it's set to false.
  24111. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24112. */
  24113. /**
  24114. * Gets if `setParticles()` computes the particle rotations or not.
  24115. * Default value : true. The SPS is faster when it's set to false.
  24116. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24117. */
  24118. computeParticleRotation: boolean;
  24119. /**
  24120. * Tells to `setParticles()` to compute the particle colors or not.
  24121. * Default value : true. The SPS is faster when it's set to false.
  24122. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24123. */
  24124. /**
  24125. * Gets if `setParticles()` computes the particle colors or not.
  24126. * Default value : true. The SPS is faster when it's set to false.
  24127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24128. */
  24129. computeParticleColor: boolean;
  24130. /**
  24131. * Gets if `setParticles()` computes the particle textures or not.
  24132. * Default value : true. The SPS is faster when it's set to false.
  24133. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24134. */
  24135. computeParticleTexture: boolean;
  24136. /**
  24137. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24138. * Default value : false. The SPS is faster when it's set to false.
  24139. * Note : the particle custom vertex positions aren't stored values.
  24140. */
  24141. /**
  24142. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24143. * Default value : false. The SPS is faster when it's set to false.
  24144. * Note : the particle custom vertex positions aren't stored values.
  24145. */
  24146. computeParticleVertex: boolean;
  24147. /**
  24148. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24149. */
  24150. /**
  24151. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24152. */
  24153. computeBoundingBox: boolean;
  24154. /**
  24155. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24156. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24157. * Default : `true`
  24158. */
  24159. /**
  24160. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24161. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24162. * Default : `true`
  24163. */
  24164. depthSortParticles: boolean;
  24165. /**
  24166. * This function does nothing. It may be overwritten to set all the particle first values.
  24167. * The SPS doesn't call this function, you may have to call it by your own.
  24168. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24169. */
  24170. initParticles(): void;
  24171. /**
  24172. * This function does nothing. It may be overwritten to recycle a particle.
  24173. * The SPS doesn't call this function, you may have to call it by your own.
  24174. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24175. * @param particle The particle to recycle
  24176. * @returns the recycled particle
  24177. */
  24178. recycleParticle(particle: SolidParticle): SolidParticle;
  24179. /**
  24180. * Updates a particle : this function should be overwritten by the user.
  24181. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24182. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24183. * @example : just set a particle position or velocity and recycle conditions
  24184. * @param particle The particle to update
  24185. * @returns the updated particle
  24186. */
  24187. updateParticle(particle: SolidParticle): SolidParticle;
  24188. /**
  24189. * Updates a vertex of a particle : it can be overwritten by the user.
  24190. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24191. * @param particle the current particle
  24192. * @param vertex the current index of the current particle
  24193. * @param pt the index of the current vertex in the particle shape
  24194. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24195. * @example : just set a vertex particle position
  24196. * @returns the updated vertex
  24197. */
  24198. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24199. /**
  24200. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24201. * This does nothing and may be overwritten by the user.
  24202. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24203. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24204. * @param update the boolean update value actually passed to setParticles()
  24205. */
  24206. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24207. /**
  24208. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24209. * This will be passed three parameters.
  24210. * This does nothing and may be overwritten by the user.
  24211. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24212. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24213. * @param update the boolean update value actually passed to setParticles()
  24214. */
  24215. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24216. }
  24217. }
  24218. declare module BABYLON {
  24219. /**
  24220. * Represents one particle of a solid particle system.
  24221. */
  24222. export class SolidParticle {
  24223. /**
  24224. * particle global index
  24225. */
  24226. idx: number;
  24227. /**
  24228. * The color of the particle
  24229. */
  24230. color: Nullable<Color4>;
  24231. /**
  24232. * The world space position of the particle.
  24233. */
  24234. position: Vector3;
  24235. /**
  24236. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24237. */
  24238. rotation: Vector3;
  24239. /**
  24240. * The world space rotation quaternion of the particle.
  24241. */
  24242. rotationQuaternion: Nullable<Quaternion>;
  24243. /**
  24244. * The scaling of the particle.
  24245. */
  24246. scaling: Vector3;
  24247. /**
  24248. * The uvs of the particle.
  24249. */
  24250. uvs: Vector4;
  24251. /**
  24252. * The current speed of the particle.
  24253. */
  24254. velocity: Vector3;
  24255. /**
  24256. * The pivot point in the particle local space.
  24257. */
  24258. pivot: Vector3;
  24259. /**
  24260. * Must the particle be translated from its pivot point in its local space ?
  24261. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24262. * Default : false
  24263. */
  24264. translateFromPivot: boolean;
  24265. /**
  24266. * Is the particle active or not ?
  24267. */
  24268. alive: boolean;
  24269. /**
  24270. * Is the particle visible or not ?
  24271. */
  24272. isVisible: boolean;
  24273. /**
  24274. * Index of this particle in the global "positions" array (Internal use)
  24275. * @hidden
  24276. */
  24277. _pos: number;
  24278. /**
  24279. * @hidden Index of this particle in the global "indices" array (Internal use)
  24280. */
  24281. _ind: number;
  24282. /**
  24283. * @hidden ModelShape of this particle (Internal use)
  24284. */
  24285. _model: ModelShape;
  24286. /**
  24287. * ModelShape id of this particle
  24288. */
  24289. shapeId: number;
  24290. /**
  24291. * Index of the particle in its shape id (Internal use)
  24292. */
  24293. idxInShape: number;
  24294. /**
  24295. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24296. */
  24297. _modelBoundingInfo: BoundingInfo;
  24298. /**
  24299. * @hidden Particle BoundingInfo object (Internal use)
  24300. */
  24301. _boundingInfo: BoundingInfo;
  24302. /**
  24303. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24304. */
  24305. _sps: SolidParticleSystem;
  24306. /**
  24307. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24308. */
  24309. _stillInvisible: boolean;
  24310. /**
  24311. * @hidden Last computed particle rotation matrix
  24312. */
  24313. _rotationMatrix: number[];
  24314. /**
  24315. * Parent particle Id, if any.
  24316. * Default null.
  24317. */
  24318. parentId: Nullable<number>;
  24319. /**
  24320. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24321. * The possible values are :
  24322. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24323. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24324. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24325. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24326. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24327. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24328. * */
  24329. cullingStrategy: number;
  24330. /**
  24331. * @hidden Internal global position in the SPS.
  24332. */
  24333. _globalPosition: Vector3;
  24334. /**
  24335. * Creates a Solid Particle object.
  24336. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24337. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24338. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24339. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24340. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24341. * @param shapeId (integer) is the model shape identifier in the SPS.
  24342. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24343. * @param sps defines the sps it is associated to
  24344. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24345. */
  24346. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24347. /**
  24348. * Legacy support, changed scale to scaling
  24349. */
  24350. /**
  24351. * Legacy support, changed scale to scaling
  24352. */
  24353. scale: Vector3;
  24354. /**
  24355. * Legacy support, changed quaternion to rotationQuaternion
  24356. */
  24357. /**
  24358. * Legacy support, changed quaternion to rotationQuaternion
  24359. */
  24360. quaternion: Nullable<Quaternion>;
  24361. /**
  24362. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24363. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24364. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24365. * @returns true if it intersects
  24366. */
  24367. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24368. /**
  24369. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24370. * A particle is in the frustum if its bounding box intersects the frustum
  24371. * @param frustumPlanes defines the frustum to test
  24372. * @returns true if the particle is in the frustum planes
  24373. */
  24374. isInFrustum(frustumPlanes: Plane[]): boolean;
  24375. /**
  24376. * get the rotation matrix of the particle
  24377. * @hidden
  24378. */
  24379. getRotationMatrix(m: Matrix): void;
  24380. }
  24381. /**
  24382. * Represents the shape of the model used by one particle of a solid particle system.
  24383. * SPS internal tool, don't use it manually.
  24384. */
  24385. export class ModelShape {
  24386. /**
  24387. * The shape id
  24388. * @hidden
  24389. */
  24390. shapeID: number;
  24391. /**
  24392. * flat array of model positions (internal use)
  24393. * @hidden
  24394. */
  24395. _shape: Vector3[];
  24396. /**
  24397. * flat array of model UVs (internal use)
  24398. * @hidden
  24399. */
  24400. _shapeUV: number[];
  24401. /**
  24402. * length of the shape in the model indices array (internal use)
  24403. * @hidden
  24404. */
  24405. _indicesLength: number;
  24406. /**
  24407. * Custom position function (internal use)
  24408. * @hidden
  24409. */
  24410. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24411. /**
  24412. * Custom vertex function (internal use)
  24413. * @hidden
  24414. */
  24415. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24416. /**
  24417. * 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.
  24418. * SPS internal tool, don't use it manually.
  24419. * @hidden
  24420. */
  24421. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  24422. }
  24423. /**
  24424. * Represents a Depth Sorted Particle in the solid particle system.
  24425. */
  24426. export class DepthSortedParticle {
  24427. /**
  24428. * Index of the particle in the "indices" array
  24429. */
  24430. ind: number;
  24431. /**
  24432. * Length of the particle shape in the "indices" array
  24433. */
  24434. indicesLength: number;
  24435. /**
  24436. * Squared distance from the particle to the camera
  24437. */
  24438. sqDistance: number;
  24439. }
  24440. }
  24441. declare module BABYLON {
  24442. /**
  24443. * @hidden
  24444. */
  24445. export class _MeshCollisionData {
  24446. _checkCollisions: boolean;
  24447. _collisionMask: number;
  24448. _collisionGroup: number;
  24449. _collider: Nullable<Collider>;
  24450. _oldPositionForCollisions: Vector3;
  24451. _diffPositionForCollisions: Vector3;
  24452. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24453. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24454. }
  24455. }
  24456. declare module BABYLON {
  24457. /** @hidden */
  24458. class _FacetDataStorage {
  24459. facetPositions: Vector3[];
  24460. facetNormals: Vector3[];
  24461. facetPartitioning: number[][];
  24462. facetNb: number;
  24463. partitioningSubdivisions: number;
  24464. partitioningBBoxRatio: number;
  24465. facetDataEnabled: boolean;
  24466. facetParameters: any;
  24467. bbSize: Vector3;
  24468. subDiv: {
  24469. max: number;
  24470. X: number;
  24471. Y: number;
  24472. Z: number;
  24473. };
  24474. facetDepthSort: boolean;
  24475. facetDepthSortEnabled: boolean;
  24476. depthSortedIndices: IndicesArray;
  24477. depthSortedFacets: {
  24478. ind: number;
  24479. sqDistance: number;
  24480. }[];
  24481. facetDepthSortFunction: (f1: {
  24482. ind: number;
  24483. sqDistance: number;
  24484. }, f2: {
  24485. ind: number;
  24486. sqDistance: number;
  24487. }) => number;
  24488. facetDepthSortFrom: Vector3;
  24489. facetDepthSortOrigin: Vector3;
  24490. invertedMatrix: Matrix;
  24491. }
  24492. /**
  24493. * @hidden
  24494. **/
  24495. class _InternalAbstractMeshDataInfo {
  24496. _hasVertexAlpha: boolean;
  24497. _useVertexColors: boolean;
  24498. _numBoneInfluencers: number;
  24499. _applyFog: boolean;
  24500. _receiveShadows: boolean;
  24501. _facetData: _FacetDataStorage;
  24502. _visibility: number;
  24503. _skeleton: Nullable<Skeleton>;
  24504. _layerMask: number;
  24505. _computeBonesUsingShaders: boolean;
  24506. _isActive: boolean;
  24507. _onlyForInstances: boolean;
  24508. _isActiveIntermediate: boolean;
  24509. _onlyForInstancesIntermediate: boolean;
  24510. }
  24511. /**
  24512. * Class used to store all common mesh properties
  24513. */
  24514. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24515. /** No occlusion */
  24516. static OCCLUSION_TYPE_NONE: number;
  24517. /** Occlusion set to optimisitic */
  24518. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24519. /** Occlusion set to strict */
  24520. static OCCLUSION_TYPE_STRICT: number;
  24521. /** Use an accurante occlusion algorithm */
  24522. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24523. /** Use a conservative occlusion algorithm */
  24524. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24525. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24526. * Test order :
  24527. * Is the bounding sphere outside the frustum ?
  24528. * If not, are the bounding box vertices outside the frustum ?
  24529. * It not, then the cullable object is in the frustum.
  24530. */
  24531. static readonly CULLINGSTRATEGY_STANDARD: number;
  24532. /** Culling strategy : Bounding Sphere Only.
  24533. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24534. * It's also less accurate than the standard because some not visible objects can still be selected.
  24535. * Test : is the bounding sphere outside the frustum ?
  24536. * If not, then the cullable object is in the frustum.
  24537. */
  24538. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24539. /** Culling strategy : Optimistic Inclusion.
  24540. * This in an inclusion test first, then the standard exclusion test.
  24541. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24542. * 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.
  24543. * Anyway, it's as accurate as the standard strategy.
  24544. * Test :
  24545. * Is the cullable object bounding sphere center in the frustum ?
  24546. * If not, apply the default culling strategy.
  24547. */
  24548. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24549. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24550. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24551. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24552. * 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.
  24553. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24554. * Test :
  24555. * Is the cullable object bounding sphere center in the frustum ?
  24556. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24557. */
  24558. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24559. /**
  24560. * No billboard
  24561. */
  24562. static readonly BILLBOARDMODE_NONE: number;
  24563. /** Billboard on X axis */
  24564. static readonly BILLBOARDMODE_X: number;
  24565. /** Billboard on Y axis */
  24566. static readonly BILLBOARDMODE_Y: number;
  24567. /** Billboard on Z axis */
  24568. static readonly BILLBOARDMODE_Z: number;
  24569. /** Billboard on all axes */
  24570. static readonly BILLBOARDMODE_ALL: number;
  24571. /** @hidden */
  24572. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24573. /**
  24574. * The culling strategy to use to check whether the mesh must be rendered or not.
  24575. * This value can be changed at any time and will be used on the next render mesh selection.
  24576. * The possible values are :
  24577. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24578. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24581. * Please read each static variable documentation to get details about the culling process.
  24582. * */
  24583. cullingStrategy: number;
  24584. /**
  24585. * Gets the number of facets in the mesh
  24586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24587. */
  24588. readonly facetNb: number;
  24589. /**
  24590. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24592. */
  24593. partitioningSubdivisions: number;
  24594. /**
  24595. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24596. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24598. */
  24599. partitioningBBoxRatio: number;
  24600. /**
  24601. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24602. * Works only for updatable meshes.
  24603. * Doesn't work with multi-materials
  24604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24605. */
  24606. mustDepthSortFacets: boolean;
  24607. /**
  24608. * The location (Vector3) where the facet depth sort must be computed from.
  24609. * By default, the active camera position.
  24610. * Used only when facet depth sort is enabled
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24612. */
  24613. facetDepthSortFrom: Vector3;
  24614. /**
  24615. * gets a boolean indicating if facetData is enabled
  24616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24617. */
  24618. readonly isFacetDataEnabled: boolean;
  24619. /** @hidden */
  24620. _updateNonUniformScalingState(value: boolean): boolean;
  24621. /**
  24622. * An event triggered when this mesh collides with another one
  24623. */
  24624. onCollideObservable: Observable<AbstractMesh>;
  24625. /** Set a function to call when this mesh collides with another one */
  24626. onCollide: () => void;
  24627. /**
  24628. * An event triggered when the collision's position changes
  24629. */
  24630. onCollisionPositionChangeObservable: Observable<Vector3>;
  24631. /** Set a function to call when the collision's position changes */
  24632. onCollisionPositionChange: () => void;
  24633. /**
  24634. * An event triggered when material is changed
  24635. */
  24636. onMaterialChangedObservable: Observable<AbstractMesh>;
  24637. /**
  24638. * Gets or sets the orientation for POV movement & rotation
  24639. */
  24640. definedFacingForward: boolean;
  24641. /** @hidden */
  24642. _occlusionQuery: Nullable<WebGLQuery>;
  24643. /** @hidden */
  24644. _renderingGroup: Nullable<RenderingGroup>;
  24645. /**
  24646. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24647. */
  24648. /**
  24649. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24650. */
  24651. visibility: number;
  24652. /** Gets or sets the alpha index used to sort transparent meshes
  24653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24654. */
  24655. alphaIndex: number;
  24656. /**
  24657. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24658. */
  24659. isVisible: boolean;
  24660. /**
  24661. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24662. */
  24663. isPickable: boolean;
  24664. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24665. showSubMeshesBoundingBox: boolean;
  24666. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24667. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24668. */
  24669. isBlocker: boolean;
  24670. /**
  24671. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24672. */
  24673. enablePointerMoveEvents: boolean;
  24674. /**
  24675. * Specifies the rendering group id for this mesh (0 by default)
  24676. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24677. */
  24678. renderingGroupId: number;
  24679. private _material;
  24680. /** Gets or sets current material */
  24681. material: Nullable<Material>;
  24682. /**
  24683. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24684. * @see http://doc.babylonjs.com/babylon101/shadows
  24685. */
  24686. receiveShadows: boolean;
  24687. /** Defines color to use when rendering outline */
  24688. outlineColor: Color3;
  24689. /** Define width to use when rendering outline */
  24690. outlineWidth: number;
  24691. /** Defines color to use when rendering overlay */
  24692. overlayColor: Color3;
  24693. /** Defines alpha to use when rendering overlay */
  24694. overlayAlpha: number;
  24695. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24696. hasVertexAlpha: boolean;
  24697. /** 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) */
  24698. useVertexColors: boolean;
  24699. /**
  24700. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24701. */
  24702. computeBonesUsingShaders: boolean;
  24703. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24704. numBoneInfluencers: number;
  24705. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24706. applyFog: boolean;
  24707. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24708. useOctreeForRenderingSelection: boolean;
  24709. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24710. useOctreeForPicking: boolean;
  24711. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24712. useOctreeForCollisions: boolean;
  24713. /**
  24714. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24715. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24716. */
  24717. layerMask: number;
  24718. /**
  24719. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24720. */
  24721. alwaysSelectAsActiveMesh: boolean;
  24722. /**
  24723. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24724. */
  24725. doNotSyncBoundingInfo: boolean;
  24726. /**
  24727. * Gets or sets the current action manager
  24728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24729. */
  24730. actionManager: Nullable<AbstractActionManager>;
  24731. private _meshCollisionData;
  24732. /**
  24733. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24735. */
  24736. ellipsoid: Vector3;
  24737. /**
  24738. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24740. */
  24741. ellipsoidOffset: Vector3;
  24742. /**
  24743. * Gets or sets a collision mask used to mask collisions (default is -1).
  24744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24745. */
  24746. collisionMask: number;
  24747. /**
  24748. * Gets or sets the current collision group mask (-1 by default).
  24749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24750. */
  24751. collisionGroup: number;
  24752. /**
  24753. * Defines edge width used when edgesRenderer is enabled
  24754. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24755. */
  24756. edgesWidth: number;
  24757. /**
  24758. * Defines edge color used when edgesRenderer is enabled
  24759. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24760. */
  24761. edgesColor: Color4;
  24762. /** @hidden */
  24763. _edgesRenderer: Nullable<IEdgesRenderer>;
  24764. /** @hidden */
  24765. _masterMesh: Nullable<AbstractMesh>;
  24766. /** @hidden */
  24767. _boundingInfo: Nullable<BoundingInfo>;
  24768. /** @hidden */
  24769. _renderId: number;
  24770. /**
  24771. * Gets or sets the list of subMeshes
  24772. * @see http://doc.babylonjs.com/how_to/multi_materials
  24773. */
  24774. subMeshes: SubMesh[];
  24775. /** @hidden */
  24776. _intersectionsInProgress: AbstractMesh[];
  24777. /** @hidden */
  24778. _unIndexed: boolean;
  24779. /** @hidden */
  24780. _lightSources: Light[];
  24781. /** Gets the list of lights affecting that mesh */
  24782. readonly lightSources: Light[];
  24783. /** @hidden */
  24784. readonly _positions: Nullable<Vector3[]>;
  24785. /** @hidden */
  24786. _waitingData: {
  24787. lods: Nullable<any>;
  24788. actions: Nullable<any>;
  24789. freezeWorldMatrix: Nullable<boolean>;
  24790. };
  24791. /** @hidden */
  24792. _bonesTransformMatrices: Nullable<Float32Array>;
  24793. /**
  24794. * Gets or sets a skeleton to apply skining transformations
  24795. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24796. */
  24797. skeleton: Nullable<Skeleton>;
  24798. /**
  24799. * An event triggered when the mesh is rebuilt.
  24800. */
  24801. onRebuildObservable: Observable<AbstractMesh>;
  24802. /**
  24803. * Creates a new AbstractMesh
  24804. * @param name defines the name of the mesh
  24805. * @param scene defines the hosting scene
  24806. */
  24807. constructor(name: string, scene?: Nullable<Scene>);
  24808. /**
  24809. * Returns the string "AbstractMesh"
  24810. * @returns "AbstractMesh"
  24811. */
  24812. getClassName(): string;
  24813. /**
  24814. * Gets a string representation of the current mesh
  24815. * @param fullDetails defines a boolean indicating if full details must be included
  24816. * @returns a string representation of the current mesh
  24817. */
  24818. toString(fullDetails?: boolean): string;
  24819. /**
  24820. * @hidden
  24821. */
  24822. protected _getEffectiveParent(): Nullable<Node>;
  24823. /** @hidden */
  24824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24825. /** @hidden */
  24826. _rebuild(): void;
  24827. /** @hidden */
  24828. _resyncLightSources(): void;
  24829. /** @hidden */
  24830. _resyncLighSource(light: Light): void;
  24831. /** @hidden */
  24832. _unBindEffect(): void;
  24833. /** @hidden */
  24834. _removeLightSource(light: Light): void;
  24835. private _markSubMeshesAsDirty;
  24836. /** @hidden */
  24837. _markSubMeshesAsLightDirty(): void;
  24838. /** @hidden */
  24839. _markSubMeshesAsAttributesDirty(): void;
  24840. /** @hidden */
  24841. _markSubMeshesAsMiscDirty(): void;
  24842. /**
  24843. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24844. */
  24845. scaling: Vector3;
  24846. /**
  24847. * Returns true if the mesh is blocked. Implemented by child classes
  24848. */
  24849. readonly isBlocked: boolean;
  24850. /**
  24851. * Returns the mesh itself by default. Implemented by child classes
  24852. * @param camera defines the camera to use to pick the right LOD level
  24853. * @returns the currentAbstractMesh
  24854. */
  24855. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24856. /**
  24857. * Returns 0 by default. Implemented by child classes
  24858. * @returns an integer
  24859. */
  24860. getTotalVertices(): number;
  24861. /**
  24862. * Returns a positive integer : the total number of indices in this mesh geometry.
  24863. * @returns the numner of indices or zero if the mesh has no geometry.
  24864. */
  24865. getTotalIndices(): number;
  24866. /**
  24867. * Returns null by default. Implemented by child classes
  24868. * @returns null
  24869. */
  24870. getIndices(): Nullable<IndicesArray>;
  24871. /**
  24872. * Returns the array of the requested vertex data kind. Implemented by child classes
  24873. * @param kind defines the vertex data kind to use
  24874. * @returns null
  24875. */
  24876. getVerticesData(kind: string): Nullable<FloatArray>;
  24877. /**
  24878. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24879. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24880. * Note that a new underlying VertexBuffer object is created each call.
  24881. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24882. * @param kind defines vertex data kind:
  24883. * * VertexBuffer.PositionKind
  24884. * * VertexBuffer.UVKind
  24885. * * VertexBuffer.UV2Kind
  24886. * * VertexBuffer.UV3Kind
  24887. * * VertexBuffer.UV4Kind
  24888. * * VertexBuffer.UV5Kind
  24889. * * VertexBuffer.UV6Kind
  24890. * * VertexBuffer.ColorKind
  24891. * * VertexBuffer.MatricesIndicesKind
  24892. * * VertexBuffer.MatricesIndicesExtraKind
  24893. * * VertexBuffer.MatricesWeightsKind
  24894. * * VertexBuffer.MatricesWeightsExtraKind
  24895. * @param data defines the data source
  24896. * @param updatable defines if the data must be flagged as updatable (or static)
  24897. * @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
  24898. * @returns the current mesh
  24899. */
  24900. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24901. /**
  24902. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24903. * If the mesh has no geometry, it is simply returned as it is.
  24904. * @param kind defines vertex data kind:
  24905. * * VertexBuffer.PositionKind
  24906. * * VertexBuffer.UVKind
  24907. * * VertexBuffer.UV2Kind
  24908. * * VertexBuffer.UV3Kind
  24909. * * VertexBuffer.UV4Kind
  24910. * * VertexBuffer.UV5Kind
  24911. * * VertexBuffer.UV6Kind
  24912. * * VertexBuffer.ColorKind
  24913. * * VertexBuffer.MatricesIndicesKind
  24914. * * VertexBuffer.MatricesIndicesExtraKind
  24915. * * VertexBuffer.MatricesWeightsKind
  24916. * * VertexBuffer.MatricesWeightsExtraKind
  24917. * @param data defines the data source
  24918. * @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
  24919. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24920. * @returns the current mesh
  24921. */
  24922. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24923. /**
  24924. * Sets the mesh indices,
  24925. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24926. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24927. * @param totalVertices Defines the total number of vertices
  24928. * @returns the current mesh
  24929. */
  24930. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24931. /**
  24932. * Gets a boolean indicating if specific vertex data is present
  24933. * @param kind defines the vertex data kind to use
  24934. * @returns true is data kind is present
  24935. */
  24936. isVerticesDataPresent(kind: string): boolean;
  24937. /**
  24938. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24939. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24940. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24941. * @returns a BoundingInfo
  24942. */
  24943. getBoundingInfo(): BoundingInfo;
  24944. /**
  24945. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24946. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24947. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24948. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24949. * @returns the current mesh
  24950. */
  24951. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24952. /**
  24953. * Overwrite the current bounding info
  24954. * @param boundingInfo defines the new bounding info
  24955. * @returns the current mesh
  24956. */
  24957. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24958. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24959. readonly useBones: boolean;
  24960. /** @hidden */
  24961. _preActivate(): void;
  24962. /** @hidden */
  24963. _preActivateForIntermediateRendering(renderId: number): void;
  24964. /** @hidden */
  24965. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24966. /** @hidden */
  24967. _postActivate(): void;
  24968. /** @hidden */
  24969. _freeze(): void;
  24970. /** @hidden */
  24971. _unFreeze(): void;
  24972. /**
  24973. * Gets the current world matrix
  24974. * @returns a Matrix
  24975. */
  24976. getWorldMatrix(): Matrix;
  24977. /** @hidden */
  24978. _getWorldMatrixDeterminant(): number;
  24979. /**
  24980. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24981. */
  24982. readonly isAnInstance: boolean;
  24983. /**
  24984. * Perform relative position change from the point of view of behind the front of the mesh.
  24985. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24986. * Supports definition of mesh facing forward or backward
  24987. * @param amountRight defines the distance on the right axis
  24988. * @param amountUp defines the distance on the up axis
  24989. * @param amountForward defines the distance on the forward axis
  24990. * @returns the current mesh
  24991. */
  24992. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24993. /**
  24994. * Calculate relative position change from the point of view of behind the front of the mesh.
  24995. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24996. * Supports definition of mesh facing forward or backward
  24997. * @param amountRight defines the distance on the right axis
  24998. * @param amountUp defines the distance on the up axis
  24999. * @param amountForward defines the distance on the forward axis
  25000. * @returns the new displacement vector
  25001. */
  25002. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25003. /**
  25004. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25005. * Supports definition of mesh facing forward or backward
  25006. * @param flipBack defines the flip
  25007. * @param twirlClockwise defines the twirl
  25008. * @param tiltRight defines the tilt
  25009. * @returns the current mesh
  25010. */
  25011. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25012. /**
  25013. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25014. * Supports definition of mesh facing forward or backward.
  25015. * @param flipBack defines the flip
  25016. * @param twirlClockwise defines the twirl
  25017. * @param tiltRight defines the tilt
  25018. * @returns the new rotation vector
  25019. */
  25020. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25021. /**
  25022. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25023. * This means the mesh underlying bounding box and sphere are recomputed.
  25024. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25025. * @returns the current mesh
  25026. */
  25027. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25028. /** @hidden */
  25029. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25030. /** @hidden */
  25031. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25032. /** @hidden */
  25033. _updateBoundingInfo(): AbstractMesh;
  25034. /** @hidden */
  25035. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25036. /** @hidden */
  25037. protected _afterComputeWorldMatrix(): void;
  25038. /** @hidden */
  25039. readonly _effectiveMesh: AbstractMesh;
  25040. /**
  25041. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25042. * A mesh is in the frustum if its bounding box intersects the frustum
  25043. * @param frustumPlanes defines the frustum to test
  25044. * @returns true if the mesh is in the frustum planes
  25045. */
  25046. isInFrustum(frustumPlanes: Plane[]): boolean;
  25047. /**
  25048. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25049. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25050. * @param frustumPlanes defines the frustum to test
  25051. * @returns true if the mesh is completely in the frustum planes
  25052. */
  25053. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25054. /**
  25055. * True if the mesh intersects another mesh or a SolidParticle object
  25056. * @param mesh defines a target mesh or SolidParticle to test
  25057. * @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)
  25058. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25059. * @returns true if there is an intersection
  25060. */
  25061. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25062. /**
  25063. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25064. * @param point defines the point to test
  25065. * @returns true if there is an intersection
  25066. */
  25067. intersectsPoint(point: Vector3): boolean;
  25068. /**
  25069. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25070. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25071. */
  25072. checkCollisions: boolean;
  25073. /**
  25074. * Gets Collider object used to compute collisions (not physics)
  25075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25076. */
  25077. readonly collider: Nullable<Collider>;
  25078. /**
  25079. * Move the mesh using collision engine
  25080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25081. * @param displacement defines the requested displacement vector
  25082. * @returns the current mesh
  25083. */
  25084. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25085. private _onCollisionPositionChange;
  25086. /** @hidden */
  25087. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25088. /** @hidden */
  25089. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25090. /** @hidden */
  25091. _checkCollision(collider: Collider): AbstractMesh;
  25092. /** @hidden */
  25093. _generatePointsArray(): boolean;
  25094. /**
  25095. * Checks if the passed Ray intersects with the mesh
  25096. * @param ray defines the ray to use
  25097. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25098. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25099. * @returns the picking info
  25100. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25101. */
  25102. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25103. /**
  25104. * Clones the current mesh
  25105. * @param name defines the mesh name
  25106. * @param newParent defines the new mesh parent
  25107. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25108. * @returns the new mesh
  25109. */
  25110. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25111. /**
  25112. * Disposes all the submeshes of the current meshnp
  25113. * @returns the current mesh
  25114. */
  25115. releaseSubMeshes(): AbstractMesh;
  25116. /**
  25117. * Releases resources associated with this abstract mesh.
  25118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25120. */
  25121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25122. /**
  25123. * Adds the passed mesh as a child to the current mesh
  25124. * @param mesh defines the child mesh
  25125. * @returns the current mesh
  25126. */
  25127. addChild(mesh: AbstractMesh): AbstractMesh;
  25128. /**
  25129. * Removes the passed mesh from the current mesh children list
  25130. * @param mesh defines the child mesh
  25131. * @returns the current mesh
  25132. */
  25133. removeChild(mesh: AbstractMesh): AbstractMesh;
  25134. /** @hidden */
  25135. private _initFacetData;
  25136. /**
  25137. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25138. * This method can be called within the render loop.
  25139. * 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
  25140. * @returns the current mesh
  25141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25142. */
  25143. updateFacetData(): AbstractMesh;
  25144. /**
  25145. * Returns the facetLocalNormals array.
  25146. * The normals are expressed in the mesh local spac
  25147. * @returns an array of Vector3
  25148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25149. */
  25150. getFacetLocalNormals(): Vector3[];
  25151. /**
  25152. * Returns the facetLocalPositions array.
  25153. * The facet positions are expressed in the mesh local space
  25154. * @returns an array of Vector3
  25155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25156. */
  25157. getFacetLocalPositions(): Vector3[];
  25158. /**
  25159. * Returns the facetLocalPartioning array
  25160. * @returns an array of array of numbers
  25161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25162. */
  25163. getFacetLocalPartitioning(): number[][];
  25164. /**
  25165. * Returns the i-th facet position in the world system.
  25166. * This method allocates a new Vector3 per call
  25167. * @param i defines the facet index
  25168. * @returns a new Vector3
  25169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25170. */
  25171. getFacetPosition(i: number): Vector3;
  25172. /**
  25173. * Sets the reference Vector3 with the i-th facet position in the world system
  25174. * @param i defines the facet index
  25175. * @param ref defines the target vector
  25176. * @returns the current mesh
  25177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25178. */
  25179. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25180. /**
  25181. * Returns the i-th facet normal in the world system.
  25182. * This method allocates a new Vector3 per call
  25183. * @param i defines the facet index
  25184. * @returns a new Vector3
  25185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25186. */
  25187. getFacetNormal(i: number): Vector3;
  25188. /**
  25189. * Sets the reference Vector3 with the i-th facet normal in the world system
  25190. * @param i defines the facet index
  25191. * @param ref defines the target vector
  25192. * @returns the current mesh
  25193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25194. */
  25195. getFacetNormalToRef(i: number, ref: Vector3): this;
  25196. /**
  25197. * 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)
  25198. * @param x defines x coordinate
  25199. * @param y defines y coordinate
  25200. * @param z defines z coordinate
  25201. * @returns the array of facet indexes
  25202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25203. */
  25204. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25205. /**
  25206. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25207. * @param projected sets as the (x,y,z) world projection on the facet
  25208. * @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
  25209. * @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
  25210. * @param x defines x coordinate
  25211. * @param y defines y coordinate
  25212. * @param z defines z coordinate
  25213. * @returns the face index if found (or null instead)
  25214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25215. */
  25216. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25217. /**
  25218. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25219. * @param projected sets as the (x,y,z) local projection on the facet
  25220. * @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
  25221. * @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
  25222. * @param x defines x coordinate
  25223. * @param y defines y coordinate
  25224. * @param z defines z coordinate
  25225. * @returns the face index if found (or null instead)
  25226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25227. */
  25228. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25229. /**
  25230. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25231. * @returns the parameters
  25232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25233. */
  25234. getFacetDataParameters(): any;
  25235. /**
  25236. * Disables the feature FacetData and frees the related memory
  25237. * @returns the current mesh
  25238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25239. */
  25240. disableFacetData(): AbstractMesh;
  25241. /**
  25242. * Updates the AbstractMesh indices array
  25243. * @param indices defines the data source
  25244. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25245. * @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)
  25246. * @returns the current mesh
  25247. */
  25248. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25249. /**
  25250. * Creates new normals data for the mesh
  25251. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25252. * @returns the current mesh
  25253. */
  25254. createNormals(updatable: boolean): AbstractMesh;
  25255. /**
  25256. * Align the mesh with a normal
  25257. * @param normal defines the normal to use
  25258. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25259. * @returns the current mesh
  25260. */
  25261. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25262. /** @hidden */
  25263. _checkOcclusionQuery(): boolean;
  25264. /**
  25265. * Disables the mesh edge rendering mode
  25266. * @returns the currentAbstractMesh
  25267. */
  25268. disableEdgesRendering(): AbstractMesh;
  25269. /**
  25270. * Enables the edge rendering mode on the mesh.
  25271. * This mode makes the mesh edges visible
  25272. * @param epsilon defines the maximal distance between two angles to detect a face
  25273. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25274. * @returns the currentAbstractMesh
  25275. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25276. */
  25277. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25278. }
  25279. }
  25280. declare module BABYLON {
  25281. /**
  25282. * Interface used to define ActionEvent
  25283. */
  25284. export interface IActionEvent {
  25285. /** The mesh or sprite that triggered the action */
  25286. source: any;
  25287. /** The X mouse cursor position at the time of the event */
  25288. pointerX: number;
  25289. /** The Y mouse cursor position at the time of the event */
  25290. pointerY: number;
  25291. /** The mesh that is currently pointed at (can be null) */
  25292. meshUnderPointer: Nullable<AbstractMesh>;
  25293. /** the original (browser) event that triggered the ActionEvent */
  25294. sourceEvent?: any;
  25295. /** additional data for the event */
  25296. additionalData?: any;
  25297. }
  25298. /**
  25299. * ActionEvent is the event being sent when an action is triggered.
  25300. */
  25301. export class ActionEvent implements IActionEvent {
  25302. /** The mesh or sprite that triggered the action */
  25303. source: any;
  25304. /** The X mouse cursor position at the time of the event */
  25305. pointerX: number;
  25306. /** The Y mouse cursor position at the time of the event */
  25307. pointerY: number;
  25308. /** The mesh that is currently pointed at (can be null) */
  25309. meshUnderPointer: Nullable<AbstractMesh>;
  25310. /** the original (browser) event that triggered the ActionEvent */
  25311. sourceEvent?: any;
  25312. /** additional data for the event */
  25313. additionalData?: any;
  25314. /**
  25315. * Creates a new ActionEvent
  25316. * @param source The mesh or sprite that triggered the action
  25317. * @param pointerX The X mouse cursor position at the time of the event
  25318. * @param pointerY The Y mouse cursor position at the time of the event
  25319. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25320. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25321. * @param additionalData additional data for the event
  25322. */
  25323. constructor(
  25324. /** The mesh or sprite that triggered the action */
  25325. source: any,
  25326. /** The X mouse cursor position at the time of the event */
  25327. pointerX: number,
  25328. /** The Y mouse cursor position at the time of the event */
  25329. pointerY: number,
  25330. /** The mesh that is currently pointed at (can be null) */
  25331. meshUnderPointer: Nullable<AbstractMesh>,
  25332. /** the original (browser) event that triggered the ActionEvent */
  25333. sourceEvent?: any,
  25334. /** additional data for the event */
  25335. additionalData?: any);
  25336. /**
  25337. * Helper function to auto-create an ActionEvent from a source mesh.
  25338. * @param source The source mesh that triggered the event
  25339. * @param evt The original (browser) event
  25340. * @param additionalData additional data for the event
  25341. * @returns the new ActionEvent
  25342. */
  25343. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25344. /**
  25345. * Helper function to auto-create an ActionEvent from a source sprite
  25346. * @param source The source sprite that triggered the event
  25347. * @param scene Scene associated with the sprite
  25348. * @param evt The original (browser) event
  25349. * @param additionalData additional data for the event
  25350. * @returns the new ActionEvent
  25351. */
  25352. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25353. /**
  25354. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25355. * @param scene the scene where the event occurred
  25356. * @param evt The original (browser) event
  25357. * @returns the new ActionEvent
  25358. */
  25359. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25360. /**
  25361. * Helper function to auto-create an ActionEvent from a primitive
  25362. * @param prim defines the target primitive
  25363. * @param pointerPos defines the pointer position
  25364. * @param evt The original (browser) event
  25365. * @param additionalData additional data for the event
  25366. * @returns the new ActionEvent
  25367. */
  25368. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25369. }
  25370. }
  25371. declare module BABYLON {
  25372. /**
  25373. * Abstract class used to decouple action Manager from scene and meshes.
  25374. * Do not instantiate.
  25375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25376. */
  25377. export abstract class AbstractActionManager implements IDisposable {
  25378. /** Gets the list of active triggers */
  25379. static Triggers: {
  25380. [key: string]: number;
  25381. };
  25382. /** Gets the cursor to use when hovering items */
  25383. hoverCursor: string;
  25384. /** Gets the list of actions */
  25385. actions: IAction[];
  25386. /**
  25387. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25388. */
  25389. isRecursive: boolean;
  25390. /**
  25391. * Releases all associated resources
  25392. */
  25393. abstract dispose(): void;
  25394. /**
  25395. * Does this action manager has pointer triggers
  25396. */
  25397. abstract readonly hasPointerTriggers: boolean;
  25398. /**
  25399. * Does this action manager has pick triggers
  25400. */
  25401. abstract readonly hasPickTriggers: boolean;
  25402. /**
  25403. * Process a specific trigger
  25404. * @param trigger defines the trigger to process
  25405. * @param evt defines the event details to be processed
  25406. */
  25407. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25408. /**
  25409. * Does this action manager handles actions of any of the given triggers
  25410. * @param triggers defines the triggers to be tested
  25411. * @return a boolean indicating whether one (or more) of the triggers is handled
  25412. */
  25413. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25414. /**
  25415. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25416. * speed.
  25417. * @param triggerA defines the trigger to be tested
  25418. * @param triggerB defines the trigger to be tested
  25419. * @return a boolean indicating whether one (or more) of the triggers is handled
  25420. */
  25421. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25422. /**
  25423. * Does this action manager handles actions of a given trigger
  25424. * @param trigger defines the trigger to be tested
  25425. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25426. * @return whether the trigger is handled
  25427. */
  25428. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25429. /**
  25430. * Serialize this manager to a JSON object
  25431. * @param name defines the property name to store this manager
  25432. * @returns a JSON representation of this manager
  25433. */
  25434. abstract serialize(name: string): any;
  25435. /**
  25436. * Registers an action to this action manager
  25437. * @param action defines the action to be registered
  25438. * @return the action amended (prepared) after registration
  25439. */
  25440. abstract registerAction(action: IAction): Nullable<IAction>;
  25441. /**
  25442. * Unregisters an action to this action manager
  25443. * @param action defines the action to be unregistered
  25444. * @return a boolean indicating whether the action has been unregistered
  25445. */
  25446. abstract unregisterAction(action: IAction): Boolean;
  25447. /**
  25448. * Does exist one action manager with at least one trigger
  25449. **/
  25450. static readonly HasTriggers: boolean;
  25451. /**
  25452. * Does exist one action manager with at least one pick trigger
  25453. **/
  25454. static readonly HasPickTriggers: boolean;
  25455. /**
  25456. * Does exist one action manager that handles actions of a given trigger
  25457. * @param trigger defines the trigger to be tested
  25458. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25459. **/
  25460. static HasSpecificTrigger(trigger: number): boolean;
  25461. }
  25462. }
  25463. declare module BABYLON {
  25464. /**
  25465. * Defines how a node can be built from a string name.
  25466. */
  25467. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25468. /**
  25469. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25470. */
  25471. export class Node implements IBehaviorAware<Node> {
  25472. /** @hidden */
  25473. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25474. private static _NodeConstructors;
  25475. /**
  25476. * Add a new node constructor
  25477. * @param type defines the type name of the node to construct
  25478. * @param constructorFunc defines the constructor function
  25479. */
  25480. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25481. /**
  25482. * Returns a node constructor based on type name
  25483. * @param type defines the type name
  25484. * @param name defines the new node name
  25485. * @param scene defines the hosting scene
  25486. * @param options defines optional options to transmit to constructors
  25487. * @returns the new constructor or null
  25488. */
  25489. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25490. /**
  25491. * Gets or sets the name of the node
  25492. */
  25493. name: string;
  25494. /**
  25495. * Gets or sets the id of the node
  25496. */
  25497. id: string;
  25498. /**
  25499. * Gets or sets the unique id of the node
  25500. */
  25501. uniqueId: number;
  25502. /**
  25503. * Gets or sets a string used to store user defined state for the node
  25504. */
  25505. state: string;
  25506. /**
  25507. * Gets or sets an object used to store user defined information for the node
  25508. */
  25509. metadata: any;
  25510. /**
  25511. * For internal use only. Please do not use.
  25512. */
  25513. reservedDataStore: any;
  25514. /**
  25515. * List of inspectable custom properties (used by the Inspector)
  25516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25517. */
  25518. inspectableCustomProperties: IInspectable[];
  25519. /**
  25520. * Gets or sets a boolean used to define if the node must be serialized
  25521. */
  25522. doNotSerialize: boolean;
  25523. /** @hidden */
  25524. _isDisposed: boolean;
  25525. /**
  25526. * Gets a list of Animations associated with the node
  25527. */
  25528. animations: Animation[];
  25529. protected _ranges: {
  25530. [name: string]: Nullable<AnimationRange>;
  25531. };
  25532. /**
  25533. * Callback raised when the node is ready to be used
  25534. */
  25535. onReady: Nullable<(node: Node) => void>;
  25536. private _isEnabled;
  25537. private _isParentEnabled;
  25538. private _isReady;
  25539. /** @hidden */
  25540. _currentRenderId: number;
  25541. private _parentUpdateId;
  25542. /** @hidden */
  25543. _childUpdateId: number;
  25544. /** @hidden */
  25545. _waitingParentId: Nullable<string>;
  25546. /** @hidden */
  25547. _scene: Scene;
  25548. /** @hidden */
  25549. _cache: any;
  25550. private _parentNode;
  25551. private _children;
  25552. /** @hidden */
  25553. _worldMatrix: Matrix;
  25554. /** @hidden */
  25555. _worldMatrixDeterminant: number;
  25556. /** @hidden */
  25557. _worldMatrixDeterminantIsDirty: boolean;
  25558. /** @hidden */
  25559. private _sceneRootNodesIndex;
  25560. /**
  25561. * Gets a boolean indicating if the node has been disposed
  25562. * @returns true if the node was disposed
  25563. */
  25564. isDisposed(): boolean;
  25565. /**
  25566. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25567. * @see https://doc.babylonjs.com/how_to/parenting
  25568. */
  25569. parent: Nullable<Node>;
  25570. private addToSceneRootNodes;
  25571. private removeFromSceneRootNodes;
  25572. private _animationPropertiesOverride;
  25573. /**
  25574. * Gets or sets the animation properties override
  25575. */
  25576. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25577. /**
  25578. * Gets a string idenfifying the name of the class
  25579. * @returns "Node" string
  25580. */
  25581. getClassName(): string;
  25582. /** @hidden */
  25583. readonly _isNode: boolean;
  25584. /**
  25585. * An event triggered when the mesh is disposed
  25586. */
  25587. onDisposeObservable: Observable<Node>;
  25588. private _onDisposeObserver;
  25589. /**
  25590. * Sets a callback that will be raised when the node will be disposed
  25591. */
  25592. onDispose: () => void;
  25593. /**
  25594. * Creates a new Node
  25595. * @param name the name and id to be given to this node
  25596. * @param scene the scene this node will be added to
  25597. * @param addToRootNodes the node will be added to scene.rootNodes
  25598. */
  25599. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25600. /**
  25601. * Gets the scene of the node
  25602. * @returns a scene
  25603. */
  25604. getScene(): Scene;
  25605. /**
  25606. * Gets the engine of the node
  25607. * @returns a Engine
  25608. */
  25609. getEngine(): Engine;
  25610. private _behaviors;
  25611. /**
  25612. * Attach a behavior to the node
  25613. * @see http://doc.babylonjs.com/features/behaviour
  25614. * @param behavior defines the behavior to attach
  25615. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25616. * @returns the current Node
  25617. */
  25618. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25619. /**
  25620. * Remove an attached behavior
  25621. * @see http://doc.babylonjs.com/features/behaviour
  25622. * @param behavior defines the behavior to attach
  25623. * @returns the current Node
  25624. */
  25625. removeBehavior(behavior: Behavior<Node>): Node;
  25626. /**
  25627. * Gets the list of attached behaviors
  25628. * @see http://doc.babylonjs.com/features/behaviour
  25629. */
  25630. readonly behaviors: Behavior<Node>[];
  25631. /**
  25632. * Gets an attached behavior by name
  25633. * @param name defines the name of the behavior to look for
  25634. * @see http://doc.babylonjs.com/features/behaviour
  25635. * @returns null if behavior was not found else the requested behavior
  25636. */
  25637. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25638. /**
  25639. * Returns the latest update of the World matrix
  25640. * @returns a Matrix
  25641. */
  25642. getWorldMatrix(): Matrix;
  25643. /** @hidden */
  25644. _getWorldMatrixDeterminant(): number;
  25645. /**
  25646. * Returns directly the latest state of the mesh World matrix.
  25647. * A Matrix is returned.
  25648. */
  25649. readonly worldMatrixFromCache: Matrix;
  25650. /** @hidden */
  25651. _initCache(): void;
  25652. /** @hidden */
  25653. updateCache(force?: boolean): void;
  25654. /** @hidden */
  25655. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25656. /** @hidden */
  25657. _updateCache(ignoreParentClass?: boolean): void;
  25658. /** @hidden */
  25659. _isSynchronized(): boolean;
  25660. /** @hidden */
  25661. _markSyncedWithParent(): void;
  25662. /** @hidden */
  25663. isSynchronizedWithParent(): boolean;
  25664. /** @hidden */
  25665. isSynchronized(): boolean;
  25666. /**
  25667. * Is this node ready to be used/rendered
  25668. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25669. * @return true if the node is ready
  25670. */
  25671. isReady(completeCheck?: boolean): boolean;
  25672. /**
  25673. * Is this node enabled?
  25674. * 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
  25675. * @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
  25676. * @return whether this node (and its parent) is enabled
  25677. */
  25678. isEnabled(checkAncestors?: boolean): boolean;
  25679. /** @hidden */
  25680. protected _syncParentEnabledState(): void;
  25681. /**
  25682. * Set the enabled state of this node
  25683. * @param value defines the new enabled state
  25684. */
  25685. setEnabled(value: boolean): void;
  25686. /**
  25687. * Is this node a descendant of the given node?
  25688. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25689. * @param ancestor defines the parent node to inspect
  25690. * @returns a boolean indicating if this node is a descendant of the given node
  25691. */
  25692. isDescendantOf(ancestor: Node): boolean;
  25693. /** @hidden */
  25694. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25695. /**
  25696. * Will return all nodes that have this node as ascendant
  25697. * @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
  25698. * @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
  25699. * @return all children nodes of all types
  25700. */
  25701. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25702. /**
  25703. * Get all child-meshes of this node
  25704. * @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)
  25705. * @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
  25706. * @returns an array of AbstractMesh
  25707. */
  25708. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25709. /**
  25710. * Get all direct children of this node
  25711. * @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
  25712. * @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)
  25713. * @returns an array of Node
  25714. */
  25715. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25716. /** @hidden */
  25717. _setReady(state: boolean): void;
  25718. /**
  25719. * Get an animation by name
  25720. * @param name defines the name of the animation to look for
  25721. * @returns null if not found else the requested animation
  25722. */
  25723. getAnimationByName(name: string): Nullable<Animation>;
  25724. /**
  25725. * Creates an animation range for this node
  25726. * @param name defines the name of the range
  25727. * @param from defines the starting key
  25728. * @param to defines the end key
  25729. */
  25730. createAnimationRange(name: string, from: number, to: number): void;
  25731. /**
  25732. * Delete a specific animation range
  25733. * @param name defines the name of the range to delete
  25734. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25735. */
  25736. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25737. /**
  25738. * Get an animation range by name
  25739. * @param name defines the name of the animation range to look for
  25740. * @returns null if not found else the requested animation range
  25741. */
  25742. getAnimationRange(name: string): Nullable<AnimationRange>;
  25743. /**
  25744. * Gets the list of all animation ranges defined on this node
  25745. * @returns an array
  25746. */
  25747. getAnimationRanges(): Nullable<AnimationRange>[];
  25748. /**
  25749. * Will start the animation sequence
  25750. * @param name defines the range frames for animation sequence
  25751. * @param loop defines if the animation should loop (false by default)
  25752. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25753. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25754. * @returns the object created for this animation. If range does not exist, it will return null
  25755. */
  25756. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25757. /**
  25758. * Serialize animation ranges into a JSON compatible object
  25759. * @returns serialization object
  25760. */
  25761. serializeAnimationRanges(): any;
  25762. /**
  25763. * Computes the world matrix of the node
  25764. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25765. * @returns the world matrix
  25766. */
  25767. computeWorldMatrix(force?: boolean): Matrix;
  25768. /**
  25769. * Releases resources associated with this node.
  25770. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25771. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25772. */
  25773. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25774. /**
  25775. * Parse animation range data from a serialization object and store them into a given node
  25776. * @param node defines where to store the animation ranges
  25777. * @param parsedNode defines the serialization object to read data from
  25778. * @param scene defines the hosting scene
  25779. */
  25780. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25781. /**
  25782. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25783. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25784. * @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
  25785. * @returns the new bounding vectors
  25786. */
  25787. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25788. min: Vector3;
  25789. max: Vector3;
  25790. };
  25791. }
  25792. }
  25793. declare module BABYLON {
  25794. /**
  25795. * @hidden
  25796. */
  25797. export class _IAnimationState {
  25798. key: number;
  25799. repeatCount: number;
  25800. workValue?: any;
  25801. loopMode?: number;
  25802. offsetValue?: any;
  25803. highLimitValue?: any;
  25804. }
  25805. /**
  25806. * Class used to store any kind of animation
  25807. */
  25808. export class Animation {
  25809. /**Name of the animation */
  25810. name: string;
  25811. /**Property to animate */
  25812. targetProperty: string;
  25813. /**The frames per second of the animation */
  25814. framePerSecond: number;
  25815. /**The data type of the animation */
  25816. dataType: number;
  25817. /**The loop mode of the animation */
  25818. loopMode?: number | undefined;
  25819. /**Specifies if blending should be enabled */
  25820. enableBlending?: boolean | undefined;
  25821. /**
  25822. * Use matrix interpolation instead of using direct key value when animating matrices
  25823. */
  25824. static AllowMatricesInterpolation: boolean;
  25825. /**
  25826. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25827. */
  25828. static AllowMatrixDecomposeForInterpolation: boolean;
  25829. /**
  25830. * Stores the key frames of the animation
  25831. */
  25832. private _keys;
  25833. /**
  25834. * Stores the easing function of the animation
  25835. */
  25836. private _easingFunction;
  25837. /**
  25838. * @hidden Internal use only
  25839. */
  25840. _runtimeAnimations: RuntimeAnimation[];
  25841. /**
  25842. * The set of event that will be linked to this animation
  25843. */
  25844. private _events;
  25845. /**
  25846. * Stores an array of target property paths
  25847. */
  25848. targetPropertyPath: string[];
  25849. /**
  25850. * Stores the blending speed of the animation
  25851. */
  25852. blendingSpeed: number;
  25853. /**
  25854. * Stores the animation ranges for the animation
  25855. */
  25856. private _ranges;
  25857. /**
  25858. * @hidden Internal use
  25859. */
  25860. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25861. /**
  25862. * Sets up an animation
  25863. * @param property The property to animate
  25864. * @param animationType The animation type to apply
  25865. * @param framePerSecond The frames per second of the animation
  25866. * @param easingFunction The easing function used in the animation
  25867. * @returns The created animation
  25868. */
  25869. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25870. /**
  25871. * Create and start an animation on a node
  25872. * @param name defines the name of the global animation that will be run on all nodes
  25873. * @param node defines the root node where the animation will take place
  25874. * @param targetProperty defines property to animate
  25875. * @param framePerSecond defines the number of frame per second yo use
  25876. * @param totalFrame defines the number of frames in total
  25877. * @param from defines the initial value
  25878. * @param to defines the final value
  25879. * @param loopMode defines which loop mode you want to use (off by default)
  25880. * @param easingFunction defines the easing function to use (linear by default)
  25881. * @param onAnimationEnd defines the callback to call when animation end
  25882. * @returns the animatable created for this animation
  25883. */
  25884. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25885. /**
  25886. * Create and start an animation on a node and its descendants
  25887. * @param name defines the name of the global animation that will be run on all nodes
  25888. * @param node defines the root node where the animation will take place
  25889. * @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
  25890. * @param targetProperty defines property to animate
  25891. * @param framePerSecond defines the number of frame per second to use
  25892. * @param totalFrame defines the number of frames in total
  25893. * @param from defines the initial value
  25894. * @param to defines the final value
  25895. * @param loopMode defines which loop mode you want to use (off by default)
  25896. * @param easingFunction defines the easing function to use (linear by default)
  25897. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25898. * @returns the list of animatables created for all nodes
  25899. * @example https://www.babylonjs-playground.com/#MH0VLI
  25900. */
  25901. 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[]>;
  25902. /**
  25903. * Creates a new animation, merges it with the existing animations and starts it
  25904. * @param name Name of the animation
  25905. * @param node Node which contains the scene that begins the animations
  25906. * @param targetProperty Specifies which property to animate
  25907. * @param framePerSecond The frames per second of the animation
  25908. * @param totalFrame The total number of frames
  25909. * @param from The frame at the beginning of the animation
  25910. * @param to The frame at the end of the animation
  25911. * @param loopMode Specifies the loop mode of the animation
  25912. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25913. * @param onAnimationEnd Callback to run once the animation is complete
  25914. * @returns Nullable animation
  25915. */
  25916. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25917. /**
  25918. * Transition property of an host to the target Value
  25919. * @param property The property to transition
  25920. * @param targetValue The target Value of the property
  25921. * @param host The object where the property to animate belongs
  25922. * @param scene Scene used to run the animation
  25923. * @param frameRate Framerate (in frame/s) to use
  25924. * @param transition The transition type we want to use
  25925. * @param duration The duration of the animation, in milliseconds
  25926. * @param onAnimationEnd Callback trigger at the end of the animation
  25927. * @returns Nullable animation
  25928. */
  25929. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25930. /**
  25931. * Return the array of runtime animations currently using this animation
  25932. */
  25933. readonly runtimeAnimations: RuntimeAnimation[];
  25934. /**
  25935. * Specifies if any of the runtime animations are currently running
  25936. */
  25937. readonly hasRunningRuntimeAnimations: boolean;
  25938. /**
  25939. * Initializes the animation
  25940. * @param name Name of the animation
  25941. * @param targetProperty Property to animate
  25942. * @param framePerSecond The frames per second of the animation
  25943. * @param dataType The data type of the animation
  25944. * @param loopMode The loop mode of the animation
  25945. * @param enableBlending Specifies if blending should be enabled
  25946. */
  25947. constructor(
  25948. /**Name of the animation */
  25949. name: string,
  25950. /**Property to animate */
  25951. targetProperty: string,
  25952. /**The frames per second of the animation */
  25953. framePerSecond: number,
  25954. /**The data type of the animation */
  25955. dataType: number,
  25956. /**The loop mode of the animation */
  25957. loopMode?: number | undefined,
  25958. /**Specifies if blending should be enabled */
  25959. enableBlending?: boolean | undefined);
  25960. /**
  25961. * Converts the animation to a string
  25962. * @param fullDetails support for multiple levels of logging within scene loading
  25963. * @returns String form of the animation
  25964. */
  25965. toString(fullDetails?: boolean): string;
  25966. /**
  25967. * Add an event to this animation
  25968. * @param event Event to add
  25969. */
  25970. addEvent(event: AnimationEvent): void;
  25971. /**
  25972. * Remove all events found at the given frame
  25973. * @param frame The frame to remove events from
  25974. */
  25975. removeEvents(frame: number): void;
  25976. /**
  25977. * Retrieves all the events from the animation
  25978. * @returns Events from the animation
  25979. */
  25980. getEvents(): AnimationEvent[];
  25981. /**
  25982. * Creates an animation range
  25983. * @param name Name of the animation range
  25984. * @param from Starting frame of the animation range
  25985. * @param to Ending frame of the animation
  25986. */
  25987. createRange(name: string, from: number, to: number): void;
  25988. /**
  25989. * Deletes an animation range by name
  25990. * @param name Name of the animation range to delete
  25991. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25992. */
  25993. deleteRange(name: string, deleteFrames?: boolean): void;
  25994. /**
  25995. * Gets the animation range by name, or null if not defined
  25996. * @param name Name of the animation range
  25997. * @returns Nullable animation range
  25998. */
  25999. getRange(name: string): Nullable<AnimationRange>;
  26000. /**
  26001. * Gets the key frames from the animation
  26002. * @returns The key frames of the animation
  26003. */
  26004. getKeys(): Array<IAnimationKey>;
  26005. /**
  26006. * Gets the highest frame rate of the animation
  26007. * @returns Highest frame rate of the animation
  26008. */
  26009. getHighestFrame(): number;
  26010. /**
  26011. * Gets the easing function of the animation
  26012. * @returns Easing function of the animation
  26013. */
  26014. getEasingFunction(): IEasingFunction;
  26015. /**
  26016. * Sets the easing function of the animation
  26017. * @param easingFunction A custom mathematical formula for animation
  26018. */
  26019. setEasingFunction(easingFunction: EasingFunction): void;
  26020. /**
  26021. * Interpolates a scalar linearly
  26022. * @param startValue Start value of the animation curve
  26023. * @param endValue End value of the animation curve
  26024. * @param gradient Scalar amount to interpolate
  26025. * @returns Interpolated scalar value
  26026. */
  26027. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26028. /**
  26029. * Interpolates a scalar cubically
  26030. * @param startValue Start value of the animation curve
  26031. * @param outTangent End tangent of the animation
  26032. * @param endValue End value of the animation curve
  26033. * @param inTangent Start tangent of the animation curve
  26034. * @param gradient Scalar amount to interpolate
  26035. * @returns Interpolated scalar value
  26036. */
  26037. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26038. /**
  26039. * Interpolates a quaternion using a spherical linear interpolation
  26040. * @param startValue Start value of the animation curve
  26041. * @param endValue End value of the animation curve
  26042. * @param gradient Scalar amount to interpolate
  26043. * @returns Interpolated quaternion value
  26044. */
  26045. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26046. /**
  26047. * Interpolates a quaternion cubically
  26048. * @param startValue Start value of the animation curve
  26049. * @param outTangent End tangent of the animation curve
  26050. * @param endValue End value of the animation curve
  26051. * @param inTangent Start tangent of the animation curve
  26052. * @param gradient Scalar amount to interpolate
  26053. * @returns Interpolated quaternion value
  26054. */
  26055. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26056. /**
  26057. * Interpolates a Vector3 linearl
  26058. * @param startValue Start value of the animation curve
  26059. * @param endValue End value of the animation curve
  26060. * @param gradient Scalar amount to interpolate
  26061. * @returns Interpolated scalar value
  26062. */
  26063. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26064. /**
  26065. * Interpolates a Vector3 cubically
  26066. * @param startValue Start value of the animation curve
  26067. * @param outTangent End tangent of the animation
  26068. * @param endValue End value of the animation curve
  26069. * @param inTangent Start tangent of the animation curve
  26070. * @param gradient Scalar amount to interpolate
  26071. * @returns InterpolatedVector3 value
  26072. */
  26073. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26074. /**
  26075. * Interpolates a Vector2 linearly
  26076. * @param startValue Start value of the animation curve
  26077. * @param endValue End value of the animation curve
  26078. * @param gradient Scalar amount to interpolate
  26079. * @returns Interpolated Vector2 value
  26080. */
  26081. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26082. /**
  26083. * Interpolates a Vector2 cubically
  26084. * @param startValue Start value of the animation curve
  26085. * @param outTangent End tangent of the animation
  26086. * @param endValue End value of the animation curve
  26087. * @param inTangent Start tangent of the animation curve
  26088. * @param gradient Scalar amount to interpolate
  26089. * @returns Interpolated Vector2 value
  26090. */
  26091. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26092. /**
  26093. * Interpolates a size linearly
  26094. * @param startValue Start value of the animation curve
  26095. * @param endValue End value of the animation curve
  26096. * @param gradient Scalar amount to interpolate
  26097. * @returns Interpolated Size value
  26098. */
  26099. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26100. /**
  26101. * Interpolates a Color3 linearly
  26102. * @param startValue Start value of the animation curve
  26103. * @param endValue End value of the animation curve
  26104. * @param gradient Scalar amount to interpolate
  26105. * @returns Interpolated Color3 value
  26106. */
  26107. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26108. /**
  26109. * @hidden Internal use only
  26110. */
  26111. _getKeyValue(value: any): any;
  26112. /**
  26113. * @hidden Internal use only
  26114. */
  26115. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26116. /**
  26117. * Defines the function to use to interpolate matrices
  26118. * @param startValue defines the start matrix
  26119. * @param endValue defines the end matrix
  26120. * @param gradient defines the gradient between both matrices
  26121. * @param result defines an optional target matrix where to store the interpolation
  26122. * @returns the interpolated matrix
  26123. */
  26124. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26125. /**
  26126. * Makes a copy of the animation
  26127. * @returns Cloned animation
  26128. */
  26129. clone(): Animation;
  26130. /**
  26131. * Sets the key frames of the animation
  26132. * @param values The animation key frames to set
  26133. */
  26134. setKeys(values: Array<IAnimationKey>): void;
  26135. /**
  26136. * Serializes the animation to an object
  26137. * @returns Serialized object
  26138. */
  26139. serialize(): any;
  26140. /**
  26141. * Float animation type
  26142. */
  26143. private static _ANIMATIONTYPE_FLOAT;
  26144. /**
  26145. * Vector3 animation type
  26146. */
  26147. private static _ANIMATIONTYPE_VECTOR3;
  26148. /**
  26149. * Quaternion animation type
  26150. */
  26151. private static _ANIMATIONTYPE_QUATERNION;
  26152. /**
  26153. * Matrix animation type
  26154. */
  26155. private static _ANIMATIONTYPE_MATRIX;
  26156. /**
  26157. * Color3 animation type
  26158. */
  26159. private static _ANIMATIONTYPE_COLOR3;
  26160. /**
  26161. * Vector2 animation type
  26162. */
  26163. private static _ANIMATIONTYPE_VECTOR2;
  26164. /**
  26165. * Size animation type
  26166. */
  26167. private static _ANIMATIONTYPE_SIZE;
  26168. /**
  26169. * Relative Loop Mode
  26170. */
  26171. private static _ANIMATIONLOOPMODE_RELATIVE;
  26172. /**
  26173. * Cycle Loop Mode
  26174. */
  26175. private static _ANIMATIONLOOPMODE_CYCLE;
  26176. /**
  26177. * Constant Loop Mode
  26178. */
  26179. private static _ANIMATIONLOOPMODE_CONSTANT;
  26180. /**
  26181. * Get the float animation type
  26182. */
  26183. static readonly ANIMATIONTYPE_FLOAT: number;
  26184. /**
  26185. * Get the Vector3 animation type
  26186. */
  26187. static readonly ANIMATIONTYPE_VECTOR3: number;
  26188. /**
  26189. * Get the Vector2 animation type
  26190. */
  26191. static readonly ANIMATIONTYPE_VECTOR2: number;
  26192. /**
  26193. * Get the Size animation type
  26194. */
  26195. static readonly ANIMATIONTYPE_SIZE: number;
  26196. /**
  26197. * Get the Quaternion animation type
  26198. */
  26199. static readonly ANIMATIONTYPE_QUATERNION: number;
  26200. /**
  26201. * Get the Matrix animation type
  26202. */
  26203. static readonly ANIMATIONTYPE_MATRIX: number;
  26204. /**
  26205. * Get the Color3 animation type
  26206. */
  26207. static readonly ANIMATIONTYPE_COLOR3: number;
  26208. /**
  26209. * Get the Relative Loop Mode
  26210. */
  26211. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26212. /**
  26213. * Get the Cycle Loop Mode
  26214. */
  26215. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26216. /**
  26217. * Get the Constant Loop Mode
  26218. */
  26219. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26220. /** @hidden */
  26221. static _UniversalLerp(left: any, right: any, amount: number): any;
  26222. /**
  26223. * Parses an animation object and creates an animation
  26224. * @param parsedAnimation Parsed animation object
  26225. * @returns Animation object
  26226. */
  26227. static Parse(parsedAnimation: any): Animation;
  26228. /**
  26229. * Appends the serialized animations from the source animations
  26230. * @param source Source containing the animations
  26231. * @param destination Target to store the animations
  26232. */
  26233. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26234. }
  26235. }
  26236. declare module BABYLON {
  26237. /**
  26238. * Base class of all the textures in babylon.
  26239. * It groups all the common properties the materials, post process, lights... might need
  26240. * in order to make a correct use of the texture.
  26241. */
  26242. export class BaseTexture implements IAnimatable {
  26243. /**
  26244. * Default anisotropic filtering level for the application.
  26245. * It is set to 4 as a good tradeoff between perf and quality.
  26246. */
  26247. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26248. /**
  26249. * Gets or sets the unique id of the texture
  26250. */
  26251. uniqueId: number;
  26252. /**
  26253. * Define the name of the texture.
  26254. */
  26255. name: string;
  26256. /**
  26257. * Gets or sets an object used to store user defined information.
  26258. */
  26259. metadata: any;
  26260. /**
  26261. * For internal use only. Please do not use.
  26262. */
  26263. reservedDataStore: any;
  26264. private _hasAlpha;
  26265. /**
  26266. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26267. */
  26268. hasAlpha: boolean;
  26269. /**
  26270. * Defines if the alpha value should be determined via the rgb values.
  26271. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26272. */
  26273. getAlphaFromRGB: boolean;
  26274. /**
  26275. * Intensity or strength of the texture.
  26276. * It is commonly used by materials to fine tune the intensity of the texture
  26277. */
  26278. level: number;
  26279. /**
  26280. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26281. * This is part of the texture as textures usually maps to one uv set.
  26282. */
  26283. coordinatesIndex: number;
  26284. private _coordinatesMode;
  26285. /**
  26286. * How a texture is mapped.
  26287. *
  26288. * | Value | Type | Description |
  26289. * | ----- | ----------------------------------- | ----------- |
  26290. * | 0 | EXPLICIT_MODE | |
  26291. * | 1 | SPHERICAL_MODE | |
  26292. * | 2 | PLANAR_MODE | |
  26293. * | 3 | CUBIC_MODE | |
  26294. * | 4 | PROJECTION_MODE | |
  26295. * | 5 | SKYBOX_MODE | |
  26296. * | 6 | INVCUBIC_MODE | |
  26297. * | 7 | EQUIRECTANGULAR_MODE | |
  26298. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26299. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26300. */
  26301. coordinatesMode: number;
  26302. /**
  26303. * | Value | Type | Description |
  26304. * | ----- | ------------------ | ----------- |
  26305. * | 0 | CLAMP_ADDRESSMODE | |
  26306. * | 1 | WRAP_ADDRESSMODE | |
  26307. * | 2 | MIRROR_ADDRESSMODE | |
  26308. */
  26309. wrapU: number;
  26310. /**
  26311. * | Value | Type | Description |
  26312. * | ----- | ------------------ | ----------- |
  26313. * | 0 | CLAMP_ADDRESSMODE | |
  26314. * | 1 | WRAP_ADDRESSMODE | |
  26315. * | 2 | MIRROR_ADDRESSMODE | |
  26316. */
  26317. wrapV: number;
  26318. /**
  26319. * | Value | Type | Description |
  26320. * | ----- | ------------------ | ----------- |
  26321. * | 0 | CLAMP_ADDRESSMODE | |
  26322. * | 1 | WRAP_ADDRESSMODE | |
  26323. * | 2 | MIRROR_ADDRESSMODE | |
  26324. */
  26325. wrapR: number;
  26326. /**
  26327. * With compliant hardware and browser (supporting anisotropic filtering)
  26328. * this defines the level of anisotropic filtering in the texture.
  26329. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26330. */
  26331. anisotropicFilteringLevel: number;
  26332. /**
  26333. * Define if the texture is a cube texture or if false a 2d texture.
  26334. */
  26335. isCube: boolean;
  26336. /**
  26337. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26338. */
  26339. is3D: boolean;
  26340. /**
  26341. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26342. * HDR texture are usually stored in linear space.
  26343. * This only impacts the PBR and Background materials
  26344. */
  26345. gammaSpace: boolean;
  26346. /**
  26347. * Gets whether or not the texture contains RGBD data.
  26348. */
  26349. readonly isRGBD: boolean;
  26350. /**
  26351. * Is Z inverted in the texture (useful in a cube texture).
  26352. */
  26353. invertZ: boolean;
  26354. /**
  26355. * Are mip maps generated for this texture or not.
  26356. */
  26357. readonly noMipmap: boolean;
  26358. /**
  26359. * @hidden
  26360. */
  26361. lodLevelInAlpha: boolean;
  26362. /**
  26363. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26364. */
  26365. lodGenerationOffset: number;
  26366. /**
  26367. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26368. */
  26369. lodGenerationScale: number;
  26370. /**
  26371. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26372. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26373. * average roughness values.
  26374. */
  26375. linearSpecularLOD: boolean;
  26376. /**
  26377. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26378. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26379. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26380. */
  26381. irradianceTexture: Nullable<BaseTexture>;
  26382. /**
  26383. * Define if the texture is a render target.
  26384. */
  26385. isRenderTarget: boolean;
  26386. /**
  26387. * Define the unique id of the texture in the scene.
  26388. */
  26389. readonly uid: string;
  26390. /**
  26391. * Return a string representation of the texture.
  26392. * @returns the texture as a string
  26393. */
  26394. toString(): string;
  26395. /**
  26396. * Get the class name of the texture.
  26397. * @returns "BaseTexture"
  26398. */
  26399. getClassName(): string;
  26400. /**
  26401. * Define the list of animation attached to the texture.
  26402. */
  26403. animations: Animation[];
  26404. /**
  26405. * An event triggered when the texture is disposed.
  26406. */
  26407. onDisposeObservable: Observable<BaseTexture>;
  26408. private _onDisposeObserver;
  26409. /**
  26410. * Callback triggered when the texture has been disposed.
  26411. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26412. */
  26413. onDispose: () => void;
  26414. /**
  26415. * Define the current state of the loading sequence when in delayed load mode.
  26416. */
  26417. delayLoadState: number;
  26418. private _scene;
  26419. /** @hidden */
  26420. _texture: Nullable<InternalTexture>;
  26421. private _uid;
  26422. /**
  26423. * Define if the texture is preventinga material to render or not.
  26424. * If not and the texture is not ready, the engine will use a default black texture instead.
  26425. */
  26426. readonly isBlocking: boolean;
  26427. /**
  26428. * Instantiates a new BaseTexture.
  26429. * Base class of all the textures in babylon.
  26430. * It groups all the common properties the materials, post process, lights... might need
  26431. * in order to make a correct use of the texture.
  26432. * @param scene Define the scene the texture blongs to
  26433. */
  26434. constructor(scene: Nullable<Scene>);
  26435. /**
  26436. * Get the scene the texture belongs to.
  26437. * @returns the scene or null if undefined
  26438. */
  26439. getScene(): Nullable<Scene>;
  26440. /**
  26441. * Get the texture transform matrix used to offset tile the texture for istance.
  26442. * @returns the transformation matrix
  26443. */
  26444. getTextureMatrix(): Matrix;
  26445. /**
  26446. * Get the texture reflection matrix used to rotate/transform the reflection.
  26447. * @returns the reflection matrix
  26448. */
  26449. getReflectionTextureMatrix(): Matrix;
  26450. /**
  26451. * Get the underlying lower level texture from Babylon.
  26452. * @returns the insternal texture
  26453. */
  26454. getInternalTexture(): Nullable<InternalTexture>;
  26455. /**
  26456. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26457. * @returns true if ready or not blocking
  26458. */
  26459. isReadyOrNotBlocking(): boolean;
  26460. /**
  26461. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26462. * @returns true if fully ready
  26463. */
  26464. isReady(): boolean;
  26465. private _cachedSize;
  26466. /**
  26467. * Get the size of the texture.
  26468. * @returns the texture size.
  26469. */
  26470. getSize(): ISize;
  26471. /**
  26472. * Get the base size of the texture.
  26473. * It can be different from the size if the texture has been resized for POT for instance
  26474. * @returns the base size
  26475. */
  26476. getBaseSize(): ISize;
  26477. /**
  26478. * Update the sampling mode of the texture.
  26479. * Default is Trilinear mode.
  26480. *
  26481. * | Value | Type | Description |
  26482. * | ----- | ------------------ | ----------- |
  26483. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26484. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26485. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26486. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26487. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26488. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26489. * | 7 | NEAREST_LINEAR | |
  26490. * | 8 | NEAREST_NEAREST | |
  26491. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26492. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26493. * | 11 | LINEAR_LINEAR | |
  26494. * | 12 | LINEAR_NEAREST | |
  26495. *
  26496. * > _mag_: magnification filter (close to the viewer)
  26497. * > _min_: minification filter (far from the viewer)
  26498. * > _mip_: filter used between mip map levels
  26499. *@param samplingMode Define the new sampling mode of the texture
  26500. */
  26501. updateSamplingMode(samplingMode: number): void;
  26502. /**
  26503. * Scales the texture if is `canRescale()`
  26504. * @param ratio the resize factor we want to use to rescale
  26505. */
  26506. scale(ratio: number): void;
  26507. /**
  26508. * Get if the texture can rescale.
  26509. */
  26510. readonly canRescale: boolean;
  26511. /** @hidden */
  26512. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26513. /** @hidden */
  26514. _rebuild(): void;
  26515. /**
  26516. * Triggers the load sequence in delayed load mode.
  26517. */
  26518. delayLoad(): void;
  26519. /**
  26520. * Clones the texture.
  26521. * @returns the cloned texture
  26522. */
  26523. clone(): Nullable<BaseTexture>;
  26524. /**
  26525. * Get the texture underlying type (INT, FLOAT...)
  26526. */
  26527. readonly textureType: number;
  26528. /**
  26529. * Get the texture underlying format (RGB, RGBA...)
  26530. */
  26531. readonly textureFormat: number;
  26532. /**
  26533. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26534. * This will returns an RGBA array buffer containing either in values (0-255) or
  26535. * float values (0-1) depending of the underlying buffer type.
  26536. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26537. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26538. * @param buffer defines a user defined buffer to fill with data (can be null)
  26539. * @returns The Array buffer containing the pixels data.
  26540. */
  26541. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26542. /**
  26543. * Release and destroy the underlying lower level texture aka internalTexture.
  26544. */
  26545. releaseInternalTexture(): void;
  26546. /**
  26547. * Get the polynomial representation of the texture data.
  26548. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26549. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26550. */
  26551. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26552. /** @hidden */
  26553. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26554. /** @hidden */
  26555. readonly _lodTextureMid: Nullable<BaseTexture>;
  26556. /** @hidden */
  26557. readonly _lodTextureLow: Nullable<BaseTexture>;
  26558. /**
  26559. * Dispose the texture and release its associated resources.
  26560. */
  26561. dispose(): void;
  26562. /**
  26563. * Serialize the texture into a JSON representation that can be parsed later on.
  26564. * @returns the JSON representation of the texture
  26565. */
  26566. serialize(): any;
  26567. /**
  26568. * Helper function to be called back once a list of texture contains only ready textures.
  26569. * @param textures Define the list of textures to wait for
  26570. * @param callback Define the callback triggered once the entire list will be ready
  26571. */
  26572. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26573. }
  26574. }
  26575. declare module BABYLON {
  26576. /**
  26577. * Uniform buffer objects.
  26578. *
  26579. * Handles blocks of uniform on the GPU.
  26580. *
  26581. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26582. *
  26583. * For more information, please refer to :
  26584. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26585. */
  26586. export class UniformBuffer {
  26587. private _engine;
  26588. private _buffer;
  26589. private _data;
  26590. private _bufferData;
  26591. private _dynamic?;
  26592. private _uniformLocations;
  26593. private _uniformSizes;
  26594. private _uniformLocationPointer;
  26595. private _needSync;
  26596. private _noUBO;
  26597. private _currentEffect;
  26598. private static _MAX_UNIFORM_SIZE;
  26599. private static _tempBuffer;
  26600. /**
  26601. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26602. * This is dynamic to allow compat with webgl 1 and 2.
  26603. * You will need to pass the name of the uniform as well as the value.
  26604. */
  26605. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26606. /**
  26607. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26608. * This is dynamic to allow compat with webgl 1 and 2.
  26609. * You will need to pass the name of the uniform as well as the value.
  26610. */
  26611. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26612. /**
  26613. * Lambda to Update a single float in a uniform buffer.
  26614. * This is dynamic to allow compat with webgl 1 and 2.
  26615. * You will need to pass the name of the uniform as well as the value.
  26616. */
  26617. updateFloat: (name: string, x: number) => void;
  26618. /**
  26619. * Lambda to Update a vec2 of float in a uniform buffer.
  26620. * This is dynamic to allow compat with webgl 1 and 2.
  26621. * You will need to pass the name of the uniform as well as the value.
  26622. */
  26623. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26624. /**
  26625. * Lambda to Update a vec3 of float in a uniform buffer.
  26626. * This is dynamic to allow compat with webgl 1 and 2.
  26627. * You will need to pass the name of the uniform as well as the value.
  26628. */
  26629. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26630. /**
  26631. * Lambda to Update a vec4 of float in a uniform buffer.
  26632. * This is dynamic to allow compat with webgl 1 and 2.
  26633. * You will need to pass the name of the uniform as well as the value.
  26634. */
  26635. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26636. /**
  26637. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26638. * This is dynamic to allow compat with webgl 1 and 2.
  26639. * You will need to pass the name of the uniform as well as the value.
  26640. */
  26641. updateMatrix: (name: string, mat: Matrix) => void;
  26642. /**
  26643. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26644. * This is dynamic to allow compat with webgl 1 and 2.
  26645. * You will need to pass the name of the uniform as well as the value.
  26646. */
  26647. updateVector3: (name: string, vector: Vector3) => void;
  26648. /**
  26649. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26650. * This is dynamic to allow compat with webgl 1 and 2.
  26651. * You will need to pass the name of the uniform as well as the value.
  26652. */
  26653. updateVector4: (name: string, vector: Vector4) => void;
  26654. /**
  26655. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26656. * This is dynamic to allow compat with webgl 1 and 2.
  26657. * You will need to pass the name of the uniform as well as the value.
  26658. */
  26659. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26660. /**
  26661. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26662. * This is dynamic to allow compat with webgl 1 and 2.
  26663. * You will need to pass the name of the uniform as well as the value.
  26664. */
  26665. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26666. /**
  26667. * Instantiates a new Uniform buffer objects.
  26668. *
  26669. * Handles blocks of uniform on the GPU.
  26670. *
  26671. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26672. *
  26673. * For more information, please refer to :
  26674. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26675. * @param engine Define the engine the buffer is associated with
  26676. * @param data Define the data contained in the buffer
  26677. * @param dynamic Define if the buffer is updatable
  26678. */
  26679. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26680. /**
  26681. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26682. * or just falling back on setUniformXXX calls.
  26683. */
  26684. readonly useUbo: boolean;
  26685. /**
  26686. * Indicates if the WebGL underlying uniform buffer is in sync
  26687. * with the javascript cache data.
  26688. */
  26689. readonly isSync: boolean;
  26690. /**
  26691. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26692. * Also, a dynamic UniformBuffer will disable cache verification and always
  26693. * update the underlying WebGL uniform buffer to the GPU.
  26694. * @returns if Dynamic, otherwise false
  26695. */
  26696. isDynamic(): boolean;
  26697. /**
  26698. * The data cache on JS side.
  26699. * @returns the underlying data as a float array
  26700. */
  26701. getData(): Float32Array;
  26702. /**
  26703. * The underlying WebGL Uniform buffer.
  26704. * @returns the webgl buffer
  26705. */
  26706. getBuffer(): Nullable<DataBuffer>;
  26707. /**
  26708. * std140 layout specifies how to align data within an UBO structure.
  26709. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26710. * for specs.
  26711. */
  26712. private _fillAlignment;
  26713. /**
  26714. * Adds an uniform in the buffer.
  26715. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26716. * for the layout to be correct !
  26717. * @param name Name of the uniform, as used in the uniform block in the shader.
  26718. * @param size Data size, or data directly.
  26719. */
  26720. addUniform(name: string, size: number | number[]): void;
  26721. /**
  26722. * Adds a Matrix 4x4 to the uniform buffer.
  26723. * @param name Name of the uniform, as used in the uniform block in the shader.
  26724. * @param mat A 4x4 matrix.
  26725. */
  26726. addMatrix(name: string, mat: Matrix): void;
  26727. /**
  26728. * Adds a vec2 to the uniform buffer.
  26729. * @param name Name of the uniform, as used in the uniform block in the shader.
  26730. * @param x Define the x component value of the vec2
  26731. * @param y Define the y component value of the vec2
  26732. */
  26733. addFloat2(name: string, x: number, y: number): void;
  26734. /**
  26735. * Adds a vec3 to the uniform buffer.
  26736. * @param name Name of the uniform, as used in the uniform block in the shader.
  26737. * @param x Define the x component value of the vec3
  26738. * @param y Define the y component value of the vec3
  26739. * @param z Define the z component value of the vec3
  26740. */
  26741. addFloat3(name: string, x: number, y: number, z: number): void;
  26742. /**
  26743. * Adds a vec3 to the uniform buffer.
  26744. * @param name Name of the uniform, as used in the uniform block in the shader.
  26745. * @param color Define the vec3 from a Color
  26746. */
  26747. addColor3(name: string, color: Color3): void;
  26748. /**
  26749. * Adds a vec4 to the uniform buffer.
  26750. * @param name Name of the uniform, as used in the uniform block in the shader.
  26751. * @param color Define the rgb components from a Color
  26752. * @param alpha Define the a component of the vec4
  26753. */
  26754. addColor4(name: string, color: Color3, alpha: number): void;
  26755. /**
  26756. * Adds a vec3 to the uniform buffer.
  26757. * @param name Name of the uniform, as used in the uniform block in the shader.
  26758. * @param vector Define the vec3 components from a Vector
  26759. */
  26760. addVector3(name: string, vector: Vector3): void;
  26761. /**
  26762. * Adds a Matrix 3x3 to the uniform buffer.
  26763. * @param name Name of the uniform, as used in the uniform block in the shader.
  26764. */
  26765. addMatrix3x3(name: string): void;
  26766. /**
  26767. * Adds a Matrix 2x2 to the uniform buffer.
  26768. * @param name Name of the uniform, as used in the uniform block in the shader.
  26769. */
  26770. addMatrix2x2(name: string): void;
  26771. /**
  26772. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26773. */
  26774. create(): void;
  26775. /** @hidden */
  26776. _rebuild(): void;
  26777. /**
  26778. * Updates the WebGL Uniform Buffer on the GPU.
  26779. * If the `dynamic` flag is set to true, no cache comparison is done.
  26780. * Otherwise, the buffer will be updated only if the cache differs.
  26781. */
  26782. update(): void;
  26783. /**
  26784. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26785. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26786. * @param data Define the flattened data
  26787. * @param size Define the size of the data.
  26788. */
  26789. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26790. private _updateMatrix3x3ForUniform;
  26791. private _updateMatrix3x3ForEffect;
  26792. private _updateMatrix2x2ForEffect;
  26793. private _updateMatrix2x2ForUniform;
  26794. private _updateFloatForEffect;
  26795. private _updateFloatForUniform;
  26796. private _updateFloat2ForEffect;
  26797. private _updateFloat2ForUniform;
  26798. private _updateFloat3ForEffect;
  26799. private _updateFloat3ForUniform;
  26800. private _updateFloat4ForEffect;
  26801. private _updateFloat4ForUniform;
  26802. private _updateMatrixForEffect;
  26803. private _updateMatrixForUniform;
  26804. private _updateVector3ForEffect;
  26805. private _updateVector3ForUniform;
  26806. private _updateVector4ForEffect;
  26807. private _updateVector4ForUniform;
  26808. private _updateColor3ForEffect;
  26809. private _updateColor3ForUniform;
  26810. private _updateColor4ForEffect;
  26811. private _updateColor4ForUniform;
  26812. /**
  26813. * Sets a sampler uniform on the effect.
  26814. * @param name Define the name of the sampler.
  26815. * @param texture Define the texture to set in the sampler
  26816. */
  26817. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26818. /**
  26819. * Directly updates the value of the uniform in the cache AND on the GPU.
  26820. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26821. * @param data Define the flattened data
  26822. */
  26823. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26824. /**
  26825. * Binds this uniform buffer to an effect.
  26826. * @param effect Define the effect to bind the buffer to
  26827. * @param name Name of the uniform block in the shader.
  26828. */
  26829. bindToEffect(effect: Effect, name: string): void;
  26830. /**
  26831. * Disposes the uniform buffer.
  26832. */
  26833. dispose(): void;
  26834. }
  26835. }
  26836. declare module BABYLON {
  26837. /**
  26838. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26840. */
  26841. export class Analyser {
  26842. /**
  26843. * Gets or sets the smoothing
  26844. * @ignorenaming
  26845. */
  26846. SMOOTHING: number;
  26847. /**
  26848. * Gets or sets the FFT table size
  26849. * @ignorenaming
  26850. */
  26851. FFT_SIZE: number;
  26852. /**
  26853. * Gets or sets the bar graph amplitude
  26854. * @ignorenaming
  26855. */
  26856. BARGRAPHAMPLITUDE: number;
  26857. /**
  26858. * Gets or sets the position of the debug canvas
  26859. * @ignorenaming
  26860. */
  26861. DEBUGCANVASPOS: {
  26862. x: number;
  26863. y: number;
  26864. };
  26865. /**
  26866. * Gets or sets the debug canvas size
  26867. * @ignorenaming
  26868. */
  26869. DEBUGCANVASSIZE: {
  26870. width: number;
  26871. height: number;
  26872. };
  26873. private _byteFreqs;
  26874. private _byteTime;
  26875. private _floatFreqs;
  26876. private _webAudioAnalyser;
  26877. private _debugCanvas;
  26878. private _debugCanvasContext;
  26879. private _scene;
  26880. private _registerFunc;
  26881. private _audioEngine;
  26882. /**
  26883. * Creates a new analyser
  26884. * @param scene defines hosting scene
  26885. */
  26886. constructor(scene: Scene);
  26887. /**
  26888. * Get the number of data values you will have to play with for the visualization
  26889. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26890. * @returns a number
  26891. */
  26892. getFrequencyBinCount(): number;
  26893. /**
  26894. * Gets the current frequency data as a byte array
  26895. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26896. * @returns a Uint8Array
  26897. */
  26898. getByteFrequencyData(): Uint8Array;
  26899. /**
  26900. * Gets the current waveform as a byte array
  26901. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26902. * @returns a Uint8Array
  26903. */
  26904. getByteTimeDomainData(): Uint8Array;
  26905. /**
  26906. * Gets the current frequency data as a float array
  26907. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26908. * @returns a Float32Array
  26909. */
  26910. getFloatFrequencyData(): Float32Array;
  26911. /**
  26912. * Renders the debug canvas
  26913. */
  26914. drawDebugCanvas(): void;
  26915. /**
  26916. * Stops rendering the debug canvas and removes it
  26917. */
  26918. stopDebugCanvas(): void;
  26919. /**
  26920. * Connects two audio nodes
  26921. * @param inputAudioNode defines first node to connect
  26922. * @param outputAudioNode defines second node to connect
  26923. */
  26924. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26925. /**
  26926. * Releases all associated resources
  26927. */
  26928. dispose(): void;
  26929. }
  26930. }
  26931. declare module BABYLON {
  26932. /**
  26933. * This represents an audio engine and it is responsible
  26934. * to play, synchronize and analyse sounds throughout the application.
  26935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26936. */
  26937. export interface IAudioEngine extends IDisposable {
  26938. /**
  26939. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26940. */
  26941. readonly canUseWebAudio: boolean;
  26942. /**
  26943. * Gets the current AudioContext if available.
  26944. */
  26945. readonly audioContext: Nullable<AudioContext>;
  26946. /**
  26947. * The master gain node defines the global audio volume of your audio engine.
  26948. */
  26949. readonly masterGain: GainNode;
  26950. /**
  26951. * Gets whether or not mp3 are supported by your browser.
  26952. */
  26953. readonly isMP3supported: boolean;
  26954. /**
  26955. * Gets whether or not ogg are supported by your browser.
  26956. */
  26957. readonly isOGGsupported: boolean;
  26958. /**
  26959. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26960. * @ignoreNaming
  26961. */
  26962. WarnedWebAudioUnsupported: boolean;
  26963. /**
  26964. * Defines if the audio engine relies on a custom unlocked button.
  26965. * In this case, the embedded button will not be displayed.
  26966. */
  26967. useCustomUnlockedButton: boolean;
  26968. /**
  26969. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26970. */
  26971. readonly unlocked: boolean;
  26972. /**
  26973. * Event raised when audio has been unlocked on the browser.
  26974. */
  26975. onAudioUnlockedObservable: Observable<AudioEngine>;
  26976. /**
  26977. * Event raised when audio has been locked on the browser.
  26978. */
  26979. onAudioLockedObservable: Observable<AudioEngine>;
  26980. /**
  26981. * Flags the audio engine in Locked state.
  26982. * This happens due to new browser policies preventing audio to autoplay.
  26983. */
  26984. lock(): void;
  26985. /**
  26986. * Unlocks the audio engine once a user action has been done on the dom.
  26987. * This is helpful to resume play once browser policies have been satisfied.
  26988. */
  26989. unlock(): void;
  26990. }
  26991. /**
  26992. * This represents the default audio engine used in babylon.
  26993. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26995. */
  26996. export class AudioEngine implements IAudioEngine {
  26997. private _audioContext;
  26998. private _audioContextInitialized;
  26999. private _muteButton;
  27000. private _hostElement;
  27001. /**
  27002. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27003. */
  27004. canUseWebAudio: boolean;
  27005. /**
  27006. * The master gain node defines the global audio volume of your audio engine.
  27007. */
  27008. masterGain: GainNode;
  27009. /**
  27010. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27011. * @ignoreNaming
  27012. */
  27013. WarnedWebAudioUnsupported: boolean;
  27014. /**
  27015. * Gets whether or not mp3 are supported by your browser.
  27016. */
  27017. isMP3supported: boolean;
  27018. /**
  27019. * Gets whether or not ogg are supported by your browser.
  27020. */
  27021. isOGGsupported: boolean;
  27022. /**
  27023. * Gets whether audio has been unlocked on the device.
  27024. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27025. * a user interaction has happened.
  27026. */
  27027. unlocked: boolean;
  27028. /**
  27029. * Defines if the audio engine relies on a custom unlocked button.
  27030. * In this case, the embedded button will not be displayed.
  27031. */
  27032. useCustomUnlockedButton: boolean;
  27033. /**
  27034. * Event raised when audio has been unlocked on the browser.
  27035. */
  27036. onAudioUnlockedObservable: Observable<AudioEngine>;
  27037. /**
  27038. * Event raised when audio has been locked on the browser.
  27039. */
  27040. onAudioLockedObservable: Observable<AudioEngine>;
  27041. /**
  27042. * Gets the current AudioContext if available.
  27043. */
  27044. readonly audioContext: Nullable<AudioContext>;
  27045. private _connectedAnalyser;
  27046. /**
  27047. * Instantiates a new audio engine.
  27048. *
  27049. * There should be only one per page as some browsers restrict the number
  27050. * of audio contexts you can create.
  27051. * @param hostElement defines the host element where to display the mute icon if necessary
  27052. */
  27053. constructor(hostElement?: Nullable<HTMLElement>);
  27054. /**
  27055. * Flags the audio engine in Locked state.
  27056. * This happens due to new browser policies preventing audio to autoplay.
  27057. */
  27058. lock(): void;
  27059. /**
  27060. * Unlocks the audio engine once a user action has been done on the dom.
  27061. * This is helpful to resume play once browser policies have been satisfied.
  27062. */
  27063. unlock(): void;
  27064. private _resumeAudioContext;
  27065. private _initializeAudioContext;
  27066. private _tryToRun;
  27067. private _triggerRunningState;
  27068. private _triggerSuspendedState;
  27069. private _displayMuteButton;
  27070. private _moveButtonToTopLeft;
  27071. private _onResize;
  27072. private _hideMuteButton;
  27073. /**
  27074. * Destroy and release the resources associated with the audio ccontext.
  27075. */
  27076. dispose(): void;
  27077. /**
  27078. * Gets the global volume sets on the master gain.
  27079. * @returns the global volume if set or -1 otherwise
  27080. */
  27081. getGlobalVolume(): number;
  27082. /**
  27083. * Sets the global volume of your experience (sets on the master gain).
  27084. * @param newVolume Defines the new global volume of the application
  27085. */
  27086. setGlobalVolume(newVolume: number): void;
  27087. /**
  27088. * Connect the audio engine to an audio analyser allowing some amazing
  27089. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27091. * @param analyser The analyser to connect to the engine
  27092. */
  27093. connectToAnalyser(analyser: Analyser): void;
  27094. }
  27095. }
  27096. declare module BABYLON {
  27097. /**
  27098. * Interface used to present a loading screen while loading a scene
  27099. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27100. */
  27101. export interface ILoadingScreen {
  27102. /**
  27103. * Function called to display the loading screen
  27104. */
  27105. displayLoadingUI: () => void;
  27106. /**
  27107. * Function called to hide the loading screen
  27108. */
  27109. hideLoadingUI: () => void;
  27110. /**
  27111. * Gets or sets the color to use for the background
  27112. */
  27113. loadingUIBackgroundColor: string;
  27114. /**
  27115. * Gets or sets the text to display while loading
  27116. */
  27117. loadingUIText: string;
  27118. }
  27119. /**
  27120. * Class used for the default loading screen
  27121. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27122. */
  27123. export class DefaultLoadingScreen implements ILoadingScreen {
  27124. private _renderingCanvas;
  27125. private _loadingText;
  27126. private _loadingDivBackgroundColor;
  27127. private _loadingDiv;
  27128. private _loadingTextDiv;
  27129. /** Gets or sets the logo url to use for the default loading screen */
  27130. static DefaultLogoUrl: string;
  27131. /** Gets or sets the spinner url to use for the default loading screen */
  27132. static DefaultSpinnerUrl: string;
  27133. /**
  27134. * Creates a new default loading screen
  27135. * @param _renderingCanvas defines the canvas used to render the scene
  27136. * @param _loadingText defines the default text to display
  27137. * @param _loadingDivBackgroundColor defines the default background color
  27138. */
  27139. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27140. /**
  27141. * Function called to display the loading screen
  27142. */
  27143. displayLoadingUI(): void;
  27144. /**
  27145. * Function called to hide the loading screen
  27146. */
  27147. hideLoadingUI(): void;
  27148. /**
  27149. * Gets or sets the text to display while loading
  27150. */
  27151. loadingUIText: string;
  27152. /**
  27153. * Gets or sets the color to use for the background
  27154. */
  27155. loadingUIBackgroundColor: string;
  27156. private _resizeLoadingUI;
  27157. }
  27158. }
  27159. declare module BABYLON {
  27160. /** @hidden */
  27161. export class WebGLPipelineContext implements IPipelineContext {
  27162. engine: Engine;
  27163. program: Nullable<WebGLProgram>;
  27164. context?: WebGLRenderingContext;
  27165. vertexShader?: WebGLShader;
  27166. fragmentShader?: WebGLShader;
  27167. isParallelCompiled: boolean;
  27168. onCompiled?: () => void;
  27169. transformFeedback?: WebGLTransformFeedback | null;
  27170. readonly isAsync: boolean;
  27171. readonly isReady: boolean;
  27172. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27173. }
  27174. }
  27175. declare module BABYLON {
  27176. /** @hidden */
  27177. export class WebGLDataBuffer extends DataBuffer {
  27178. private _buffer;
  27179. constructor(resource: WebGLBuffer);
  27180. readonly underlyingResource: any;
  27181. }
  27182. }
  27183. declare module BABYLON {
  27184. /** @hidden */
  27185. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27186. attributeProcessor(attribute: string): string;
  27187. varyingProcessor(varying: string, isFragment: boolean): string;
  27188. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /**
  27193. * Settings for finer control over video usage
  27194. */
  27195. export interface VideoTextureSettings {
  27196. /**
  27197. * Applies `autoplay` to video, if specified
  27198. */
  27199. autoPlay?: boolean;
  27200. /**
  27201. * Applies `loop` to video, if specified
  27202. */
  27203. loop?: boolean;
  27204. /**
  27205. * Automatically updates internal texture from video at every frame in the render loop
  27206. */
  27207. autoUpdateTexture: boolean;
  27208. /**
  27209. * Image src displayed during the video loading or until the user interacts with the video.
  27210. */
  27211. poster?: string;
  27212. }
  27213. /**
  27214. * If you want to display a video in your scene, this is the special texture for that.
  27215. * This special texture works similar to other textures, with the exception of a few parameters.
  27216. * @see https://doc.babylonjs.com/how_to/video_texture
  27217. */
  27218. export class VideoTexture extends Texture {
  27219. /**
  27220. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27221. */
  27222. readonly autoUpdateTexture: boolean;
  27223. /**
  27224. * The video instance used by the texture internally
  27225. */
  27226. readonly video: HTMLVideoElement;
  27227. private _onUserActionRequestedObservable;
  27228. /**
  27229. * Event triggerd when a dom action is required by the user to play the video.
  27230. * This happens due to recent changes in browser policies preventing video to auto start.
  27231. */
  27232. readonly onUserActionRequestedObservable: Observable<Texture>;
  27233. private _generateMipMaps;
  27234. private _engine;
  27235. private _stillImageCaptured;
  27236. private _displayingPosterTexture;
  27237. private _settings;
  27238. private _createInternalTextureOnEvent;
  27239. /**
  27240. * Creates a video texture.
  27241. * If you want to display a video in your scene, this is the special texture for that.
  27242. * This special texture works similar to other textures, with the exception of a few parameters.
  27243. * @see https://doc.babylonjs.com/how_to/video_texture
  27244. * @param name optional name, will detect from video source, if not defined
  27245. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27246. * @param scene is obviously the current scene.
  27247. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27248. * @param invertY is false by default but can be used to invert video on Y axis
  27249. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27250. * @param settings allows finer control over video usage
  27251. */
  27252. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27253. private _getName;
  27254. private _getVideo;
  27255. private _createInternalTexture;
  27256. private reset;
  27257. /**
  27258. * @hidden Internal method to initiate `update`.
  27259. */
  27260. _rebuild(): void;
  27261. /**
  27262. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27263. */
  27264. update(): void;
  27265. /**
  27266. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27267. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27268. */
  27269. updateTexture(isVisible: boolean): void;
  27270. protected _updateInternalTexture: () => void;
  27271. /**
  27272. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27273. * @param url New url.
  27274. */
  27275. updateURL(url: string): void;
  27276. /**
  27277. * Dispose the texture and release its associated resources.
  27278. */
  27279. dispose(): void;
  27280. /**
  27281. * Creates a video texture straight from a stream.
  27282. * @param scene Define the scene the texture should be created in
  27283. * @param stream Define the stream the texture should be created from
  27284. * @returns The created video texture as a promise
  27285. */
  27286. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27287. /**
  27288. * Creates a video texture straight from your WebCam video feed.
  27289. * @param scene Define the scene the texture should be created in
  27290. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27291. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27292. * @returns The created video texture as a promise
  27293. */
  27294. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27295. minWidth: number;
  27296. maxWidth: number;
  27297. minHeight: number;
  27298. maxHeight: number;
  27299. deviceId: string;
  27300. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27301. /**
  27302. * Creates a video texture straight from your WebCam video feed.
  27303. * @param scene Define the scene the texture should be created in
  27304. * @param onReady Define a callback to triggered once the texture will be ready
  27305. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27306. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27307. */
  27308. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27309. minWidth: number;
  27310. maxWidth: number;
  27311. minHeight: number;
  27312. maxHeight: number;
  27313. deviceId: string;
  27314. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27315. }
  27316. }
  27317. declare module BABYLON {
  27318. /**
  27319. * Interface for attribute information associated with buffer instanciation
  27320. */
  27321. export class InstancingAttributeInfo {
  27322. /**
  27323. * Index/offset of the attribute in the vertex shader
  27324. */
  27325. index: number;
  27326. /**
  27327. * size of the attribute, 1, 2, 3 or 4
  27328. */
  27329. attributeSize: number;
  27330. /**
  27331. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27332. * default is FLOAT
  27333. */
  27334. attribyteType: number;
  27335. /**
  27336. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27337. */
  27338. normalized: boolean;
  27339. /**
  27340. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27341. */
  27342. offset: number;
  27343. /**
  27344. * Name of the GLSL attribute, for debugging purpose only
  27345. */
  27346. attributeName: string;
  27347. }
  27348. /**
  27349. * Define options used to create a depth texture
  27350. */
  27351. export class DepthTextureCreationOptions {
  27352. /** Specifies whether or not a stencil should be allocated in the texture */
  27353. generateStencil?: boolean;
  27354. /** Specifies whether or not bilinear filtering is enable on the texture */
  27355. bilinearFiltering?: boolean;
  27356. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27357. comparisonFunction?: number;
  27358. /** Specifies if the created texture is a cube texture */
  27359. isCube?: boolean;
  27360. }
  27361. /**
  27362. * Class used to describe the capabilities of the engine relatively to the current browser
  27363. */
  27364. export class EngineCapabilities {
  27365. /** Maximum textures units per fragment shader */
  27366. maxTexturesImageUnits: number;
  27367. /** Maximum texture units per vertex shader */
  27368. maxVertexTextureImageUnits: number;
  27369. /** Maximum textures units in the entire pipeline */
  27370. maxCombinedTexturesImageUnits: number;
  27371. /** Maximum texture size */
  27372. maxTextureSize: number;
  27373. /** Maximum cube texture size */
  27374. maxCubemapTextureSize: number;
  27375. /** Maximum render texture size */
  27376. maxRenderTextureSize: number;
  27377. /** Maximum number of vertex attributes */
  27378. maxVertexAttribs: number;
  27379. /** Maximum number of varyings */
  27380. maxVaryingVectors: number;
  27381. /** Maximum number of uniforms per vertex shader */
  27382. maxVertexUniformVectors: number;
  27383. /** Maximum number of uniforms per fragment shader */
  27384. maxFragmentUniformVectors: number;
  27385. /** Defines if standard derivates (dx/dy) are supported */
  27386. standardDerivatives: boolean;
  27387. /** Defines if s3tc texture compression is supported */
  27388. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27389. /** Defines if pvrtc texture compression is supported */
  27390. pvrtc: any;
  27391. /** Defines if etc1 texture compression is supported */
  27392. etc1: any;
  27393. /** Defines if etc2 texture compression is supported */
  27394. etc2: any;
  27395. /** Defines if astc texture compression is supported */
  27396. astc: any;
  27397. /** Defines if float textures are supported */
  27398. textureFloat: boolean;
  27399. /** Defines if vertex array objects are supported */
  27400. vertexArrayObject: boolean;
  27401. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27402. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27403. /** Gets the maximum level of anisotropy supported */
  27404. maxAnisotropy: number;
  27405. /** Defines if instancing is supported */
  27406. instancedArrays: boolean;
  27407. /** Defines if 32 bits indices are supported */
  27408. uintIndices: boolean;
  27409. /** Defines if high precision shaders are supported */
  27410. highPrecisionShaderSupported: boolean;
  27411. /** Defines if depth reading in the fragment shader is supported */
  27412. fragmentDepthSupported: boolean;
  27413. /** Defines if float texture linear filtering is supported*/
  27414. textureFloatLinearFiltering: boolean;
  27415. /** Defines if rendering to float textures is supported */
  27416. textureFloatRender: boolean;
  27417. /** Defines if half float textures are supported*/
  27418. textureHalfFloat: boolean;
  27419. /** Defines if half float texture linear filtering is supported*/
  27420. textureHalfFloatLinearFiltering: boolean;
  27421. /** Defines if rendering to half float textures is supported */
  27422. textureHalfFloatRender: boolean;
  27423. /** Defines if textureLOD shader command is supported */
  27424. textureLOD: boolean;
  27425. /** Defines if draw buffers extension is supported */
  27426. drawBuffersExtension: boolean;
  27427. /** Defines if depth textures are supported */
  27428. depthTextureExtension: boolean;
  27429. /** Defines if float color buffer are supported */
  27430. colorBufferFloat: boolean;
  27431. /** Gets disjoint timer query extension (null if not supported) */
  27432. timerQuery: EXT_disjoint_timer_query;
  27433. /** Defines if timestamp can be used with timer query */
  27434. canUseTimestampForTimerQuery: boolean;
  27435. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27436. multiview: any;
  27437. /** Function used to let the system compiles shaders in background */
  27438. parallelShaderCompile: {
  27439. COMPLETION_STATUS_KHR: number;
  27440. };
  27441. }
  27442. /** Interface defining initialization parameters for Engine class */
  27443. export interface EngineOptions extends WebGLContextAttributes {
  27444. /**
  27445. * Defines if the engine should no exceed a specified device ratio
  27446. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27447. */
  27448. limitDeviceRatio?: number;
  27449. /**
  27450. * Defines if webvr should be enabled automatically
  27451. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27452. */
  27453. autoEnableWebVR?: boolean;
  27454. /**
  27455. * Defines if webgl2 should be turned off even if supported
  27456. * @see http://doc.babylonjs.com/features/webgl2
  27457. */
  27458. disableWebGL2Support?: boolean;
  27459. /**
  27460. * Defines if webaudio should be initialized as well
  27461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27462. */
  27463. audioEngine?: boolean;
  27464. /**
  27465. * Defines if animations should run using a deterministic lock step
  27466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27467. */
  27468. deterministicLockstep?: boolean;
  27469. /** Defines the maximum steps to use with deterministic lock step mode */
  27470. lockstepMaxSteps?: number;
  27471. /**
  27472. * Defines that engine should ignore context lost events
  27473. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27474. */
  27475. doNotHandleContextLost?: boolean;
  27476. /**
  27477. * Defines that engine should ignore modifying touch action attribute and style
  27478. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27479. */
  27480. doNotHandleTouchAction?: boolean;
  27481. /**
  27482. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27483. */
  27484. useHighPrecisionFloats?: boolean;
  27485. }
  27486. /**
  27487. * Defines the interface used by display changed events
  27488. */
  27489. export interface IDisplayChangedEventArgs {
  27490. /** Gets the vrDisplay object (if any) */
  27491. vrDisplay: Nullable<any>;
  27492. /** Gets a boolean indicating if webVR is supported */
  27493. vrSupported: boolean;
  27494. }
  27495. /**
  27496. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27497. */
  27498. export class Engine {
  27499. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27500. static ExceptionList: ({
  27501. key: string;
  27502. capture: string;
  27503. captureConstraint: number;
  27504. targets: string[];
  27505. } | {
  27506. key: string;
  27507. capture: null;
  27508. captureConstraint: null;
  27509. targets: string[];
  27510. })[];
  27511. /** Gets the list of created engines */
  27512. static readonly Instances: Engine[];
  27513. /**
  27514. * Gets the latest created engine
  27515. */
  27516. static readonly LastCreatedEngine: Nullable<Engine>;
  27517. /**
  27518. * Gets the latest created scene
  27519. */
  27520. static readonly LastCreatedScene: Nullable<Scene>;
  27521. /**
  27522. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27523. * @param flag defines which part of the materials must be marked as dirty
  27524. * @param predicate defines a predicate used to filter which materials should be affected
  27525. */
  27526. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27527. /** @hidden */
  27528. static _TextureLoaders: IInternalTextureLoader[];
  27529. /** Defines that alpha blending is disabled */
  27530. static readonly ALPHA_DISABLE: number;
  27531. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27532. static readonly ALPHA_ADD: number;
  27533. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27534. static readonly ALPHA_COMBINE: number;
  27535. /** Defines that alpha blending to DEST - SRC * DEST */
  27536. static readonly ALPHA_SUBTRACT: number;
  27537. /** Defines that alpha blending to SRC * DEST */
  27538. static readonly ALPHA_MULTIPLY: number;
  27539. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27540. static readonly ALPHA_MAXIMIZED: number;
  27541. /** Defines that alpha blending to SRC + DEST */
  27542. static readonly ALPHA_ONEONE: number;
  27543. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27544. static readonly ALPHA_PREMULTIPLIED: number;
  27545. /**
  27546. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27547. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27548. */
  27549. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27550. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27551. static readonly ALPHA_INTERPOLATE: number;
  27552. /**
  27553. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27554. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27555. */
  27556. static readonly ALPHA_SCREENMODE: number;
  27557. /** Defines that the ressource is not delayed*/
  27558. static readonly DELAYLOADSTATE_NONE: number;
  27559. /** Defines that the ressource was successfully delay loaded */
  27560. static readonly DELAYLOADSTATE_LOADED: number;
  27561. /** Defines that the ressource is currently delay loading */
  27562. static readonly DELAYLOADSTATE_LOADING: number;
  27563. /** Defines that the ressource is delayed and has not started loading */
  27564. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27565. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27566. static readonly NEVER: number;
  27567. /** 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 */
  27568. static readonly ALWAYS: number;
  27569. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27570. static readonly LESS: number;
  27571. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27572. static readonly EQUAL: number;
  27573. /** 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 */
  27574. static readonly LEQUAL: number;
  27575. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27576. static readonly GREATER: number;
  27577. /** 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 */
  27578. static readonly GEQUAL: number;
  27579. /** 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 */
  27580. static readonly NOTEQUAL: number;
  27581. /** Passed to stencilOperation to specify that stencil value must be kept */
  27582. static readonly KEEP: number;
  27583. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27584. static readonly REPLACE: number;
  27585. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27586. static readonly INCR: number;
  27587. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27588. static readonly DECR: number;
  27589. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27590. static readonly INVERT: number;
  27591. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27592. static readonly INCR_WRAP: number;
  27593. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27594. static readonly DECR_WRAP: number;
  27595. /** Texture is not repeating outside of 0..1 UVs */
  27596. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27597. /** Texture is repeating outside of 0..1 UVs */
  27598. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27599. /** Texture is repeating and mirrored */
  27600. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27601. /** ALPHA */
  27602. static readonly TEXTUREFORMAT_ALPHA: number;
  27603. /** LUMINANCE */
  27604. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27605. /** LUMINANCE_ALPHA */
  27606. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27607. /** RGB */
  27608. static readonly TEXTUREFORMAT_RGB: number;
  27609. /** RGBA */
  27610. static readonly TEXTUREFORMAT_RGBA: number;
  27611. /** RED */
  27612. static readonly TEXTUREFORMAT_RED: number;
  27613. /** RED (2nd reference) */
  27614. static readonly TEXTUREFORMAT_R: number;
  27615. /** RG */
  27616. static readonly TEXTUREFORMAT_RG: number;
  27617. /** RED_INTEGER */
  27618. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27619. /** RED_INTEGER (2nd reference) */
  27620. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27621. /** RG_INTEGER */
  27622. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27623. /** RGB_INTEGER */
  27624. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27625. /** RGBA_INTEGER */
  27626. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27627. /** UNSIGNED_BYTE */
  27628. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27629. /** UNSIGNED_BYTE (2nd reference) */
  27630. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27631. /** FLOAT */
  27632. static readonly TEXTURETYPE_FLOAT: number;
  27633. /** HALF_FLOAT */
  27634. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27635. /** BYTE */
  27636. static readonly TEXTURETYPE_BYTE: number;
  27637. /** SHORT */
  27638. static readonly TEXTURETYPE_SHORT: number;
  27639. /** UNSIGNED_SHORT */
  27640. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27641. /** INT */
  27642. static readonly TEXTURETYPE_INT: number;
  27643. /** UNSIGNED_INT */
  27644. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27645. /** UNSIGNED_SHORT_4_4_4_4 */
  27646. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27647. /** UNSIGNED_SHORT_5_5_5_1 */
  27648. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27649. /** UNSIGNED_SHORT_5_6_5 */
  27650. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27651. /** UNSIGNED_INT_2_10_10_10_REV */
  27652. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27653. /** UNSIGNED_INT_24_8 */
  27654. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27655. /** UNSIGNED_INT_10F_11F_11F_REV */
  27656. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27657. /** UNSIGNED_INT_5_9_9_9_REV */
  27658. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27659. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27660. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27661. /** nearest is mag = nearest and min = nearest and mip = linear */
  27662. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27663. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27664. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27665. /** Trilinear is mag = linear and min = linear and mip = linear */
  27666. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27667. /** nearest is mag = nearest and min = nearest and mip = linear */
  27668. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27669. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27670. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27671. /** Trilinear is mag = linear and min = linear and mip = linear */
  27672. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27673. /** mag = nearest and min = nearest and mip = nearest */
  27674. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27675. /** mag = nearest and min = linear and mip = nearest */
  27676. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27677. /** mag = nearest and min = linear and mip = linear */
  27678. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27679. /** mag = nearest and min = linear and mip = none */
  27680. static readonly TEXTURE_NEAREST_LINEAR: number;
  27681. /** mag = nearest and min = nearest and mip = none */
  27682. static readonly TEXTURE_NEAREST_NEAREST: number;
  27683. /** mag = linear and min = nearest and mip = nearest */
  27684. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27685. /** mag = linear and min = nearest and mip = linear */
  27686. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27687. /** mag = linear and min = linear and mip = none */
  27688. static readonly TEXTURE_LINEAR_LINEAR: number;
  27689. /** mag = linear and min = nearest and mip = none */
  27690. static readonly TEXTURE_LINEAR_NEAREST: number;
  27691. /** Explicit coordinates mode */
  27692. static readonly TEXTURE_EXPLICIT_MODE: number;
  27693. /** Spherical coordinates mode */
  27694. static readonly TEXTURE_SPHERICAL_MODE: number;
  27695. /** Planar coordinates mode */
  27696. static readonly TEXTURE_PLANAR_MODE: number;
  27697. /** Cubic coordinates mode */
  27698. static readonly TEXTURE_CUBIC_MODE: number;
  27699. /** Projection coordinates mode */
  27700. static readonly TEXTURE_PROJECTION_MODE: number;
  27701. /** Skybox coordinates mode */
  27702. static readonly TEXTURE_SKYBOX_MODE: number;
  27703. /** Inverse Cubic coordinates mode */
  27704. static readonly TEXTURE_INVCUBIC_MODE: number;
  27705. /** Equirectangular coordinates mode */
  27706. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27707. /** Equirectangular Fixed coordinates mode */
  27708. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27709. /** Equirectangular Fixed Mirrored coordinates mode */
  27710. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27711. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27712. static readonly SCALEMODE_FLOOR: number;
  27713. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27714. static readonly SCALEMODE_NEAREST: number;
  27715. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27716. static readonly SCALEMODE_CEILING: number;
  27717. /**
  27718. * Returns the current npm package of the sdk
  27719. */
  27720. static readonly NpmPackage: string;
  27721. /**
  27722. * Returns the current version of the framework
  27723. */
  27724. static readonly Version: string;
  27725. /**
  27726. * Returns a string describing the current engine
  27727. */
  27728. readonly description: string;
  27729. /**
  27730. * Gets or sets the epsilon value used by collision engine
  27731. */
  27732. static CollisionsEpsilon: number;
  27733. /**
  27734. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27735. */
  27736. static ShadersRepository: string;
  27737. /**
  27738. * Method called to create the default loading screen.
  27739. * This can be overriden in your own app.
  27740. * @param canvas The rendering canvas element
  27741. * @returns The loading screen
  27742. */
  27743. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27744. /**
  27745. * Method called to create the default rescale post process on each engine.
  27746. */
  27747. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27748. /** @hidden */
  27749. _shaderProcessor: IShaderProcessor;
  27750. /**
  27751. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27752. */
  27753. forcePOTTextures: boolean;
  27754. /**
  27755. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27756. */
  27757. isFullscreen: boolean;
  27758. /**
  27759. * Gets a boolean indicating if the pointer is currently locked
  27760. */
  27761. isPointerLock: boolean;
  27762. /**
  27763. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27764. */
  27765. cullBackFaces: boolean;
  27766. /**
  27767. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27768. */
  27769. renderEvenInBackground: boolean;
  27770. /**
  27771. * Gets or sets a boolean indicating that cache can be kept between frames
  27772. */
  27773. preventCacheWipeBetweenFrames: boolean;
  27774. /**
  27775. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27776. **/
  27777. enableOfflineSupport: boolean;
  27778. /**
  27779. * 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)
  27780. **/
  27781. disableManifestCheck: boolean;
  27782. /**
  27783. * Gets the list of created scenes
  27784. */
  27785. scenes: Scene[];
  27786. /**
  27787. * Event raised when a new scene is created
  27788. */
  27789. onNewSceneAddedObservable: Observable<Scene>;
  27790. /**
  27791. * Gets the list of created postprocesses
  27792. */
  27793. postProcesses: PostProcess[];
  27794. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27795. validateShaderPrograms: boolean;
  27796. /**
  27797. * Observable event triggered each time the rendering canvas is resized
  27798. */
  27799. onResizeObservable: Observable<Engine>;
  27800. /**
  27801. * Observable event triggered each time the canvas loses focus
  27802. */
  27803. onCanvasBlurObservable: Observable<Engine>;
  27804. /**
  27805. * Observable event triggered each time the canvas gains focus
  27806. */
  27807. onCanvasFocusObservable: Observable<Engine>;
  27808. /**
  27809. * Observable event triggered each time the canvas receives pointerout event
  27810. */
  27811. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27812. /**
  27813. * Observable event triggered before each texture is initialized
  27814. */
  27815. onBeforeTextureInitObservable: Observable<Texture>;
  27816. /**
  27817. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27818. */
  27819. disableUniformBuffers: boolean;
  27820. /** @hidden */
  27821. _uniformBuffers: UniformBuffer[];
  27822. /**
  27823. * Gets a boolean indicating that the engine supports uniform buffers
  27824. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27825. */
  27826. readonly supportsUniformBuffers: boolean;
  27827. /**
  27828. * Observable raised when the engine begins a new frame
  27829. */
  27830. onBeginFrameObservable: Observable<Engine>;
  27831. /**
  27832. * If set, will be used to request the next animation frame for the render loop
  27833. */
  27834. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27835. /**
  27836. * Observable raised when the engine ends the current frame
  27837. */
  27838. onEndFrameObservable: Observable<Engine>;
  27839. /**
  27840. * Observable raised when the engine is about to compile a shader
  27841. */
  27842. onBeforeShaderCompilationObservable: Observable<Engine>;
  27843. /**
  27844. * Observable raised when the engine has jsut compiled a shader
  27845. */
  27846. onAfterShaderCompilationObservable: Observable<Engine>;
  27847. /** @hidden */
  27848. _gl: WebGLRenderingContext;
  27849. private _renderingCanvas;
  27850. private _windowIsBackground;
  27851. private _webGLVersion;
  27852. protected _highPrecisionShadersAllowed: boolean;
  27853. /** @hidden */
  27854. readonly _shouldUseHighPrecisionShader: boolean;
  27855. /**
  27856. * Gets a boolean indicating that only power of 2 textures are supported
  27857. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27858. */
  27859. readonly needPOTTextures: boolean;
  27860. /** @hidden */
  27861. _badOS: boolean;
  27862. /** @hidden */
  27863. _badDesktopOS: boolean;
  27864. /**
  27865. * Gets the audio engine
  27866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27867. * @ignorenaming
  27868. */
  27869. static audioEngine: IAudioEngine;
  27870. /**
  27871. * Default AudioEngine factory responsible of creating the Audio Engine.
  27872. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27873. */
  27874. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27875. /**
  27876. * Default offline support factory responsible of creating a tool used to store data locally.
  27877. * By default, this will create a Database object if the workload has been embedded.
  27878. */
  27879. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27880. private _onFocus;
  27881. private _onBlur;
  27882. private _onCanvasPointerOut;
  27883. private _onCanvasBlur;
  27884. private _onCanvasFocus;
  27885. private _onFullscreenChange;
  27886. private _onPointerLockChange;
  27887. private _hardwareScalingLevel;
  27888. /** @hidden */
  27889. _caps: EngineCapabilities;
  27890. private _pointerLockRequested;
  27891. private _isStencilEnable;
  27892. private _colorWrite;
  27893. private _loadingScreen;
  27894. /** @hidden */
  27895. _drawCalls: PerfCounter;
  27896. private _glVersion;
  27897. private _glRenderer;
  27898. private _glVendor;
  27899. private _videoTextureSupported;
  27900. private _renderingQueueLaunched;
  27901. private _activeRenderLoops;
  27902. private _deterministicLockstep;
  27903. private _lockstepMaxSteps;
  27904. /**
  27905. * Observable signaled when a context lost event is raised
  27906. */
  27907. onContextLostObservable: Observable<Engine>;
  27908. /**
  27909. * Observable signaled when a context restored event is raised
  27910. */
  27911. onContextRestoredObservable: Observable<Engine>;
  27912. private _onContextLost;
  27913. private _onContextRestored;
  27914. private _contextWasLost;
  27915. /** @hidden */
  27916. _doNotHandleContextLost: boolean;
  27917. /**
  27918. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27920. */
  27921. doNotHandleContextLost: boolean;
  27922. private _performanceMonitor;
  27923. private _fps;
  27924. private _deltaTime;
  27925. /**
  27926. * Turn this value on if you want to pause FPS computation when in background
  27927. */
  27928. disablePerformanceMonitorInBackground: boolean;
  27929. /**
  27930. * Gets the performance monitor attached to this engine
  27931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27932. */
  27933. readonly performanceMonitor: PerformanceMonitor;
  27934. /**
  27935. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27936. */
  27937. disableVertexArrayObjects: boolean;
  27938. /** @hidden */
  27939. protected _depthCullingState: _DepthCullingState;
  27940. /** @hidden */
  27941. protected _stencilState: _StencilState;
  27942. /** @hidden */
  27943. protected _alphaState: _AlphaState;
  27944. /** @hidden */
  27945. protected _alphaMode: number;
  27946. /** @hidden */
  27947. _internalTexturesCache: InternalTexture[];
  27948. /** @hidden */
  27949. protected _activeChannel: number;
  27950. private _currentTextureChannel;
  27951. /** @hidden */
  27952. protected _boundTexturesCache: {
  27953. [key: string]: Nullable<InternalTexture>;
  27954. };
  27955. /** @hidden */
  27956. protected _currentEffect: Nullable<Effect>;
  27957. /** @hidden */
  27958. protected _currentProgram: Nullable<WebGLProgram>;
  27959. private _compiledEffects;
  27960. private _vertexAttribArraysEnabled;
  27961. /** @hidden */
  27962. protected _cachedViewport: Nullable<Viewport>;
  27963. private _cachedVertexArrayObject;
  27964. /** @hidden */
  27965. protected _cachedVertexBuffers: any;
  27966. /** @hidden */
  27967. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27968. /** @hidden */
  27969. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27970. /** @hidden */
  27971. _currentRenderTarget: Nullable<InternalTexture>;
  27972. private _uintIndicesCurrentlySet;
  27973. private _currentBoundBuffer;
  27974. /** @hidden */
  27975. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27976. private _currentBufferPointers;
  27977. private _currentInstanceLocations;
  27978. private _currentInstanceBuffers;
  27979. private _textureUnits;
  27980. /** @hidden */
  27981. _workingCanvas: Nullable<HTMLCanvasElement>;
  27982. /** @hidden */
  27983. _workingContext: Nullable<CanvasRenderingContext2D>;
  27984. private _rescalePostProcess;
  27985. private _dummyFramebuffer;
  27986. private _externalData;
  27987. /** @hidden */
  27988. _bindedRenderFunction: any;
  27989. private _vaoRecordInProgress;
  27990. private _mustWipeVertexAttributes;
  27991. private _emptyTexture;
  27992. private _emptyCubeTexture;
  27993. private _emptyTexture3D;
  27994. /** @hidden */
  27995. _frameHandler: number;
  27996. private _nextFreeTextureSlots;
  27997. private _maxSimultaneousTextures;
  27998. private _activeRequests;
  27999. private _texturesSupported;
  28000. /** @hidden */
  28001. _textureFormatInUse: Nullable<string>;
  28002. /**
  28003. * Gets the list of texture formats supported
  28004. */
  28005. readonly texturesSupported: Array<string>;
  28006. /**
  28007. * Gets the list of texture formats in use
  28008. */
  28009. readonly textureFormatInUse: Nullable<string>;
  28010. /**
  28011. * Gets the current viewport
  28012. */
  28013. readonly currentViewport: Nullable<Viewport>;
  28014. /**
  28015. * Gets the default empty texture
  28016. */
  28017. readonly emptyTexture: InternalTexture;
  28018. /**
  28019. * Gets the default empty 3D texture
  28020. */
  28021. readonly emptyTexture3D: InternalTexture;
  28022. /**
  28023. * Gets the default empty cube texture
  28024. */
  28025. readonly emptyCubeTexture: InternalTexture;
  28026. /**
  28027. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28028. */
  28029. readonly premultipliedAlpha: boolean;
  28030. /**
  28031. * Creates a new engine
  28032. * @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
  28033. * @param antialias defines enable antialiasing (default: false)
  28034. * @param options defines further options to be sent to the getContext() function
  28035. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28036. */
  28037. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28038. /**
  28039. * Initializes a webVR display and starts listening to display change events
  28040. * The onVRDisplayChangedObservable will be notified upon these changes
  28041. * @returns The onVRDisplayChangedObservable
  28042. */
  28043. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28044. /** @hidden */
  28045. _prepareVRComponent(): void;
  28046. /** @hidden */
  28047. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28048. /** @hidden */
  28049. _submitVRFrame(): void;
  28050. /**
  28051. * Call this function to leave webVR mode
  28052. * Will do nothing if webVR is not supported or if there is no webVR device
  28053. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28054. */
  28055. disableVR(): void;
  28056. /**
  28057. * Gets a boolean indicating that the system is in VR mode and is presenting
  28058. * @returns true if VR mode is engaged
  28059. */
  28060. isVRPresenting(): boolean;
  28061. /** @hidden */
  28062. _requestVRFrame(): void;
  28063. private _disableTouchAction;
  28064. private _rebuildInternalTextures;
  28065. private _rebuildEffects;
  28066. /**
  28067. * Gets a boolean indicating if all created effects are ready
  28068. * @returns true if all effects are ready
  28069. */
  28070. areAllEffectsReady(): boolean;
  28071. private _rebuildBuffers;
  28072. private _initGLContext;
  28073. /**
  28074. * Gets version of the current webGL context
  28075. */
  28076. readonly webGLVersion: number;
  28077. /**
  28078. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28079. */
  28080. readonly isStencilEnable: boolean;
  28081. /** @hidden */
  28082. _prepareWorkingCanvas(): void;
  28083. /**
  28084. * Reset the texture cache to empty state
  28085. */
  28086. resetTextureCache(): void;
  28087. /**
  28088. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28089. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28090. * @returns true if engine is in deterministic lock step mode
  28091. */
  28092. isDeterministicLockStep(): boolean;
  28093. /**
  28094. * Gets the max steps when engine is running in deterministic lock step
  28095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28096. * @returns the max steps
  28097. */
  28098. getLockstepMaxSteps(): number;
  28099. /**
  28100. * Gets an object containing information about the current webGL context
  28101. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28102. */
  28103. getGlInfo(): {
  28104. vendor: string;
  28105. renderer: string;
  28106. version: string;
  28107. };
  28108. /**
  28109. * Gets current aspect ratio
  28110. * @param camera defines the camera to use to get the aspect ratio
  28111. * @param useScreen defines if screen size must be used (or the current render target if any)
  28112. * @returns a number defining the aspect ratio
  28113. */
  28114. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28115. /**
  28116. * Gets current screen aspect ratio
  28117. * @returns a number defining the aspect ratio
  28118. */
  28119. getScreenAspectRatio(): number;
  28120. /**
  28121. * Gets the current render width
  28122. * @param useScreen defines if screen size must be used (or the current render target if any)
  28123. * @returns a number defining the current render width
  28124. */
  28125. getRenderWidth(useScreen?: boolean): number;
  28126. /**
  28127. * Gets the current render height
  28128. * @param useScreen defines if screen size must be used (or the current render target if any)
  28129. * @returns a number defining the current render height
  28130. */
  28131. getRenderHeight(useScreen?: boolean): number;
  28132. /**
  28133. * Gets the HTML canvas attached with the current webGL context
  28134. * @returns a HTML canvas
  28135. */
  28136. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28137. /**
  28138. * Gets the client rect of the HTML canvas attached with the current webGL context
  28139. * @returns a client rectanglee
  28140. */
  28141. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28142. /**
  28143. * Defines the hardware scaling level.
  28144. * By default the hardware scaling level is computed from the window device ratio.
  28145. * 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.
  28146. * @param level defines the level to use
  28147. */
  28148. setHardwareScalingLevel(level: number): void;
  28149. /**
  28150. * Gets the current hardware scaling level.
  28151. * By default the hardware scaling level is computed from the window device ratio.
  28152. * 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.
  28153. * @returns a number indicating the current hardware scaling level
  28154. */
  28155. getHardwareScalingLevel(): number;
  28156. /**
  28157. * Gets the list of loaded textures
  28158. * @returns an array containing all loaded textures
  28159. */
  28160. getLoadedTexturesCache(): InternalTexture[];
  28161. /**
  28162. * Gets the object containing all engine capabilities
  28163. * @returns the EngineCapabilities object
  28164. */
  28165. getCaps(): EngineCapabilities;
  28166. /**
  28167. * Gets the current depth function
  28168. * @returns a number defining the depth function
  28169. */
  28170. getDepthFunction(): Nullable<number>;
  28171. /**
  28172. * Sets the current depth function
  28173. * @param depthFunc defines the function to use
  28174. */
  28175. setDepthFunction(depthFunc: number): void;
  28176. /**
  28177. * Sets the current depth function to GREATER
  28178. */
  28179. setDepthFunctionToGreater(): void;
  28180. /**
  28181. * Sets the current depth function to GEQUAL
  28182. */
  28183. setDepthFunctionToGreaterOrEqual(): void;
  28184. /**
  28185. * Sets the current depth function to LESS
  28186. */
  28187. setDepthFunctionToLess(): void;
  28188. private _cachedStencilBuffer;
  28189. private _cachedStencilFunction;
  28190. private _cachedStencilMask;
  28191. private _cachedStencilOperationPass;
  28192. private _cachedStencilOperationFail;
  28193. private _cachedStencilOperationDepthFail;
  28194. private _cachedStencilReference;
  28195. /**
  28196. * Caches the the state of the stencil buffer
  28197. */
  28198. cacheStencilState(): void;
  28199. /**
  28200. * Restores the state of the stencil buffer
  28201. */
  28202. restoreStencilState(): void;
  28203. /**
  28204. * Sets the current depth function to LEQUAL
  28205. */
  28206. setDepthFunctionToLessOrEqual(): void;
  28207. /**
  28208. * Gets a boolean indicating if stencil buffer is enabled
  28209. * @returns the current stencil buffer state
  28210. */
  28211. getStencilBuffer(): boolean;
  28212. /**
  28213. * Enable or disable the stencil buffer
  28214. * @param enable defines if the stencil buffer must be enabled or disabled
  28215. */
  28216. setStencilBuffer(enable: boolean): void;
  28217. /**
  28218. * Gets the current stencil mask
  28219. * @returns a number defining the new stencil mask to use
  28220. */
  28221. getStencilMask(): number;
  28222. /**
  28223. * Sets the current stencil mask
  28224. * @param mask defines the new stencil mask to use
  28225. */
  28226. setStencilMask(mask: number): void;
  28227. /**
  28228. * Gets the current stencil function
  28229. * @returns a number defining the stencil function to use
  28230. */
  28231. getStencilFunction(): number;
  28232. /**
  28233. * Gets the current stencil reference value
  28234. * @returns a number defining the stencil reference value to use
  28235. */
  28236. getStencilFunctionReference(): number;
  28237. /**
  28238. * Gets the current stencil mask
  28239. * @returns a number defining the stencil mask to use
  28240. */
  28241. getStencilFunctionMask(): number;
  28242. /**
  28243. * Sets the current stencil function
  28244. * @param stencilFunc defines the new stencil function to use
  28245. */
  28246. setStencilFunction(stencilFunc: number): void;
  28247. /**
  28248. * Sets the current stencil reference
  28249. * @param reference defines the new stencil reference to use
  28250. */
  28251. setStencilFunctionReference(reference: number): void;
  28252. /**
  28253. * Sets the current stencil mask
  28254. * @param mask defines the new stencil mask to use
  28255. */
  28256. setStencilFunctionMask(mask: number): void;
  28257. /**
  28258. * Gets the current stencil operation when stencil fails
  28259. * @returns a number defining stencil operation to use when stencil fails
  28260. */
  28261. getStencilOperationFail(): number;
  28262. /**
  28263. * Gets the current stencil operation when depth fails
  28264. * @returns a number defining stencil operation to use when depth fails
  28265. */
  28266. getStencilOperationDepthFail(): number;
  28267. /**
  28268. * Gets the current stencil operation when stencil passes
  28269. * @returns a number defining stencil operation to use when stencil passes
  28270. */
  28271. getStencilOperationPass(): number;
  28272. /**
  28273. * Sets the stencil operation to use when stencil fails
  28274. * @param operation defines the stencil operation to use when stencil fails
  28275. */
  28276. setStencilOperationFail(operation: number): void;
  28277. /**
  28278. * Sets the stencil operation to use when depth fails
  28279. * @param operation defines the stencil operation to use when depth fails
  28280. */
  28281. setStencilOperationDepthFail(operation: number): void;
  28282. /**
  28283. * Sets the stencil operation to use when stencil passes
  28284. * @param operation defines the stencil operation to use when stencil passes
  28285. */
  28286. setStencilOperationPass(operation: number): void;
  28287. /**
  28288. * Sets a boolean indicating if the dithering state is enabled or disabled
  28289. * @param value defines the dithering state
  28290. */
  28291. setDitheringState(value: boolean): void;
  28292. /**
  28293. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28294. * @param value defines the rasterizer state
  28295. */
  28296. setRasterizerState(value: boolean): void;
  28297. /**
  28298. * stop executing a render loop function and remove it from the execution array
  28299. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28300. */
  28301. stopRenderLoop(renderFunction?: () => void): void;
  28302. /** @hidden */
  28303. _renderLoop(): void;
  28304. /**
  28305. * Register and execute a render loop. The engine can have more than one render function
  28306. * @param renderFunction defines the function to continuously execute
  28307. */
  28308. runRenderLoop(renderFunction: () => void): void;
  28309. /**
  28310. * Toggle full screen mode
  28311. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28312. */
  28313. switchFullscreen(requestPointerLock: boolean): void;
  28314. /**
  28315. * Enters full screen mode
  28316. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28317. */
  28318. enterFullscreen(requestPointerLock: boolean): void;
  28319. /**
  28320. * Exits full screen mode
  28321. */
  28322. exitFullscreen(): void;
  28323. /**
  28324. * Enters Pointerlock mode
  28325. */
  28326. enterPointerlock(): void;
  28327. /**
  28328. * Exits Pointerlock mode
  28329. */
  28330. exitPointerlock(): void;
  28331. /**
  28332. * Clear the current render buffer or the current render target (if any is set up)
  28333. * @param color defines the color to use
  28334. * @param backBuffer defines if the back buffer must be cleared
  28335. * @param depth defines if the depth buffer must be cleared
  28336. * @param stencil defines if the stencil buffer must be cleared
  28337. */
  28338. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28339. /**
  28340. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28341. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28342. * @param y defines the y-coordinate of the corner of the clear rectangle
  28343. * @param width defines the width of the clear rectangle
  28344. * @param height defines the height of the clear rectangle
  28345. * @param clearColor defines the clear color
  28346. */
  28347. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28348. /**
  28349. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28350. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28351. * @param y defines the y-coordinate of the corner of the clear rectangle
  28352. * @param width defines the width of the clear rectangle
  28353. * @param height defines the height of the clear rectangle
  28354. */
  28355. enableScissor(x: number, y: number, width: number, height: number): void;
  28356. /**
  28357. * Disable previously set scissor test rectangle
  28358. */
  28359. disableScissor(): void;
  28360. private _viewportCached;
  28361. /** @hidden */
  28362. _viewport(x: number, y: number, width: number, height: number): void;
  28363. /**
  28364. * Set the WebGL's viewport
  28365. * @param viewport defines the viewport element to be used
  28366. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28367. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28368. */
  28369. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28370. /**
  28371. * Directly set the WebGL Viewport
  28372. * @param x defines the x coordinate of the viewport (in screen space)
  28373. * @param y defines the y coordinate of the viewport (in screen space)
  28374. * @param width defines the width of the viewport (in screen space)
  28375. * @param height defines the height of the viewport (in screen space)
  28376. * @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
  28377. */
  28378. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28379. /**
  28380. * Begin a new frame
  28381. */
  28382. beginFrame(): void;
  28383. /**
  28384. * Enf the current frame
  28385. */
  28386. endFrame(): void;
  28387. /**
  28388. * Resize the view according to the canvas' size
  28389. */
  28390. resize(): void;
  28391. /**
  28392. * Force a specific size of the canvas
  28393. * @param width defines the new canvas' width
  28394. * @param height defines the new canvas' height
  28395. */
  28396. setSize(width: number, height: number): void;
  28397. /**
  28398. * Binds the frame buffer to the specified texture.
  28399. * @param texture The texture to render to or null for the default canvas
  28400. * @param faceIndex The face of the texture to render to in case of cube texture
  28401. * @param requiredWidth The width of the target to render to
  28402. * @param requiredHeight The height of the target to render to
  28403. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28404. * @param depthStencilTexture The depth stencil texture to use to render
  28405. * @param lodLevel defines le lod level to bind to the frame buffer
  28406. */
  28407. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28408. /** @hidden */
  28409. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28410. /**
  28411. * Unbind the current render target texture from the webGL context
  28412. * @param texture defines the render target texture to unbind
  28413. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28414. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28415. */
  28416. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28417. /**
  28418. * Force the mipmap generation for the given render target texture
  28419. * @param texture defines the render target texture to use
  28420. */
  28421. generateMipMapsForCubemap(texture: InternalTexture): void;
  28422. /**
  28423. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28424. */
  28425. flushFramebuffer(): void;
  28426. /**
  28427. * Unbind the current render target and bind the default framebuffer
  28428. */
  28429. restoreDefaultFramebuffer(): void;
  28430. /**
  28431. * Create an uniform buffer
  28432. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28433. * @param elements defines the content of the uniform buffer
  28434. * @returns the webGL uniform buffer
  28435. */
  28436. createUniformBuffer(elements: FloatArray): DataBuffer;
  28437. /**
  28438. * Create a dynamic uniform buffer
  28439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28440. * @param elements defines the content of the uniform buffer
  28441. * @returns the webGL uniform buffer
  28442. */
  28443. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28444. /**
  28445. * Update an existing uniform buffer
  28446. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28447. * @param uniformBuffer defines the target uniform buffer
  28448. * @param elements defines the content to update
  28449. * @param offset defines the offset in the uniform buffer where update should start
  28450. * @param count defines the size of the data to update
  28451. */
  28452. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28453. private _resetVertexBufferBinding;
  28454. /**
  28455. * Creates a vertex buffer
  28456. * @param data the data for the vertex buffer
  28457. * @returns the new WebGL static buffer
  28458. */
  28459. createVertexBuffer(data: DataArray): DataBuffer;
  28460. /**
  28461. * Creates a dynamic vertex buffer
  28462. * @param data the data for the dynamic vertex buffer
  28463. * @returns the new WebGL dynamic buffer
  28464. */
  28465. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28466. /**
  28467. * Update a dynamic index buffer
  28468. * @param indexBuffer defines the target index buffer
  28469. * @param indices defines the data to update
  28470. * @param offset defines the offset in the target index buffer where update should start
  28471. */
  28472. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28473. /**
  28474. * Updates a dynamic vertex buffer.
  28475. * @param vertexBuffer the vertex buffer to update
  28476. * @param data the data used to update the vertex buffer
  28477. * @param byteOffset the byte offset of the data
  28478. * @param byteLength the byte length of the data
  28479. */
  28480. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28481. private _resetIndexBufferBinding;
  28482. /**
  28483. * Creates a new index buffer
  28484. * @param indices defines the content of the index buffer
  28485. * @param updatable defines if the index buffer must be updatable
  28486. * @returns a new webGL buffer
  28487. */
  28488. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28489. /**
  28490. * Bind a webGL buffer to the webGL context
  28491. * @param buffer defines the buffer to bind
  28492. */
  28493. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28494. /**
  28495. * Bind an uniform buffer to the current webGL context
  28496. * @param buffer defines the buffer to bind
  28497. */
  28498. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28499. /**
  28500. * Bind a buffer to the current webGL context at a given location
  28501. * @param buffer defines the buffer to bind
  28502. * @param location defines the index where to bind the buffer
  28503. */
  28504. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28505. /**
  28506. * Bind a specific block at a given index in a specific shader program
  28507. * @param pipelineContext defines the pipeline context to use
  28508. * @param blockName defines the block name
  28509. * @param index defines the index where to bind the block
  28510. */
  28511. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28512. private bindIndexBuffer;
  28513. private bindBuffer;
  28514. /**
  28515. * update the bound buffer with the given data
  28516. * @param data defines the data to update
  28517. */
  28518. updateArrayBuffer(data: Float32Array): void;
  28519. private _vertexAttribPointer;
  28520. private _bindIndexBufferWithCache;
  28521. private _bindVertexBuffersAttributes;
  28522. /**
  28523. * Records a vertex array object
  28524. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28525. * @param vertexBuffers defines the list of vertex buffers to store
  28526. * @param indexBuffer defines the index buffer to store
  28527. * @param effect defines the effect to store
  28528. * @returns the new vertex array object
  28529. */
  28530. recordVertexArrayObject(vertexBuffers: {
  28531. [key: string]: VertexBuffer;
  28532. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28533. /**
  28534. * Bind a specific vertex array object
  28535. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28536. * @param vertexArrayObject defines the vertex array object to bind
  28537. * @param indexBuffer defines the index buffer to bind
  28538. */
  28539. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28540. /**
  28541. * Bind webGl buffers directly to the webGL context
  28542. * @param vertexBuffer defines the vertex buffer to bind
  28543. * @param indexBuffer defines the index buffer to bind
  28544. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28545. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28546. * @param effect defines the effect associated with the vertex buffer
  28547. */
  28548. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28549. private _unbindVertexArrayObject;
  28550. /**
  28551. * Bind a list of vertex buffers to the webGL context
  28552. * @param vertexBuffers defines the list of vertex buffers to bind
  28553. * @param indexBuffer defines the index buffer to bind
  28554. * @param effect defines the effect associated with the vertex buffers
  28555. */
  28556. bindBuffers(vertexBuffers: {
  28557. [key: string]: Nullable<VertexBuffer>;
  28558. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28559. /**
  28560. * Unbind all instance attributes
  28561. */
  28562. unbindInstanceAttributes(): void;
  28563. /**
  28564. * Release and free the memory of a vertex array object
  28565. * @param vao defines the vertex array object to delete
  28566. */
  28567. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28568. /** @hidden */
  28569. _releaseBuffer(buffer: DataBuffer): boolean;
  28570. /**
  28571. * Creates a webGL buffer to use with instanciation
  28572. * @param capacity defines the size of the buffer
  28573. * @returns the webGL buffer
  28574. */
  28575. createInstancesBuffer(capacity: number): DataBuffer;
  28576. /**
  28577. * Delete a webGL buffer used with instanciation
  28578. * @param buffer defines the webGL buffer to delete
  28579. */
  28580. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28581. /**
  28582. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28583. * @param instancesBuffer defines the webGL buffer to update and bind
  28584. * @param data defines the data to store in the buffer
  28585. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28586. */
  28587. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28588. /**
  28589. * Apply all cached states (depth, culling, stencil and alpha)
  28590. */
  28591. applyStates(): void;
  28592. /**
  28593. * Send a draw order
  28594. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28595. * @param indexStart defines the starting index
  28596. * @param indexCount defines the number of index to draw
  28597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28598. */
  28599. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28600. /**
  28601. * Draw a list of points
  28602. * @param verticesStart defines the index of first vertex to draw
  28603. * @param verticesCount defines the count of vertices to draw
  28604. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28605. */
  28606. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28607. /**
  28608. * Draw a list of unindexed primitives
  28609. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28610. * @param verticesStart defines the index of first vertex to draw
  28611. * @param verticesCount defines the count of vertices to draw
  28612. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28613. */
  28614. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28615. /**
  28616. * Draw a list of indexed primitives
  28617. * @param fillMode defines the primitive to use
  28618. * @param indexStart defines the starting index
  28619. * @param indexCount defines the number of index to draw
  28620. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28621. */
  28622. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28623. /**
  28624. * Draw a list of unindexed primitives
  28625. * @param fillMode defines the primitive to use
  28626. * @param verticesStart defines the index of first vertex to draw
  28627. * @param verticesCount defines the count of vertices to draw
  28628. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28629. */
  28630. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28631. private _drawMode;
  28632. /** @hidden */
  28633. _releaseEffect(effect: Effect): void;
  28634. /** @hidden */
  28635. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28636. /**
  28637. * Create a new effect (used to store vertex/fragment shaders)
  28638. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28639. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28640. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28641. * @param samplers defines an array of string used to represent textures
  28642. * @param defines defines the string containing the defines to use to compile the shaders
  28643. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28644. * @param onCompiled defines a function to call when the effect creation is successful
  28645. * @param onError defines a function to call when the effect creation has failed
  28646. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28647. * @returns the new Effect
  28648. */
  28649. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28650. private _compileShader;
  28651. private _compileRawShader;
  28652. /**
  28653. * Directly creates a webGL program
  28654. * @param pipelineContext defines the pipeline context to attach to
  28655. * @param vertexCode defines the vertex shader code to use
  28656. * @param fragmentCode defines the fragment shader code to use
  28657. * @param context defines the webGL context to use (if not set, the current one will be used)
  28658. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28659. * @returns the new webGL program
  28660. */
  28661. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28662. /**
  28663. * Creates a webGL program
  28664. * @param pipelineContext defines the pipeline context to attach to
  28665. * @param vertexCode defines the vertex shader code to use
  28666. * @param fragmentCode defines the fragment shader code to use
  28667. * @param defines defines the string containing the defines to use to compile the shaders
  28668. * @param context defines the webGL context to use (if not set, the current one will be used)
  28669. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28670. * @returns the new webGL program
  28671. */
  28672. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28673. /**
  28674. * Creates a new pipeline context
  28675. * @returns the new pipeline
  28676. */
  28677. createPipelineContext(): WebGLPipelineContext;
  28678. private _createShaderProgram;
  28679. private _finalizePipelineContext;
  28680. /** @hidden */
  28681. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28682. /** @hidden */
  28683. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28684. /** @hidden */
  28685. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28686. /**
  28687. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28688. * @param pipelineContext defines the pipeline context to use
  28689. * @param uniformsNames defines the list of uniform names
  28690. * @returns an array of webGL uniform locations
  28691. */
  28692. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28693. /**
  28694. * Gets the lsit of active attributes for a given webGL program
  28695. * @param pipelineContext defines the pipeline context to use
  28696. * @param attributesNames defines the list of attribute names to get
  28697. * @returns an array of indices indicating the offset of each attribute
  28698. */
  28699. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28700. /**
  28701. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28702. * @param effect defines the effect to activate
  28703. */
  28704. enableEffect(effect: Nullable<Effect>): void;
  28705. /**
  28706. * Set the value of an uniform to an array of int32
  28707. * @param uniform defines the webGL uniform location where to store the value
  28708. * @param array defines the array of int32 to store
  28709. */
  28710. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28711. /**
  28712. * Set the value of an uniform to an array of int32 (stored as vec2)
  28713. * @param uniform defines the webGL uniform location where to store the value
  28714. * @param array defines the array of int32 to store
  28715. */
  28716. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28717. /**
  28718. * Set the value of an uniform to an array of int32 (stored as vec3)
  28719. * @param uniform defines the webGL uniform location where to store the value
  28720. * @param array defines the array of int32 to store
  28721. */
  28722. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28723. /**
  28724. * Set the value of an uniform to an array of int32 (stored as vec4)
  28725. * @param uniform defines the webGL uniform location where to store the value
  28726. * @param array defines the array of int32 to store
  28727. */
  28728. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28729. /**
  28730. * Set the value of an uniform to an array of float32
  28731. * @param uniform defines the webGL uniform location where to store the value
  28732. * @param array defines the array of float32 to store
  28733. */
  28734. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28735. /**
  28736. * Set the value of an uniform to an array of float32 (stored as vec2)
  28737. * @param uniform defines the webGL uniform location where to store the value
  28738. * @param array defines the array of float32 to store
  28739. */
  28740. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28741. /**
  28742. * Set the value of an uniform to an array of float32 (stored as vec3)
  28743. * @param uniform defines the webGL uniform location where to store the value
  28744. * @param array defines the array of float32 to store
  28745. */
  28746. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28747. /**
  28748. * Set the value of an uniform to an array of float32 (stored as vec4)
  28749. * @param uniform defines the webGL uniform location where to store the value
  28750. * @param array defines the array of float32 to store
  28751. */
  28752. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28753. /**
  28754. * Set the value of an uniform to an array of number
  28755. * @param uniform defines the webGL uniform location where to store the value
  28756. * @param array defines the array of number to store
  28757. */
  28758. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28759. /**
  28760. * Set the value of an uniform to an array of number (stored as vec2)
  28761. * @param uniform defines the webGL uniform location where to store the value
  28762. * @param array defines the array of number to store
  28763. */
  28764. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28765. /**
  28766. * Set the value of an uniform to an array of number (stored as vec3)
  28767. * @param uniform defines the webGL uniform location where to store the value
  28768. * @param array defines the array of number to store
  28769. */
  28770. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28771. /**
  28772. * Set the value of an uniform to an array of number (stored as vec4)
  28773. * @param uniform defines the webGL uniform location where to store the value
  28774. * @param array defines the array of number to store
  28775. */
  28776. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28777. /**
  28778. * Set the value of an uniform to an array of float32 (stored as matrices)
  28779. * @param uniform defines the webGL uniform location where to store the value
  28780. * @param matrices defines the array of float32 to store
  28781. */
  28782. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28783. /**
  28784. * Set the value of an uniform to a matrix
  28785. * @param uniform defines the webGL uniform location where to store the value
  28786. * @param matrix defines the matrix to store
  28787. */
  28788. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28789. /**
  28790. * Set the value of an uniform to a matrix (3x3)
  28791. * @param uniform defines the webGL uniform location where to store the value
  28792. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28793. */
  28794. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28795. /**
  28796. * Set the value of an uniform to a matrix (2x2)
  28797. * @param uniform defines the webGL uniform location where to store the value
  28798. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28799. */
  28800. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28801. /**
  28802. * Set the value of an uniform to a number (int)
  28803. * @param uniform defines the webGL uniform location where to store the value
  28804. * @param value defines the int number to store
  28805. */
  28806. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28807. /**
  28808. * Set the value of an uniform to a number (float)
  28809. * @param uniform defines the webGL uniform location where to store the value
  28810. * @param value defines the float number to store
  28811. */
  28812. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28813. /**
  28814. * Set the value of an uniform to a vec2
  28815. * @param uniform defines the webGL uniform location where to store the value
  28816. * @param x defines the 1st component of the value
  28817. * @param y defines the 2nd component of the value
  28818. */
  28819. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28820. /**
  28821. * Set the value of an uniform to a vec3
  28822. * @param uniform defines the webGL uniform location where to store the value
  28823. * @param x defines the 1st component of the value
  28824. * @param y defines the 2nd component of the value
  28825. * @param z defines the 3rd component of the value
  28826. */
  28827. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28828. /**
  28829. * Set the value of an uniform to a boolean
  28830. * @param uniform defines the webGL uniform location where to store the value
  28831. * @param bool defines the boolean to store
  28832. */
  28833. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28834. /**
  28835. * Set the value of an uniform to a vec4
  28836. * @param uniform defines the webGL uniform location where to store the value
  28837. * @param x defines the 1st component of the value
  28838. * @param y defines the 2nd component of the value
  28839. * @param z defines the 3rd component of the value
  28840. * @param w defines the 4th component of the value
  28841. */
  28842. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28843. /**
  28844. * Set the value of an uniform to a Color3
  28845. * @param uniform defines the webGL uniform location where to store the value
  28846. * @param color3 defines the color to store
  28847. */
  28848. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28849. /**
  28850. * Set the value of an uniform to a Color3 and an alpha value
  28851. * @param uniform defines the webGL uniform location where to store the value
  28852. * @param color3 defines the color to store
  28853. * @param alpha defines the alpha component to store
  28854. */
  28855. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28856. /**
  28857. * Sets a Color4 on a uniform variable
  28858. * @param uniform defines the uniform location
  28859. * @param color4 defines the value to be set
  28860. */
  28861. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28862. /**
  28863. * Set various states to the webGL context
  28864. * @param culling defines backface culling state
  28865. * @param zOffset defines the value to apply to zOffset (0 by default)
  28866. * @param force defines if states must be applied even if cache is up to date
  28867. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28868. */
  28869. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28870. /**
  28871. * Set the z offset to apply to current rendering
  28872. * @param value defines the offset to apply
  28873. */
  28874. setZOffset(value: number): void;
  28875. /**
  28876. * Gets the current value of the zOffset
  28877. * @returns the current zOffset state
  28878. */
  28879. getZOffset(): number;
  28880. /**
  28881. * Enable or disable depth buffering
  28882. * @param enable defines the state to set
  28883. */
  28884. setDepthBuffer(enable: boolean): void;
  28885. /**
  28886. * Gets a boolean indicating if depth writing is enabled
  28887. * @returns the current depth writing state
  28888. */
  28889. getDepthWrite(): boolean;
  28890. /**
  28891. * Enable or disable depth writing
  28892. * @param enable defines the state to set
  28893. */
  28894. setDepthWrite(enable: boolean): void;
  28895. /**
  28896. * Enable or disable color writing
  28897. * @param enable defines the state to set
  28898. */
  28899. setColorWrite(enable: boolean): void;
  28900. /**
  28901. * Gets a boolean indicating if color writing is enabled
  28902. * @returns the current color writing state
  28903. */
  28904. getColorWrite(): boolean;
  28905. /**
  28906. * Sets alpha constants used by some alpha blending modes
  28907. * @param r defines the red component
  28908. * @param g defines the green component
  28909. * @param b defines the blue component
  28910. * @param a defines the alpha component
  28911. */
  28912. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28913. /**
  28914. * Sets the current alpha mode
  28915. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28916. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28917. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28918. */
  28919. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28920. /**
  28921. * Gets the current alpha mode
  28922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28923. * @returns the current alpha mode
  28924. */
  28925. getAlphaMode(): number;
  28926. /**
  28927. * Clears the list of texture accessible through engine.
  28928. * This can help preventing texture load conflict due to name collision.
  28929. */
  28930. clearInternalTexturesCache(): void;
  28931. /**
  28932. * Force the entire cache to be cleared
  28933. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28934. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28935. */
  28936. wipeCaches(bruteForce?: boolean): void;
  28937. /**
  28938. * Set the compressed texture format to use, based on the formats you have, and the formats
  28939. * supported by the hardware / browser.
  28940. *
  28941. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28942. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28943. * to API arguments needed to compressed textures. This puts the burden on the container
  28944. * generator to house the arcane code for determining these for current & future formats.
  28945. *
  28946. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28947. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28948. *
  28949. * Note: The result of this call is not taken into account when a texture is base64.
  28950. *
  28951. * @param formatsAvailable defines the list of those format families you have created
  28952. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28953. *
  28954. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28955. * @returns The extension selected.
  28956. */
  28957. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28958. /** @hidden */
  28959. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28960. min: number;
  28961. mag: number;
  28962. };
  28963. /** @hidden */
  28964. _createTexture(): WebGLTexture;
  28965. /**
  28966. * Usually called from Texture.ts.
  28967. * Passed information to create a WebGLTexture
  28968. * @param urlArg defines a value which contains one of the following:
  28969. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28970. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28971. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28972. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28973. * @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)
  28974. * @param scene needed for loading to the correct scene
  28975. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28976. * @param onLoad optional callback to be called upon successful completion
  28977. * @param onError optional callback to be called upon failure
  28978. * @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
  28979. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28980. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28981. * @param forcedExtension defines the extension to use to pick the right loader
  28982. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28983. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28984. */
  28985. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28986. /**
  28987. * @hidden
  28988. * Rescales a texture
  28989. * @param source input texutre
  28990. * @param destination destination texture
  28991. * @param scene scene to use to render the resize
  28992. * @param internalFormat format to use when resizing
  28993. * @param onComplete callback to be called when resize has completed
  28994. */
  28995. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  28996. private _unpackFlipYCached;
  28997. /**
  28998. * In case you are sharing the context with other applications, it might
  28999. * be interested to not cache the unpack flip y state to ensure a consistent
  29000. * value would be set.
  29001. */
  29002. enableUnpackFlipYCached: boolean;
  29003. /** @hidden */
  29004. _unpackFlipY(value: boolean): void;
  29005. /** @hidden */
  29006. _getUnpackAlignement(): number;
  29007. /**
  29008. * Creates a dynamic texture
  29009. * @param width defines the width of the texture
  29010. * @param height defines the height of the texture
  29011. * @param generateMipMaps defines if the engine should generate the mip levels
  29012. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29013. * @returns the dynamic texture inside an InternalTexture
  29014. */
  29015. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29016. /**
  29017. * Update the sampling mode of a given texture
  29018. * @param samplingMode defines the required sampling mode
  29019. * @param texture defines the texture to update
  29020. */
  29021. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29022. /**
  29023. * Update the content of a dynamic texture
  29024. * @param texture defines the texture to update
  29025. * @param canvas defines the canvas containing the source
  29026. * @param invertY defines if data must be stored with Y axis inverted
  29027. * @param premulAlpha defines if alpha is stored as premultiplied
  29028. * @param format defines the format of the data
  29029. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29030. */
  29031. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29032. /**
  29033. * Update a video texture
  29034. * @param texture defines the texture to update
  29035. * @param video defines the video element to use
  29036. * @param invertY defines if data must be stored with Y axis inverted
  29037. */
  29038. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29039. /**
  29040. * Updates a depth texture Comparison Mode and Function.
  29041. * If the comparison Function is equal to 0, the mode will be set to none.
  29042. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29043. * @param texture The texture to set the comparison function for
  29044. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29045. */
  29046. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29047. /** @hidden */
  29048. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29049. width: number;
  29050. height: number;
  29051. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29052. /**
  29053. * Creates a depth stencil texture.
  29054. * This is only available in WebGL 2 or with the depth texture extension available.
  29055. * @param size The size of face edge in the texture.
  29056. * @param options The options defining the texture.
  29057. * @returns The texture
  29058. */
  29059. createDepthStencilTexture(size: number | {
  29060. width: number;
  29061. height: number;
  29062. }, options: DepthTextureCreationOptions): InternalTexture;
  29063. /**
  29064. * Creates a depth stencil texture.
  29065. * This is only available in WebGL 2 or with the depth texture extension available.
  29066. * @param size The size of face edge in the texture.
  29067. * @param options The options defining the texture.
  29068. * @returns The texture
  29069. */
  29070. private _createDepthStencilTexture;
  29071. /**
  29072. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29073. * @param renderTarget The render target to set the frame buffer for
  29074. */
  29075. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29076. /**
  29077. * Creates a new render target texture
  29078. * @param size defines the size of the texture
  29079. * @param options defines the options used to create the texture
  29080. * @returns a new render target texture stored in an InternalTexture
  29081. */
  29082. createRenderTargetTexture(size: number | {
  29083. width: number;
  29084. height: number;
  29085. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29086. /** @hidden */
  29087. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29088. /**
  29089. * Updates the sample count of a render target texture
  29090. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29091. * @param texture defines the texture to update
  29092. * @param samples defines the sample count to set
  29093. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29094. */
  29095. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29096. /** @hidden */
  29097. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29098. /** @hidden */
  29099. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29100. /** @hidden */
  29101. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29102. /** @hidden */
  29103. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29104. /**
  29105. * @hidden
  29106. */
  29107. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29108. private _prepareWebGLTextureContinuation;
  29109. private _prepareWebGLTexture;
  29110. /** @hidden */
  29111. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29112. /** @hidden */
  29113. _releaseFramebufferObjects(texture: InternalTexture): void;
  29114. /** @hidden */
  29115. _releaseTexture(texture: InternalTexture): void;
  29116. private setProgram;
  29117. private _boundUniforms;
  29118. /**
  29119. * Binds an effect to the webGL context
  29120. * @param effect defines the effect to bind
  29121. */
  29122. bindSamplers(effect: Effect): void;
  29123. private _activateCurrentTexture;
  29124. /** @hidden */
  29125. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29126. /** @hidden */
  29127. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29128. /**
  29129. * Sets a texture to the webGL context from a postprocess
  29130. * @param channel defines the channel to use
  29131. * @param postProcess defines the source postprocess
  29132. */
  29133. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29134. /**
  29135. * Binds the output of the passed in post process to the texture channel specified
  29136. * @param channel The channel the texture should be bound to
  29137. * @param postProcess The post process which's output should be bound
  29138. */
  29139. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29140. /**
  29141. * Unbind all textures from the webGL context
  29142. */
  29143. unbindAllTextures(): void;
  29144. /**
  29145. * Sets a texture to the according uniform.
  29146. * @param channel The texture channel
  29147. * @param uniform The uniform to set
  29148. * @param texture The texture to apply
  29149. */
  29150. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29151. /**
  29152. * Sets a depth stencil texture from a render target to the according uniform.
  29153. * @param channel The texture channel
  29154. * @param uniform The uniform to set
  29155. * @param texture The render target texture containing the depth stencil texture to apply
  29156. */
  29157. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29158. private _bindSamplerUniformToChannel;
  29159. private _getTextureWrapMode;
  29160. private _setTexture;
  29161. /**
  29162. * Sets an array of texture to the webGL context
  29163. * @param channel defines the channel where the texture array must be set
  29164. * @param uniform defines the associated uniform location
  29165. * @param textures defines the array of textures to bind
  29166. */
  29167. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29168. /** @hidden */
  29169. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29170. private _setTextureParameterFloat;
  29171. private _setTextureParameterInteger;
  29172. /**
  29173. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29174. * @param x defines the x coordinate of the rectangle where pixels must be read
  29175. * @param y defines the y coordinate of the rectangle where pixels must be read
  29176. * @param width defines the width of the rectangle where pixels must be read
  29177. * @param height defines the height of the rectangle where pixels must be read
  29178. * @returns a Uint8Array containing RGBA colors
  29179. */
  29180. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29181. /**
  29182. * Add an externaly attached data from its key.
  29183. * This method call will fail and return false, if such key already exists.
  29184. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29185. * @param key the unique key that identifies the data
  29186. * @param data the data object to associate to the key for this Engine instance
  29187. * @return true if no such key were already present and the data was added successfully, false otherwise
  29188. */
  29189. addExternalData<T>(key: string, data: T): boolean;
  29190. /**
  29191. * Get an externaly attached data from its key
  29192. * @param key the unique key that identifies the data
  29193. * @return the associated data, if present (can be null), or undefined if not present
  29194. */
  29195. getExternalData<T>(key: string): T;
  29196. /**
  29197. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29198. * @param key the unique key that identifies the data
  29199. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29200. * @return the associated data, can be null if the factory returned null.
  29201. */
  29202. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29203. /**
  29204. * Remove an externaly attached data from the Engine instance
  29205. * @param key the unique key that identifies the data
  29206. * @return true if the data was successfully removed, false if it doesn't exist
  29207. */
  29208. removeExternalData(key: string): boolean;
  29209. /**
  29210. * Unbind all vertex attributes from the webGL context
  29211. */
  29212. unbindAllAttributes(): void;
  29213. /**
  29214. * 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
  29215. */
  29216. releaseEffects(): void;
  29217. /**
  29218. * Dispose and release all associated resources
  29219. */
  29220. dispose(): void;
  29221. /**
  29222. * Display the loading screen
  29223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29224. */
  29225. displayLoadingUI(): void;
  29226. /**
  29227. * Hide the loading screen
  29228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29229. */
  29230. hideLoadingUI(): void;
  29231. /**
  29232. * Gets the current loading screen object
  29233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29234. */
  29235. /**
  29236. * Sets the current loading screen object
  29237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29238. */
  29239. loadingScreen: ILoadingScreen;
  29240. /**
  29241. * Sets the current loading screen text
  29242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29243. */
  29244. loadingUIText: string;
  29245. /**
  29246. * Sets the current loading screen background color
  29247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29248. */
  29249. loadingUIBackgroundColor: string;
  29250. /**
  29251. * Attach a new callback raised when context lost event is fired
  29252. * @param callback defines the callback to call
  29253. */
  29254. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29255. /**
  29256. * Attach a new callback raised when context restored event is fired
  29257. * @param callback defines the callback to call
  29258. */
  29259. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29260. /**
  29261. * Gets the source code of the vertex shader associated with a specific webGL program
  29262. * @param program defines the program to use
  29263. * @returns a string containing the source code of the vertex shader associated with the program
  29264. */
  29265. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29266. /**
  29267. * Gets the source code of the fragment shader associated with a specific webGL program
  29268. * @param program defines the program to use
  29269. * @returns a string containing the source code of the fragment shader associated with the program
  29270. */
  29271. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29272. /**
  29273. * Get the current error code of the webGL context
  29274. * @returns the error code
  29275. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29276. */
  29277. getError(): number;
  29278. /**
  29279. * Gets the current framerate
  29280. * @returns a number representing the framerate
  29281. */
  29282. getFps(): number;
  29283. /**
  29284. * Gets the time spent between current and previous frame
  29285. * @returns a number representing the delta time in ms
  29286. */
  29287. getDeltaTime(): number;
  29288. private _measureFps;
  29289. /** @hidden */
  29290. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29291. private _canRenderToFloatFramebuffer;
  29292. private _canRenderToHalfFloatFramebuffer;
  29293. private _canRenderToFramebuffer;
  29294. /** @hidden */
  29295. _getWebGLTextureType(type: number): number;
  29296. /** @hidden */
  29297. _getInternalFormat(format: number): number;
  29298. /** @hidden */
  29299. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29300. /** @hidden */
  29301. _getRGBAMultiSampleBufferFormat(type: number): number;
  29302. /** @hidden */
  29303. _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;
  29304. /** @hidden */
  29305. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29306. /**
  29307. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29308. * @returns true if the engine can be created
  29309. * @ignorenaming
  29310. */
  29311. static isSupported(): boolean;
  29312. }
  29313. }
  29314. declare module BABYLON {
  29315. /**
  29316. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29317. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29318. */
  29319. export class EffectFallbacks {
  29320. private _defines;
  29321. private _currentRank;
  29322. private _maxRank;
  29323. private _mesh;
  29324. /**
  29325. * Removes the fallback from the bound mesh.
  29326. */
  29327. unBindMesh(): void;
  29328. /**
  29329. * Adds a fallback on the specified property.
  29330. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29331. * @param define The name of the define in the shader
  29332. */
  29333. addFallback(rank: number, define: string): void;
  29334. /**
  29335. * Sets the mesh to use CPU skinning when needing to fallback.
  29336. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29337. * @param mesh The mesh to use the fallbacks.
  29338. */
  29339. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29340. /**
  29341. * Checks to see if more fallbacks are still availible.
  29342. */
  29343. readonly isMoreFallbacks: boolean;
  29344. /**
  29345. * Removes the defines that should be removed when falling back.
  29346. * @param currentDefines defines the current define statements for the shader.
  29347. * @param effect defines the current effect we try to compile
  29348. * @returns The resulting defines with defines of the current rank removed.
  29349. */
  29350. reduce(currentDefines: string, effect: Effect): string;
  29351. }
  29352. /**
  29353. * Options to be used when creating an effect.
  29354. */
  29355. export class EffectCreationOptions {
  29356. /**
  29357. * Atrributes that will be used in the shader.
  29358. */
  29359. attributes: string[];
  29360. /**
  29361. * Uniform varible names that will be set in the shader.
  29362. */
  29363. uniformsNames: string[];
  29364. /**
  29365. * Uniform buffer varible names that will be set in the shader.
  29366. */
  29367. uniformBuffersNames: string[];
  29368. /**
  29369. * Sampler texture variable names that will be set in the shader.
  29370. */
  29371. samplers: string[];
  29372. /**
  29373. * Define statements that will be set in the shader.
  29374. */
  29375. defines: any;
  29376. /**
  29377. * Possible fallbacks for this effect to improve performance when needed.
  29378. */
  29379. fallbacks: Nullable<EffectFallbacks>;
  29380. /**
  29381. * Callback that will be called when the shader is compiled.
  29382. */
  29383. onCompiled: Nullable<(effect: Effect) => void>;
  29384. /**
  29385. * Callback that will be called if an error occurs during shader compilation.
  29386. */
  29387. onError: Nullable<(effect: Effect, errors: string) => void>;
  29388. /**
  29389. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29390. */
  29391. indexParameters: any;
  29392. /**
  29393. * Max number of lights that can be used in the shader.
  29394. */
  29395. maxSimultaneousLights: number;
  29396. /**
  29397. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29398. */
  29399. transformFeedbackVaryings: Nullable<string[]>;
  29400. }
  29401. /**
  29402. * Effect containing vertex and fragment shader that can be executed on an object.
  29403. */
  29404. export class Effect implements IDisposable {
  29405. /**
  29406. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29407. */
  29408. static ShadersRepository: string;
  29409. /**
  29410. * Name of the effect.
  29411. */
  29412. name: any;
  29413. /**
  29414. * String container all the define statements that should be set on the shader.
  29415. */
  29416. defines: string;
  29417. /**
  29418. * Callback that will be called when the shader is compiled.
  29419. */
  29420. onCompiled: Nullable<(effect: Effect) => void>;
  29421. /**
  29422. * Callback that will be called if an error occurs during shader compilation.
  29423. */
  29424. onError: Nullable<(effect: Effect, errors: string) => void>;
  29425. /**
  29426. * Callback that will be called when effect is bound.
  29427. */
  29428. onBind: Nullable<(effect: Effect) => void>;
  29429. /**
  29430. * Unique ID of the effect.
  29431. */
  29432. uniqueId: number;
  29433. /**
  29434. * Observable that will be called when the shader is compiled.
  29435. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29436. */
  29437. onCompileObservable: Observable<Effect>;
  29438. /**
  29439. * Observable that will be called if an error occurs during shader compilation.
  29440. */
  29441. onErrorObservable: Observable<Effect>;
  29442. /** @hidden */
  29443. _onBindObservable: Nullable<Observable<Effect>>;
  29444. /**
  29445. * Observable that will be called when effect is bound.
  29446. */
  29447. readonly onBindObservable: Observable<Effect>;
  29448. /** @hidden */
  29449. _bonesComputationForcedToCPU: boolean;
  29450. private static _uniqueIdSeed;
  29451. private _engine;
  29452. private _uniformBuffersNames;
  29453. private _uniformsNames;
  29454. private _samplerList;
  29455. private _samplers;
  29456. private _isReady;
  29457. private _compilationError;
  29458. private _attributesNames;
  29459. private _attributes;
  29460. private _uniforms;
  29461. /**
  29462. * Key for the effect.
  29463. * @hidden
  29464. */
  29465. _key: string;
  29466. private _indexParameters;
  29467. private _fallbacks;
  29468. private _vertexSourceCode;
  29469. private _fragmentSourceCode;
  29470. private _vertexSourceCodeOverride;
  29471. private _fragmentSourceCodeOverride;
  29472. private _transformFeedbackVaryings;
  29473. /**
  29474. * Compiled shader to webGL program.
  29475. * @hidden
  29476. */
  29477. _pipelineContext: Nullable<IPipelineContext>;
  29478. private _valueCache;
  29479. private static _baseCache;
  29480. /**
  29481. * Instantiates an effect.
  29482. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29483. * @param baseName Name of the effect.
  29484. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29485. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29486. * @param samplers List of sampler variables that will be passed to the shader.
  29487. * @param engine Engine to be used to render the effect
  29488. * @param defines Define statements to be added to the shader.
  29489. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29490. * @param onCompiled Callback that will be called when the shader is compiled.
  29491. * @param onError Callback that will be called if an error occurs during shader compilation.
  29492. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29493. */
  29494. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29495. private _useFinalCode;
  29496. /**
  29497. * Unique key for this effect
  29498. */
  29499. readonly key: string;
  29500. /**
  29501. * If the effect has been compiled and prepared.
  29502. * @returns if the effect is compiled and prepared.
  29503. */
  29504. isReady(): boolean;
  29505. /**
  29506. * The engine the effect was initialized with.
  29507. * @returns the engine.
  29508. */
  29509. getEngine(): Engine;
  29510. /**
  29511. * The pipeline context for this effect
  29512. * @returns the associated pipeline context
  29513. */
  29514. getPipelineContext(): Nullable<IPipelineContext>;
  29515. /**
  29516. * The set of names of attribute variables for the shader.
  29517. * @returns An array of attribute names.
  29518. */
  29519. getAttributesNames(): string[];
  29520. /**
  29521. * Returns the attribute at the given index.
  29522. * @param index The index of the attribute.
  29523. * @returns The location of the attribute.
  29524. */
  29525. getAttributeLocation(index: number): number;
  29526. /**
  29527. * Returns the attribute based on the name of the variable.
  29528. * @param name of the attribute to look up.
  29529. * @returns the attribute location.
  29530. */
  29531. getAttributeLocationByName(name: string): number;
  29532. /**
  29533. * The number of attributes.
  29534. * @returns the numnber of attributes.
  29535. */
  29536. getAttributesCount(): number;
  29537. /**
  29538. * Gets the index of a uniform variable.
  29539. * @param uniformName of the uniform to look up.
  29540. * @returns the index.
  29541. */
  29542. getUniformIndex(uniformName: string): number;
  29543. /**
  29544. * Returns the attribute based on the name of the variable.
  29545. * @param uniformName of the uniform to look up.
  29546. * @returns the location of the uniform.
  29547. */
  29548. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29549. /**
  29550. * Returns an array of sampler variable names
  29551. * @returns The array of sampler variable neames.
  29552. */
  29553. getSamplers(): string[];
  29554. /**
  29555. * The error from the last compilation.
  29556. * @returns the error string.
  29557. */
  29558. getCompilationError(): string;
  29559. /**
  29560. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29561. * @param func The callback to be used.
  29562. */
  29563. executeWhenCompiled(func: (effect: Effect) => void): void;
  29564. private _checkIsReady;
  29565. /** @hidden */
  29566. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29567. /** @hidden */
  29568. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29569. /** @hidden */
  29570. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29571. /**
  29572. * Recompiles the webGL program
  29573. * @param vertexSourceCode The source code for the vertex shader.
  29574. * @param fragmentSourceCode The source code for the fragment shader.
  29575. * @param onCompiled Callback called when completed.
  29576. * @param onError Callback called on error.
  29577. * @hidden
  29578. */
  29579. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29580. /**
  29581. * Prepares the effect
  29582. * @hidden
  29583. */
  29584. _prepareEffect(): void;
  29585. /**
  29586. * Checks if the effect is supported. (Must be called after compilation)
  29587. */
  29588. readonly isSupported: boolean;
  29589. /**
  29590. * Binds a texture to the engine to be used as output of the shader.
  29591. * @param channel Name of the output variable.
  29592. * @param texture Texture to bind.
  29593. * @hidden
  29594. */
  29595. _bindTexture(channel: string, texture: InternalTexture): void;
  29596. /**
  29597. * Sets a texture on the engine to be used in the shader.
  29598. * @param channel Name of the sampler variable.
  29599. * @param texture Texture to set.
  29600. */
  29601. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29602. /**
  29603. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29604. * @param channel Name of the sampler variable.
  29605. * @param texture Texture to set.
  29606. */
  29607. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29608. /**
  29609. * Sets an array of textures on the engine to be used in the shader.
  29610. * @param channel Name of the variable.
  29611. * @param textures Textures to set.
  29612. */
  29613. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29614. /**
  29615. * 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)
  29616. * @param channel Name of the sampler variable.
  29617. * @param postProcess Post process to get the input texture from.
  29618. */
  29619. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29620. /**
  29621. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29622. * 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)
  29623. * @param channel Name of the sampler variable.
  29624. * @param postProcess Post process to get the output texture from.
  29625. */
  29626. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29627. /** @hidden */
  29628. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29629. /** @hidden */
  29630. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29631. /** @hidden */
  29632. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29633. /** @hidden */
  29634. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29635. /**
  29636. * Binds a buffer to a uniform.
  29637. * @param buffer Buffer to bind.
  29638. * @param name Name of the uniform variable to bind to.
  29639. */
  29640. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29641. /**
  29642. * Binds block to a uniform.
  29643. * @param blockName Name of the block to bind.
  29644. * @param index Index to bind.
  29645. */
  29646. bindUniformBlock(blockName: string, index: number): void;
  29647. /**
  29648. * Sets an interger value on a uniform variable.
  29649. * @param uniformName Name of the variable.
  29650. * @param value Value to be set.
  29651. * @returns this effect.
  29652. */
  29653. setInt(uniformName: string, value: number): Effect;
  29654. /**
  29655. * Sets an int array on a uniform variable.
  29656. * @param uniformName Name of the variable.
  29657. * @param array array to be set.
  29658. * @returns this effect.
  29659. */
  29660. setIntArray(uniformName: string, array: Int32Array): Effect;
  29661. /**
  29662. * 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)
  29663. * @param uniformName Name of the variable.
  29664. * @param array array to be set.
  29665. * @returns this effect.
  29666. */
  29667. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29668. /**
  29669. * 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)
  29670. * @param uniformName Name of the variable.
  29671. * @param array array to be set.
  29672. * @returns this effect.
  29673. */
  29674. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29675. /**
  29676. * 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)
  29677. * @param uniformName Name of the variable.
  29678. * @param array array to be set.
  29679. * @returns this effect.
  29680. */
  29681. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29682. /**
  29683. * Sets an float array on a uniform variable.
  29684. * @param uniformName Name of the variable.
  29685. * @param array array to be set.
  29686. * @returns this effect.
  29687. */
  29688. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29689. /**
  29690. * 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)
  29691. * @param uniformName Name of the variable.
  29692. * @param array array to be set.
  29693. * @returns this effect.
  29694. */
  29695. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29696. /**
  29697. * 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)
  29698. * @param uniformName Name of the variable.
  29699. * @param array array to be set.
  29700. * @returns this effect.
  29701. */
  29702. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29703. /**
  29704. * 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)
  29705. * @param uniformName Name of the variable.
  29706. * @param array array to be set.
  29707. * @returns this effect.
  29708. */
  29709. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29710. /**
  29711. * Sets an array on a uniform variable.
  29712. * @param uniformName Name of the variable.
  29713. * @param array array to be set.
  29714. * @returns this effect.
  29715. */
  29716. setArray(uniformName: string, array: number[]): Effect;
  29717. /**
  29718. * 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)
  29719. * @param uniformName Name of the variable.
  29720. * @param array array to be set.
  29721. * @returns this effect.
  29722. */
  29723. setArray2(uniformName: string, array: number[]): Effect;
  29724. /**
  29725. * 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)
  29726. * @param uniformName Name of the variable.
  29727. * @param array array to be set.
  29728. * @returns this effect.
  29729. */
  29730. setArray3(uniformName: string, array: number[]): Effect;
  29731. /**
  29732. * 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)
  29733. * @param uniformName Name of the variable.
  29734. * @param array array to be set.
  29735. * @returns this effect.
  29736. */
  29737. setArray4(uniformName: string, array: number[]): Effect;
  29738. /**
  29739. * Sets matrices on a uniform variable.
  29740. * @param uniformName Name of the variable.
  29741. * @param matrices matrices to be set.
  29742. * @returns this effect.
  29743. */
  29744. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29745. /**
  29746. * Sets matrix on a uniform variable.
  29747. * @param uniformName Name of the variable.
  29748. * @param matrix matrix to be set.
  29749. * @returns this effect.
  29750. */
  29751. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29752. /**
  29753. * 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)
  29754. * @param uniformName Name of the variable.
  29755. * @param matrix matrix to be set.
  29756. * @returns this effect.
  29757. */
  29758. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29759. /**
  29760. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29761. * @param uniformName Name of the variable.
  29762. * @param matrix matrix to be set.
  29763. * @returns this effect.
  29764. */
  29765. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29766. /**
  29767. * Sets a float on a uniform variable.
  29768. * @param uniformName Name of the variable.
  29769. * @param value value to be set.
  29770. * @returns this effect.
  29771. */
  29772. setFloat(uniformName: string, value: number): Effect;
  29773. /**
  29774. * Sets a boolean on a uniform variable.
  29775. * @param uniformName Name of the variable.
  29776. * @param bool value to be set.
  29777. * @returns this effect.
  29778. */
  29779. setBool(uniformName: string, bool: boolean): Effect;
  29780. /**
  29781. * Sets a Vector2 on a uniform variable.
  29782. * @param uniformName Name of the variable.
  29783. * @param vector2 vector2 to be set.
  29784. * @returns this effect.
  29785. */
  29786. setVector2(uniformName: string, vector2: Vector2): Effect;
  29787. /**
  29788. * Sets a float2 on a uniform variable.
  29789. * @param uniformName Name of the variable.
  29790. * @param x First float in float2.
  29791. * @param y Second float in float2.
  29792. * @returns this effect.
  29793. */
  29794. setFloat2(uniformName: string, x: number, y: number): Effect;
  29795. /**
  29796. * Sets a Vector3 on a uniform variable.
  29797. * @param uniformName Name of the variable.
  29798. * @param vector3 Value to be set.
  29799. * @returns this effect.
  29800. */
  29801. setVector3(uniformName: string, vector3: Vector3): Effect;
  29802. /**
  29803. * Sets a float3 on a uniform variable.
  29804. * @param uniformName Name of the variable.
  29805. * @param x First float in float3.
  29806. * @param y Second float in float3.
  29807. * @param z Third float in float3.
  29808. * @returns this effect.
  29809. */
  29810. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29811. /**
  29812. * Sets a Vector4 on a uniform variable.
  29813. * @param uniformName Name of the variable.
  29814. * @param vector4 Value to be set.
  29815. * @returns this effect.
  29816. */
  29817. setVector4(uniformName: string, vector4: Vector4): Effect;
  29818. /**
  29819. * Sets a float4 on a uniform variable.
  29820. * @param uniformName Name of the variable.
  29821. * @param x First float in float4.
  29822. * @param y Second float in float4.
  29823. * @param z Third float in float4.
  29824. * @param w Fourth float in float4.
  29825. * @returns this effect.
  29826. */
  29827. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29828. /**
  29829. * Sets a Color3 on a uniform variable.
  29830. * @param uniformName Name of the variable.
  29831. * @param color3 Value to be set.
  29832. * @returns this effect.
  29833. */
  29834. setColor3(uniformName: string, color3: Color3): Effect;
  29835. /**
  29836. * Sets a Color4 on a uniform variable.
  29837. * @param uniformName Name of the variable.
  29838. * @param color3 Value to be set.
  29839. * @param alpha Alpha value to be set.
  29840. * @returns this effect.
  29841. */
  29842. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29843. /**
  29844. * Sets a Color4 on a uniform variable
  29845. * @param uniformName defines the name of the variable
  29846. * @param color4 defines the value to be set
  29847. * @returns this effect.
  29848. */
  29849. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29850. /** Release all associated resources */
  29851. dispose(): void;
  29852. /**
  29853. * This function will add a new shader to the shader store
  29854. * @param name the name of the shader
  29855. * @param pixelShader optional pixel shader content
  29856. * @param vertexShader optional vertex shader content
  29857. */
  29858. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29859. /**
  29860. * Store of each shader (The can be looked up using effect.key)
  29861. */
  29862. static ShadersStore: {
  29863. [key: string]: string;
  29864. };
  29865. /**
  29866. * Store of each included file for a shader (The can be looked up using effect.key)
  29867. */
  29868. static IncludesShadersStore: {
  29869. [key: string]: string;
  29870. };
  29871. /**
  29872. * Resets the cache of effects.
  29873. */
  29874. static ResetCache(): void;
  29875. }
  29876. }
  29877. declare module BABYLON {
  29878. /**
  29879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29881. * 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;
  29882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29883. */
  29884. export class ColorCurves {
  29885. private _dirty;
  29886. private _tempColor;
  29887. private _globalCurve;
  29888. private _highlightsCurve;
  29889. private _midtonesCurve;
  29890. private _shadowsCurve;
  29891. private _positiveCurve;
  29892. private _negativeCurve;
  29893. private _globalHue;
  29894. private _globalDensity;
  29895. private _globalSaturation;
  29896. private _globalExposure;
  29897. /**
  29898. * Gets the global Hue value.
  29899. * 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).
  29900. */
  29901. /**
  29902. * Sets the global Hue value.
  29903. * 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).
  29904. */
  29905. globalHue: number;
  29906. /**
  29907. * Gets the global Density value.
  29908. * 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.
  29909. * Values less than zero provide a filter of opposite hue.
  29910. */
  29911. /**
  29912. * Sets the global Density value.
  29913. * 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.
  29914. * Values less than zero provide a filter of opposite hue.
  29915. */
  29916. globalDensity: number;
  29917. /**
  29918. * Gets the global Saturation value.
  29919. * 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.
  29920. */
  29921. /**
  29922. * Sets the global Saturation value.
  29923. * 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.
  29924. */
  29925. globalSaturation: number;
  29926. /**
  29927. * Gets the global Exposure value.
  29928. * 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.
  29929. */
  29930. /**
  29931. * Sets the global Exposure value.
  29932. * 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.
  29933. */
  29934. globalExposure: number;
  29935. private _highlightsHue;
  29936. private _highlightsDensity;
  29937. private _highlightsSaturation;
  29938. private _highlightsExposure;
  29939. /**
  29940. * Gets the highlights Hue value.
  29941. * 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).
  29942. */
  29943. /**
  29944. * Sets the highlights Hue value.
  29945. * 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).
  29946. */
  29947. highlightsHue: number;
  29948. /**
  29949. * Gets the highlights Density value.
  29950. * 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.
  29951. * Values less than zero provide a filter of opposite hue.
  29952. */
  29953. /**
  29954. * Sets the highlights Density value.
  29955. * 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.
  29956. * Values less than zero provide a filter of opposite hue.
  29957. */
  29958. highlightsDensity: number;
  29959. /**
  29960. * Gets the highlights Saturation value.
  29961. * 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.
  29962. */
  29963. /**
  29964. * Sets the highlights Saturation value.
  29965. * 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.
  29966. */
  29967. highlightsSaturation: number;
  29968. /**
  29969. * Gets the highlights Exposure value.
  29970. * 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.
  29971. */
  29972. /**
  29973. * Sets the highlights Exposure value.
  29974. * 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.
  29975. */
  29976. highlightsExposure: number;
  29977. private _midtonesHue;
  29978. private _midtonesDensity;
  29979. private _midtonesSaturation;
  29980. private _midtonesExposure;
  29981. /**
  29982. * Gets the midtones Hue value.
  29983. * 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).
  29984. */
  29985. /**
  29986. * Sets the midtones Hue value.
  29987. * 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).
  29988. */
  29989. midtonesHue: number;
  29990. /**
  29991. * Gets the midtones Density value.
  29992. * 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.
  29993. * Values less than zero provide a filter of opposite hue.
  29994. */
  29995. /**
  29996. * Sets the midtones Density value.
  29997. * 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.
  29998. * Values less than zero provide a filter of opposite hue.
  29999. */
  30000. midtonesDensity: number;
  30001. /**
  30002. * Gets the midtones Saturation value.
  30003. * 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.
  30004. */
  30005. /**
  30006. * Sets the midtones Saturation value.
  30007. * 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.
  30008. */
  30009. midtonesSaturation: number;
  30010. /**
  30011. * Gets the midtones Exposure value.
  30012. * 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.
  30013. */
  30014. /**
  30015. * Sets the midtones Exposure value.
  30016. * 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.
  30017. */
  30018. midtonesExposure: number;
  30019. private _shadowsHue;
  30020. private _shadowsDensity;
  30021. private _shadowsSaturation;
  30022. private _shadowsExposure;
  30023. /**
  30024. * Gets the shadows Hue value.
  30025. * 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).
  30026. */
  30027. /**
  30028. * Sets the shadows Hue value.
  30029. * 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).
  30030. */
  30031. shadowsHue: number;
  30032. /**
  30033. * Gets the shadows Density value.
  30034. * 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.
  30035. * Values less than zero provide a filter of opposite hue.
  30036. */
  30037. /**
  30038. * Sets the shadows Density value.
  30039. * 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.
  30040. * Values less than zero provide a filter of opposite hue.
  30041. */
  30042. shadowsDensity: number;
  30043. /**
  30044. * Gets the shadows Saturation value.
  30045. * 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.
  30046. */
  30047. /**
  30048. * Sets the shadows Saturation value.
  30049. * 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.
  30050. */
  30051. shadowsSaturation: number;
  30052. /**
  30053. * Gets the shadows Exposure value.
  30054. * 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.
  30055. */
  30056. /**
  30057. * Sets the shadows Exposure value.
  30058. * 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.
  30059. */
  30060. shadowsExposure: number;
  30061. /**
  30062. * Returns the class name
  30063. * @returns The class name
  30064. */
  30065. getClassName(): string;
  30066. /**
  30067. * Binds the color curves to the shader.
  30068. * @param colorCurves The color curve to bind
  30069. * @param effect The effect to bind to
  30070. * @param positiveUniform The positive uniform shader parameter
  30071. * @param neutralUniform The neutral uniform shader parameter
  30072. * @param negativeUniform The negative uniform shader parameter
  30073. */
  30074. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30075. /**
  30076. * Prepare the list of uniforms associated with the ColorCurves effects.
  30077. * @param uniformsList The list of uniforms used in the effect
  30078. */
  30079. static PrepareUniforms(uniformsList: string[]): void;
  30080. /**
  30081. * Returns color grading data based on a hue, density, saturation and exposure value.
  30082. * @param filterHue The hue of the color filter.
  30083. * @param filterDensity The density of the color filter.
  30084. * @param saturation The saturation.
  30085. * @param exposure The exposure.
  30086. * @param result The result data container.
  30087. */
  30088. private getColorGradingDataToRef;
  30089. /**
  30090. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30091. * @param value The input slider value in range [-100,100].
  30092. * @returns Adjusted value.
  30093. */
  30094. private static applyColorGradingSliderNonlinear;
  30095. /**
  30096. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30097. * @param hue The hue (H) input.
  30098. * @param saturation The saturation (S) input.
  30099. * @param brightness The brightness (B) input.
  30100. * @result An RGBA color represented as Vector4.
  30101. */
  30102. private static fromHSBToRef;
  30103. /**
  30104. * Returns a value clamped between min and max
  30105. * @param value The value to clamp
  30106. * @param min The minimum of value
  30107. * @param max The maximum of value
  30108. * @returns The clamped value.
  30109. */
  30110. private static clamp;
  30111. /**
  30112. * Clones the current color curve instance.
  30113. * @return The cloned curves
  30114. */
  30115. clone(): ColorCurves;
  30116. /**
  30117. * Serializes the current color curve instance to a json representation.
  30118. * @return a JSON representation
  30119. */
  30120. serialize(): any;
  30121. /**
  30122. * Parses the color curve from a json representation.
  30123. * @param source the JSON source to parse
  30124. * @return The parsed curves
  30125. */
  30126. static Parse(source: any): ColorCurves;
  30127. }
  30128. }
  30129. declare module BABYLON {
  30130. /**
  30131. * Interface to follow in your material defines to integrate easily the
  30132. * Image proccessing functions.
  30133. * @hidden
  30134. */
  30135. export interface IImageProcessingConfigurationDefines {
  30136. IMAGEPROCESSING: boolean;
  30137. VIGNETTE: boolean;
  30138. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30139. VIGNETTEBLENDMODEOPAQUE: boolean;
  30140. TONEMAPPING: boolean;
  30141. TONEMAPPING_ACES: boolean;
  30142. CONTRAST: boolean;
  30143. EXPOSURE: boolean;
  30144. COLORCURVES: boolean;
  30145. COLORGRADING: boolean;
  30146. COLORGRADING3D: boolean;
  30147. SAMPLER3DGREENDEPTH: boolean;
  30148. SAMPLER3DBGRMAP: boolean;
  30149. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30150. }
  30151. /**
  30152. * @hidden
  30153. */
  30154. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30155. IMAGEPROCESSING: boolean;
  30156. VIGNETTE: boolean;
  30157. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30158. VIGNETTEBLENDMODEOPAQUE: boolean;
  30159. TONEMAPPING: boolean;
  30160. TONEMAPPING_ACES: boolean;
  30161. CONTRAST: boolean;
  30162. COLORCURVES: boolean;
  30163. COLORGRADING: boolean;
  30164. COLORGRADING3D: boolean;
  30165. SAMPLER3DGREENDEPTH: boolean;
  30166. SAMPLER3DBGRMAP: boolean;
  30167. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30168. EXPOSURE: boolean;
  30169. constructor();
  30170. }
  30171. /**
  30172. * This groups together the common properties used for image processing either in direct forward pass
  30173. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30174. * or not.
  30175. */
  30176. export class ImageProcessingConfiguration {
  30177. /**
  30178. * Default tone mapping applied in BabylonJS.
  30179. */
  30180. static readonly TONEMAPPING_STANDARD: number;
  30181. /**
  30182. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30183. * to other engines rendering to increase portability.
  30184. */
  30185. static readonly TONEMAPPING_ACES: number;
  30186. /**
  30187. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30188. */
  30189. colorCurves: Nullable<ColorCurves>;
  30190. private _colorCurvesEnabled;
  30191. /**
  30192. * Gets wether the color curves effect is enabled.
  30193. */
  30194. /**
  30195. * Sets wether the color curves effect is enabled.
  30196. */
  30197. colorCurvesEnabled: boolean;
  30198. private _colorGradingTexture;
  30199. /**
  30200. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30201. */
  30202. /**
  30203. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30204. */
  30205. colorGradingTexture: Nullable<BaseTexture>;
  30206. private _colorGradingEnabled;
  30207. /**
  30208. * Gets wether the color grading effect is enabled.
  30209. */
  30210. /**
  30211. * Sets wether the color grading effect is enabled.
  30212. */
  30213. colorGradingEnabled: boolean;
  30214. private _colorGradingWithGreenDepth;
  30215. /**
  30216. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30217. */
  30218. /**
  30219. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30220. */
  30221. colorGradingWithGreenDepth: boolean;
  30222. private _colorGradingBGR;
  30223. /**
  30224. * Gets wether the color grading texture contains BGR values.
  30225. */
  30226. /**
  30227. * Sets wether the color grading texture contains BGR values.
  30228. */
  30229. colorGradingBGR: boolean;
  30230. /** @hidden */
  30231. _exposure: number;
  30232. /**
  30233. * Gets the Exposure used in the effect.
  30234. */
  30235. /**
  30236. * Sets the Exposure used in the effect.
  30237. */
  30238. exposure: number;
  30239. private _toneMappingEnabled;
  30240. /**
  30241. * Gets wether the tone mapping effect is enabled.
  30242. */
  30243. /**
  30244. * Sets wether the tone mapping effect is enabled.
  30245. */
  30246. toneMappingEnabled: boolean;
  30247. private _toneMappingType;
  30248. /**
  30249. * Gets the type of tone mapping effect.
  30250. */
  30251. /**
  30252. * Sets the type of tone mapping effect used in BabylonJS.
  30253. */
  30254. toneMappingType: number;
  30255. protected _contrast: number;
  30256. /**
  30257. * Gets the contrast used in the effect.
  30258. */
  30259. /**
  30260. * Sets the contrast used in the effect.
  30261. */
  30262. contrast: number;
  30263. /**
  30264. * Vignette stretch size.
  30265. */
  30266. vignetteStretch: number;
  30267. /**
  30268. * Vignette centre X Offset.
  30269. */
  30270. vignetteCentreX: number;
  30271. /**
  30272. * Vignette centre Y Offset.
  30273. */
  30274. vignetteCentreY: number;
  30275. /**
  30276. * Vignette weight or intensity of the vignette effect.
  30277. */
  30278. vignetteWeight: number;
  30279. /**
  30280. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30281. * if vignetteEnabled is set to true.
  30282. */
  30283. vignetteColor: Color4;
  30284. /**
  30285. * Camera field of view used by the Vignette effect.
  30286. */
  30287. vignetteCameraFov: number;
  30288. private _vignetteBlendMode;
  30289. /**
  30290. * Gets the vignette blend mode allowing different kind of effect.
  30291. */
  30292. /**
  30293. * Sets the vignette blend mode allowing different kind of effect.
  30294. */
  30295. vignetteBlendMode: number;
  30296. private _vignetteEnabled;
  30297. /**
  30298. * Gets wether the vignette effect is enabled.
  30299. */
  30300. /**
  30301. * Sets wether the vignette effect is enabled.
  30302. */
  30303. vignetteEnabled: boolean;
  30304. private _applyByPostProcess;
  30305. /**
  30306. * Gets wether the image processing is applied through a post process or not.
  30307. */
  30308. /**
  30309. * Sets wether the image processing is applied through a post process or not.
  30310. */
  30311. applyByPostProcess: boolean;
  30312. private _isEnabled;
  30313. /**
  30314. * Gets wether the image processing is enabled or not.
  30315. */
  30316. /**
  30317. * Sets wether the image processing is enabled or not.
  30318. */
  30319. isEnabled: boolean;
  30320. /**
  30321. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30322. */
  30323. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30324. /**
  30325. * Method called each time the image processing information changes requires to recompile the effect.
  30326. */
  30327. protected _updateParameters(): void;
  30328. /**
  30329. * Gets the current class name.
  30330. * @return "ImageProcessingConfiguration"
  30331. */
  30332. getClassName(): string;
  30333. /**
  30334. * Prepare the list of uniforms associated with the Image Processing effects.
  30335. * @param uniforms The list of uniforms used in the effect
  30336. * @param defines the list of defines currently in use
  30337. */
  30338. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30339. /**
  30340. * Prepare the list of samplers associated with the Image Processing effects.
  30341. * @param samplersList The list of uniforms used in the effect
  30342. * @param defines the list of defines currently in use
  30343. */
  30344. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30345. /**
  30346. * Prepare the list of defines associated to the shader.
  30347. * @param defines the list of defines to complete
  30348. * @param forPostProcess Define if we are currently in post process mode or not
  30349. */
  30350. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30351. /**
  30352. * Returns true if all the image processing information are ready.
  30353. * @returns True if ready, otherwise, false
  30354. */
  30355. isReady(): boolean;
  30356. /**
  30357. * Binds the image processing to the shader.
  30358. * @param effect The effect to bind to
  30359. * @param aspectRatio Define the current aspect ratio of the effect
  30360. */
  30361. bind(effect: Effect, aspectRatio?: number): void;
  30362. /**
  30363. * Clones the current image processing instance.
  30364. * @return The cloned image processing
  30365. */
  30366. clone(): ImageProcessingConfiguration;
  30367. /**
  30368. * Serializes the current image processing instance to a json representation.
  30369. * @return a JSON representation
  30370. */
  30371. serialize(): any;
  30372. /**
  30373. * Parses the image processing from a json representation.
  30374. * @param source the JSON source to parse
  30375. * @return The parsed image processing
  30376. */
  30377. static Parse(source: any): ImageProcessingConfiguration;
  30378. private static _VIGNETTEMODE_MULTIPLY;
  30379. private static _VIGNETTEMODE_OPAQUE;
  30380. /**
  30381. * Used to apply the vignette as a mix with the pixel color.
  30382. */
  30383. static readonly VIGNETTEMODE_MULTIPLY: number;
  30384. /**
  30385. * Used to apply the vignette as a replacement of the pixel color.
  30386. */
  30387. static readonly VIGNETTEMODE_OPAQUE: number;
  30388. }
  30389. }
  30390. declare module BABYLON {
  30391. /**
  30392. * This represents all the required information to add a fresnel effect on a material:
  30393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30394. */
  30395. export class FresnelParameters {
  30396. private _isEnabled;
  30397. /**
  30398. * Define if the fresnel effect is enable or not.
  30399. */
  30400. isEnabled: boolean;
  30401. /**
  30402. * Define the color used on edges (grazing angle)
  30403. */
  30404. leftColor: Color3;
  30405. /**
  30406. * Define the color used on center
  30407. */
  30408. rightColor: Color3;
  30409. /**
  30410. * Define bias applied to computed fresnel term
  30411. */
  30412. bias: number;
  30413. /**
  30414. * Defined the power exponent applied to fresnel term
  30415. */
  30416. power: number;
  30417. /**
  30418. * Clones the current fresnel and its valuues
  30419. * @returns a clone fresnel configuration
  30420. */
  30421. clone(): FresnelParameters;
  30422. /**
  30423. * Serializes the current fresnel parameters to a JSON representation.
  30424. * @return the JSON serialization
  30425. */
  30426. serialize(): any;
  30427. /**
  30428. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30429. * @param parsedFresnelParameters Define the JSON representation
  30430. * @returns the parsed parameters
  30431. */
  30432. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30433. }
  30434. }
  30435. declare module BABYLON {
  30436. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30437. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30446. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30447. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30448. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30449. /**
  30450. * Decorator used to define property that can be serialized as reference to a camera
  30451. * @param sourceName defines the name of the property to decorate
  30452. */
  30453. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30454. /**
  30455. * Class used to help serialization objects
  30456. */
  30457. export class SerializationHelper {
  30458. /** @hidden */
  30459. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30460. /** @hidden */
  30461. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30462. /** @hidden */
  30463. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30464. /** @hidden */
  30465. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30466. /**
  30467. * Appends the serialized animations from the source animations
  30468. * @param source Source containing the animations
  30469. * @param destination Target to store the animations
  30470. */
  30471. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30472. /**
  30473. * Static function used to serialized a specific entity
  30474. * @param entity defines the entity to serialize
  30475. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30476. * @returns a JSON compatible object representing the serialization of the entity
  30477. */
  30478. static Serialize<T>(entity: T, serializationObject?: any): any;
  30479. /**
  30480. * Creates a new entity from a serialization data object
  30481. * @param creationFunction defines a function used to instanciated the new entity
  30482. * @param source defines the source serialization data
  30483. * @param scene defines the hosting scene
  30484. * @param rootUrl defines the root url for resources
  30485. * @returns a new entity
  30486. */
  30487. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30488. /**
  30489. * Clones an object
  30490. * @param creationFunction defines the function used to instanciate the new object
  30491. * @param source defines the source object
  30492. * @returns the cloned object
  30493. */
  30494. static Clone<T>(creationFunction: () => T, source: T): T;
  30495. /**
  30496. * Instanciates a new object based on a source one (some data will be shared between both object)
  30497. * @param creationFunction defines the function used to instanciate the new object
  30498. * @param source defines the source object
  30499. * @returns the new object
  30500. */
  30501. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30502. }
  30503. }
  30504. declare module BABYLON {
  30505. /**
  30506. * This is the base class of all the camera used in the application.
  30507. * @see http://doc.babylonjs.com/features/cameras
  30508. */
  30509. export class Camera extends Node {
  30510. /** @hidden */
  30511. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30512. /**
  30513. * This is the default projection mode used by the cameras.
  30514. * It helps recreating a feeling of perspective and better appreciate depth.
  30515. * This is the best way to simulate real life cameras.
  30516. */
  30517. static readonly PERSPECTIVE_CAMERA: number;
  30518. /**
  30519. * This helps creating camera with an orthographic mode.
  30520. * 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.
  30521. */
  30522. static readonly ORTHOGRAPHIC_CAMERA: number;
  30523. /**
  30524. * This is the default FOV mode for perspective cameras.
  30525. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30526. */
  30527. static readonly FOVMODE_VERTICAL_FIXED: number;
  30528. /**
  30529. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30530. */
  30531. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30532. /**
  30533. * This specifies ther is no need for a camera rig.
  30534. * Basically only one eye is rendered corresponding to the camera.
  30535. */
  30536. static readonly RIG_MODE_NONE: number;
  30537. /**
  30538. * Simulates a camera Rig with one blue eye and one red eye.
  30539. * This can be use with 3d blue and red glasses.
  30540. */
  30541. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30542. /**
  30543. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30544. */
  30545. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30546. /**
  30547. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30548. */
  30549. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30550. /**
  30551. * Defines that both eyes of the camera will be rendered over under each other.
  30552. */
  30553. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30554. /**
  30555. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30556. */
  30557. static readonly RIG_MODE_VR: number;
  30558. /**
  30559. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30560. */
  30561. static readonly RIG_MODE_WEBVR: number;
  30562. /**
  30563. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30564. */
  30565. static readonly RIG_MODE_CUSTOM: number;
  30566. /**
  30567. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30568. */
  30569. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30570. /**
  30571. * Define the input manager associated with the camera.
  30572. */
  30573. inputs: CameraInputsManager<Camera>;
  30574. /** @hidden */
  30575. _position: Vector3;
  30576. /**
  30577. * Define the current local position of the camera in the scene
  30578. */
  30579. position: Vector3;
  30580. /**
  30581. * The vector the camera should consider as up.
  30582. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30583. */
  30584. upVector: Vector3;
  30585. /**
  30586. * Define the current limit on the left side for an orthographic camera
  30587. * In scene unit
  30588. */
  30589. orthoLeft: Nullable<number>;
  30590. /**
  30591. * Define the current limit on the right side for an orthographic camera
  30592. * In scene unit
  30593. */
  30594. orthoRight: Nullable<number>;
  30595. /**
  30596. * Define the current limit on the bottom side for an orthographic camera
  30597. * In scene unit
  30598. */
  30599. orthoBottom: Nullable<number>;
  30600. /**
  30601. * Define the current limit on the top side for an orthographic camera
  30602. * In scene unit
  30603. */
  30604. orthoTop: Nullable<number>;
  30605. /**
  30606. * Field Of View is set in Radians. (default is 0.8)
  30607. */
  30608. fov: number;
  30609. /**
  30610. * Define the minimum distance the camera can see from.
  30611. * This is important to note that the depth buffer are not infinite and the closer it starts
  30612. * the more your scene might encounter depth fighting issue.
  30613. */
  30614. minZ: number;
  30615. /**
  30616. * Define the maximum distance the camera can see to.
  30617. * This is important to note that the depth buffer are not infinite and the further it end
  30618. * the more your scene might encounter depth fighting issue.
  30619. */
  30620. maxZ: number;
  30621. /**
  30622. * Define the default inertia of the camera.
  30623. * This helps giving a smooth feeling to the camera movement.
  30624. */
  30625. inertia: number;
  30626. /**
  30627. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30628. */
  30629. mode: number;
  30630. /**
  30631. * Define wether the camera is intermediate.
  30632. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30633. */
  30634. isIntermediate: boolean;
  30635. /**
  30636. * Define the viewport of the camera.
  30637. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30638. */
  30639. viewport: Viewport;
  30640. /**
  30641. * Restricts the camera to viewing objects with the same layerMask.
  30642. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30643. */
  30644. layerMask: number;
  30645. /**
  30646. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30647. */
  30648. fovMode: number;
  30649. /**
  30650. * Rig mode of the camera.
  30651. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30652. * This is normally controlled byt the camera themselves as internal use.
  30653. */
  30654. cameraRigMode: number;
  30655. /**
  30656. * Defines the distance between both "eyes" in case of a RIG
  30657. */
  30658. interaxialDistance: number;
  30659. /**
  30660. * Defines if stereoscopic rendering is done side by side or over under.
  30661. */
  30662. isStereoscopicSideBySide: boolean;
  30663. /**
  30664. * 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
  30665. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30666. * else in the scene.
  30667. */
  30668. customRenderTargets: RenderTargetTexture[];
  30669. /**
  30670. * When set, the camera will render to this render target instead of the default canvas
  30671. */
  30672. outputRenderTarget: Nullable<RenderTargetTexture>;
  30673. /**
  30674. * Observable triggered when the camera view matrix has changed.
  30675. */
  30676. onViewMatrixChangedObservable: Observable<Camera>;
  30677. /**
  30678. * Observable triggered when the camera Projection matrix has changed.
  30679. */
  30680. onProjectionMatrixChangedObservable: Observable<Camera>;
  30681. /**
  30682. * Observable triggered when the inputs have been processed.
  30683. */
  30684. onAfterCheckInputsObservable: Observable<Camera>;
  30685. /**
  30686. * Observable triggered when reset has been called and applied to the camera.
  30687. */
  30688. onRestoreStateObservable: Observable<Camera>;
  30689. /** @hidden */
  30690. _cameraRigParams: any;
  30691. /** @hidden */
  30692. _rigCameras: Camera[];
  30693. /** @hidden */
  30694. _rigPostProcess: Nullable<PostProcess>;
  30695. protected _webvrViewMatrix: Matrix;
  30696. /** @hidden */
  30697. _skipRendering: boolean;
  30698. /** @hidden */
  30699. _projectionMatrix: Matrix;
  30700. /** @hidden */
  30701. _postProcesses: Nullable<PostProcess>[];
  30702. /** @hidden */
  30703. _activeMeshes: SmartArray<AbstractMesh>;
  30704. protected _globalPosition: Vector3;
  30705. /** @hidden */
  30706. _computedViewMatrix: Matrix;
  30707. private _doNotComputeProjectionMatrix;
  30708. private _transformMatrix;
  30709. private _frustumPlanes;
  30710. private _refreshFrustumPlanes;
  30711. private _storedFov;
  30712. private _stateStored;
  30713. /**
  30714. * Instantiates a new camera object.
  30715. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30716. * @see http://doc.babylonjs.com/features/cameras
  30717. * @param name Defines the name of the camera in the scene
  30718. * @param position Defines the position of the camera
  30719. * @param scene Defines the scene the camera belongs too
  30720. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30721. */
  30722. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30723. /**
  30724. * Store current camera state (fov, position, etc..)
  30725. * @returns the camera
  30726. */
  30727. storeState(): Camera;
  30728. /**
  30729. * Restores the camera state values if it has been stored. You must call storeState() first
  30730. */
  30731. protected _restoreStateValues(): boolean;
  30732. /**
  30733. * Restored camera state. You must call storeState() first.
  30734. * @returns true if restored and false otherwise
  30735. */
  30736. restoreState(): boolean;
  30737. /**
  30738. * Gets the class name of the camera.
  30739. * @returns the class name
  30740. */
  30741. getClassName(): string;
  30742. /** @hidden */
  30743. readonly _isCamera: boolean;
  30744. /**
  30745. * Gets a string representation of the camera useful for debug purpose.
  30746. * @param fullDetails Defines that a more verboe level of logging is required
  30747. * @returns the string representation
  30748. */
  30749. toString(fullDetails?: boolean): string;
  30750. /**
  30751. * Gets the current world space position of the camera.
  30752. */
  30753. readonly globalPosition: Vector3;
  30754. /**
  30755. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30756. * @returns the active meshe list
  30757. */
  30758. getActiveMeshes(): SmartArray<AbstractMesh>;
  30759. /**
  30760. * Check wether a mesh is part of the current active mesh list of the camera
  30761. * @param mesh Defines the mesh to check
  30762. * @returns true if active, false otherwise
  30763. */
  30764. isActiveMesh(mesh: Mesh): boolean;
  30765. /**
  30766. * Is this camera ready to be used/rendered
  30767. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30768. * @return true if the camera is ready
  30769. */
  30770. isReady(completeCheck?: boolean): boolean;
  30771. /** @hidden */
  30772. _initCache(): void;
  30773. /** @hidden */
  30774. _updateCache(ignoreParentClass?: boolean): void;
  30775. /** @hidden */
  30776. _isSynchronized(): boolean;
  30777. /** @hidden */
  30778. _isSynchronizedViewMatrix(): boolean;
  30779. /** @hidden */
  30780. _isSynchronizedProjectionMatrix(): boolean;
  30781. /**
  30782. * Attach the input controls to a specific dom element to get the input from.
  30783. * @param element Defines the element the controls should be listened from
  30784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30785. */
  30786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30787. /**
  30788. * Detach the current controls from the specified dom element.
  30789. * @param element Defines the element to stop listening the inputs from
  30790. */
  30791. detachControl(element: HTMLElement): void;
  30792. /**
  30793. * Update the camera state according to the different inputs gathered during the frame.
  30794. */
  30795. update(): void;
  30796. /** @hidden */
  30797. _checkInputs(): void;
  30798. /** @hidden */
  30799. readonly rigCameras: Camera[];
  30800. /**
  30801. * Gets the post process used by the rig cameras
  30802. */
  30803. readonly rigPostProcess: Nullable<PostProcess>;
  30804. /**
  30805. * Internal, gets the first post proces.
  30806. * @returns the first post process to be run on this camera.
  30807. */
  30808. _getFirstPostProcess(): Nullable<PostProcess>;
  30809. private _cascadePostProcessesToRigCams;
  30810. /**
  30811. * Attach a post process to the camera.
  30812. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30813. * @param postProcess The post process to attach to the camera
  30814. * @param insertAt The position of the post process in case several of them are in use in the scene
  30815. * @returns the position the post process has been inserted at
  30816. */
  30817. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30818. /**
  30819. * Detach a post process to the camera.
  30820. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30821. * @param postProcess The post process to detach from the camera
  30822. */
  30823. detachPostProcess(postProcess: PostProcess): void;
  30824. /**
  30825. * Gets the current world matrix of the camera
  30826. */
  30827. getWorldMatrix(): Matrix;
  30828. /** @hidden */
  30829. _getViewMatrix(): Matrix;
  30830. /**
  30831. * Gets the current view matrix of the camera.
  30832. * @param force forces the camera to recompute the matrix without looking at the cached state
  30833. * @returns the view matrix
  30834. */
  30835. getViewMatrix(force?: boolean): Matrix;
  30836. /**
  30837. * Freeze the projection matrix.
  30838. * It will prevent the cache check of the camera projection compute and can speed up perf
  30839. * if no parameter of the camera are meant to change
  30840. * @param projection Defines manually a projection if necessary
  30841. */
  30842. freezeProjectionMatrix(projection?: Matrix): void;
  30843. /**
  30844. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30845. */
  30846. unfreezeProjectionMatrix(): void;
  30847. /**
  30848. * Gets the current projection matrix of the camera.
  30849. * @param force forces the camera to recompute the matrix without looking at the cached state
  30850. * @returns the projection matrix
  30851. */
  30852. getProjectionMatrix(force?: boolean): Matrix;
  30853. /**
  30854. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30855. * @returns a Matrix
  30856. */
  30857. getTransformationMatrix(): Matrix;
  30858. private _updateFrustumPlanes;
  30859. /**
  30860. * Checks if a cullable object (mesh...) is in the camera frustum
  30861. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30862. * @param target The object to check
  30863. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30864. * @returns true if the object is in frustum otherwise false
  30865. */
  30866. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30867. /**
  30868. * Checks if a cullable object (mesh...) is in the camera frustum
  30869. * Unlike isInFrustum this cheks the full bounding box
  30870. * @param target The object to check
  30871. * @returns true if the object is in frustum otherwise false
  30872. */
  30873. isCompletelyInFrustum(target: ICullable): boolean;
  30874. /**
  30875. * Gets a ray in the forward direction from the camera.
  30876. * @param length Defines the length of the ray to create
  30877. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30878. * @param origin Defines the start point of the ray which defaults to the camera position
  30879. * @returns the forward ray
  30880. */
  30881. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30882. /**
  30883. * Releases resources associated with this node.
  30884. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30885. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30886. */
  30887. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30888. /** @hidden */
  30889. _isLeftCamera: boolean;
  30890. /**
  30891. * Gets the left camera of a rig setup in case of Rigged Camera
  30892. */
  30893. readonly isLeftCamera: boolean;
  30894. /** @hidden */
  30895. _isRightCamera: boolean;
  30896. /**
  30897. * Gets the right camera of a rig setup in case of Rigged Camera
  30898. */
  30899. readonly isRightCamera: boolean;
  30900. /**
  30901. * Gets the left camera of a rig setup in case of Rigged Camera
  30902. */
  30903. readonly leftCamera: Nullable<FreeCamera>;
  30904. /**
  30905. * Gets the right camera of a rig setup in case of Rigged Camera
  30906. */
  30907. readonly rightCamera: Nullable<FreeCamera>;
  30908. /**
  30909. * Gets the left camera target of a rig setup in case of Rigged Camera
  30910. * @returns the target position
  30911. */
  30912. getLeftTarget(): Nullable<Vector3>;
  30913. /**
  30914. * Gets the right camera target of a rig setup in case of Rigged Camera
  30915. * @returns the target position
  30916. */
  30917. getRightTarget(): Nullable<Vector3>;
  30918. /**
  30919. * @hidden
  30920. */
  30921. setCameraRigMode(mode: number, rigParams: any): void;
  30922. /** @hidden */
  30923. static _setStereoscopicRigMode(camera: Camera): void;
  30924. /** @hidden */
  30925. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30926. /** @hidden */
  30927. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30928. /** @hidden */
  30929. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30930. /** @hidden */
  30931. _getVRProjectionMatrix(): Matrix;
  30932. protected _updateCameraRotationMatrix(): void;
  30933. protected _updateWebVRCameraRotationMatrix(): void;
  30934. /**
  30935. * This function MUST be overwritten by the different WebVR cameras available.
  30936. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30937. * @hidden
  30938. */
  30939. _getWebVRProjectionMatrix(): Matrix;
  30940. /**
  30941. * This function MUST be overwritten by the different WebVR cameras available.
  30942. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30943. * @hidden
  30944. */
  30945. _getWebVRViewMatrix(): Matrix;
  30946. /** @hidden */
  30947. setCameraRigParameter(name: string, value: any): void;
  30948. /**
  30949. * needs to be overridden by children so sub has required properties to be copied
  30950. * @hidden
  30951. */
  30952. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30953. /**
  30954. * May need to be overridden by children
  30955. * @hidden
  30956. */
  30957. _updateRigCameras(): void;
  30958. /** @hidden */
  30959. _setupInputs(): void;
  30960. /**
  30961. * Serialiaze the camera setup to a json represention
  30962. * @returns the JSON representation
  30963. */
  30964. serialize(): any;
  30965. /**
  30966. * Clones the current camera.
  30967. * @param name The cloned camera name
  30968. * @returns the cloned camera
  30969. */
  30970. clone(name: string): Camera;
  30971. /**
  30972. * Gets the direction of the camera relative to a given local axis.
  30973. * @param localAxis Defines the reference axis to provide a relative direction.
  30974. * @return the direction
  30975. */
  30976. getDirection(localAxis: Vector3): Vector3;
  30977. /**
  30978. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30979. * @param localAxis Defines the reference axis to provide a relative direction.
  30980. * @param result Defines the vector to store the result in
  30981. */
  30982. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30983. /**
  30984. * Gets a camera constructor for a given camera type
  30985. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30986. * @param name The name of the camera the result will be able to instantiate
  30987. * @param scene The scene the result will construct the camera in
  30988. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30989. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30990. * @returns a factory method to construc the camera
  30991. */
  30992. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30993. /**
  30994. * Compute the world matrix of the camera.
  30995. * @returns the camera workd matrix
  30996. */
  30997. computeWorldMatrix(): Matrix;
  30998. /**
  30999. * Parse a JSON and creates the camera from the parsed information
  31000. * @param parsedCamera The JSON to parse
  31001. * @param scene The scene to instantiate the camera in
  31002. * @returns the newly constructed camera
  31003. */
  31004. static Parse(parsedCamera: any, scene: Scene): Camera;
  31005. }
  31006. }
  31007. declare module BABYLON {
  31008. /**
  31009. * Interface for any object that can request an animation frame
  31010. */
  31011. export interface ICustomAnimationFrameRequester {
  31012. /**
  31013. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31014. */
  31015. renderFunction?: Function;
  31016. /**
  31017. * Called to request the next frame to render to
  31018. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31019. */
  31020. requestAnimationFrame: Function;
  31021. /**
  31022. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31023. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31024. */
  31025. requestID?: number;
  31026. }
  31027. /**
  31028. * Interface containing an array of animations
  31029. */
  31030. export interface IAnimatable {
  31031. /**
  31032. * Array of animations
  31033. */
  31034. animations: Nullable<Array<Animation>>;
  31035. }
  31036. /** Interface used by value gradients (color, factor, ...) */
  31037. export interface IValueGradient {
  31038. /**
  31039. * Gets or sets the gradient value (between 0 and 1)
  31040. */
  31041. gradient: number;
  31042. }
  31043. /** Class used to store color4 gradient */
  31044. export class ColorGradient implements IValueGradient {
  31045. /**
  31046. * Gets or sets the gradient value (between 0 and 1)
  31047. */
  31048. gradient: number;
  31049. /**
  31050. * Gets or sets first associated color
  31051. */
  31052. color1: Color4;
  31053. /**
  31054. * Gets or sets second associated color
  31055. */
  31056. color2?: Color4;
  31057. /**
  31058. * Will get a color picked randomly between color1 and color2.
  31059. * If color2 is undefined then color1 will be used
  31060. * @param result defines the target Color4 to store the result in
  31061. */
  31062. getColorToRef(result: Color4): void;
  31063. }
  31064. /** Class used to store color 3 gradient */
  31065. export class Color3Gradient implements IValueGradient {
  31066. /**
  31067. * Gets or sets the gradient value (between 0 and 1)
  31068. */
  31069. gradient: number;
  31070. /**
  31071. * Gets or sets the associated color
  31072. */
  31073. color: Color3;
  31074. }
  31075. /** Class used to store factor gradient */
  31076. export class FactorGradient implements IValueGradient {
  31077. /**
  31078. * Gets or sets the gradient value (between 0 and 1)
  31079. */
  31080. gradient: number;
  31081. /**
  31082. * Gets or sets first associated factor
  31083. */
  31084. factor1: number;
  31085. /**
  31086. * Gets or sets second associated factor
  31087. */
  31088. factor2?: number;
  31089. /**
  31090. * Will get a number picked randomly between factor1 and factor2.
  31091. * If factor2 is undefined then factor1 will be used
  31092. * @returns the picked number
  31093. */
  31094. getFactor(): number;
  31095. }
  31096. /**
  31097. * @ignore
  31098. * Application error to support additional information when loading a file
  31099. */
  31100. export class LoadFileError extends Error {
  31101. /** defines the optional web request */
  31102. request?: WebRequest | undefined;
  31103. private static _setPrototypeOf;
  31104. /**
  31105. * Creates a new LoadFileError
  31106. * @param message defines the message of the error
  31107. * @param request defines the optional web request
  31108. */
  31109. constructor(message: string,
  31110. /** defines the optional web request */
  31111. request?: WebRequest | undefined);
  31112. }
  31113. /**
  31114. * Class used to define a retry strategy when error happens while loading assets
  31115. */
  31116. export class RetryStrategy {
  31117. /**
  31118. * Function used to defines an exponential back off strategy
  31119. * @param maxRetries defines the maximum number of retries (3 by default)
  31120. * @param baseInterval defines the interval between retries
  31121. * @returns the strategy function to use
  31122. */
  31123. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31124. }
  31125. /**
  31126. * File request interface
  31127. */
  31128. export interface IFileRequest {
  31129. /**
  31130. * Raised when the request is complete (success or error).
  31131. */
  31132. onCompleteObservable: Observable<IFileRequest>;
  31133. /**
  31134. * Aborts the request for a file.
  31135. */
  31136. abort: () => void;
  31137. }
  31138. /**
  31139. * Class containing a set of static utilities functions
  31140. */
  31141. export class Tools {
  31142. /**
  31143. * Gets or sets the base URL to use to load assets
  31144. */
  31145. static BaseUrl: string;
  31146. /**
  31147. * Enable/Disable Custom HTTP Request Headers globally.
  31148. * default = false
  31149. * @see CustomRequestHeaders
  31150. */
  31151. static UseCustomRequestHeaders: boolean;
  31152. /**
  31153. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31154. * i.e. when loading files, where the server/service expects an Authorization header
  31155. */
  31156. static CustomRequestHeaders: {
  31157. [key: string]: string;
  31158. };
  31159. /**
  31160. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31161. */
  31162. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31163. /**
  31164. * Default behaviour for cors in the application.
  31165. * It can be a string if the expected behavior is identical in the entire app.
  31166. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31167. */
  31168. static CorsBehavior: string | ((url: string | string[]) => string);
  31169. /**
  31170. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31171. * @ignorenaming
  31172. */
  31173. static UseFallbackTexture: boolean;
  31174. /**
  31175. * Use this object to register external classes like custom textures or material
  31176. * to allow the laoders to instantiate them
  31177. */
  31178. static RegisteredExternalClasses: {
  31179. [key: string]: Object;
  31180. };
  31181. /**
  31182. * Texture content used if a texture cannot loaded
  31183. * @ignorenaming
  31184. */
  31185. static fallbackTexture: string;
  31186. /**
  31187. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31188. * @param u defines the coordinate on X axis
  31189. * @param v defines the coordinate on Y axis
  31190. * @param width defines the width of the source data
  31191. * @param height defines the height of the source data
  31192. * @param pixels defines the source byte array
  31193. * @param color defines the output color
  31194. */
  31195. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31196. /**
  31197. * Interpolates between a and b via alpha
  31198. * @param a The lower value (returned when alpha = 0)
  31199. * @param b The upper value (returned when alpha = 1)
  31200. * @param alpha The interpolation-factor
  31201. * @return The mixed value
  31202. */
  31203. static Mix(a: number, b: number, alpha: number): number;
  31204. /**
  31205. * Tries to instantiate a new object from a given class name
  31206. * @param className defines the class name to instantiate
  31207. * @returns the new object or null if the system was not able to do the instantiation
  31208. */
  31209. static Instantiate(className: string): any;
  31210. /**
  31211. * Provides a slice function that will work even on IE
  31212. * @param data defines the array to slice
  31213. * @param start defines the start of the data (optional)
  31214. * @param end defines the end of the data (optional)
  31215. * @returns the new sliced array
  31216. */
  31217. static Slice<T>(data: T, start?: number, end?: number): T;
  31218. /**
  31219. * Polyfill for setImmediate
  31220. * @param action defines the action to execute after the current execution block
  31221. */
  31222. static SetImmediate(action: () => void): void;
  31223. /**
  31224. * Function indicating if a number is an exponent of 2
  31225. * @param value defines the value to test
  31226. * @returns true if the value is an exponent of 2
  31227. */
  31228. static IsExponentOfTwo(value: number): boolean;
  31229. private static _tmpFloatArray;
  31230. /**
  31231. * Returns the nearest 32-bit single precision float representation of a Number
  31232. * @param value A Number. If the parameter is of a different type, it will get converted
  31233. * to a number or to NaN if it cannot be converted
  31234. * @returns number
  31235. */
  31236. static FloatRound(value: number): number;
  31237. /**
  31238. * Find the next highest power of two.
  31239. * @param x Number to start search from.
  31240. * @return Next highest power of two.
  31241. */
  31242. static CeilingPOT(x: number): number;
  31243. /**
  31244. * Find the next lowest power of two.
  31245. * @param x Number to start search from.
  31246. * @return Next lowest power of two.
  31247. */
  31248. static FloorPOT(x: number): number;
  31249. /**
  31250. * Find the nearest power of two.
  31251. * @param x Number to start search from.
  31252. * @return Next nearest power of two.
  31253. */
  31254. static NearestPOT(x: number): number;
  31255. /**
  31256. * Get the closest exponent of two
  31257. * @param value defines the value to approximate
  31258. * @param max defines the maximum value to return
  31259. * @param mode defines how to define the closest value
  31260. * @returns closest exponent of two of the given value
  31261. */
  31262. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31263. /**
  31264. * Extracts the filename from a path
  31265. * @param path defines the path to use
  31266. * @returns the filename
  31267. */
  31268. static GetFilename(path: string): string;
  31269. /**
  31270. * Extracts the "folder" part of a path (everything before the filename).
  31271. * @param uri The URI to extract the info from
  31272. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31273. * @returns The "folder" part of the path
  31274. */
  31275. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31276. /**
  31277. * Extracts text content from a DOM element hierarchy
  31278. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31279. */
  31280. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31281. /**
  31282. * Convert an angle in radians to degrees
  31283. * @param angle defines the angle to convert
  31284. * @returns the angle in degrees
  31285. */
  31286. static ToDegrees(angle: number): number;
  31287. /**
  31288. * Convert an angle in degrees to radians
  31289. * @param angle defines the angle to convert
  31290. * @returns the angle in radians
  31291. */
  31292. static ToRadians(angle: number): number;
  31293. /**
  31294. * Encode a buffer to a base64 string
  31295. * @param buffer defines the buffer to encode
  31296. * @returns the encoded string
  31297. */
  31298. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31299. /**
  31300. * Extracts minimum and maximum values from a list of indexed positions
  31301. * @param positions defines the positions to use
  31302. * @param indices defines the indices to the positions
  31303. * @param indexStart defines the start index
  31304. * @param indexCount defines the end index
  31305. * @param bias defines bias value to add to the result
  31306. * @return minimum and maximum values
  31307. */
  31308. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31309. minimum: Vector3;
  31310. maximum: Vector3;
  31311. };
  31312. /**
  31313. * Extracts minimum and maximum values from a list of positions
  31314. * @param positions defines the positions to use
  31315. * @param start defines the start index in the positions array
  31316. * @param count defines the number of positions to handle
  31317. * @param bias defines bias value to add to the result
  31318. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31319. * @return minimum and maximum values
  31320. */
  31321. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31322. minimum: Vector3;
  31323. maximum: Vector3;
  31324. };
  31325. /**
  31326. * Returns an array if obj is not an array
  31327. * @param obj defines the object to evaluate as an array
  31328. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31329. * @returns either obj directly if obj is an array or a new array containing obj
  31330. */
  31331. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31332. /**
  31333. * Gets the pointer prefix to use
  31334. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31335. */
  31336. static GetPointerPrefix(): string;
  31337. /**
  31338. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31339. * @param func - the function to be called
  31340. * @param requester - the object that will request the next frame. Falls back to window.
  31341. * @returns frame number
  31342. */
  31343. static QueueNewFrame(func: () => void, requester?: any): number;
  31344. /**
  31345. * Ask the browser to promote the current element to fullscreen rendering mode
  31346. * @param element defines the DOM element to promote
  31347. */
  31348. static RequestFullscreen(element: HTMLElement): void;
  31349. /**
  31350. * Asks the browser to exit fullscreen mode
  31351. */
  31352. static ExitFullscreen(): void;
  31353. /**
  31354. * Ask the browser to promote the current element to pointerlock mode
  31355. * @param element defines the DOM element to promote
  31356. */
  31357. static RequestPointerlock(element: HTMLElement): void;
  31358. /**
  31359. * Asks the browser to exit pointerlock mode
  31360. */
  31361. static ExitPointerlock(): void;
  31362. /**
  31363. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31364. * @param url define the url we are trying
  31365. * @param element define the dom element where to configure the cors policy
  31366. */
  31367. static SetCorsBehavior(url: string | string[], element: {
  31368. crossOrigin: string | null;
  31369. }): void;
  31370. /**
  31371. * Removes unwanted characters from an url
  31372. * @param url defines the url to clean
  31373. * @returns the cleaned url
  31374. */
  31375. static CleanUrl(url: string): string;
  31376. /**
  31377. * Gets or sets a function used to pre-process url before using them to load assets
  31378. */
  31379. static PreprocessUrl: (url: string) => string;
  31380. /**
  31381. * Loads an image as an HTMLImageElement.
  31382. * @param input url string, ArrayBuffer, or Blob to load
  31383. * @param onLoad callback called when the image successfully loads
  31384. * @param onError callback called when the image fails to load
  31385. * @param offlineProvider offline provider for caching
  31386. * @returns the HTMLImageElement of the loaded image
  31387. */
  31388. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31389. /**
  31390. * Loads a file
  31391. * @param url url string, ArrayBuffer, or Blob to load
  31392. * @param onSuccess callback called when the file successfully loads
  31393. * @param onProgress callback called while file is loading (if the server supports this mode)
  31394. * @param offlineProvider defines the offline provider for caching
  31395. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31396. * @param onError callback called when the file fails to load
  31397. * @returns a file request object
  31398. */
  31399. 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;
  31400. /**
  31401. * Loads a file from a url
  31402. * @param url the file url to load
  31403. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31404. */
  31405. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31406. /**
  31407. * Load a script (identified by an url). When the url returns, the
  31408. * content of this file is added into a new script element, attached to the DOM (body element)
  31409. * @param scriptUrl defines the url of the script to laod
  31410. * @param onSuccess defines the callback called when the script is loaded
  31411. * @param onError defines the callback to call if an error occurs
  31412. * @param scriptId defines the id of the script element
  31413. */
  31414. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31415. /**
  31416. * Load an asynchronous script (identified by an url). When the url returns, the
  31417. * content of this file is added into a new script element, attached to the DOM (body element)
  31418. * @param scriptUrl defines the url of the script to laod
  31419. * @param scriptId defines the id of the script element
  31420. * @returns a promise request object
  31421. */
  31422. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31423. /**
  31424. * Loads a file from a blob
  31425. * @param fileToLoad defines the blob to use
  31426. * @param callback defines the callback to call when data is loaded
  31427. * @param progressCallback defines the callback to call during loading process
  31428. * @returns a file request object
  31429. */
  31430. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31431. /**
  31432. * Loads a file
  31433. * @param fileToLoad defines the file to load
  31434. * @param callback defines the callback to call when data is loaded
  31435. * @param progressCallBack defines the callback to call during loading process
  31436. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31437. * @returns a file request object
  31438. */
  31439. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31440. /**
  31441. * Creates a data url from a given string content
  31442. * @param content defines the content to convert
  31443. * @returns the new data url link
  31444. */
  31445. static FileAsURL(content: string): string;
  31446. /**
  31447. * Format the given number to a specific decimal format
  31448. * @param value defines the number to format
  31449. * @param decimals defines the number of decimals to use
  31450. * @returns the formatted string
  31451. */
  31452. static Format(value: number, decimals?: number): string;
  31453. /**
  31454. * Checks if a given vector is inside a specific range
  31455. * @param v defines the vector to test
  31456. * @param min defines the minimum range
  31457. * @param max defines the maximum range
  31458. */
  31459. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31460. /**
  31461. * Tries to copy an object by duplicating every property
  31462. * @param source defines the source object
  31463. * @param destination defines the target object
  31464. * @param doNotCopyList defines a list of properties to avoid
  31465. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31466. */
  31467. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31468. /**
  31469. * Gets a boolean indicating if the given object has no own property
  31470. * @param obj defines the object to test
  31471. * @returns true if object has no own property
  31472. */
  31473. static IsEmpty(obj: any): boolean;
  31474. /**
  31475. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31476. * @param str Source string
  31477. * @param suffix Suffix to search for in the source string
  31478. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31479. */
  31480. static EndsWith(str: string, suffix: string): boolean;
  31481. /**
  31482. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31483. * @param str Source string
  31484. * @param suffix Suffix to search for in the source string
  31485. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31486. */
  31487. static StartsWith(str: string, suffix: string): boolean;
  31488. /**
  31489. * Function used to register events at window level
  31490. * @param events defines the events to register
  31491. */
  31492. static RegisterTopRootEvents(events: {
  31493. name: string;
  31494. handler: Nullable<(e: FocusEvent) => any>;
  31495. }[]): void;
  31496. /**
  31497. * Function used to unregister events from window level
  31498. * @param events defines the events to unregister
  31499. */
  31500. static UnregisterTopRootEvents(events: {
  31501. name: string;
  31502. handler: Nullable<(e: FocusEvent) => any>;
  31503. }[]): void;
  31504. /**
  31505. * @ignore
  31506. */
  31507. static _ScreenshotCanvas: HTMLCanvasElement;
  31508. /**
  31509. * Dumps the current bound framebuffer
  31510. * @param width defines the rendering width
  31511. * @param height defines the rendering height
  31512. * @param engine defines the hosting engine
  31513. * @param successCallback defines the callback triggered once the data are available
  31514. * @param mimeType defines the mime type of the result
  31515. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31516. */
  31517. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31518. /**
  31519. * Converts the canvas data to blob.
  31520. * This acts as a polyfill for browsers not supporting the to blob function.
  31521. * @param canvas Defines the canvas to extract the data from
  31522. * @param successCallback Defines the callback triggered once the data are available
  31523. * @param mimeType Defines the mime type of the result
  31524. */
  31525. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31526. /**
  31527. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31528. * @param successCallback defines the callback triggered once the data are available
  31529. * @param mimeType defines the mime type of the result
  31530. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31531. */
  31532. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31533. /**
  31534. * Downloads a blob in the browser
  31535. * @param blob defines the blob to download
  31536. * @param fileName defines the name of the downloaded file
  31537. */
  31538. static Download(blob: Blob, fileName: string): void;
  31539. /**
  31540. * Captures a screenshot of the current rendering
  31541. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31542. * @param engine defines the rendering engine
  31543. * @param camera defines the source camera
  31544. * @param size This parameter can be set to a single number or to an object with the
  31545. * following (optional) properties: precision, width, height. If a single number is passed,
  31546. * it will be used for both width and height. If an object is passed, the screenshot size
  31547. * will be derived from the parameters. The precision property is a multiplier allowing
  31548. * rendering at a higher or lower resolution
  31549. * @param successCallback defines the callback receives a single parameter which contains the
  31550. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31551. * src parameter of an <img> to display it
  31552. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31553. * Check your browser for supported MIME types
  31554. */
  31555. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31556. /**
  31557. * Generates an image screenshot from the specified camera.
  31558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31559. * @param engine The engine to use for rendering
  31560. * @param camera The camera to use for rendering
  31561. * @param size This parameter can be set to a single number or to an object with the
  31562. * following (optional) properties: precision, width, height. If a single number is passed,
  31563. * it will be used for both width and height. If an object is passed, the screenshot size
  31564. * will be derived from the parameters. The precision property is a multiplier allowing
  31565. * rendering at a higher or lower resolution
  31566. * @param successCallback The callback receives a single parameter which contains the
  31567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31568. * src parameter of an <img> to display it
  31569. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31570. * Check your browser for supported MIME types
  31571. * @param samples Texture samples (default: 1)
  31572. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31573. * @param fileName A name for for the downloaded file.
  31574. */
  31575. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31576. /**
  31577. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31578. * Be aware Math.random() could cause collisions, but:
  31579. * "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"
  31580. * @returns a pseudo random id
  31581. */
  31582. static RandomId(): string;
  31583. /**
  31584. * Test if the given uri is a base64 string
  31585. * @param uri The uri to test
  31586. * @return True if the uri is a base64 string or false otherwise
  31587. */
  31588. static IsBase64(uri: string): boolean;
  31589. /**
  31590. * Decode the given base64 uri.
  31591. * @param uri The uri to decode
  31592. * @return The decoded base64 data.
  31593. */
  31594. static DecodeBase64(uri: string): ArrayBuffer;
  31595. /**
  31596. * Gets the absolute url.
  31597. * @param url the input url
  31598. * @return the absolute url
  31599. */
  31600. static GetAbsoluteUrl(url: string): string;
  31601. /**
  31602. * No log
  31603. */
  31604. static readonly NoneLogLevel: number;
  31605. /**
  31606. * Only message logs
  31607. */
  31608. static readonly MessageLogLevel: number;
  31609. /**
  31610. * Only warning logs
  31611. */
  31612. static readonly WarningLogLevel: number;
  31613. /**
  31614. * Only error logs
  31615. */
  31616. static readonly ErrorLogLevel: number;
  31617. /**
  31618. * All logs
  31619. */
  31620. static readonly AllLogLevel: number;
  31621. /**
  31622. * Gets a value indicating the number of loading errors
  31623. * @ignorenaming
  31624. */
  31625. static readonly errorsCount: number;
  31626. /**
  31627. * Callback called when a new log is added
  31628. */
  31629. static OnNewCacheEntry: (entry: string) => void;
  31630. /**
  31631. * Log a message to the console
  31632. * @param message defines the message to log
  31633. */
  31634. static Log(message: string): void;
  31635. /**
  31636. * Write a warning message to the console
  31637. * @param message defines the message to log
  31638. */
  31639. static Warn(message: string): void;
  31640. /**
  31641. * Write an error message to the console
  31642. * @param message defines the message to log
  31643. */
  31644. static Error(message: string): void;
  31645. /**
  31646. * Gets current log cache (list of logs)
  31647. */
  31648. static readonly LogCache: string;
  31649. /**
  31650. * Clears the log cache
  31651. */
  31652. static ClearLogCache(): void;
  31653. /**
  31654. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31655. */
  31656. static LogLevels: number;
  31657. /**
  31658. * Checks if the loaded document was accessed via `file:`-Protocol.
  31659. * @returns boolean
  31660. */
  31661. static IsFileURL(): boolean;
  31662. /**
  31663. * Checks if the window object exists
  31664. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31665. */
  31666. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31667. /**
  31668. * No performance log
  31669. */
  31670. static readonly PerformanceNoneLogLevel: number;
  31671. /**
  31672. * Use user marks to log performance
  31673. */
  31674. static readonly PerformanceUserMarkLogLevel: number;
  31675. /**
  31676. * Log performance to the console
  31677. */
  31678. static readonly PerformanceConsoleLogLevel: number;
  31679. private static _performance;
  31680. /**
  31681. * Sets the current performance log level
  31682. */
  31683. static PerformanceLogLevel: number;
  31684. private static _StartPerformanceCounterDisabled;
  31685. private static _EndPerformanceCounterDisabled;
  31686. private static _StartUserMark;
  31687. private static _EndUserMark;
  31688. private static _StartPerformanceConsole;
  31689. private static _EndPerformanceConsole;
  31690. /**
  31691. * Starts a performance counter
  31692. */
  31693. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31694. /**
  31695. * Ends a specific performance coutner
  31696. */
  31697. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31698. /**
  31699. * Gets either window.performance.now() if supported or Date.now() else
  31700. */
  31701. static readonly Now: number;
  31702. /**
  31703. * This method will return the name of the class used to create the instance of the given object.
  31704. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31705. * @param object the object to get the class name from
  31706. * @param isType defines if the object is actually a type
  31707. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31708. */
  31709. static GetClassName(object: any, isType?: boolean): string;
  31710. /**
  31711. * Gets the first element of an array satisfying a given predicate
  31712. * @param array defines the array to browse
  31713. * @param predicate defines the predicate to use
  31714. * @returns null if not found or the element
  31715. */
  31716. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31717. /**
  31718. * This method will return the name of the full name of the class, including its owning module (if any).
  31719. * 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).
  31720. * @param object the object to get the class name from
  31721. * @param isType defines if the object is actually a type
  31722. * @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.
  31723. * @ignorenaming
  31724. */
  31725. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31726. /**
  31727. * Returns a promise that resolves after the given amount of time.
  31728. * @param delay Number of milliseconds to delay
  31729. * @returns Promise that resolves after the given amount of time
  31730. */
  31731. static DelayAsync(delay: number): Promise<void>;
  31732. /**
  31733. * Gets the current gradient from an array of IValueGradient
  31734. * @param ratio defines the current ratio to get
  31735. * @param gradients defines the array of IValueGradient
  31736. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31737. */
  31738. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31739. }
  31740. /**
  31741. * This class is used to track a performance counter which is number based.
  31742. * The user has access to many properties which give statistics of different nature.
  31743. *
  31744. * The implementer can track two kinds of Performance Counter: time and count.
  31745. * 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.
  31746. * 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.
  31747. */
  31748. export class PerfCounter {
  31749. /**
  31750. * Gets or sets a global boolean to turn on and off all the counters
  31751. */
  31752. static Enabled: boolean;
  31753. /**
  31754. * Returns the smallest value ever
  31755. */
  31756. readonly min: number;
  31757. /**
  31758. * Returns the biggest value ever
  31759. */
  31760. readonly max: number;
  31761. /**
  31762. * Returns the average value since the performance counter is running
  31763. */
  31764. readonly average: number;
  31765. /**
  31766. * Returns the average value of the last second the counter was monitored
  31767. */
  31768. readonly lastSecAverage: number;
  31769. /**
  31770. * Returns the current value
  31771. */
  31772. readonly current: number;
  31773. /**
  31774. * Gets the accumulated total
  31775. */
  31776. readonly total: number;
  31777. /**
  31778. * Gets the total value count
  31779. */
  31780. readonly count: number;
  31781. /**
  31782. * Creates a new counter
  31783. */
  31784. constructor();
  31785. /**
  31786. * Call this method to start monitoring a new frame.
  31787. * 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.
  31788. */
  31789. fetchNewFrame(): void;
  31790. /**
  31791. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31792. * @param newCount the count value to add to the monitored count
  31793. * @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.
  31794. */
  31795. addCount(newCount: number, fetchResult: boolean): void;
  31796. /**
  31797. * Start monitoring this performance counter
  31798. */
  31799. beginMonitoring(): void;
  31800. /**
  31801. * Compute the time lapsed since the previous beginMonitoring() call.
  31802. * @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
  31803. */
  31804. endMonitoring(newFrame?: boolean): void;
  31805. private _fetchResult;
  31806. private _startMonitoringTime;
  31807. private _min;
  31808. private _max;
  31809. private _average;
  31810. private _current;
  31811. private _totalValueCount;
  31812. private _totalAccumulated;
  31813. private _lastSecAverage;
  31814. private _lastSecAccumulated;
  31815. private _lastSecTime;
  31816. private _lastSecValueCount;
  31817. }
  31818. /**
  31819. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31820. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31821. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31822. * @param name The name of the class, case should be preserved
  31823. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31824. */
  31825. export function className(name: string, module?: string): (target: Object) => void;
  31826. /**
  31827. * An implementation of a loop for asynchronous functions.
  31828. */
  31829. export class AsyncLoop {
  31830. /**
  31831. * Defines the number of iterations for the loop
  31832. */
  31833. iterations: number;
  31834. /**
  31835. * Defines the current index of the loop.
  31836. */
  31837. index: number;
  31838. private _done;
  31839. private _fn;
  31840. private _successCallback;
  31841. /**
  31842. * Constructor.
  31843. * @param iterations the number of iterations.
  31844. * @param func the function to run each iteration
  31845. * @param successCallback the callback that will be called upon succesful execution
  31846. * @param offset starting offset.
  31847. */
  31848. constructor(
  31849. /**
  31850. * Defines the number of iterations for the loop
  31851. */
  31852. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31853. /**
  31854. * Execute the next iteration. Must be called after the last iteration was finished.
  31855. */
  31856. executeNext(): void;
  31857. /**
  31858. * Break the loop and run the success callback.
  31859. */
  31860. breakLoop(): void;
  31861. /**
  31862. * Create and run an async loop.
  31863. * @param iterations the number of iterations.
  31864. * @param fn the function to run each iteration
  31865. * @param successCallback the callback that will be called upon succesful execution
  31866. * @param offset starting offset.
  31867. * @returns the created async loop object
  31868. */
  31869. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31870. /**
  31871. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31872. * @param iterations total number of iterations
  31873. * @param syncedIterations number of synchronous iterations in each async iteration.
  31874. * @param fn the function to call each iteration.
  31875. * @param callback a success call back that will be called when iterating stops.
  31876. * @param breakFunction a break condition (optional)
  31877. * @param timeout timeout settings for the setTimeout function. default - 0.
  31878. * @returns the created async loop object
  31879. */
  31880. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /** @hidden */
  31885. export interface ICollisionCoordinator {
  31886. createCollider(): Collider;
  31887. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31888. init(scene: Scene): void;
  31889. }
  31890. /** @hidden */
  31891. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31892. private _scene;
  31893. private _scaledPosition;
  31894. private _scaledVelocity;
  31895. private _finalPosition;
  31896. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31897. createCollider(): Collider;
  31898. init(scene: Scene): void;
  31899. private _collideWithWorld;
  31900. }
  31901. }
  31902. declare module BABYLON {
  31903. /**
  31904. * Class used to manage all inputs for the scene.
  31905. */
  31906. export class InputManager {
  31907. /** The distance in pixel that you have to move to prevent some events */
  31908. static DragMovementThreshold: number;
  31909. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31910. static LongPressDelay: number;
  31911. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31912. static DoubleClickDelay: number;
  31913. /** If you need to check double click without raising a single click at first click, enable this flag */
  31914. static ExclusiveDoubleClickMode: boolean;
  31915. private _wheelEventName;
  31916. private _onPointerMove;
  31917. private _onPointerDown;
  31918. private _onPointerUp;
  31919. private _initClickEvent;
  31920. private _initActionManager;
  31921. private _delayedSimpleClick;
  31922. private _delayedSimpleClickTimeout;
  31923. private _previousDelayedSimpleClickTimeout;
  31924. private _meshPickProceed;
  31925. private _previousButtonPressed;
  31926. private _currentPickResult;
  31927. private _previousPickResult;
  31928. private _totalPointersPressed;
  31929. private _doubleClickOccured;
  31930. private _pointerOverMesh;
  31931. private _pickedDownMesh;
  31932. private _pickedUpMesh;
  31933. private _pointerX;
  31934. private _pointerY;
  31935. private _unTranslatedPointerX;
  31936. private _unTranslatedPointerY;
  31937. private _startingPointerPosition;
  31938. private _previousStartingPointerPosition;
  31939. private _startingPointerTime;
  31940. private _previousStartingPointerTime;
  31941. private _pointerCaptures;
  31942. private _onKeyDown;
  31943. private _onKeyUp;
  31944. private _onCanvasFocusObserver;
  31945. private _onCanvasBlurObserver;
  31946. private _scene;
  31947. /**
  31948. * Creates a new InputManager
  31949. * @param scene defines the hosting scene
  31950. */
  31951. constructor(scene: Scene);
  31952. /**
  31953. * Gets the mesh that is currently under the pointer
  31954. */
  31955. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31956. /**
  31957. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31958. */
  31959. readonly unTranslatedPointer: Vector2;
  31960. /**
  31961. * Gets or sets the current on-screen X position of the pointer
  31962. */
  31963. pointerX: number;
  31964. /**
  31965. * Gets or sets the current on-screen Y position of the pointer
  31966. */
  31967. pointerY: number;
  31968. private _updatePointerPosition;
  31969. private _processPointerMove;
  31970. private _setRayOnPointerInfo;
  31971. private _checkPrePointerObservable;
  31972. /**
  31973. * Use this method to simulate a pointer move on a mesh
  31974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31977. */
  31978. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31979. /**
  31980. * Use this method to simulate a pointer down on a mesh
  31981. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31982. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31983. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31984. */
  31985. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31986. private _processPointerDown;
  31987. /** @hidden */
  31988. _isPointerSwiping(): boolean;
  31989. /**
  31990. * Use this method to simulate a pointer up on a mesh
  31991. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31992. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31993. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31994. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31995. */
  31996. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31997. private _processPointerUp;
  31998. /**
  31999. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32000. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32001. * @returns true if the pointer was captured
  32002. */
  32003. isPointerCaptured(pointerId?: number): boolean;
  32004. /**
  32005. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32006. * @param attachUp defines if you want to attach events to pointerup
  32007. * @param attachDown defines if you want to attach events to pointerdown
  32008. * @param attachMove defines if you want to attach events to pointermove
  32009. */
  32010. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32011. /**
  32012. * Detaches all event handlers
  32013. */
  32014. detachControl(): void;
  32015. /**
  32016. * Force the value of meshUnderPointer
  32017. * @param mesh defines the mesh to use
  32018. */
  32019. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32020. /**
  32021. * Gets the mesh under the pointer
  32022. * @returns a Mesh or null if no mesh is under the pointer
  32023. */
  32024. getPointerOverMesh(): Nullable<AbstractMesh>;
  32025. }
  32026. }
  32027. declare module BABYLON {
  32028. /**
  32029. * This class defines the direct association between an animation and a target
  32030. */
  32031. export class TargetedAnimation {
  32032. /**
  32033. * Animation to perform
  32034. */
  32035. animation: Animation;
  32036. /**
  32037. * Target to animate
  32038. */
  32039. target: any;
  32040. /**
  32041. * Serialize the object
  32042. * @returns the JSON object representing the current entity
  32043. */
  32044. serialize(): any;
  32045. }
  32046. /**
  32047. * Use this class to create coordinated animations on multiple targets
  32048. */
  32049. export class AnimationGroup implements IDisposable {
  32050. /** The name of the animation group */
  32051. name: string;
  32052. private _scene;
  32053. private _targetedAnimations;
  32054. private _animatables;
  32055. private _from;
  32056. private _to;
  32057. private _isStarted;
  32058. private _isPaused;
  32059. private _speedRatio;
  32060. private _loopAnimation;
  32061. /**
  32062. * Gets or sets the unique id of the node
  32063. */
  32064. uniqueId: number;
  32065. /**
  32066. * This observable will notify when one animation have ended
  32067. */
  32068. onAnimationEndObservable: Observable<TargetedAnimation>;
  32069. /**
  32070. * Observer raised when one animation loops
  32071. */
  32072. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32073. /**
  32074. * This observable will notify when all animations have ended.
  32075. */
  32076. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32077. /**
  32078. * This observable will notify when all animations have paused.
  32079. */
  32080. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32081. /**
  32082. * This observable will notify when all animations are playing.
  32083. */
  32084. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32085. /**
  32086. * Gets the first frame
  32087. */
  32088. readonly from: number;
  32089. /**
  32090. * Gets the last frame
  32091. */
  32092. readonly to: number;
  32093. /**
  32094. * Define if the animations are started
  32095. */
  32096. readonly isStarted: boolean;
  32097. /**
  32098. * Gets a value indicating that the current group is playing
  32099. */
  32100. readonly isPlaying: boolean;
  32101. /**
  32102. * Gets or sets the speed ratio to use for all animations
  32103. */
  32104. /**
  32105. * Gets or sets the speed ratio to use for all animations
  32106. */
  32107. speedRatio: number;
  32108. /**
  32109. * Gets or sets if all animations should loop or not
  32110. */
  32111. loopAnimation: boolean;
  32112. /**
  32113. * Gets the targeted animations for this animation group
  32114. */
  32115. readonly targetedAnimations: Array<TargetedAnimation>;
  32116. /**
  32117. * returning the list of animatables controlled by this animation group.
  32118. */
  32119. readonly animatables: Array<Animatable>;
  32120. /**
  32121. * Instantiates a new Animation Group.
  32122. * This helps managing several animations at once.
  32123. * @see http://doc.babylonjs.com/how_to/group
  32124. * @param name Defines the name of the group
  32125. * @param scene Defines the scene the group belongs to
  32126. */
  32127. constructor(
  32128. /** The name of the animation group */
  32129. name: string, scene?: Nullable<Scene>);
  32130. /**
  32131. * Add an animation (with its target) in the group
  32132. * @param animation defines the animation we want to add
  32133. * @param target defines the target of the animation
  32134. * @returns the TargetedAnimation object
  32135. */
  32136. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32137. /**
  32138. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32139. * It can add constant keys at begin or end
  32140. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32141. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32142. * @returns the animation group
  32143. */
  32144. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32145. /**
  32146. * Start all animations on given targets
  32147. * @param loop defines if animations must loop
  32148. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32149. * @param from defines the from key (optional)
  32150. * @param to defines the to key (optional)
  32151. * @returns the current animation group
  32152. */
  32153. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32154. /**
  32155. * Pause all animations
  32156. * @returns the animation group
  32157. */
  32158. pause(): AnimationGroup;
  32159. /**
  32160. * Play all animations to initial state
  32161. * This function will start() the animations if they were not started or will restart() them if they were paused
  32162. * @param loop defines if animations must loop
  32163. * @returns the animation group
  32164. */
  32165. play(loop?: boolean): AnimationGroup;
  32166. /**
  32167. * Reset all animations to initial state
  32168. * @returns the animation group
  32169. */
  32170. reset(): AnimationGroup;
  32171. /**
  32172. * Restart animations from key 0
  32173. * @returns the animation group
  32174. */
  32175. restart(): AnimationGroup;
  32176. /**
  32177. * Stop all animations
  32178. * @returns the animation group
  32179. */
  32180. stop(): AnimationGroup;
  32181. /**
  32182. * Set animation weight for all animatables
  32183. * @param weight defines the weight to use
  32184. * @return the animationGroup
  32185. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32186. */
  32187. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32188. /**
  32189. * Synchronize and normalize all animatables with a source animatable
  32190. * @param root defines the root animatable to synchronize with
  32191. * @return the animationGroup
  32192. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32193. */
  32194. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32195. /**
  32196. * Goes to a specific frame in this animation group
  32197. * @param frame the frame number to go to
  32198. * @return the animationGroup
  32199. */
  32200. goToFrame(frame: number): AnimationGroup;
  32201. /**
  32202. * Dispose all associated resources
  32203. */
  32204. dispose(): void;
  32205. private _checkAnimationGroupEnded;
  32206. /**
  32207. * Clone the current animation group and returns a copy
  32208. * @param newName defines the name of the new group
  32209. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32210. * @returns the new aniamtion group
  32211. */
  32212. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32213. /**
  32214. * Serializes the animationGroup to an object
  32215. * @returns Serialized object
  32216. */
  32217. serialize(): any;
  32218. /**
  32219. * Returns a new AnimationGroup object parsed from the source provided.
  32220. * @param parsedAnimationGroup defines the source
  32221. * @param scene defines the scene that will receive the animationGroup
  32222. * @returns a new AnimationGroup
  32223. */
  32224. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32225. /**
  32226. * Returns the string "AnimationGroup"
  32227. * @returns "AnimationGroup"
  32228. */
  32229. getClassName(): string;
  32230. /**
  32231. * Creates a detailled string about the object
  32232. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32233. * @returns a string representing the object
  32234. */
  32235. toString(fullDetails?: boolean): string;
  32236. }
  32237. }
  32238. declare module BABYLON {
  32239. /**
  32240. * Define an interface for all classes that will hold resources
  32241. */
  32242. export interface IDisposable {
  32243. /**
  32244. * Releases all held resources
  32245. */
  32246. dispose(): void;
  32247. }
  32248. /** Interface defining initialization parameters for Scene class */
  32249. export interface SceneOptions {
  32250. /**
  32251. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32252. * It will improve performance when the number of geometries becomes important.
  32253. */
  32254. useGeometryUniqueIdsMap?: boolean;
  32255. /**
  32256. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32257. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32258. */
  32259. useMaterialMeshMap?: boolean;
  32260. /**
  32261. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32262. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32263. */
  32264. useClonedMeshhMap?: boolean;
  32265. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32266. virtual?: boolean;
  32267. }
  32268. /**
  32269. * Represents a scene to be rendered by the engine.
  32270. * @see http://doc.babylonjs.com/features/scene
  32271. */
  32272. export class Scene extends AbstractScene implements IAnimatable {
  32273. private static _uniqueIdCounter;
  32274. /** The fog is deactivated */
  32275. static readonly FOGMODE_NONE: number;
  32276. /** The fog density is following an exponential function */
  32277. static readonly FOGMODE_EXP: number;
  32278. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32279. static readonly FOGMODE_EXP2: number;
  32280. /** The fog density is following a linear function. */
  32281. static readonly FOGMODE_LINEAR: number;
  32282. /**
  32283. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32284. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32285. */
  32286. static MinDeltaTime: number;
  32287. /**
  32288. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32290. */
  32291. static MaxDeltaTime: number;
  32292. /**
  32293. * Factory used to create the default material.
  32294. * @param name The name of the material to create
  32295. * @param scene The scene to create the material for
  32296. * @returns The default material
  32297. */
  32298. static DefaultMaterialFactory(scene: Scene): Material;
  32299. /**
  32300. * Factory used to create the a collision coordinator.
  32301. * @returns The collision coordinator
  32302. */
  32303. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32304. /** @hidden */
  32305. _inputManager: InputManager;
  32306. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32307. cameraToUseForPointers: Nullable<Camera>;
  32308. /** @hidden */
  32309. readonly _isScene: boolean;
  32310. /**
  32311. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32312. */
  32313. autoClear: boolean;
  32314. /**
  32315. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32316. */
  32317. autoClearDepthAndStencil: boolean;
  32318. /**
  32319. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32320. */
  32321. clearColor: Color4;
  32322. /**
  32323. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32324. */
  32325. ambientColor: Color3;
  32326. /**
  32327. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32328. * It should only be one of the following (if not the default embedded one):
  32329. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32330. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32331. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32332. * The material properties need to be setup according to the type of texture in use.
  32333. */
  32334. environmentBRDFTexture: BaseTexture;
  32335. /** @hidden */
  32336. protected _environmentTexture: Nullable<BaseTexture>;
  32337. /**
  32338. * Texture used in all pbr material as the reflection texture.
  32339. * As in the majority of the scene they are the same (exception for multi room and so on),
  32340. * this is easier to reference from here than from all the materials.
  32341. */
  32342. /**
  32343. * Texture used in all pbr material as the reflection texture.
  32344. * As in the majority of the scene they are the same (exception for multi room and so on),
  32345. * this is easier to set here than in all the materials.
  32346. */
  32347. environmentTexture: Nullable<BaseTexture>;
  32348. /** @hidden */
  32349. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32350. /**
  32351. * Default image processing configuration used either in the rendering
  32352. * Forward main pass or through the imageProcessingPostProcess if present.
  32353. * As in the majority of the scene they are the same (exception for multi camera),
  32354. * this is easier to reference from here than from all the materials and post process.
  32355. *
  32356. * No setter as we it is a shared configuration, you can set the values instead.
  32357. */
  32358. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32359. private _forceWireframe;
  32360. /**
  32361. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32362. */
  32363. forceWireframe: boolean;
  32364. private _forcePointsCloud;
  32365. /**
  32366. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32367. */
  32368. forcePointsCloud: boolean;
  32369. /**
  32370. * Gets or sets the active clipplane 1
  32371. */
  32372. clipPlane: Nullable<Plane>;
  32373. /**
  32374. * Gets or sets the active clipplane 2
  32375. */
  32376. clipPlane2: Nullable<Plane>;
  32377. /**
  32378. * Gets or sets the active clipplane 3
  32379. */
  32380. clipPlane3: Nullable<Plane>;
  32381. /**
  32382. * Gets or sets the active clipplane 4
  32383. */
  32384. clipPlane4: Nullable<Plane>;
  32385. /**
  32386. * Gets or sets a boolean indicating if animations are enabled
  32387. */
  32388. animationsEnabled: boolean;
  32389. private _animationPropertiesOverride;
  32390. /**
  32391. * Gets or sets the animation properties override
  32392. */
  32393. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32394. /**
  32395. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32396. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32397. */
  32398. useConstantAnimationDeltaTime: boolean;
  32399. /**
  32400. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32401. * Please note that it requires to run a ray cast through the scene on every frame
  32402. */
  32403. constantlyUpdateMeshUnderPointer: boolean;
  32404. /**
  32405. * Defines the HTML cursor to use when hovering over interactive elements
  32406. */
  32407. hoverCursor: string;
  32408. /**
  32409. * Defines the HTML default cursor to use (empty by default)
  32410. */
  32411. defaultCursor: string;
  32412. /**
  32413. * This is used to call preventDefault() on pointer down
  32414. * in order to block unwanted artifacts like system double clicks
  32415. */
  32416. preventDefaultOnPointerDown: boolean;
  32417. /**
  32418. * This is used to call preventDefault() on pointer up
  32419. * in order to block unwanted artifacts like system double clicks
  32420. */
  32421. preventDefaultOnPointerUp: boolean;
  32422. /**
  32423. * Gets or sets user defined metadata
  32424. */
  32425. metadata: any;
  32426. /**
  32427. * For internal use only. Please do not use.
  32428. */
  32429. reservedDataStore: any;
  32430. /**
  32431. * Gets the name of the plugin used to load this scene (null by default)
  32432. */
  32433. loadingPluginName: string;
  32434. /**
  32435. * Use this array to add regular expressions used to disable offline support for specific urls
  32436. */
  32437. disableOfflineSupportExceptionRules: RegExp[];
  32438. /**
  32439. * An event triggered when the scene is disposed.
  32440. */
  32441. onDisposeObservable: Observable<Scene>;
  32442. private _onDisposeObserver;
  32443. /** Sets a function to be executed when this scene is disposed. */
  32444. onDispose: () => void;
  32445. /**
  32446. * An event triggered before rendering the scene (right after animations and physics)
  32447. */
  32448. onBeforeRenderObservable: Observable<Scene>;
  32449. private _onBeforeRenderObserver;
  32450. /** Sets a function to be executed before rendering this scene */
  32451. beforeRender: Nullable<() => void>;
  32452. /**
  32453. * An event triggered after rendering the scene
  32454. */
  32455. onAfterRenderObservable: Observable<Scene>;
  32456. /**
  32457. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32458. */
  32459. onAfterRenderCameraObservable: Observable<Camera>;
  32460. private _onAfterRenderObserver;
  32461. /** Sets a function to be executed after rendering this scene */
  32462. afterRender: Nullable<() => void>;
  32463. /**
  32464. * An event triggered before animating the scene
  32465. */
  32466. onBeforeAnimationsObservable: Observable<Scene>;
  32467. /**
  32468. * An event triggered after animations processing
  32469. */
  32470. onAfterAnimationsObservable: Observable<Scene>;
  32471. /**
  32472. * An event triggered before draw calls are ready to be sent
  32473. */
  32474. onBeforeDrawPhaseObservable: Observable<Scene>;
  32475. /**
  32476. * An event triggered after draw calls have been sent
  32477. */
  32478. onAfterDrawPhaseObservable: Observable<Scene>;
  32479. /**
  32480. * An event triggered when the scene is ready
  32481. */
  32482. onReadyObservable: Observable<Scene>;
  32483. /**
  32484. * An event triggered before rendering a camera
  32485. */
  32486. onBeforeCameraRenderObservable: Observable<Camera>;
  32487. private _onBeforeCameraRenderObserver;
  32488. /** Sets a function to be executed before rendering a camera*/
  32489. beforeCameraRender: () => void;
  32490. /**
  32491. * An event triggered after rendering a camera
  32492. */
  32493. onAfterCameraRenderObservable: Observable<Camera>;
  32494. private _onAfterCameraRenderObserver;
  32495. /** Sets a function to be executed after rendering a camera*/
  32496. afterCameraRender: () => void;
  32497. /**
  32498. * An event triggered when active meshes evaluation is about to start
  32499. */
  32500. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32501. /**
  32502. * An event triggered when active meshes evaluation is done
  32503. */
  32504. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32505. /**
  32506. * An event triggered when particles rendering is about to start
  32507. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32508. */
  32509. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32510. /**
  32511. * An event triggered when particles rendering is done
  32512. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32513. */
  32514. onAfterParticlesRenderingObservable: Observable<Scene>;
  32515. /**
  32516. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32517. */
  32518. onDataLoadedObservable: Observable<Scene>;
  32519. /**
  32520. * An event triggered when a camera is created
  32521. */
  32522. onNewCameraAddedObservable: Observable<Camera>;
  32523. /**
  32524. * An event triggered when a camera is removed
  32525. */
  32526. onCameraRemovedObservable: Observable<Camera>;
  32527. /**
  32528. * An event triggered when a light is created
  32529. */
  32530. onNewLightAddedObservable: Observable<Light>;
  32531. /**
  32532. * An event triggered when a light is removed
  32533. */
  32534. onLightRemovedObservable: Observable<Light>;
  32535. /**
  32536. * An event triggered when a geometry is created
  32537. */
  32538. onNewGeometryAddedObservable: Observable<Geometry>;
  32539. /**
  32540. * An event triggered when a geometry is removed
  32541. */
  32542. onGeometryRemovedObservable: Observable<Geometry>;
  32543. /**
  32544. * An event triggered when a transform node is created
  32545. */
  32546. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32547. /**
  32548. * An event triggered when a transform node is removed
  32549. */
  32550. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32551. /**
  32552. * An event triggered when a mesh is created
  32553. */
  32554. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32555. /**
  32556. * An event triggered when a mesh is removed
  32557. */
  32558. onMeshRemovedObservable: Observable<AbstractMesh>;
  32559. /**
  32560. * An event triggered when a skeleton is created
  32561. */
  32562. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32563. /**
  32564. * An event triggered when a skeleton is removed
  32565. */
  32566. onSkeletonRemovedObservable: Observable<Skeleton>;
  32567. /**
  32568. * An event triggered when a material is created
  32569. */
  32570. onNewMaterialAddedObservable: Observable<Material>;
  32571. /**
  32572. * An event triggered when a material is removed
  32573. */
  32574. onMaterialRemovedObservable: Observable<Material>;
  32575. /**
  32576. * An event triggered when a texture is created
  32577. */
  32578. onNewTextureAddedObservable: Observable<BaseTexture>;
  32579. /**
  32580. * An event triggered when a texture is removed
  32581. */
  32582. onTextureRemovedObservable: Observable<BaseTexture>;
  32583. /**
  32584. * An event triggered when render targets are about to be rendered
  32585. * Can happen multiple times per frame.
  32586. */
  32587. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32588. /**
  32589. * An event triggered when render targets were rendered.
  32590. * Can happen multiple times per frame.
  32591. */
  32592. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32593. /**
  32594. * An event triggered before calculating deterministic simulation step
  32595. */
  32596. onBeforeStepObservable: Observable<Scene>;
  32597. /**
  32598. * An event triggered after calculating deterministic simulation step
  32599. */
  32600. onAfterStepObservable: Observable<Scene>;
  32601. /**
  32602. * An event triggered when the activeCamera property is updated
  32603. */
  32604. onActiveCameraChanged: Observable<Scene>;
  32605. /**
  32606. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32607. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32608. * 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)
  32609. */
  32610. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32611. /**
  32612. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32613. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32614. * 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)
  32615. */
  32616. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32617. /**
  32618. * This Observable will when a mesh has been imported into the scene.
  32619. */
  32620. onMeshImportedObservable: Observable<AbstractMesh>;
  32621. /**
  32622. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32623. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32624. */
  32625. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32626. /** @hidden */
  32627. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32628. /**
  32629. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32630. */
  32631. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32632. /**
  32633. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32634. */
  32635. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32636. /**
  32637. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32638. */
  32639. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32640. /** Callback called when a pointer move is detected */
  32641. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32642. /** Callback called when a pointer down is detected */
  32643. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32644. /** Callback called when a pointer up is detected */
  32645. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32646. /** Callback called when a pointer pick is detected */
  32647. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32648. /**
  32649. * 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).
  32650. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32651. */
  32652. onPrePointerObservable: Observable<PointerInfoPre>;
  32653. /**
  32654. * Observable event triggered each time an input event is received from the rendering canvas
  32655. */
  32656. onPointerObservable: Observable<PointerInfo>;
  32657. /**
  32658. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32659. */
  32660. readonly unTranslatedPointer: Vector2;
  32661. /**
  32662. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32663. */
  32664. static DragMovementThreshold: number;
  32665. /**
  32666. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32667. */
  32668. static LongPressDelay: number;
  32669. /**
  32670. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32671. */
  32672. static DoubleClickDelay: number;
  32673. /** If you need to check double click without raising a single click at first click, enable this flag */
  32674. static ExclusiveDoubleClickMode: boolean;
  32675. /** @hidden */
  32676. _mirroredCameraPosition: Nullable<Vector3>;
  32677. /**
  32678. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32679. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32680. */
  32681. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32682. /**
  32683. * Observable event triggered each time an keyboard event is received from the hosting window
  32684. */
  32685. onKeyboardObservable: Observable<KeyboardInfo>;
  32686. private _useRightHandedSystem;
  32687. /**
  32688. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32689. */
  32690. useRightHandedSystem: boolean;
  32691. private _timeAccumulator;
  32692. private _currentStepId;
  32693. private _currentInternalStep;
  32694. /**
  32695. * Sets the step Id used by deterministic lock step
  32696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32697. * @param newStepId defines the step Id
  32698. */
  32699. setStepId(newStepId: number): void;
  32700. /**
  32701. * Gets the step Id used by deterministic lock step
  32702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32703. * @returns the step Id
  32704. */
  32705. getStepId(): number;
  32706. /**
  32707. * Gets the internal step used by deterministic lock step
  32708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32709. * @returns the internal step
  32710. */
  32711. getInternalStep(): number;
  32712. private _fogEnabled;
  32713. /**
  32714. * Gets or sets a boolean indicating if fog is enabled on this scene
  32715. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32716. * (Default is true)
  32717. */
  32718. fogEnabled: boolean;
  32719. private _fogMode;
  32720. /**
  32721. * Gets or sets the fog mode to use
  32722. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32723. * | mode | value |
  32724. * | --- | --- |
  32725. * | FOGMODE_NONE | 0 |
  32726. * | FOGMODE_EXP | 1 |
  32727. * | FOGMODE_EXP2 | 2 |
  32728. * | FOGMODE_LINEAR | 3 |
  32729. */
  32730. fogMode: number;
  32731. /**
  32732. * Gets or sets the fog color to use
  32733. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32734. * (Default is Color3(0.2, 0.2, 0.3))
  32735. */
  32736. fogColor: Color3;
  32737. /**
  32738. * Gets or sets the fog density to use
  32739. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32740. * (Default is 0.1)
  32741. */
  32742. fogDensity: number;
  32743. /**
  32744. * Gets or sets the fog start distance to use
  32745. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32746. * (Default is 0)
  32747. */
  32748. fogStart: number;
  32749. /**
  32750. * Gets or sets the fog end distance to use
  32751. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32752. * (Default is 1000)
  32753. */
  32754. fogEnd: number;
  32755. private _shadowsEnabled;
  32756. /**
  32757. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32758. */
  32759. shadowsEnabled: boolean;
  32760. private _lightsEnabled;
  32761. /**
  32762. * Gets or sets a boolean indicating if lights are enabled on this scene
  32763. */
  32764. lightsEnabled: boolean;
  32765. /** All of the active cameras added to this scene. */
  32766. activeCameras: Camera[];
  32767. /** @hidden */
  32768. _activeCamera: Nullable<Camera>;
  32769. /** Gets or sets the current active camera */
  32770. activeCamera: Nullable<Camera>;
  32771. private _defaultMaterial;
  32772. /** The default material used on meshes when no material is affected */
  32773. /** The default material used on meshes when no material is affected */
  32774. defaultMaterial: Material;
  32775. private _texturesEnabled;
  32776. /**
  32777. * Gets or sets a boolean indicating if textures are enabled on this scene
  32778. */
  32779. texturesEnabled: boolean;
  32780. /**
  32781. * Gets or sets a boolean indicating if particles are enabled on this scene
  32782. */
  32783. particlesEnabled: boolean;
  32784. /**
  32785. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32786. */
  32787. spritesEnabled: boolean;
  32788. private _skeletonsEnabled;
  32789. /**
  32790. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32791. */
  32792. skeletonsEnabled: boolean;
  32793. /**
  32794. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32795. */
  32796. lensFlaresEnabled: boolean;
  32797. /**
  32798. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32799. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32800. */
  32801. collisionsEnabled: boolean;
  32802. private _collisionCoordinator;
  32803. /** @hidden */
  32804. readonly collisionCoordinator: ICollisionCoordinator;
  32805. /**
  32806. * Defines the gravity applied to this scene (used only for collisions)
  32807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32808. */
  32809. gravity: Vector3;
  32810. /**
  32811. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32812. */
  32813. postProcessesEnabled: boolean;
  32814. /**
  32815. * The list of postprocesses added to the scene
  32816. */
  32817. postProcesses: PostProcess[];
  32818. /**
  32819. * Gets the current postprocess manager
  32820. */
  32821. postProcessManager: PostProcessManager;
  32822. /**
  32823. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32824. */
  32825. renderTargetsEnabled: boolean;
  32826. /**
  32827. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32828. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32829. */
  32830. dumpNextRenderTargets: boolean;
  32831. /**
  32832. * The list of user defined render targets added to the scene
  32833. */
  32834. customRenderTargets: RenderTargetTexture[];
  32835. /**
  32836. * Defines if texture loading must be delayed
  32837. * If true, textures will only be loaded when they need to be rendered
  32838. */
  32839. useDelayedTextureLoading: boolean;
  32840. /**
  32841. * Gets the list of meshes imported to the scene through SceneLoader
  32842. */
  32843. importedMeshesFiles: String[];
  32844. /**
  32845. * Gets or sets a boolean indicating if probes are enabled on this scene
  32846. */
  32847. probesEnabled: boolean;
  32848. /**
  32849. * Gets or sets the current offline provider to use to store scene data
  32850. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32851. */
  32852. offlineProvider: IOfflineProvider;
  32853. /**
  32854. * Gets or sets the action manager associated with the scene
  32855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32856. */
  32857. actionManager: AbstractActionManager;
  32858. private _meshesForIntersections;
  32859. /**
  32860. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32861. */
  32862. proceduralTexturesEnabled: boolean;
  32863. private _engine;
  32864. private _totalVertices;
  32865. /** @hidden */
  32866. _activeIndices: PerfCounter;
  32867. /** @hidden */
  32868. _activeParticles: PerfCounter;
  32869. /** @hidden */
  32870. _activeBones: PerfCounter;
  32871. private _animationRatio;
  32872. /** @hidden */
  32873. _animationTimeLast: number;
  32874. /** @hidden */
  32875. _animationTime: number;
  32876. /**
  32877. * Gets or sets a general scale for animation speed
  32878. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32879. */
  32880. animationTimeScale: number;
  32881. /** @hidden */
  32882. _cachedMaterial: Nullable<Material>;
  32883. /** @hidden */
  32884. _cachedEffect: Nullable<Effect>;
  32885. /** @hidden */
  32886. _cachedVisibility: Nullable<number>;
  32887. private _renderId;
  32888. private _frameId;
  32889. private _executeWhenReadyTimeoutId;
  32890. private _intermediateRendering;
  32891. private _viewUpdateFlag;
  32892. private _projectionUpdateFlag;
  32893. /** @hidden */
  32894. _toBeDisposed: Nullable<IDisposable>[];
  32895. private _activeRequests;
  32896. /** @hidden */
  32897. _pendingData: any[];
  32898. private _isDisposed;
  32899. /**
  32900. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32901. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32902. */
  32903. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32904. private _activeMeshes;
  32905. private _processedMaterials;
  32906. private _renderTargets;
  32907. /** @hidden */
  32908. _activeParticleSystems: SmartArray<IParticleSystem>;
  32909. private _activeSkeletons;
  32910. private _softwareSkinnedMeshes;
  32911. private _renderingManager;
  32912. /** @hidden */
  32913. _activeAnimatables: Animatable[];
  32914. private _transformMatrix;
  32915. private _sceneUbo;
  32916. /** @hidden */
  32917. _viewMatrix: Matrix;
  32918. private _projectionMatrix;
  32919. /** @hidden */
  32920. _forcedViewPosition: Nullable<Vector3>;
  32921. /** @hidden */
  32922. _frustumPlanes: Plane[];
  32923. /**
  32924. * Gets the list of frustum planes (built from the active camera)
  32925. */
  32926. readonly frustumPlanes: Plane[];
  32927. /**
  32928. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32929. * This is useful if there are more lights that the maximum simulteanous authorized
  32930. */
  32931. requireLightSorting: boolean;
  32932. /** @hidden */
  32933. readonly useMaterialMeshMap: boolean;
  32934. /** @hidden */
  32935. readonly useClonedMeshhMap: boolean;
  32936. private _externalData;
  32937. private _uid;
  32938. /**
  32939. * @hidden
  32940. * Backing store of defined scene components.
  32941. */
  32942. _components: ISceneComponent[];
  32943. /**
  32944. * @hidden
  32945. * Backing store of defined scene components.
  32946. */
  32947. _serializableComponents: ISceneSerializableComponent[];
  32948. /**
  32949. * List of components to register on the next registration step.
  32950. */
  32951. private _transientComponents;
  32952. /**
  32953. * Registers the transient components if needed.
  32954. */
  32955. private _registerTransientComponents;
  32956. /**
  32957. * @hidden
  32958. * Add a component to the scene.
  32959. * Note that the ccomponent could be registered on th next frame if this is called after
  32960. * the register component stage.
  32961. * @param component Defines the component to add to the scene
  32962. */
  32963. _addComponent(component: ISceneComponent): void;
  32964. /**
  32965. * @hidden
  32966. * Gets a component from the scene.
  32967. * @param name defines the name of the component to retrieve
  32968. * @returns the component or null if not present
  32969. */
  32970. _getComponent(name: string): Nullable<ISceneComponent>;
  32971. /**
  32972. * @hidden
  32973. * Defines the actions happening before camera updates.
  32974. */
  32975. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32976. /**
  32977. * @hidden
  32978. * Defines the actions happening before clear the canvas.
  32979. */
  32980. _beforeClearStage: Stage<SimpleStageAction>;
  32981. /**
  32982. * @hidden
  32983. * Defines the actions when collecting render targets for the frame.
  32984. */
  32985. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32986. /**
  32987. * @hidden
  32988. * Defines the actions happening for one camera in the frame.
  32989. */
  32990. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32991. /**
  32992. * @hidden
  32993. * Defines the actions happening during the per mesh ready checks.
  32994. */
  32995. _isReadyForMeshStage: Stage<MeshStageAction>;
  32996. /**
  32997. * @hidden
  32998. * Defines the actions happening before evaluate active mesh checks.
  32999. */
  33000. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33001. /**
  33002. * @hidden
  33003. * Defines the actions happening during the evaluate sub mesh checks.
  33004. */
  33005. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33006. /**
  33007. * @hidden
  33008. * Defines the actions happening during the active mesh stage.
  33009. */
  33010. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33011. /**
  33012. * @hidden
  33013. * Defines the actions happening during the per camera render target step.
  33014. */
  33015. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33016. /**
  33017. * @hidden
  33018. * Defines the actions happening just before the active camera is drawing.
  33019. */
  33020. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33021. /**
  33022. * @hidden
  33023. * Defines the actions happening just before a render target is drawing.
  33024. */
  33025. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33026. /**
  33027. * @hidden
  33028. * Defines the actions happening just before a rendering group is drawing.
  33029. */
  33030. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33031. /**
  33032. * @hidden
  33033. * Defines the actions happening just before a mesh is drawing.
  33034. */
  33035. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33036. /**
  33037. * @hidden
  33038. * Defines the actions happening just after a mesh has been drawn.
  33039. */
  33040. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33041. /**
  33042. * @hidden
  33043. * Defines the actions happening just after a rendering group has been drawn.
  33044. */
  33045. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33046. /**
  33047. * @hidden
  33048. * Defines the actions happening just after the active camera has been drawn.
  33049. */
  33050. _afterCameraDrawStage: Stage<CameraStageAction>;
  33051. /**
  33052. * @hidden
  33053. * Defines the actions happening just after a render target has been drawn.
  33054. */
  33055. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33056. /**
  33057. * @hidden
  33058. * Defines the actions happening just after rendering all cameras and computing intersections.
  33059. */
  33060. _afterRenderStage: Stage<SimpleStageAction>;
  33061. /**
  33062. * @hidden
  33063. * Defines the actions happening when a pointer move event happens.
  33064. */
  33065. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33066. /**
  33067. * @hidden
  33068. * Defines the actions happening when a pointer down event happens.
  33069. */
  33070. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33071. /**
  33072. * @hidden
  33073. * Defines the actions happening when a pointer up event happens.
  33074. */
  33075. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33076. /**
  33077. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33078. */
  33079. private geometriesByUniqueId;
  33080. /**
  33081. * Creates a new Scene
  33082. * @param engine defines the engine to use to render this scene
  33083. * @param options defines the scene options
  33084. */
  33085. constructor(engine: Engine, options?: SceneOptions);
  33086. /**
  33087. * Gets a string idenfifying the name of the class
  33088. * @returns "Scene" string
  33089. */
  33090. getClassName(): string;
  33091. private _defaultMeshCandidates;
  33092. /**
  33093. * @hidden
  33094. */
  33095. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33096. private _defaultSubMeshCandidates;
  33097. /**
  33098. * @hidden
  33099. */
  33100. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33101. /**
  33102. * Sets the default candidate providers for the scene.
  33103. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33104. * and getCollidingSubMeshCandidates to their default function
  33105. */
  33106. setDefaultCandidateProviders(): void;
  33107. /**
  33108. * Gets the mesh that is currently under the pointer
  33109. */
  33110. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33111. /**
  33112. * Gets or sets the current on-screen X position of the pointer
  33113. */
  33114. pointerX: number;
  33115. /**
  33116. * Gets or sets the current on-screen Y position of the pointer
  33117. */
  33118. pointerY: number;
  33119. /**
  33120. * Gets the cached material (ie. the latest rendered one)
  33121. * @returns the cached material
  33122. */
  33123. getCachedMaterial(): Nullable<Material>;
  33124. /**
  33125. * Gets the cached effect (ie. the latest rendered one)
  33126. * @returns the cached effect
  33127. */
  33128. getCachedEffect(): Nullable<Effect>;
  33129. /**
  33130. * Gets the cached visibility state (ie. the latest rendered one)
  33131. * @returns the cached visibility state
  33132. */
  33133. getCachedVisibility(): Nullable<number>;
  33134. /**
  33135. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33136. * @param material defines the current material
  33137. * @param effect defines the current effect
  33138. * @param visibility defines the current visibility state
  33139. * @returns true if one parameter is not cached
  33140. */
  33141. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33142. /**
  33143. * Gets the engine associated with the scene
  33144. * @returns an Engine
  33145. */
  33146. getEngine(): Engine;
  33147. /**
  33148. * Gets the total number of vertices rendered per frame
  33149. * @returns the total number of vertices rendered per frame
  33150. */
  33151. getTotalVertices(): number;
  33152. /**
  33153. * Gets the performance counter for total vertices
  33154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33155. */
  33156. readonly totalVerticesPerfCounter: PerfCounter;
  33157. /**
  33158. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33159. * @returns the total number of active indices rendered per frame
  33160. */
  33161. getActiveIndices(): number;
  33162. /**
  33163. * Gets the performance counter for active indices
  33164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33165. */
  33166. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33167. /**
  33168. * Gets the total number of active particles rendered per frame
  33169. * @returns the total number of active particles rendered per frame
  33170. */
  33171. getActiveParticles(): number;
  33172. /**
  33173. * Gets the performance counter for active particles
  33174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33175. */
  33176. readonly activeParticlesPerfCounter: PerfCounter;
  33177. /**
  33178. * Gets the total number of active bones rendered per frame
  33179. * @returns the total number of active bones rendered per frame
  33180. */
  33181. getActiveBones(): number;
  33182. /**
  33183. * Gets the performance counter for active bones
  33184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33185. */
  33186. readonly activeBonesPerfCounter: PerfCounter;
  33187. /**
  33188. * Gets the array of active meshes
  33189. * @returns an array of AbstractMesh
  33190. */
  33191. getActiveMeshes(): SmartArray<AbstractMesh>;
  33192. /**
  33193. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33194. * @returns a number
  33195. */
  33196. getAnimationRatio(): number;
  33197. /**
  33198. * Gets an unique Id for the current render phase
  33199. * @returns a number
  33200. */
  33201. getRenderId(): number;
  33202. /**
  33203. * Gets an unique Id for the current frame
  33204. * @returns a number
  33205. */
  33206. getFrameId(): number;
  33207. /** Call this function if you want to manually increment the render Id*/
  33208. incrementRenderId(): void;
  33209. private _createUbo;
  33210. /**
  33211. * Use this method to simulate a pointer move on a mesh
  33212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33215. * @returns the current scene
  33216. */
  33217. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33218. /**
  33219. * Use this method to simulate a pointer down on a mesh
  33220. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33221. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33222. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33223. * @returns the current scene
  33224. */
  33225. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33226. /**
  33227. * Use this method to simulate a pointer up on a mesh
  33228. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33229. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33230. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33231. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33232. * @returns the current scene
  33233. */
  33234. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33235. /**
  33236. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33237. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33238. * @returns true if the pointer was captured
  33239. */
  33240. isPointerCaptured(pointerId?: number): boolean;
  33241. /**
  33242. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33243. * @param attachUp defines if you want to attach events to pointerup
  33244. * @param attachDown defines if you want to attach events to pointerdown
  33245. * @param attachMove defines if you want to attach events to pointermove
  33246. */
  33247. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33248. /** Detaches all event handlers*/
  33249. detachControl(): void;
  33250. /**
  33251. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33252. * Delay loaded resources are not taking in account
  33253. * @return true if all required resources are ready
  33254. */
  33255. isReady(): boolean;
  33256. /** Resets all cached information relative to material (including effect and visibility) */
  33257. resetCachedMaterial(): void;
  33258. /**
  33259. * Registers a function to be called before every frame render
  33260. * @param func defines the function to register
  33261. */
  33262. registerBeforeRender(func: () => void): void;
  33263. /**
  33264. * Unregisters a function called before every frame render
  33265. * @param func defines the function to unregister
  33266. */
  33267. unregisterBeforeRender(func: () => void): void;
  33268. /**
  33269. * Registers a function to be called after every frame render
  33270. * @param func defines the function to register
  33271. */
  33272. registerAfterRender(func: () => void): void;
  33273. /**
  33274. * Unregisters a function called after every frame render
  33275. * @param func defines the function to unregister
  33276. */
  33277. unregisterAfterRender(func: () => void): void;
  33278. private _executeOnceBeforeRender;
  33279. /**
  33280. * The provided function will run before render once and will be disposed afterwards.
  33281. * A timeout delay can be provided so that the function will be executed in N ms.
  33282. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33283. * @param func The function to be executed.
  33284. * @param timeout optional delay in ms
  33285. */
  33286. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33287. /** @hidden */
  33288. _addPendingData(data: any): void;
  33289. /** @hidden */
  33290. _removePendingData(data: any): void;
  33291. /**
  33292. * Returns the number of items waiting to be loaded
  33293. * @returns the number of items waiting to be loaded
  33294. */
  33295. getWaitingItemsCount(): number;
  33296. /**
  33297. * Returns a boolean indicating if the scene is still loading data
  33298. */
  33299. readonly isLoading: boolean;
  33300. /**
  33301. * Registers a function to be executed when the scene is ready
  33302. * @param {Function} func - the function to be executed
  33303. */
  33304. executeWhenReady(func: () => void): void;
  33305. /**
  33306. * Returns a promise that resolves when the scene is ready
  33307. * @returns A promise that resolves when the scene is ready
  33308. */
  33309. whenReadyAsync(): Promise<void>;
  33310. /** @hidden */
  33311. _checkIsReady(): void;
  33312. /**
  33313. * Gets all animatable attached to the scene
  33314. */
  33315. readonly animatables: Animatable[];
  33316. /**
  33317. * Resets the last animation time frame.
  33318. * Useful to override when animations start running when loading a scene for the first time.
  33319. */
  33320. resetLastAnimationTimeFrame(): void;
  33321. /**
  33322. * Gets the current view matrix
  33323. * @returns a Matrix
  33324. */
  33325. getViewMatrix(): Matrix;
  33326. /**
  33327. * Gets the current projection matrix
  33328. * @returns a Matrix
  33329. */
  33330. getProjectionMatrix(): Matrix;
  33331. /**
  33332. * Gets the current transform matrix
  33333. * @returns a Matrix made of View * Projection
  33334. */
  33335. getTransformMatrix(): Matrix;
  33336. /**
  33337. * Sets the current transform matrix
  33338. * @param viewL defines the View matrix to use
  33339. * @param projectionL defines the Projection matrix to use
  33340. * @param viewR defines the right View matrix to use (if provided)
  33341. * @param projectionR defines the right Projection matrix to use (if provided)
  33342. */
  33343. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33344. /**
  33345. * Gets the uniform buffer used to store scene data
  33346. * @returns a UniformBuffer
  33347. */
  33348. getSceneUniformBuffer(): UniformBuffer;
  33349. /**
  33350. * Gets an unique (relatively to the current scene) Id
  33351. * @returns an unique number for the scene
  33352. */
  33353. getUniqueId(): number;
  33354. /**
  33355. * Add a mesh to the list of scene's meshes
  33356. * @param newMesh defines the mesh to add
  33357. * @param recursive if all child meshes should also be added to the scene
  33358. */
  33359. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33360. /**
  33361. * Remove a mesh for the list of scene's meshes
  33362. * @param toRemove defines the mesh to remove
  33363. * @param recursive if all child meshes should also be removed from the scene
  33364. * @returns the index where the mesh was in the mesh list
  33365. */
  33366. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33367. /**
  33368. * Add a transform node to the list of scene's transform nodes
  33369. * @param newTransformNode defines the transform node to add
  33370. */
  33371. addTransformNode(newTransformNode: TransformNode): void;
  33372. /**
  33373. * Remove a transform node for the list of scene's transform nodes
  33374. * @param toRemove defines the transform node to remove
  33375. * @returns the index where the transform node was in the transform node list
  33376. */
  33377. removeTransformNode(toRemove: TransformNode): number;
  33378. /**
  33379. * Remove a skeleton for the list of scene's skeletons
  33380. * @param toRemove defines the skeleton to remove
  33381. * @returns the index where the skeleton was in the skeleton list
  33382. */
  33383. removeSkeleton(toRemove: Skeleton): number;
  33384. /**
  33385. * Remove a morph target for the list of scene's morph targets
  33386. * @param toRemove defines the morph target to remove
  33387. * @returns the index where the morph target was in the morph target list
  33388. */
  33389. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33390. /**
  33391. * Remove a light for the list of scene's lights
  33392. * @param toRemove defines the light to remove
  33393. * @returns the index where the light was in the light list
  33394. */
  33395. removeLight(toRemove: Light): number;
  33396. /**
  33397. * Remove a camera for the list of scene's cameras
  33398. * @param toRemove defines the camera to remove
  33399. * @returns the index where the camera was in the camera list
  33400. */
  33401. removeCamera(toRemove: Camera): number;
  33402. /**
  33403. * Remove a particle system for the list of scene's particle systems
  33404. * @param toRemove defines the particle system to remove
  33405. * @returns the index where the particle system was in the particle system list
  33406. */
  33407. removeParticleSystem(toRemove: IParticleSystem): number;
  33408. /**
  33409. * Remove a animation for the list of scene's animations
  33410. * @param toRemove defines the animation to remove
  33411. * @returns the index where the animation was in the animation list
  33412. */
  33413. removeAnimation(toRemove: Animation): number;
  33414. /**
  33415. * Will stop the animation of the given target
  33416. * @param target - the target
  33417. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33418. * @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)
  33419. */
  33420. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33421. /**
  33422. * Removes the given animation group from this scene.
  33423. * @param toRemove The animation group to remove
  33424. * @returns The index of the removed animation group
  33425. */
  33426. removeAnimationGroup(toRemove: AnimationGroup): number;
  33427. /**
  33428. * Removes the given multi-material from this scene.
  33429. * @param toRemove The multi-material to remove
  33430. * @returns The index of the removed multi-material
  33431. */
  33432. removeMultiMaterial(toRemove: MultiMaterial): number;
  33433. /**
  33434. * Removes the given material from this scene.
  33435. * @param toRemove The material to remove
  33436. * @returns The index of the removed material
  33437. */
  33438. removeMaterial(toRemove: Material): number;
  33439. /**
  33440. * Removes the given action manager from this scene.
  33441. * @param toRemove The action manager to remove
  33442. * @returns The index of the removed action manager
  33443. */
  33444. removeActionManager(toRemove: AbstractActionManager): number;
  33445. /**
  33446. * Removes the given texture from this scene.
  33447. * @param toRemove The texture to remove
  33448. * @returns The index of the removed texture
  33449. */
  33450. removeTexture(toRemove: BaseTexture): number;
  33451. /**
  33452. * Adds the given light to this scene
  33453. * @param newLight The light to add
  33454. */
  33455. addLight(newLight: Light): void;
  33456. /**
  33457. * Sorts the list list based on light priorities
  33458. */
  33459. sortLightsByPriority(): void;
  33460. /**
  33461. * Adds the given camera to this scene
  33462. * @param newCamera The camera to add
  33463. */
  33464. addCamera(newCamera: Camera): void;
  33465. /**
  33466. * Adds the given skeleton to this scene
  33467. * @param newSkeleton The skeleton to add
  33468. */
  33469. addSkeleton(newSkeleton: Skeleton): void;
  33470. /**
  33471. * Adds the given particle system to this scene
  33472. * @param newParticleSystem The particle system to add
  33473. */
  33474. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33475. /**
  33476. * Adds the given animation to this scene
  33477. * @param newAnimation The animation to add
  33478. */
  33479. addAnimation(newAnimation: Animation): void;
  33480. /**
  33481. * Adds the given animation group to this scene.
  33482. * @param newAnimationGroup The animation group to add
  33483. */
  33484. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33485. /**
  33486. * Adds the given multi-material to this scene
  33487. * @param newMultiMaterial The multi-material to add
  33488. */
  33489. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33490. /**
  33491. * Adds the given material to this scene
  33492. * @param newMaterial The material to add
  33493. */
  33494. addMaterial(newMaterial: Material): void;
  33495. /**
  33496. * Adds the given morph target to this scene
  33497. * @param newMorphTargetManager The morph target to add
  33498. */
  33499. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33500. /**
  33501. * Adds the given geometry to this scene
  33502. * @param newGeometry The geometry to add
  33503. */
  33504. addGeometry(newGeometry: Geometry): void;
  33505. /**
  33506. * Adds the given action manager to this scene
  33507. * @param newActionManager The action manager to add
  33508. */
  33509. addActionManager(newActionManager: AbstractActionManager): void;
  33510. /**
  33511. * Adds the given texture to this scene.
  33512. * @param newTexture The texture to add
  33513. */
  33514. addTexture(newTexture: BaseTexture): void;
  33515. /**
  33516. * Switch active camera
  33517. * @param newCamera defines the new active camera
  33518. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33519. */
  33520. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33521. /**
  33522. * sets the active camera of the scene using its ID
  33523. * @param id defines the camera's ID
  33524. * @return the new active camera or null if none found.
  33525. */
  33526. setActiveCameraByID(id: string): Nullable<Camera>;
  33527. /**
  33528. * sets the active camera of the scene using its name
  33529. * @param name defines the camera's name
  33530. * @returns the new active camera or null if none found.
  33531. */
  33532. setActiveCameraByName(name: string): Nullable<Camera>;
  33533. /**
  33534. * get an animation group using its name
  33535. * @param name defines the material's name
  33536. * @return the animation group or null if none found.
  33537. */
  33538. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33539. /**
  33540. * Get a material using its unique id
  33541. * @param uniqueId defines the material's unique id
  33542. * @return the material or null if none found.
  33543. */
  33544. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33545. /**
  33546. * get a material using its id
  33547. * @param id defines the material's ID
  33548. * @return the material or null if none found.
  33549. */
  33550. getMaterialByID(id: string): Nullable<Material>;
  33551. /**
  33552. * Gets a material using its name
  33553. * @param name defines the material's name
  33554. * @return the material or null if none found.
  33555. */
  33556. getMaterialByName(name: string): Nullable<Material>;
  33557. /**
  33558. * Gets a camera using its id
  33559. * @param id defines the id to look for
  33560. * @returns the camera or null if not found
  33561. */
  33562. getCameraByID(id: string): Nullable<Camera>;
  33563. /**
  33564. * Gets a camera using its unique id
  33565. * @param uniqueId defines the unique id to look for
  33566. * @returns the camera or null if not found
  33567. */
  33568. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33569. /**
  33570. * Gets a camera using its name
  33571. * @param name defines the camera's name
  33572. * @return the camera or null if none found.
  33573. */
  33574. getCameraByName(name: string): Nullable<Camera>;
  33575. /**
  33576. * Gets a bone using its id
  33577. * @param id defines the bone's id
  33578. * @return the bone or null if not found
  33579. */
  33580. getBoneByID(id: string): Nullable<Bone>;
  33581. /**
  33582. * Gets a bone using its id
  33583. * @param name defines the bone's name
  33584. * @return the bone or null if not found
  33585. */
  33586. getBoneByName(name: string): Nullable<Bone>;
  33587. /**
  33588. * Gets a light node using its name
  33589. * @param name defines the the light's name
  33590. * @return the light or null if none found.
  33591. */
  33592. getLightByName(name: string): Nullable<Light>;
  33593. /**
  33594. * Gets a light node using its id
  33595. * @param id defines the light's id
  33596. * @return the light or null if none found.
  33597. */
  33598. getLightByID(id: string): Nullable<Light>;
  33599. /**
  33600. * Gets a light node using its scene-generated unique ID
  33601. * @param uniqueId defines the light's unique id
  33602. * @return the light or null if none found.
  33603. */
  33604. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33605. /**
  33606. * Gets a particle system by id
  33607. * @param id defines the particle system id
  33608. * @return the corresponding system or null if none found
  33609. */
  33610. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33611. /**
  33612. * Gets a geometry using its ID
  33613. * @param id defines the geometry's id
  33614. * @return the geometry or null if none found.
  33615. */
  33616. getGeometryByID(id: string): Nullable<Geometry>;
  33617. private _getGeometryByUniqueID;
  33618. /**
  33619. * Add a new geometry to this scene
  33620. * @param geometry defines the geometry to be added to the scene.
  33621. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33622. * @return a boolean defining if the geometry was added or not
  33623. */
  33624. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33625. /**
  33626. * Removes an existing geometry
  33627. * @param geometry defines the geometry to be removed from the scene
  33628. * @return a boolean defining if the geometry was removed or not
  33629. */
  33630. removeGeometry(geometry: Geometry): boolean;
  33631. /**
  33632. * Gets the list of geometries attached to the scene
  33633. * @returns an array of Geometry
  33634. */
  33635. getGeometries(): Geometry[];
  33636. /**
  33637. * Gets the first added mesh found of a given ID
  33638. * @param id defines the id to search for
  33639. * @return the mesh found or null if not found at all
  33640. */
  33641. getMeshByID(id: string): Nullable<AbstractMesh>;
  33642. /**
  33643. * Gets a list of meshes using their id
  33644. * @param id defines the id to search for
  33645. * @returns a list of meshes
  33646. */
  33647. getMeshesByID(id: string): Array<AbstractMesh>;
  33648. /**
  33649. * Gets the first added transform node found of a given ID
  33650. * @param id defines the id to search for
  33651. * @return the found transform node or null if not found at all.
  33652. */
  33653. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33654. /**
  33655. * Gets a transform node with its auto-generated unique id
  33656. * @param uniqueId efines the unique id to search for
  33657. * @return the found transform node or null if not found at all.
  33658. */
  33659. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33660. /**
  33661. * Gets a list of transform nodes using their id
  33662. * @param id defines the id to search for
  33663. * @returns a list of transform nodes
  33664. */
  33665. getTransformNodesByID(id: string): Array<TransformNode>;
  33666. /**
  33667. * Gets a mesh with its auto-generated unique id
  33668. * @param uniqueId defines the unique id to search for
  33669. * @return the found mesh or null if not found at all.
  33670. */
  33671. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33672. /**
  33673. * Gets a the last added mesh using a given id
  33674. * @param id defines the id to search for
  33675. * @return the found mesh or null if not found at all.
  33676. */
  33677. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33678. /**
  33679. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33680. * @param id defines the id to search for
  33681. * @return the found node or null if not found at all
  33682. */
  33683. getLastEntryByID(id: string): Nullable<Node>;
  33684. /**
  33685. * Gets a node (Mesh, Camera, Light) using a given id
  33686. * @param id defines the id to search for
  33687. * @return the found node or null if not found at all
  33688. */
  33689. getNodeByID(id: string): Nullable<Node>;
  33690. /**
  33691. * Gets a node (Mesh, Camera, Light) using a given name
  33692. * @param name defines the name to search for
  33693. * @return the found node or null if not found at all.
  33694. */
  33695. getNodeByName(name: string): Nullable<Node>;
  33696. /**
  33697. * Gets a mesh using a given name
  33698. * @param name defines the name to search for
  33699. * @return the found mesh or null if not found at all.
  33700. */
  33701. getMeshByName(name: string): Nullable<AbstractMesh>;
  33702. /**
  33703. * Gets a transform node using a given name
  33704. * @param name defines the name to search for
  33705. * @return the found transform node or null if not found at all.
  33706. */
  33707. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33708. /**
  33709. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33710. * @param id defines the id to search for
  33711. * @return the found skeleton or null if not found at all.
  33712. */
  33713. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33714. /**
  33715. * Gets a skeleton using a given auto generated unique id
  33716. * @param uniqueId defines the unique id to search for
  33717. * @return the found skeleton or null if not found at all.
  33718. */
  33719. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33720. /**
  33721. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33722. * @param id defines the id to search for
  33723. * @return the found skeleton or null if not found at all.
  33724. */
  33725. getSkeletonById(id: string): Nullable<Skeleton>;
  33726. /**
  33727. * Gets a skeleton using a given name
  33728. * @param name defines the name to search for
  33729. * @return the found skeleton or null if not found at all.
  33730. */
  33731. getSkeletonByName(name: string): Nullable<Skeleton>;
  33732. /**
  33733. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33734. * @param id defines the id to search for
  33735. * @return the found morph target manager or null if not found at all.
  33736. */
  33737. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33738. /**
  33739. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33740. * @param id defines the id to search for
  33741. * @return the found morph target or null if not found at all.
  33742. */
  33743. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33744. /**
  33745. * Gets a boolean indicating if the given mesh is active
  33746. * @param mesh defines the mesh to look for
  33747. * @returns true if the mesh is in the active list
  33748. */
  33749. isActiveMesh(mesh: AbstractMesh): boolean;
  33750. /**
  33751. * Return a unique id as a string which can serve as an identifier for the scene
  33752. */
  33753. readonly uid: string;
  33754. /**
  33755. * Add an externaly attached data from its key.
  33756. * This method call will fail and return false, if such key already exists.
  33757. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33758. * @param key the unique key that identifies the data
  33759. * @param data the data object to associate to the key for this Engine instance
  33760. * @return true if no such key were already present and the data was added successfully, false otherwise
  33761. */
  33762. addExternalData<T>(key: string, data: T): boolean;
  33763. /**
  33764. * Get an externaly attached data from its key
  33765. * @param key the unique key that identifies the data
  33766. * @return the associated data, if present (can be null), or undefined if not present
  33767. */
  33768. getExternalData<T>(key: string): Nullable<T>;
  33769. /**
  33770. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33771. * @param key the unique key that identifies the data
  33772. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33773. * @return the associated data, can be null if the factory returned null.
  33774. */
  33775. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33776. /**
  33777. * Remove an externaly attached data from the Engine instance
  33778. * @param key the unique key that identifies the data
  33779. * @return true if the data was successfully removed, false if it doesn't exist
  33780. */
  33781. removeExternalData(key: string): boolean;
  33782. private _evaluateSubMesh;
  33783. /**
  33784. * Clear the processed materials smart array preventing retention point in material dispose.
  33785. */
  33786. freeProcessedMaterials(): void;
  33787. private _preventFreeActiveMeshesAndRenderingGroups;
  33788. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33789. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33790. * when disposing several meshes in a row or a hierarchy of meshes.
  33791. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33792. */
  33793. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33794. /**
  33795. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33796. */
  33797. freeActiveMeshes(): void;
  33798. /**
  33799. * Clear the info related to rendering groups preventing retention points during dispose.
  33800. */
  33801. freeRenderingGroups(): void;
  33802. /** @hidden */
  33803. _isInIntermediateRendering(): boolean;
  33804. /**
  33805. * Lambda returning the list of potentially active meshes.
  33806. */
  33807. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33808. /**
  33809. * Lambda returning the list of potentially active sub meshes.
  33810. */
  33811. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33812. /**
  33813. * Lambda returning the list of potentially intersecting sub meshes.
  33814. */
  33815. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33816. /**
  33817. * Lambda returning the list of potentially colliding sub meshes.
  33818. */
  33819. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33820. private _activeMeshesFrozen;
  33821. /**
  33822. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33823. * @returns the current scene
  33824. */
  33825. freezeActiveMeshes(): Scene;
  33826. /**
  33827. * Use this function to restart evaluating active meshes on every frame
  33828. * @returns the current scene
  33829. */
  33830. unfreezeActiveMeshes(): Scene;
  33831. private _evaluateActiveMeshes;
  33832. private _activeMesh;
  33833. /**
  33834. * Update the transform matrix to update from the current active camera
  33835. * @param force defines a boolean used to force the update even if cache is up to date
  33836. */
  33837. updateTransformMatrix(force?: boolean): void;
  33838. private _bindFrameBuffer;
  33839. /** @hidden */
  33840. _allowPostProcessClearColor: boolean;
  33841. /** @hidden */
  33842. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33843. private _processSubCameras;
  33844. private _checkIntersections;
  33845. /** @hidden */
  33846. _advancePhysicsEngineStep(step: number): void;
  33847. /**
  33848. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33849. */
  33850. getDeterministicFrameTime: () => number;
  33851. /** @hidden */
  33852. _animate(): void;
  33853. /** Execute all animations (for a frame) */
  33854. animate(): void;
  33855. /**
  33856. * Render the scene
  33857. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33858. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33859. */
  33860. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33861. /**
  33862. * Freeze all materials
  33863. * A frozen material will not be updatable but should be faster to render
  33864. */
  33865. freezeMaterials(): void;
  33866. /**
  33867. * Unfreeze all materials
  33868. * A frozen material will not be updatable but should be faster to render
  33869. */
  33870. unfreezeMaterials(): void;
  33871. /**
  33872. * Releases all held ressources
  33873. */
  33874. dispose(): void;
  33875. /**
  33876. * Gets if the scene is already disposed
  33877. */
  33878. readonly isDisposed: boolean;
  33879. /**
  33880. * Call this function to reduce memory footprint of the scene.
  33881. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33882. */
  33883. clearCachedVertexData(): void;
  33884. /**
  33885. * This function will remove the local cached buffer data from texture.
  33886. * It will save memory but will prevent the texture from being rebuilt
  33887. */
  33888. cleanCachedTextureBuffer(): void;
  33889. /**
  33890. * Get the world extend vectors with an optional filter
  33891. *
  33892. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33893. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33894. */
  33895. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33896. min: Vector3;
  33897. max: Vector3;
  33898. };
  33899. /**
  33900. * Creates a ray that can be used to pick in the scene
  33901. * @param x defines the x coordinate of the origin (on-screen)
  33902. * @param y defines the y coordinate of the origin (on-screen)
  33903. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33904. * @param camera defines the camera to use for the picking
  33905. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33906. * @returns a Ray
  33907. */
  33908. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33909. /**
  33910. * Creates a ray that can be used to pick in the scene
  33911. * @param x defines the x coordinate of the origin (on-screen)
  33912. * @param y defines the y coordinate of the origin (on-screen)
  33913. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33914. * @param result defines the ray where to store the picking ray
  33915. * @param camera defines the camera to use for the picking
  33916. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33917. * @returns the current scene
  33918. */
  33919. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33920. /**
  33921. * Creates a ray that can be used to pick in the scene
  33922. * @param x defines the x coordinate of the origin (on-screen)
  33923. * @param y defines the y coordinate of the origin (on-screen)
  33924. * @param camera defines the camera to use for the picking
  33925. * @returns a Ray
  33926. */
  33927. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33928. /**
  33929. * Creates a ray that can be used to pick in the scene
  33930. * @param x defines the x coordinate of the origin (on-screen)
  33931. * @param y defines the y coordinate of the origin (on-screen)
  33932. * @param result defines the ray where to store the picking ray
  33933. * @param camera defines the camera to use for the picking
  33934. * @returns the current scene
  33935. */
  33936. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33937. /** Launch a ray to try to pick a mesh in the scene
  33938. * @param x position on screen
  33939. * @param y position on screen
  33940. * @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
  33941. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33942. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33943. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33944. * @returns a PickingInfo
  33945. */
  33946. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33947. /** Use the given ray to pick a mesh in the scene
  33948. * @param ray The ray to use to pick meshes
  33949. * @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
  33950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33952. * @returns a PickingInfo
  33953. */
  33954. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33955. /**
  33956. * Launch a ray to try to pick a mesh in the scene
  33957. * @param x X position on screen
  33958. * @param y Y position on screen
  33959. * @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
  33960. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33961. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33962. * @returns an array of PickingInfo
  33963. */
  33964. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33965. /**
  33966. * Launch a ray to try to pick a mesh in the scene
  33967. * @param ray Ray to use
  33968. * @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
  33969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33970. * @returns an array of PickingInfo
  33971. */
  33972. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33973. /**
  33974. * Force the value of meshUnderPointer
  33975. * @param mesh defines the mesh to use
  33976. */
  33977. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33978. /**
  33979. * Gets the mesh under the pointer
  33980. * @returns a Mesh or null if no mesh is under the pointer
  33981. */
  33982. getPointerOverMesh(): Nullable<AbstractMesh>;
  33983. /** @hidden */
  33984. _rebuildGeometries(): void;
  33985. /** @hidden */
  33986. _rebuildTextures(): void;
  33987. private _getByTags;
  33988. /**
  33989. * Get a list of meshes by tags
  33990. * @param tagsQuery defines the tags query to use
  33991. * @param forEach defines a predicate used to filter results
  33992. * @returns an array of Mesh
  33993. */
  33994. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33995. /**
  33996. * Get a list of cameras by tags
  33997. * @param tagsQuery defines the tags query to use
  33998. * @param forEach defines a predicate used to filter results
  33999. * @returns an array of Camera
  34000. */
  34001. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34002. /**
  34003. * Get a list of lights by tags
  34004. * @param tagsQuery defines the tags query to use
  34005. * @param forEach defines a predicate used to filter results
  34006. * @returns an array of Light
  34007. */
  34008. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34009. /**
  34010. * Get a list of materials by tags
  34011. * @param tagsQuery defines the tags query to use
  34012. * @param forEach defines a predicate used to filter results
  34013. * @returns an array of Material
  34014. */
  34015. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34016. /**
  34017. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34018. * This allowed control for front to back rendering or reversly depending of the special needs.
  34019. *
  34020. * @param renderingGroupId The rendering group id corresponding to its index
  34021. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34022. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34023. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34024. */
  34025. 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;
  34026. /**
  34027. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34028. *
  34029. * @param renderingGroupId The rendering group id corresponding to its index
  34030. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34031. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34032. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34033. */
  34034. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34035. /**
  34036. * Gets the current auto clear configuration for one rendering group of the rendering
  34037. * manager.
  34038. * @param index the rendering group index to get the information for
  34039. * @returns The auto clear setup for the requested rendering group
  34040. */
  34041. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34042. private _blockMaterialDirtyMechanism;
  34043. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34044. blockMaterialDirtyMechanism: boolean;
  34045. /**
  34046. * Will flag all materials as dirty to trigger new shader compilation
  34047. * @param flag defines the flag used to specify which material part must be marked as dirty
  34048. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34049. */
  34050. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34051. /** @hidden */
  34052. _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;
  34053. /** @hidden */
  34054. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34055. }
  34056. }
  34057. declare module BABYLON {
  34058. /**
  34059. * Set of assets to keep when moving a scene into an asset container.
  34060. */
  34061. export class KeepAssets extends AbstractScene {
  34062. }
  34063. /**
  34064. * Container with a set of assets that can be added or removed from a scene.
  34065. */
  34066. export class AssetContainer extends AbstractScene {
  34067. /**
  34068. * The scene the AssetContainer belongs to.
  34069. */
  34070. scene: Scene;
  34071. /**
  34072. * Instantiates an AssetContainer.
  34073. * @param scene The scene the AssetContainer belongs to.
  34074. */
  34075. constructor(scene: Scene);
  34076. /**
  34077. * Adds all the assets from the container to the scene.
  34078. */
  34079. addAllToScene(): void;
  34080. /**
  34081. * Removes all the assets in the container from the scene
  34082. */
  34083. removeAllFromScene(): void;
  34084. /**
  34085. * Disposes all the assets in the container
  34086. */
  34087. dispose(): void;
  34088. private _moveAssets;
  34089. /**
  34090. * Removes all the assets contained in the scene and adds them to the container.
  34091. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34092. */
  34093. moveAllFromScene(keepAssets?: KeepAssets): void;
  34094. /**
  34095. * 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.
  34096. * @returns the root mesh
  34097. */
  34098. createRootMesh(): Mesh;
  34099. }
  34100. }
  34101. declare module BABYLON {
  34102. /**
  34103. * Defines how the parser contract is defined.
  34104. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34105. */
  34106. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34107. /**
  34108. * Defines how the individual parser contract is defined.
  34109. * These parser can parse an individual asset
  34110. */
  34111. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34112. /**
  34113. * Base class of the scene acting as a container for the different elements composing a scene.
  34114. * This class is dynamically extended by the different components of the scene increasing
  34115. * flexibility and reducing coupling
  34116. */
  34117. export abstract class AbstractScene {
  34118. /**
  34119. * Stores the list of available parsers in the application.
  34120. */
  34121. private static _BabylonFileParsers;
  34122. /**
  34123. * Stores the list of available individual parsers in the application.
  34124. */
  34125. private static _IndividualBabylonFileParsers;
  34126. /**
  34127. * Adds a parser in the list of available ones
  34128. * @param name Defines the name of the parser
  34129. * @param parser Defines the parser to add
  34130. */
  34131. static AddParser(name: string, parser: BabylonFileParser): void;
  34132. /**
  34133. * Gets a general parser from the list of avaialble ones
  34134. * @param name Defines the name of the parser
  34135. * @returns the requested parser or null
  34136. */
  34137. static GetParser(name: string): Nullable<BabylonFileParser>;
  34138. /**
  34139. * Adds n individual parser in the list of available ones
  34140. * @param name Defines the name of the parser
  34141. * @param parser Defines the parser to add
  34142. */
  34143. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34144. /**
  34145. * Gets an individual parser from the list of avaialble ones
  34146. * @param name Defines the name of the parser
  34147. * @returns the requested parser or null
  34148. */
  34149. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34150. /**
  34151. * Parser json data and populate both a scene and its associated container object
  34152. * @param jsonData Defines the data to parse
  34153. * @param scene Defines the scene to parse the data for
  34154. * @param container Defines the container attached to the parsing sequence
  34155. * @param rootUrl Defines the root url of the data
  34156. */
  34157. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34158. /**
  34159. * Gets the list of root nodes (ie. nodes with no parent)
  34160. */
  34161. rootNodes: Node[];
  34162. /** All of the cameras added to this scene
  34163. * @see http://doc.babylonjs.com/babylon101/cameras
  34164. */
  34165. cameras: Camera[];
  34166. /**
  34167. * All of the lights added to this scene
  34168. * @see http://doc.babylonjs.com/babylon101/lights
  34169. */
  34170. lights: Light[];
  34171. /**
  34172. * All of the (abstract) meshes added to this scene
  34173. */
  34174. meshes: AbstractMesh[];
  34175. /**
  34176. * The list of skeletons added to the scene
  34177. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34178. */
  34179. skeletons: Skeleton[];
  34180. /**
  34181. * All of the particle systems added to this scene
  34182. * @see http://doc.babylonjs.com/babylon101/particles
  34183. */
  34184. particleSystems: IParticleSystem[];
  34185. /**
  34186. * Gets a list of Animations associated with the scene
  34187. */
  34188. animations: Animation[];
  34189. /**
  34190. * All of the animation groups added to this scene
  34191. * @see http://doc.babylonjs.com/how_to/group
  34192. */
  34193. animationGroups: AnimationGroup[];
  34194. /**
  34195. * All of the multi-materials added to this scene
  34196. * @see http://doc.babylonjs.com/how_to/multi_materials
  34197. */
  34198. multiMaterials: MultiMaterial[];
  34199. /**
  34200. * All of the materials added to this scene
  34201. * In the context of a Scene, it is not supposed to be modified manually.
  34202. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34203. * Note also that the order of the Material wihin the array is not significant and might change.
  34204. * @see http://doc.babylonjs.com/babylon101/materials
  34205. */
  34206. materials: Material[];
  34207. /**
  34208. * The list of morph target managers added to the scene
  34209. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34210. */
  34211. morphTargetManagers: MorphTargetManager[];
  34212. /**
  34213. * The list of geometries used in the scene.
  34214. */
  34215. geometries: Geometry[];
  34216. /**
  34217. * All of the tranform nodes added to this scene
  34218. * In the context of a Scene, it is not supposed to be modified manually.
  34219. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34220. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34221. * @see http://doc.babylonjs.com/how_to/transformnode
  34222. */
  34223. transformNodes: TransformNode[];
  34224. /**
  34225. * ActionManagers available on the scene.
  34226. */
  34227. actionManagers: AbstractActionManager[];
  34228. /**
  34229. * Textures to keep.
  34230. */
  34231. textures: BaseTexture[];
  34232. /**
  34233. * Environment texture for the scene
  34234. */
  34235. environmentTexture: Nullable<BaseTexture>;
  34236. }
  34237. }
  34238. declare module BABYLON {
  34239. /**
  34240. * Interface used to define options for Sound class
  34241. */
  34242. export interface ISoundOptions {
  34243. /**
  34244. * Does the sound autoplay once loaded.
  34245. */
  34246. autoplay?: boolean;
  34247. /**
  34248. * Does the sound loop after it finishes playing once.
  34249. */
  34250. loop?: boolean;
  34251. /**
  34252. * Sound's volume
  34253. */
  34254. volume?: number;
  34255. /**
  34256. * Is it a spatial sound?
  34257. */
  34258. spatialSound?: boolean;
  34259. /**
  34260. * Maximum distance to hear that sound
  34261. */
  34262. maxDistance?: number;
  34263. /**
  34264. * Uses user defined attenuation function
  34265. */
  34266. useCustomAttenuation?: boolean;
  34267. /**
  34268. * Define the roll off factor of spatial sounds.
  34269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34270. */
  34271. rolloffFactor?: number;
  34272. /**
  34273. * Define the reference distance the sound should be heard perfectly.
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34275. */
  34276. refDistance?: number;
  34277. /**
  34278. * Define the distance attenuation model the sound will follow.
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34280. */
  34281. distanceModel?: string;
  34282. /**
  34283. * Defines the playback speed (1 by default)
  34284. */
  34285. playbackRate?: number;
  34286. /**
  34287. * Defines if the sound is from a streaming source
  34288. */
  34289. streaming?: boolean;
  34290. /**
  34291. * Defines an optional length (in seconds) inside the sound file
  34292. */
  34293. length?: number;
  34294. /**
  34295. * Defines an optional offset (in seconds) inside the sound file
  34296. */
  34297. offset?: number;
  34298. }
  34299. /**
  34300. * Defines a sound that can be played in the application.
  34301. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34303. */
  34304. export class Sound {
  34305. /**
  34306. * The name of the sound in the scene.
  34307. */
  34308. name: string;
  34309. /**
  34310. * Does the sound autoplay once loaded.
  34311. */
  34312. autoplay: boolean;
  34313. /**
  34314. * Does the sound loop after it finishes playing once.
  34315. */
  34316. loop: boolean;
  34317. /**
  34318. * Does the sound use a custom attenuation curve to simulate the falloff
  34319. * happening when the source gets further away from the camera.
  34320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34321. */
  34322. useCustomAttenuation: boolean;
  34323. /**
  34324. * The sound track id this sound belongs to.
  34325. */
  34326. soundTrackId: number;
  34327. /**
  34328. * Is this sound currently played.
  34329. */
  34330. isPlaying: boolean;
  34331. /**
  34332. * Is this sound currently paused.
  34333. */
  34334. isPaused: boolean;
  34335. /**
  34336. * Does this sound enables spatial sound.
  34337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34338. */
  34339. spatialSound: boolean;
  34340. /**
  34341. * Define the reference distance the sound should be heard perfectly.
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34343. */
  34344. refDistance: number;
  34345. /**
  34346. * Define the roll off factor of spatial sounds.
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34348. */
  34349. rolloffFactor: number;
  34350. /**
  34351. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34353. */
  34354. maxDistance: number;
  34355. /**
  34356. * Define the distance attenuation model the sound will follow.
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34358. */
  34359. distanceModel: string;
  34360. /**
  34361. * @hidden
  34362. * Back Compat
  34363. **/
  34364. onended: () => any;
  34365. /**
  34366. * Observable event when the current playing sound finishes.
  34367. */
  34368. onEndedObservable: Observable<Sound>;
  34369. private _panningModel;
  34370. private _playbackRate;
  34371. private _streaming;
  34372. private _startTime;
  34373. private _startOffset;
  34374. private _position;
  34375. /** @hidden */
  34376. _positionInEmitterSpace: boolean;
  34377. private _localDirection;
  34378. private _volume;
  34379. private _isReadyToPlay;
  34380. private _isDirectional;
  34381. private _readyToPlayCallback;
  34382. private _audioBuffer;
  34383. private _soundSource;
  34384. private _streamingSource;
  34385. private _soundPanner;
  34386. private _soundGain;
  34387. private _inputAudioNode;
  34388. private _outputAudioNode;
  34389. private _coneInnerAngle;
  34390. private _coneOuterAngle;
  34391. private _coneOuterGain;
  34392. private _scene;
  34393. private _connectedTransformNode;
  34394. private _customAttenuationFunction;
  34395. private _registerFunc;
  34396. private _isOutputConnected;
  34397. private _htmlAudioElement;
  34398. private _urlType;
  34399. private _length?;
  34400. private _offset?;
  34401. /** @hidden */
  34402. static _SceneComponentInitialization: (scene: Scene) => void;
  34403. /**
  34404. * Create a sound and attach it to a scene
  34405. * @param name Name of your sound
  34406. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34407. * @param scene defines the scene the sound belongs to
  34408. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34409. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34410. */
  34411. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34412. /**
  34413. * Release the sound and its associated resources
  34414. */
  34415. dispose(): void;
  34416. /**
  34417. * Gets if the sounds is ready to be played or not.
  34418. * @returns true if ready, otherwise false
  34419. */
  34420. isReady(): boolean;
  34421. private _soundLoaded;
  34422. /**
  34423. * Sets the data of the sound from an audiobuffer
  34424. * @param audioBuffer The audioBuffer containing the data
  34425. */
  34426. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34427. /**
  34428. * Updates the current sounds options such as maxdistance, loop...
  34429. * @param options A JSON object containing values named as the object properties
  34430. */
  34431. updateOptions(options: ISoundOptions): void;
  34432. private _createSpatialParameters;
  34433. private _updateSpatialParameters;
  34434. /**
  34435. * Switch the panning model to HRTF:
  34436. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34438. */
  34439. switchPanningModelToHRTF(): void;
  34440. /**
  34441. * Switch the panning model to Equal Power:
  34442. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34444. */
  34445. switchPanningModelToEqualPower(): void;
  34446. private _switchPanningModel;
  34447. /**
  34448. * Connect this sound to a sound track audio node like gain...
  34449. * @param soundTrackAudioNode the sound track audio node to connect to
  34450. */
  34451. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34452. /**
  34453. * Transform this sound into a directional source
  34454. * @param coneInnerAngle Size of the inner cone in degree
  34455. * @param coneOuterAngle Size of the outer cone in degree
  34456. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34457. */
  34458. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34459. /**
  34460. * Gets or sets the inner angle for the directional cone.
  34461. */
  34462. /**
  34463. * Gets or sets the inner angle for the directional cone.
  34464. */
  34465. directionalConeInnerAngle: number;
  34466. /**
  34467. * Gets or sets the outer angle for the directional cone.
  34468. */
  34469. /**
  34470. * Gets or sets the outer angle for the directional cone.
  34471. */
  34472. directionalConeOuterAngle: number;
  34473. /**
  34474. * Sets the position of the emitter if spatial sound is enabled
  34475. * @param newPosition Defines the new posisiton
  34476. */
  34477. setPosition(newPosition: Vector3): void;
  34478. /**
  34479. * Sets the local direction of the emitter if spatial sound is enabled
  34480. * @param newLocalDirection Defines the new local direction
  34481. */
  34482. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34483. private _updateDirection;
  34484. /** @hidden */
  34485. updateDistanceFromListener(): void;
  34486. /**
  34487. * Sets a new custom attenuation function for the sound.
  34488. * @param callback Defines the function used for the attenuation
  34489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34490. */
  34491. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34492. /**
  34493. * Play the sound
  34494. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34495. * @param offset (optional) Start the sound at a specific time in seconds
  34496. * @param length (optional) Sound duration (in seconds)
  34497. */
  34498. play(time?: number, offset?: number, length?: number): void;
  34499. private _onended;
  34500. /**
  34501. * Stop the sound
  34502. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34503. */
  34504. stop(time?: number): void;
  34505. /**
  34506. * Put the sound in pause
  34507. */
  34508. pause(): void;
  34509. /**
  34510. * Sets a dedicated volume for this sounds
  34511. * @param newVolume Define the new volume of the sound
  34512. * @param time Define time for gradual change to new volume
  34513. */
  34514. setVolume(newVolume: number, time?: number): void;
  34515. /**
  34516. * Set the sound play back rate
  34517. * @param newPlaybackRate Define the playback rate the sound should be played at
  34518. */
  34519. setPlaybackRate(newPlaybackRate: number): void;
  34520. /**
  34521. * Gets the volume of the sound.
  34522. * @returns the volume of the sound
  34523. */
  34524. getVolume(): number;
  34525. /**
  34526. * Attach the sound to a dedicated mesh
  34527. * @param transformNode The transform node to connect the sound with
  34528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34529. */
  34530. attachToMesh(transformNode: TransformNode): void;
  34531. /**
  34532. * Detach the sound from the previously attached mesh
  34533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34534. */
  34535. detachFromMesh(): void;
  34536. private _onRegisterAfterWorldMatrixUpdate;
  34537. /**
  34538. * Clone the current sound in the scene.
  34539. * @returns the new sound clone
  34540. */
  34541. clone(): Nullable<Sound>;
  34542. /**
  34543. * Gets the current underlying audio buffer containing the data
  34544. * @returns the audio buffer
  34545. */
  34546. getAudioBuffer(): Nullable<AudioBuffer>;
  34547. /**
  34548. * Serializes the Sound in a JSON representation
  34549. * @returns the JSON representation of the sound
  34550. */
  34551. serialize(): any;
  34552. /**
  34553. * Parse a JSON representation of a sound to innstantiate in a given scene
  34554. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34555. * @param scene Define the scene the new parsed sound should be created in
  34556. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34557. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34558. * @returns the newly parsed sound
  34559. */
  34560. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34561. }
  34562. }
  34563. declare module BABYLON {
  34564. /**
  34565. * This defines an action helpful to play a defined sound on a triggered action.
  34566. */
  34567. export class PlaySoundAction extends Action {
  34568. private _sound;
  34569. /**
  34570. * Instantiate the action
  34571. * @param triggerOptions defines the trigger options
  34572. * @param sound defines the sound to play
  34573. * @param condition defines the trigger related conditions
  34574. */
  34575. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34576. /** @hidden */
  34577. _prepare(): void;
  34578. /**
  34579. * Execute the action and play the sound.
  34580. */
  34581. execute(): void;
  34582. /**
  34583. * Serializes the actions and its related information.
  34584. * @param parent defines the object to serialize in
  34585. * @returns the serialized object
  34586. */
  34587. serialize(parent: any): any;
  34588. }
  34589. /**
  34590. * This defines an action helpful to stop a defined sound on a triggered action.
  34591. */
  34592. export class StopSoundAction extends Action {
  34593. private _sound;
  34594. /**
  34595. * Instantiate the action
  34596. * @param triggerOptions defines the trigger options
  34597. * @param sound defines the sound to stop
  34598. * @param condition defines the trigger related conditions
  34599. */
  34600. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34601. /** @hidden */
  34602. _prepare(): void;
  34603. /**
  34604. * Execute the action and stop the sound.
  34605. */
  34606. execute(): void;
  34607. /**
  34608. * Serializes the actions and its related information.
  34609. * @param parent defines the object to serialize in
  34610. * @returns the serialized object
  34611. */
  34612. serialize(parent: any): any;
  34613. }
  34614. }
  34615. declare module BABYLON {
  34616. /**
  34617. * This defines an action responsible to change the value of a property
  34618. * by interpolating between its current value and the newly set one once triggered.
  34619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34620. */
  34621. export class InterpolateValueAction extends Action {
  34622. /**
  34623. * Defines the path of the property where the value should be interpolated
  34624. */
  34625. propertyPath: string;
  34626. /**
  34627. * Defines the target value at the end of the interpolation.
  34628. */
  34629. value: any;
  34630. /**
  34631. * Defines the time it will take for the property to interpolate to the value.
  34632. */
  34633. duration: number;
  34634. /**
  34635. * Defines if the other scene animations should be stopped when the action has been triggered
  34636. */
  34637. stopOtherAnimations?: boolean;
  34638. /**
  34639. * Defines a callback raised once the interpolation animation has been done.
  34640. */
  34641. onInterpolationDone?: () => void;
  34642. /**
  34643. * Observable triggered once the interpolation animation has been done.
  34644. */
  34645. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34646. private _target;
  34647. private _effectiveTarget;
  34648. private _property;
  34649. /**
  34650. * Instantiate the action
  34651. * @param triggerOptions defines the trigger options
  34652. * @param target defines the object containing the value to interpolate
  34653. * @param propertyPath defines the path to the property in the target object
  34654. * @param value defines the target value at the end of the interpolation
  34655. * @param duration deines the time it will take for the property to interpolate to the value.
  34656. * @param condition defines the trigger related conditions
  34657. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34658. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34659. */
  34660. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34661. /** @hidden */
  34662. _prepare(): void;
  34663. /**
  34664. * Execute the action starts the value interpolation.
  34665. */
  34666. execute(): void;
  34667. /**
  34668. * Serializes the actions and its related information.
  34669. * @param parent defines the object to serialize in
  34670. * @returns the serialized object
  34671. */
  34672. serialize(parent: any): any;
  34673. }
  34674. }
  34675. declare module BABYLON {
  34676. /**
  34677. * Options allowed during the creation of a sound track.
  34678. */
  34679. export interface ISoundTrackOptions {
  34680. /**
  34681. * The volume the sound track should take during creation
  34682. */
  34683. volume?: number;
  34684. /**
  34685. * Define if the sound track is the main sound track of the scene
  34686. */
  34687. mainTrack?: boolean;
  34688. }
  34689. /**
  34690. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34691. * It will be also used in a future release to apply effects on a specific track.
  34692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34693. */
  34694. export class SoundTrack {
  34695. /**
  34696. * The unique identifier of the sound track in the scene.
  34697. */
  34698. id: number;
  34699. /**
  34700. * The list of sounds included in the sound track.
  34701. */
  34702. soundCollection: Array<Sound>;
  34703. private _outputAudioNode;
  34704. private _scene;
  34705. private _isMainTrack;
  34706. private _connectedAnalyser;
  34707. private _options;
  34708. private _isInitialized;
  34709. /**
  34710. * Creates a new sound track.
  34711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34712. * @param scene Define the scene the sound track belongs to
  34713. * @param options
  34714. */
  34715. constructor(scene: Scene, options?: ISoundTrackOptions);
  34716. private _initializeSoundTrackAudioGraph;
  34717. /**
  34718. * Release the sound track and its associated resources
  34719. */
  34720. dispose(): void;
  34721. /**
  34722. * Adds a sound to this sound track
  34723. * @param sound define the cound to add
  34724. * @ignoreNaming
  34725. */
  34726. AddSound(sound: Sound): void;
  34727. /**
  34728. * Removes a sound to this sound track
  34729. * @param sound define the cound to remove
  34730. * @ignoreNaming
  34731. */
  34732. RemoveSound(sound: Sound): void;
  34733. /**
  34734. * Set a global volume for the full sound track.
  34735. * @param newVolume Define the new volume of the sound track
  34736. */
  34737. setVolume(newVolume: number): void;
  34738. /**
  34739. * Switch the panning model to HRTF:
  34740. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34742. */
  34743. switchPanningModelToHRTF(): void;
  34744. /**
  34745. * Switch the panning model to Equal Power:
  34746. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34748. */
  34749. switchPanningModelToEqualPower(): void;
  34750. /**
  34751. * Connect the sound track to an audio analyser allowing some amazing
  34752. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34754. * @param analyser The analyser to connect to the engine
  34755. */
  34756. connectToAnalyser(analyser: Analyser): void;
  34757. }
  34758. }
  34759. declare module BABYLON {
  34760. interface AbstractScene {
  34761. /**
  34762. * The list of sounds used in the scene.
  34763. */
  34764. sounds: Nullable<Array<Sound>>;
  34765. }
  34766. interface Scene {
  34767. /**
  34768. * @hidden
  34769. * Backing field
  34770. */
  34771. _mainSoundTrack: SoundTrack;
  34772. /**
  34773. * The main sound track played by the scene.
  34774. * It cotains your primary collection of sounds.
  34775. */
  34776. mainSoundTrack: SoundTrack;
  34777. /**
  34778. * The list of sound tracks added to the scene
  34779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34780. */
  34781. soundTracks: Nullable<Array<SoundTrack>>;
  34782. /**
  34783. * Gets a sound using a given name
  34784. * @param name defines the name to search for
  34785. * @return the found sound or null if not found at all.
  34786. */
  34787. getSoundByName(name: string): Nullable<Sound>;
  34788. /**
  34789. * Gets or sets if audio support is enabled
  34790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34791. */
  34792. audioEnabled: boolean;
  34793. /**
  34794. * Gets or sets if audio will be output to headphones
  34795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34796. */
  34797. headphone: boolean;
  34798. }
  34799. /**
  34800. * Defines the sound scene component responsible to manage any sounds
  34801. * in a given scene.
  34802. */
  34803. export class AudioSceneComponent implements ISceneSerializableComponent {
  34804. /**
  34805. * The component name helpfull to identify the component in the list of scene components.
  34806. */
  34807. readonly name: string;
  34808. /**
  34809. * The scene the component belongs to.
  34810. */
  34811. scene: Scene;
  34812. private _audioEnabled;
  34813. /**
  34814. * Gets whether audio is enabled or not.
  34815. * Please use related enable/disable method to switch state.
  34816. */
  34817. readonly audioEnabled: boolean;
  34818. private _headphone;
  34819. /**
  34820. * Gets whether audio is outputing to headphone or not.
  34821. * Please use the according Switch methods to change output.
  34822. */
  34823. readonly headphone: boolean;
  34824. /**
  34825. * Creates a new instance of the component for the given scene
  34826. * @param scene Defines the scene to register the component in
  34827. */
  34828. constructor(scene: Scene);
  34829. /**
  34830. * Registers the component in a given scene
  34831. */
  34832. register(): void;
  34833. /**
  34834. * Rebuilds the elements related to this component in case of
  34835. * context lost for instance.
  34836. */
  34837. rebuild(): void;
  34838. /**
  34839. * Serializes the component data to the specified json object
  34840. * @param serializationObject The object to serialize to
  34841. */
  34842. serialize(serializationObject: any): void;
  34843. /**
  34844. * Adds all the elements from the container to the scene
  34845. * @param container the container holding the elements
  34846. */
  34847. addFromContainer(container: AbstractScene): void;
  34848. /**
  34849. * Removes all the elements in the container from the scene
  34850. * @param container contains the elements to remove
  34851. * @param dispose if the removed element should be disposed (default: false)
  34852. */
  34853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34854. /**
  34855. * Disposes the component and the associated ressources.
  34856. */
  34857. dispose(): void;
  34858. /**
  34859. * Disables audio in the associated scene.
  34860. */
  34861. disableAudio(): void;
  34862. /**
  34863. * Enables audio in the associated scene.
  34864. */
  34865. enableAudio(): void;
  34866. /**
  34867. * Switch audio to headphone output.
  34868. */
  34869. switchAudioModeForHeadphones(): void;
  34870. /**
  34871. * Switch audio to normal speakers.
  34872. */
  34873. switchAudioModeForNormalSpeakers(): void;
  34874. private _afterRender;
  34875. }
  34876. }
  34877. declare module BABYLON {
  34878. /**
  34879. * Wraps one or more Sound objects and selects one with random weight for playback.
  34880. */
  34881. export class WeightedSound {
  34882. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34883. loop: boolean;
  34884. private _coneInnerAngle;
  34885. private _coneOuterAngle;
  34886. private _volume;
  34887. /** A Sound is currently playing. */
  34888. isPlaying: boolean;
  34889. /** A Sound is currently paused. */
  34890. isPaused: boolean;
  34891. private _sounds;
  34892. private _weights;
  34893. private _currentIndex?;
  34894. /**
  34895. * Creates a new WeightedSound from the list of sounds given.
  34896. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34897. * @param sounds Array of Sounds that will be selected from.
  34898. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34899. */
  34900. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34901. /**
  34902. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34903. */
  34904. /**
  34905. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34906. */
  34907. directionalConeInnerAngle: number;
  34908. /**
  34909. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34910. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34911. */
  34912. /**
  34913. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34914. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34915. */
  34916. directionalConeOuterAngle: number;
  34917. /**
  34918. * Playback volume.
  34919. */
  34920. /**
  34921. * Playback volume.
  34922. */
  34923. volume: number;
  34924. private _onended;
  34925. /**
  34926. * Suspend playback
  34927. */
  34928. pause(): void;
  34929. /**
  34930. * Stop playback
  34931. */
  34932. stop(): void;
  34933. /**
  34934. * Start playback.
  34935. * @param startOffset Position the clip head at a specific time in seconds.
  34936. */
  34937. play(startOffset?: number): void;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34943. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34944. */
  34945. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34946. /**
  34947. * Gets the name of the behavior.
  34948. */
  34949. readonly name: string;
  34950. /**
  34951. * The easing function used by animations
  34952. */
  34953. static EasingFunction: BackEase;
  34954. /**
  34955. * The easing mode used by animations
  34956. */
  34957. static EasingMode: number;
  34958. /**
  34959. * The duration of the animation, in milliseconds
  34960. */
  34961. transitionDuration: number;
  34962. /**
  34963. * Length of the distance animated by the transition when lower radius is reached
  34964. */
  34965. lowerRadiusTransitionRange: number;
  34966. /**
  34967. * Length of the distance animated by the transition when upper radius is reached
  34968. */
  34969. upperRadiusTransitionRange: number;
  34970. private _autoTransitionRange;
  34971. /**
  34972. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34973. */
  34974. /**
  34975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34977. */
  34978. autoTransitionRange: boolean;
  34979. private _attachedCamera;
  34980. private _onAfterCheckInputsObserver;
  34981. private _onMeshTargetChangedObserver;
  34982. /**
  34983. * Initializes the behavior.
  34984. */
  34985. init(): void;
  34986. /**
  34987. * Attaches the behavior to its arc rotate camera.
  34988. * @param camera Defines the camera to attach the behavior to
  34989. */
  34990. attach(camera: ArcRotateCamera): void;
  34991. /**
  34992. * Detaches the behavior from its current arc rotate camera.
  34993. */
  34994. detach(): void;
  34995. private _radiusIsAnimating;
  34996. private _radiusBounceTransition;
  34997. private _animatables;
  34998. private _cachedWheelPrecision;
  34999. /**
  35000. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35001. * @param radiusLimit The limit to check against.
  35002. * @return Bool to indicate if at limit.
  35003. */
  35004. private _isRadiusAtLimit;
  35005. /**
  35006. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35007. * @param radiusDelta The delta by which to animate to. Can be negative.
  35008. */
  35009. private _applyBoundRadiusAnimation;
  35010. /**
  35011. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35012. */
  35013. protected _clearAnimationLocks(): void;
  35014. /**
  35015. * Stops and removes all animations that have been applied to the camera
  35016. */
  35017. stopAllAnimations(): void;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. /**
  35022. * 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.
  35023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35024. */
  35025. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35026. /**
  35027. * Gets the name of the behavior.
  35028. */
  35029. readonly name: string;
  35030. private _mode;
  35031. private _radiusScale;
  35032. private _positionScale;
  35033. private _defaultElevation;
  35034. private _elevationReturnTime;
  35035. private _elevationReturnWaitTime;
  35036. private _zoomStopsAnimation;
  35037. private _framingTime;
  35038. /**
  35039. * The easing function used by animations
  35040. */
  35041. static EasingFunction: ExponentialEase;
  35042. /**
  35043. * The easing mode used by animations
  35044. */
  35045. static EasingMode: number;
  35046. /**
  35047. * Sets the current mode used by the behavior
  35048. */
  35049. /**
  35050. * Gets current mode used by the behavior.
  35051. */
  35052. mode: number;
  35053. /**
  35054. * Sets the scale applied to the radius (1 by default)
  35055. */
  35056. /**
  35057. * Gets the scale applied to the radius
  35058. */
  35059. radiusScale: number;
  35060. /**
  35061. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35062. */
  35063. /**
  35064. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35065. */
  35066. positionScale: number;
  35067. /**
  35068. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35069. * behaviour is triggered, in radians.
  35070. */
  35071. /**
  35072. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35073. * behaviour is triggered, in radians.
  35074. */
  35075. defaultElevation: number;
  35076. /**
  35077. * Sets the time (in milliseconds) taken to return to the default beta position.
  35078. * Negative value indicates camera should not return to default.
  35079. */
  35080. /**
  35081. * Gets the time (in milliseconds) taken to return to the default beta position.
  35082. * Negative value indicates camera should not return to default.
  35083. */
  35084. elevationReturnTime: number;
  35085. /**
  35086. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35087. */
  35088. /**
  35089. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35090. */
  35091. elevationReturnWaitTime: number;
  35092. /**
  35093. * Sets the flag that indicates if user zooming should stop animation.
  35094. */
  35095. /**
  35096. * Gets the flag that indicates if user zooming should stop animation.
  35097. */
  35098. zoomStopsAnimation: boolean;
  35099. /**
  35100. * Sets the transition time when framing the mesh, in milliseconds
  35101. */
  35102. /**
  35103. * Gets the transition time when framing the mesh, in milliseconds
  35104. */
  35105. framingTime: number;
  35106. /**
  35107. * Define if the behavior should automatically change the configured
  35108. * camera limits and sensibilities.
  35109. */
  35110. autoCorrectCameraLimitsAndSensibility: boolean;
  35111. private _onPrePointerObservableObserver;
  35112. private _onAfterCheckInputsObserver;
  35113. private _onMeshTargetChangedObserver;
  35114. private _attachedCamera;
  35115. private _isPointerDown;
  35116. private _lastInteractionTime;
  35117. /**
  35118. * Initializes the behavior.
  35119. */
  35120. init(): void;
  35121. /**
  35122. * Attaches the behavior to its arc rotate camera.
  35123. * @param camera Defines the camera to attach the behavior to
  35124. */
  35125. attach(camera: ArcRotateCamera): void;
  35126. /**
  35127. * Detaches the behavior from its current arc rotate camera.
  35128. */
  35129. detach(): void;
  35130. private _animatables;
  35131. private _betaIsAnimating;
  35132. private _betaTransition;
  35133. private _radiusTransition;
  35134. private _vectorTransition;
  35135. /**
  35136. * Targets the given mesh and updates zoom level accordingly.
  35137. * @param mesh The mesh to target.
  35138. * @param radius Optional. If a cached radius position already exists, overrides default.
  35139. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35140. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35141. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35142. */
  35143. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35144. /**
  35145. * Targets the given mesh with its children and updates zoom level accordingly.
  35146. * @param mesh The mesh to target.
  35147. * @param radius Optional. If a cached radius position already exists, overrides default.
  35148. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35151. */
  35152. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35153. /**
  35154. * Targets the given meshes with their children and updates zoom level accordingly.
  35155. * @param meshes The mesh to target.
  35156. * @param radius Optional. If a cached radius position already exists, overrides default.
  35157. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35158. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35159. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35160. */
  35161. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35162. /**
  35163. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35164. * @param minimumWorld Determines the smaller position of the bounding box extend
  35165. * @param maximumWorld Determines the bigger position of the bounding box extend
  35166. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35167. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35168. */
  35169. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35170. /**
  35171. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35172. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35173. * frustum width.
  35174. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35175. * to fully enclose the mesh in the viewing frustum.
  35176. */
  35177. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35178. /**
  35179. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35180. * is automatically returned to its default position (expected to be above ground plane).
  35181. */
  35182. private _maintainCameraAboveGround;
  35183. /**
  35184. * Returns the frustum slope based on the canvas ratio and camera FOV
  35185. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35186. */
  35187. private _getFrustumSlope;
  35188. /**
  35189. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35190. */
  35191. private _clearAnimationLocks;
  35192. /**
  35193. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35194. */
  35195. private _applyUserInteraction;
  35196. /**
  35197. * Stops and removes all animations that have been applied to the camera
  35198. */
  35199. stopAllAnimations(): void;
  35200. /**
  35201. * Gets a value indicating if the user is moving the camera
  35202. */
  35203. readonly isUserIsMoving: boolean;
  35204. /**
  35205. * The camera can move all the way towards the mesh.
  35206. */
  35207. static IgnoreBoundsSizeMode: number;
  35208. /**
  35209. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35210. */
  35211. static FitFrustumSidesMode: number;
  35212. }
  35213. }
  35214. declare module BABYLON {
  35215. /**
  35216. * Base class for Camera Pointer Inputs.
  35217. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35218. * for example usage.
  35219. */
  35220. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35221. /**
  35222. * Defines the camera the input is attached to.
  35223. */
  35224. abstract camera: Camera;
  35225. /**
  35226. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35227. */
  35228. protected _altKey: boolean;
  35229. protected _ctrlKey: boolean;
  35230. protected _metaKey: boolean;
  35231. protected _shiftKey: boolean;
  35232. /**
  35233. * Which mouse buttons were pressed at time of last mouse event.
  35234. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35235. */
  35236. protected _buttonsPressed: number;
  35237. /**
  35238. * Defines the buttons associated with the input to handle camera move.
  35239. */
  35240. buttons: number[];
  35241. /**
  35242. * Attach the input controls to a specific dom element to get the input from.
  35243. * @param element Defines the element the controls should be listened from
  35244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35245. */
  35246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35247. /**
  35248. * Detach the current controls from the specified dom element.
  35249. * @param element Defines the element to stop listening the inputs from
  35250. */
  35251. detachControl(element: Nullable<HTMLElement>): void;
  35252. /**
  35253. * Gets the class name of the current input.
  35254. * @returns the class name
  35255. */
  35256. getClassName(): string;
  35257. /**
  35258. * Get the friendly name associated with the input class.
  35259. * @returns the input friendly name
  35260. */
  35261. getSimpleName(): string;
  35262. /**
  35263. * Called on pointer POINTERDOUBLETAP event.
  35264. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35265. */
  35266. protected onDoubleTap(type: string): void;
  35267. /**
  35268. * Called on pointer POINTERMOVE event if only a single touch is active.
  35269. * Override this method to provide functionality.
  35270. */
  35271. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35272. /**
  35273. * Called on pointer POINTERMOVE event if multiple touches are active.
  35274. * Override this method to provide functionality.
  35275. */
  35276. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35277. /**
  35278. * Called on JS contextmenu event.
  35279. * Override this method to provide functionality.
  35280. */
  35281. protected onContextMenu(evt: PointerEvent): void;
  35282. /**
  35283. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35284. * press.
  35285. * Override this method to provide functionality.
  35286. */
  35287. protected onButtonDown(evt: PointerEvent): void;
  35288. /**
  35289. * Called each time a new POINTERUP event occurs. Ie, for each button
  35290. * release.
  35291. * Override this method to provide functionality.
  35292. */
  35293. protected onButtonUp(evt: PointerEvent): void;
  35294. /**
  35295. * Called when window becomes inactive.
  35296. * Override this method to provide functionality.
  35297. */
  35298. protected onLostFocus(): void;
  35299. private _pointerInput;
  35300. private _observer;
  35301. private _onLostFocus;
  35302. private pointA;
  35303. private pointB;
  35304. }
  35305. }
  35306. declare module BABYLON {
  35307. /**
  35308. * Manage the pointers inputs to control an arc rotate camera.
  35309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35310. */
  35311. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35312. /**
  35313. * Defines the camera the input is attached to.
  35314. */
  35315. camera: ArcRotateCamera;
  35316. /**
  35317. * Gets the class name of the current input.
  35318. * @returns the class name
  35319. */
  35320. getClassName(): string;
  35321. /**
  35322. * Defines the buttons associated with the input to handle camera move.
  35323. */
  35324. buttons: number[];
  35325. /**
  35326. * Defines the pointer angular sensibility along the X axis or how fast is
  35327. * the camera rotating.
  35328. */
  35329. angularSensibilityX: number;
  35330. /**
  35331. * Defines the pointer angular sensibility along the Y axis or how fast is
  35332. * the camera rotating.
  35333. */
  35334. angularSensibilityY: number;
  35335. /**
  35336. * Defines the pointer pinch precision or how fast is the camera zooming.
  35337. */
  35338. pinchPrecision: number;
  35339. /**
  35340. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35341. * from 0.
  35342. * It defines the percentage of current camera.radius to use as delta when
  35343. * pinch zoom is used.
  35344. */
  35345. pinchDeltaPercentage: number;
  35346. /**
  35347. * Defines the pointer panning sensibility or how fast is the camera moving.
  35348. */
  35349. panningSensibility: number;
  35350. /**
  35351. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35352. */
  35353. multiTouchPanning: boolean;
  35354. /**
  35355. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35356. * zoom (pinch) through multitouch.
  35357. */
  35358. multiTouchPanAndZoom: boolean;
  35359. /**
  35360. * Revers pinch action direction.
  35361. */
  35362. pinchInwards: boolean;
  35363. private _isPanClick;
  35364. private _twoFingerActivityCount;
  35365. private _isPinching;
  35366. /**
  35367. * Called on pointer POINTERMOVE event if only a single touch is active.
  35368. */
  35369. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35370. /**
  35371. * Called on pointer POINTERDOUBLETAP event.
  35372. */
  35373. protected onDoubleTap(type: string): void;
  35374. /**
  35375. * Called on pointer POINTERMOVE event if multiple touches are active.
  35376. */
  35377. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35378. /**
  35379. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35380. * press.
  35381. */
  35382. protected onButtonDown(evt: PointerEvent): void;
  35383. /**
  35384. * Called each time a new POINTERUP event occurs. Ie, for each button
  35385. * release.
  35386. */
  35387. protected onButtonUp(evt: PointerEvent): void;
  35388. /**
  35389. * Called when window becomes inactive.
  35390. */
  35391. protected onLostFocus(): void;
  35392. }
  35393. }
  35394. declare module BABYLON {
  35395. /**
  35396. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35398. */
  35399. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35400. /**
  35401. * Defines the camera the input is attached to.
  35402. */
  35403. camera: ArcRotateCamera;
  35404. /**
  35405. * Defines the list of key codes associated with the up action (increase alpha)
  35406. */
  35407. keysUp: number[];
  35408. /**
  35409. * Defines the list of key codes associated with the down action (decrease alpha)
  35410. */
  35411. keysDown: number[];
  35412. /**
  35413. * Defines the list of key codes associated with the left action (increase beta)
  35414. */
  35415. keysLeft: number[];
  35416. /**
  35417. * Defines the list of key codes associated with the right action (decrease beta)
  35418. */
  35419. keysRight: number[];
  35420. /**
  35421. * Defines the list of key codes associated with the reset action.
  35422. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35423. */
  35424. keysReset: number[];
  35425. /**
  35426. * Defines the panning sensibility of the inputs.
  35427. * (How fast is the camera paning)
  35428. */
  35429. panningSensibility: number;
  35430. /**
  35431. * Defines the zooming sensibility of the inputs.
  35432. * (How fast is the camera zooming)
  35433. */
  35434. zoomingSensibility: number;
  35435. /**
  35436. * Defines wether maintaining the alt key down switch the movement mode from
  35437. * orientation to zoom.
  35438. */
  35439. useAltToZoom: boolean;
  35440. /**
  35441. * Rotation speed of the camera
  35442. */
  35443. angularSpeed: number;
  35444. private _keys;
  35445. private _ctrlPressed;
  35446. private _altPressed;
  35447. private _onCanvasBlurObserver;
  35448. private _onKeyboardObserver;
  35449. private _engine;
  35450. private _scene;
  35451. /**
  35452. * Attach the input controls to a specific dom element to get the input from.
  35453. * @param element Defines the element the controls should be listened from
  35454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35455. */
  35456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35457. /**
  35458. * Detach the current controls from the specified dom element.
  35459. * @param element Defines the element to stop listening the inputs from
  35460. */
  35461. detachControl(element: Nullable<HTMLElement>): void;
  35462. /**
  35463. * Update the current camera state depending on the inputs that have been used this frame.
  35464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35465. */
  35466. checkInputs(): void;
  35467. /**
  35468. * Gets the class name of the current intput.
  35469. * @returns the class name
  35470. */
  35471. getClassName(): string;
  35472. /**
  35473. * Get the friendly name associated with the input class.
  35474. * @returns the input friendly name
  35475. */
  35476. getSimpleName(): string;
  35477. }
  35478. }
  35479. declare module BABYLON {
  35480. /**
  35481. * Manage the mouse wheel inputs to control an arc rotate camera.
  35482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35483. */
  35484. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35485. /**
  35486. * Defines the camera the input is attached to.
  35487. */
  35488. camera: ArcRotateCamera;
  35489. /**
  35490. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35491. */
  35492. wheelPrecision: number;
  35493. /**
  35494. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35495. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35496. */
  35497. wheelDeltaPercentage: number;
  35498. private _wheel;
  35499. private _observer;
  35500. private computeDeltaFromMouseWheelLegacyEvent;
  35501. /**
  35502. * Attach the input controls to a specific dom element to get the input from.
  35503. * @param element Defines the element the controls should be listened from
  35504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35505. */
  35506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35507. /**
  35508. * Detach the current controls from the specified dom element.
  35509. * @param element Defines the element to stop listening the inputs from
  35510. */
  35511. detachControl(element: Nullable<HTMLElement>): void;
  35512. /**
  35513. * Gets the class name of the current intput.
  35514. * @returns the class name
  35515. */
  35516. getClassName(): string;
  35517. /**
  35518. * Get the friendly name associated with the input class.
  35519. * @returns the input friendly name
  35520. */
  35521. getSimpleName(): string;
  35522. }
  35523. }
  35524. declare module BABYLON {
  35525. /**
  35526. * Default Inputs manager for the ArcRotateCamera.
  35527. * It groups all the default supported inputs for ease of use.
  35528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35529. */
  35530. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35531. /**
  35532. * Instantiates a new ArcRotateCameraInputsManager.
  35533. * @param camera Defines the camera the inputs belong to
  35534. */
  35535. constructor(camera: ArcRotateCamera);
  35536. /**
  35537. * Add mouse wheel input support to the input manager.
  35538. * @returns the current input manager
  35539. */
  35540. addMouseWheel(): ArcRotateCameraInputsManager;
  35541. /**
  35542. * Add pointers input support to the input manager.
  35543. * @returns the current input manager
  35544. */
  35545. addPointers(): ArcRotateCameraInputsManager;
  35546. /**
  35547. * Add keyboard input support to the input manager.
  35548. * @returns the current input manager
  35549. */
  35550. addKeyboard(): ArcRotateCameraInputsManager;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. /**
  35555. * This represents an orbital type of camera.
  35556. *
  35557. * 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.
  35558. * 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.
  35559. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35560. */
  35561. export class ArcRotateCamera extends TargetCamera {
  35562. /**
  35563. * Defines the rotation angle of the camera along the longitudinal axis.
  35564. */
  35565. alpha: number;
  35566. /**
  35567. * Defines the rotation angle of the camera along the latitudinal axis.
  35568. */
  35569. beta: number;
  35570. /**
  35571. * Defines the radius of the camera from it s target point.
  35572. */
  35573. radius: number;
  35574. protected _target: Vector3;
  35575. protected _targetHost: Nullable<AbstractMesh>;
  35576. /**
  35577. * Defines the target point of the camera.
  35578. * The camera looks towards it form the radius distance.
  35579. */
  35580. target: Vector3;
  35581. /**
  35582. * Define the current local position of the camera in the scene
  35583. */
  35584. position: Vector3;
  35585. protected _upVector: Vector3;
  35586. protected _upToYMatrix: Matrix;
  35587. protected _YToUpMatrix: Matrix;
  35588. /**
  35589. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35590. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35591. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35592. */
  35593. upVector: Vector3;
  35594. /**
  35595. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35596. */
  35597. setMatUp(): void;
  35598. /**
  35599. * Current inertia value on the longitudinal axis.
  35600. * The bigger this number the longer it will take for the camera to stop.
  35601. */
  35602. inertialAlphaOffset: number;
  35603. /**
  35604. * Current inertia value on the latitudinal axis.
  35605. * The bigger this number the longer it will take for the camera to stop.
  35606. */
  35607. inertialBetaOffset: number;
  35608. /**
  35609. * Current inertia value on the radius axis.
  35610. * The bigger this number the longer it will take for the camera to stop.
  35611. */
  35612. inertialRadiusOffset: number;
  35613. /**
  35614. * Minimum allowed angle on the longitudinal axis.
  35615. * This can help limiting how the Camera is able to move in the scene.
  35616. */
  35617. lowerAlphaLimit: Nullable<number>;
  35618. /**
  35619. * Maximum allowed angle on the longitudinal axis.
  35620. * This can help limiting how the Camera is able to move in the scene.
  35621. */
  35622. upperAlphaLimit: Nullable<number>;
  35623. /**
  35624. * Minimum allowed angle on the latitudinal axis.
  35625. * This can help limiting how the Camera is able to move in the scene.
  35626. */
  35627. lowerBetaLimit: number;
  35628. /**
  35629. * Maximum allowed angle on the latitudinal axis.
  35630. * This can help limiting how the Camera is able to move in the scene.
  35631. */
  35632. upperBetaLimit: number;
  35633. /**
  35634. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35635. * This can help limiting how the Camera is able to move in the scene.
  35636. */
  35637. lowerRadiusLimit: Nullable<number>;
  35638. /**
  35639. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35640. * This can help limiting how the Camera is able to move in the scene.
  35641. */
  35642. upperRadiusLimit: Nullable<number>;
  35643. /**
  35644. * Defines the current inertia value used during panning of the camera along the X axis.
  35645. */
  35646. inertialPanningX: number;
  35647. /**
  35648. * Defines the current inertia value used during panning of the camera along the Y axis.
  35649. */
  35650. inertialPanningY: number;
  35651. /**
  35652. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35653. * Basically if your fingers moves away from more than this distance you will be considered
  35654. * in pinch mode.
  35655. */
  35656. pinchToPanMaxDistance: number;
  35657. /**
  35658. * Defines the maximum distance the camera can pan.
  35659. * This could help keeping the cammera always in your scene.
  35660. */
  35661. panningDistanceLimit: Nullable<number>;
  35662. /**
  35663. * Defines the target of the camera before paning.
  35664. */
  35665. panningOriginTarget: Vector3;
  35666. /**
  35667. * Defines the value of the inertia used during panning.
  35668. * 0 would mean stop inertia and one would mean no decelleration at all.
  35669. */
  35670. panningInertia: number;
  35671. /**
  35672. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35673. */
  35674. angularSensibilityX: number;
  35675. /**
  35676. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35677. */
  35678. angularSensibilityY: number;
  35679. /**
  35680. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35681. */
  35682. pinchPrecision: number;
  35683. /**
  35684. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35685. * It will be used instead of pinchDeltaPrecision if different from 0.
  35686. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35687. */
  35688. pinchDeltaPercentage: number;
  35689. /**
  35690. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35691. */
  35692. panningSensibility: number;
  35693. /**
  35694. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35695. */
  35696. keysUp: number[];
  35697. /**
  35698. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35699. */
  35700. keysDown: number[];
  35701. /**
  35702. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35703. */
  35704. keysLeft: number[];
  35705. /**
  35706. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35707. */
  35708. keysRight: number[];
  35709. /**
  35710. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35711. */
  35712. wheelPrecision: number;
  35713. /**
  35714. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35715. * It will be used instead of pinchDeltaPrecision if different from 0.
  35716. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35717. */
  35718. wheelDeltaPercentage: number;
  35719. /**
  35720. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35721. */
  35722. zoomOnFactor: number;
  35723. /**
  35724. * Defines a screen offset for the camera position.
  35725. */
  35726. targetScreenOffset: Vector2;
  35727. /**
  35728. * Allows the camera to be completely reversed.
  35729. * If false the camera can not arrive upside down.
  35730. */
  35731. allowUpsideDown: boolean;
  35732. /**
  35733. * Define if double tap/click is used to restore the previously saved state of the camera.
  35734. */
  35735. useInputToRestoreState: boolean;
  35736. /** @hidden */
  35737. _viewMatrix: Matrix;
  35738. /** @hidden */
  35739. _useCtrlForPanning: boolean;
  35740. /** @hidden */
  35741. _panningMouseButton: number;
  35742. /**
  35743. * Defines the input associated to the camera.
  35744. */
  35745. inputs: ArcRotateCameraInputsManager;
  35746. /** @hidden */
  35747. _reset: () => void;
  35748. /**
  35749. * Defines the allowed panning axis.
  35750. */
  35751. panningAxis: Vector3;
  35752. protected _localDirection: Vector3;
  35753. protected _transformedDirection: Vector3;
  35754. private _bouncingBehavior;
  35755. /**
  35756. * Gets the bouncing behavior of the camera if it has been enabled.
  35757. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35758. */
  35759. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35760. /**
  35761. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35763. */
  35764. useBouncingBehavior: boolean;
  35765. private _framingBehavior;
  35766. /**
  35767. * Gets the framing behavior of the camera if it has been enabled.
  35768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35769. */
  35770. readonly framingBehavior: Nullable<FramingBehavior>;
  35771. /**
  35772. * Defines if the framing behavior of the camera is enabled on the camera.
  35773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35774. */
  35775. useFramingBehavior: boolean;
  35776. private _autoRotationBehavior;
  35777. /**
  35778. * Gets the auto rotation behavior of the camera if it has been enabled.
  35779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35780. */
  35781. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35782. /**
  35783. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35785. */
  35786. useAutoRotationBehavior: boolean;
  35787. /**
  35788. * Observable triggered when the mesh target has been changed on the camera.
  35789. */
  35790. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35791. /**
  35792. * Event raised when the camera is colliding with a mesh.
  35793. */
  35794. onCollide: (collidedMesh: AbstractMesh) => void;
  35795. /**
  35796. * Defines whether the camera should check collision with the objects oh the scene.
  35797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35798. */
  35799. checkCollisions: boolean;
  35800. /**
  35801. * Defines the collision radius of the camera.
  35802. * This simulates a sphere around the camera.
  35803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35804. */
  35805. collisionRadius: Vector3;
  35806. protected _collider: Collider;
  35807. protected _previousPosition: Vector3;
  35808. protected _collisionVelocity: Vector3;
  35809. protected _newPosition: Vector3;
  35810. protected _previousAlpha: number;
  35811. protected _previousBeta: number;
  35812. protected _previousRadius: number;
  35813. protected _collisionTriggered: boolean;
  35814. protected _targetBoundingCenter: Nullable<Vector3>;
  35815. private _computationVector;
  35816. /**
  35817. * Instantiates a new ArcRotateCamera in a given scene
  35818. * @param name Defines the name of the camera
  35819. * @param alpha Defines the camera rotation along the logitudinal axis
  35820. * @param beta Defines the camera rotation along the latitudinal axis
  35821. * @param radius Defines the camera distance from its target
  35822. * @param target Defines the camera target
  35823. * @param scene Defines the scene the camera belongs to
  35824. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35825. */
  35826. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35827. /** @hidden */
  35828. _initCache(): void;
  35829. /** @hidden */
  35830. _updateCache(ignoreParentClass?: boolean): void;
  35831. protected _getTargetPosition(): Vector3;
  35832. private _storedAlpha;
  35833. private _storedBeta;
  35834. private _storedRadius;
  35835. private _storedTarget;
  35836. /**
  35837. * Stores the current state of the camera (alpha, beta, radius and target)
  35838. * @returns the camera itself
  35839. */
  35840. storeState(): Camera;
  35841. /**
  35842. * @hidden
  35843. * Restored camera state. You must call storeState() first
  35844. */
  35845. _restoreStateValues(): boolean;
  35846. /** @hidden */
  35847. _isSynchronizedViewMatrix(): boolean;
  35848. /**
  35849. * Attached controls to the current camera.
  35850. * @param element Defines the element the controls should be listened from
  35851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35852. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35853. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35854. */
  35855. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35856. /**
  35857. * Detach the current controls from the camera.
  35858. * The camera will stop reacting to inputs.
  35859. * @param element Defines the element to stop listening the inputs from
  35860. */
  35861. detachControl(element: HTMLElement): void;
  35862. /** @hidden */
  35863. _checkInputs(): void;
  35864. protected _checkLimits(): void;
  35865. /**
  35866. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35867. */
  35868. rebuildAnglesAndRadius(): void;
  35869. /**
  35870. * Use a position to define the current camera related information like aplha, beta and radius
  35871. * @param position Defines the position to set the camera at
  35872. */
  35873. setPosition(position: Vector3): void;
  35874. /**
  35875. * Defines the target the camera should look at.
  35876. * This will automatically adapt alpha beta and radius to fit within the new target.
  35877. * @param target Defines the new target as a Vector or a mesh
  35878. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35879. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35880. */
  35881. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35882. /** @hidden */
  35883. _getViewMatrix(): Matrix;
  35884. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35885. /**
  35886. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35887. * @param meshes Defines the mesh to zoom on
  35888. * @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)
  35889. */
  35890. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35891. /**
  35892. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35893. * The target will be changed but the radius
  35894. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35895. * @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)
  35896. */
  35897. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35898. min: Vector3;
  35899. max: Vector3;
  35900. distance: number;
  35901. }, doNotUpdateMaxZ?: boolean): void;
  35902. /**
  35903. * @override
  35904. * Override Camera.createRigCamera
  35905. */
  35906. createRigCamera(name: string, cameraIndex: number): Camera;
  35907. /**
  35908. * @hidden
  35909. * @override
  35910. * Override Camera._updateRigCameras
  35911. */
  35912. _updateRigCameras(): void;
  35913. /**
  35914. * Destroy the camera and release the current resources hold by it.
  35915. */
  35916. dispose(): void;
  35917. /**
  35918. * Gets the current object class name.
  35919. * @return the class name
  35920. */
  35921. getClassName(): string;
  35922. }
  35923. }
  35924. declare module BABYLON {
  35925. /**
  35926. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35928. */
  35929. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35930. /**
  35931. * Gets the name of the behavior.
  35932. */
  35933. readonly name: string;
  35934. private _zoomStopsAnimation;
  35935. private _idleRotationSpeed;
  35936. private _idleRotationWaitTime;
  35937. private _idleRotationSpinupTime;
  35938. /**
  35939. * Sets the flag that indicates if user zooming should stop animation.
  35940. */
  35941. /**
  35942. * Gets the flag that indicates if user zooming should stop animation.
  35943. */
  35944. zoomStopsAnimation: boolean;
  35945. /**
  35946. * Sets the default speed at which the camera rotates around the model.
  35947. */
  35948. /**
  35949. * Gets the default speed at which the camera rotates around the model.
  35950. */
  35951. idleRotationSpeed: number;
  35952. /**
  35953. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35954. */
  35955. /**
  35956. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35957. */
  35958. idleRotationWaitTime: number;
  35959. /**
  35960. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35961. */
  35962. /**
  35963. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35964. */
  35965. idleRotationSpinupTime: number;
  35966. /**
  35967. * Gets a value indicating if the camera is currently rotating because of this behavior
  35968. */
  35969. readonly rotationInProgress: boolean;
  35970. private _onPrePointerObservableObserver;
  35971. private _onAfterCheckInputsObserver;
  35972. private _attachedCamera;
  35973. private _isPointerDown;
  35974. private _lastFrameTime;
  35975. private _lastInteractionTime;
  35976. private _cameraRotationSpeed;
  35977. /**
  35978. * Initializes the behavior.
  35979. */
  35980. init(): void;
  35981. /**
  35982. * Attaches the behavior to its arc rotate camera.
  35983. * @param camera Defines the camera to attach the behavior to
  35984. */
  35985. attach(camera: ArcRotateCamera): void;
  35986. /**
  35987. * Detaches the behavior from its current arc rotate camera.
  35988. */
  35989. detach(): void;
  35990. /**
  35991. * Returns true if user is scrolling.
  35992. * @return true if user is scrolling.
  35993. */
  35994. private _userIsZooming;
  35995. private _lastFrameRadius;
  35996. private _shouldAnimationStopForInteraction;
  35997. /**
  35998. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35999. */
  36000. private _applyUserInteraction;
  36001. private _userIsMoving;
  36002. }
  36003. }
  36004. declare module BABYLON {
  36005. /**
  36006. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36007. */
  36008. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36009. private ui;
  36010. /**
  36011. * The name of the behavior
  36012. */
  36013. name: string;
  36014. /**
  36015. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36016. */
  36017. distanceAwayFromFace: number;
  36018. /**
  36019. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36020. */
  36021. distanceAwayFromBottomOfFace: number;
  36022. private _faceVectors;
  36023. private _target;
  36024. private _scene;
  36025. private _onRenderObserver;
  36026. private _tmpMatrix;
  36027. private _tmpVector;
  36028. /**
  36029. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36030. * @param ui The transform node that should be attched to the mesh
  36031. */
  36032. constructor(ui: TransformNode);
  36033. /**
  36034. * Initializes the behavior
  36035. */
  36036. init(): void;
  36037. private _closestFace;
  36038. private _zeroVector;
  36039. private _lookAtTmpMatrix;
  36040. private _lookAtToRef;
  36041. /**
  36042. * Attaches the AttachToBoxBehavior to the passed in mesh
  36043. * @param target The mesh that the specified node will be attached to
  36044. */
  36045. attach(target: Mesh): void;
  36046. /**
  36047. * Detaches the behavior from the mesh
  36048. */
  36049. detach(): void;
  36050. }
  36051. }
  36052. declare module BABYLON {
  36053. /**
  36054. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36055. */
  36056. export class FadeInOutBehavior implements Behavior<Mesh> {
  36057. /**
  36058. * Time in milliseconds to delay before fading in (Default: 0)
  36059. */
  36060. delay: number;
  36061. /**
  36062. * Time in milliseconds for the mesh to fade in (Default: 300)
  36063. */
  36064. fadeInTime: number;
  36065. private _millisecondsPerFrame;
  36066. private _hovered;
  36067. private _hoverValue;
  36068. private _ownerNode;
  36069. /**
  36070. * Instatiates the FadeInOutBehavior
  36071. */
  36072. constructor();
  36073. /**
  36074. * The name of the behavior
  36075. */
  36076. readonly name: string;
  36077. /**
  36078. * Initializes the behavior
  36079. */
  36080. init(): void;
  36081. /**
  36082. * Attaches the fade behavior on the passed in mesh
  36083. * @param ownerNode The mesh that will be faded in/out once attached
  36084. */
  36085. attach(ownerNode: Mesh): void;
  36086. /**
  36087. * Detaches the behavior from the mesh
  36088. */
  36089. detach(): void;
  36090. /**
  36091. * Triggers the mesh to begin fading in or out
  36092. * @param value if the object should fade in or out (true to fade in)
  36093. */
  36094. fadeIn(value: boolean): void;
  36095. private _update;
  36096. private _setAllVisibility;
  36097. }
  36098. }
  36099. declare module BABYLON {
  36100. /**
  36101. * Class containing a set of static utilities functions for managing Pivots
  36102. * @hidden
  36103. */
  36104. export class PivotTools {
  36105. private static _PivotCached;
  36106. private static _OldPivotPoint;
  36107. private static _PivotTranslation;
  36108. private static _PivotTmpVector;
  36109. /** @hidden */
  36110. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36111. /** @hidden */
  36112. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36113. }
  36114. }
  36115. declare module BABYLON {
  36116. /**
  36117. * Class containing static functions to help procedurally build meshes
  36118. */
  36119. export class PlaneBuilder {
  36120. /**
  36121. * Creates a plane mesh
  36122. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36123. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36124. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36126. * * 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
  36127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36128. * @param name defines the name of the mesh
  36129. * @param options defines the options used to create the mesh
  36130. * @param scene defines the hosting scene
  36131. * @returns the plane mesh
  36132. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36133. */
  36134. static CreatePlane(name: string, options: {
  36135. size?: number;
  36136. width?: number;
  36137. height?: number;
  36138. sideOrientation?: number;
  36139. frontUVs?: Vector4;
  36140. backUVs?: Vector4;
  36141. updatable?: boolean;
  36142. sourcePlane?: Plane;
  36143. }, scene?: Nullable<Scene>): Mesh;
  36144. }
  36145. }
  36146. declare module BABYLON {
  36147. /**
  36148. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36149. */
  36150. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36151. private static _AnyMouseID;
  36152. /**
  36153. * Abstract mesh the behavior is set on
  36154. */
  36155. attachedNode: AbstractMesh;
  36156. private _dragPlane;
  36157. private _scene;
  36158. private _pointerObserver;
  36159. private _beforeRenderObserver;
  36160. private static _planeScene;
  36161. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36162. /**
  36163. * 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)
  36164. */
  36165. maxDragAngle: number;
  36166. /**
  36167. * @hidden
  36168. */
  36169. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36170. /**
  36171. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36172. */
  36173. currentDraggingPointerID: number;
  36174. /**
  36175. * The last position where the pointer hit the drag plane in world space
  36176. */
  36177. lastDragPosition: Vector3;
  36178. /**
  36179. * If the behavior is currently in a dragging state
  36180. */
  36181. dragging: boolean;
  36182. /**
  36183. * 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)
  36184. */
  36185. dragDeltaRatio: number;
  36186. /**
  36187. * If the drag plane orientation should be updated during the dragging (Default: true)
  36188. */
  36189. updateDragPlane: boolean;
  36190. private _debugMode;
  36191. private _moving;
  36192. /**
  36193. * Fires each time the attached mesh is dragged with the pointer
  36194. * * delta between last drag position and current drag position in world space
  36195. * * dragDistance along the drag axis
  36196. * * dragPlaneNormal normal of the current drag plane used during the drag
  36197. * * dragPlanePoint in world space where the drag intersects the drag plane
  36198. */
  36199. onDragObservable: Observable<{
  36200. delta: Vector3;
  36201. dragPlanePoint: Vector3;
  36202. dragPlaneNormal: Vector3;
  36203. dragDistance: number;
  36204. pointerId: number;
  36205. }>;
  36206. /**
  36207. * Fires each time a drag begins (eg. mouse down on mesh)
  36208. */
  36209. onDragStartObservable: Observable<{
  36210. dragPlanePoint: Vector3;
  36211. pointerId: number;
  36212. }>;
  36213. /**
  36214. * Fires each time a drag ends (eg. mouse release after drag)
  36215. */
  36216. onDragEndObservable: Observable<{
  36217. dragPlanePoint: Vector3;
  36218. pointerId: number;
  36219. }>;
  36220. /**
  36221. * If the attached mesh should be moved when dragged
  36222. */
  36223. moveAttached: boolean;
  36224. /**
  36225. * If the drag behavior will react to drag events (Default: true)
  36226. */
  36227. enabled: boolean;
  36228. /**
  36229. * If camera controls should be detached during the drag
  36230. */
  36231. detachCameraControls: boolean;
  36232. /**
  36233. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36234. */
  36235. useObjectOrienationForDragging: boolean;
  36236. private _options;
  36237. /**
  36238. * Creates a pointer drag behavior that can be attached to a mesh
  36239. * @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)
  36240. */
  36241. constructor(options?: {
  36242. dragAxis?: Vector3;
  36243. dragPlaneNormal?: Vector3;
  36244. });
  36245. /**
  36246. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36247. */
  36248. validateDrag: (targetPosition: Vector3) => boolean;
  36249. /**
  36250. * The name of the behavior
  36251. */
  36252. readonly name: string;
  36253. /**
  36254. * Initializes the behavior
  36255. */
  36256. init(): void;
  36257. private _tmpVector;
  36258. private _alternatePickedPoint;
  36259. private _worldDragAxis;
  36260. private _targetPosition;
  36261. private _attachedElement;
  36262. /**
  36263. * Attaches the drag behavior the passed in mesh
  36264. * @param ownerNode The mesh that will be dragged around once attached
  36265. */
  36266. attach(ownerNode: AbstractMesh): void;
  36267. /**
  36268. * Force relase the drag action by code.
  36269. */
  36270. releaseDrag(): void;
  36271. private _startDragRay;
  36272. private _lastPointerRay;
  36273. /**
  36274. * Simulates the start of a pointer drag event on the behavior
  36275. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36276. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36277. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36278. */
  36279. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36280. private _startDrag;
  36281. private _dragDelta;
  36282. private _moveDrag;
  36283. private _pickWithRayOnDragPlane;
  36284. private _pointA;
  36285. private _pointB;
  36286. private _pointC;
  36287. private _lineA;
  36288. private _lineB;
  36289. private _localAxis;
  36290. private _lookAt;
  36291. private _updateDragPlanePosition;
  36292. /**
  36293. * Detaches the behavior from the mesh
  36294. */
  36295. detach(): void;
  36296. }
  36297. }
  36298. declare module BABYLON {
  36299. /**
  36300. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36301. */
  36302. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36303. private _dragBehaviorA;
  36304. private _dragBehaviorB;
  36305. private _startDistance;
  36306. private _initialScale;
  36307. private _targetScale;
  36308. private _ownerNode;
  36309. private _sceneRenderObserver;
  36310. /**
  36311. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36312. */
  36313. constructor();
  36314. /**
  36315. * The name of the behavior
  36316. */
  36317. readonly name: string;
  36318. /**
  36319. * Initializes the behavior
  36320. */
  36321. init(): void;
  36322. private _getCurrentDistance;
  36323. /**
  36324. * Attaches the scale behavior the passed in mesh
  36325. * @param ownerNode The mesh that will be scaled around once attached
  36326. */
  36327. attach(ownerNode: Mesh): void;
  36328. /**
  36329. * Detaches the behavior from the mesh
  36330. */
  36331. detach(): void;
  36332. }
  36333. }
  36334. declare module BABYLON {
  36335. /**
  36336. * 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
  36337. */
  36338. export class SixDofDragBehavior implements Behavior<Mesh> {
  36339. private static _virtualScene;
  36340. private _ownerNode;
  36341. private _sceneRenderObserver;
  36342. private _scene;
  36343. private _targetPosition;
  36344. private _virtualOriginMesh;
  36345. private _virtualDragMesh;
  36346. private _pointerObserver;
  36347. private _moving;
  36348. private _startingOrientation;
  36349. /**
  36350. * 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)
  36351. */
  36352. private zDragFactor;
  36353. /**
  36354. * If the object should rotate to face the drag origin
  36355. */
  36356. rotateDraggedObject: boolean;
  36357. /**
  36358. * If the behavior is currently in a dragging state
  36359. */
  36360. dragging: boolean;
  36361. /**
  36362. * 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)
  36363. */
  36364. dragDeltaRatio: number;
  36365. /**
  36366. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36367. */
  36368. currentDraggingPointerID: number;
  36369. /**
  36370. * If camera controls should be detached during the drag
  36371. */
  36372. detachCameraControls: boolean;
  36373. /**
  36374. * Fires each time a drag starts
  36375. */
  36376. onDragStartObservable: Observable<{}>;
  36377. /**
  36378. * Fires each time a drag ends (eg. mouse release after drag)
  36379. */
  36380. onDragEndObservable: Observable<{}>;
  36381. /**
  36382. * 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
  36383. */
  36384. constructor();
  36385. /**
  36386. * The name of the behavior
  36387. */
  36388. readonly name: string;
  36389. /**
  36390. * Initializes the behavior
  36391. */
  36392. init(): void;
  36393. /**
  36394. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36395. */
  36396. private readonly _pointerCamera;
  36397. /**
  36398. * Attaches the scale behavior the passed in mesh
  36399. * @param ownerNode The mesh that will be scaled around once attached
  36400. */
  36401. attach(ownerNode: Mesh): void;
  36402. /**
  36403. * Detaches the behavior from the mesh
  36404. */
  36405. detach(): void;
  36406. }
  36407. }
  36408. declare module BABYLON {
  36409. /**
  36410. * Class used to apply inverse kinematics to bones
  36411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36412. */
  36413. export class BoneIKController {
  36414. private static _tmpVecs;
  36415. private static _tmpQuat;
  36416. private static _tmpMats;
  36417. /**
  36418. * Gets or sets the target mesh
  36419. */
  36420. targetMesh: AbstractMesh;
  36421. /** Gets or sets the mesh used as pole */
  36422. poleTargetMesh: AbstractMesh;
  36423. /**
  36424. * Gets or sets the bone used as pole
  36425. */
  36426. poleTargetBone: Nullable<Bone>;
  36427. /**
  36428. * Gets or sets the target position
  36429. */
  36430. targetPosition: Vector3;
  36431. /**
  36432. * Gets or sets the pole target position
  36433. */
  36434. poleTargetPosition: Vector3;
  36435. /**
  36436. * Gets or sets the pole target local offset
  36437. */
  36438. poleTargetLocalOffset: Vector3;
  36439. /**
  36440. * Gets or sets the pole angle
  36441. */
  36442. poleAngle: number;
  36443. /**
  36444. * Gets or sets the mesh associated with the controller
  36445. */
  36446. mesh: AbstractMesh;
  36447. /**
  36448. * 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)
  36449. */
  36450. slerpAmount: number;
  36451. private _bone1Quat;
  36452. private _bone1Mat;
  36453. private _bone2Ang;
  36454. private _bone1;
  36455. private _bone2;
  36456. private _bone1Length;
  36457. private _bone2Length;
  36458. private _maxAngle;
  36459. private _maxReach;
  36460. private _rightHandedSystem;
  36461. private _bendAxis;
  36462. private _slerping;
  36463. private _adjustRoll;
  36464. /**
  36465. * Gets or sets maximum allowed angle
  36466. */
  36467. maxAngle: number;
  36468. /**
  36469. * Creates a new BoneIKController
  36470. * @param mesh defines the mesh to control
  36471. * @param bone defines the bone to control
  36472. * @param options defines options to set up the controller
  36473. */
  36474. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36475. targetMesh?: AbstractMesh;
  36476. poleTargetMesh?: AbstractMesh;
  36477. poleTargetBone?: Bone;
  36478. poleTargetLocalOffset?: Vector3;
  36479. poleAngle?: number;
  36480. bendAxis?: Vector3;
  36481. maxAngle?: number;
  36482. slerpAmount?: number;
  36483. });
  36484. private _setMaxAngle;
  36485. /**
  36486. * Force the controller to update the bones
  36487. */
  36488. update(): void;
  36489. }
  36490. }
  36491. declare module BABYLON {
  36492. /**
  36493. * Class used to make a bone look toward a point in space
  36494. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36495. */
  36496. export class BoneLookController {
  36497. private static _tmpVecs;
  36498. private static _tmpQuat;
  36499. private static _tmpMats;
  36500. /**
  36501. * The target Vector3 that the bone will look at
  36502. */
  36503. target: Vector3;
  36504. /**
  36505. * The mesh that the bone is attached to
  36506. */
  36507. mesh: AbstractMesh;
  36508. /**
  36509. * The bone that will be looking to the target
  36510. */
  36511. bone: Bone;
  36512. /**
  36513. * The up axis of the coordinate system that is used when the bone is rotated
  36514. */
  36515. upAxis: Vector3;
  36516. /**
  36517. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36518. */
  36519. upAxisSpace: Space;
  36520. /**
  36521. * Used to make an adjustment to the yaw of the bone
  36522. */
  36523. adjustYaw: number;
  36524. /**
  36525. * Used to make an adjustment to the pitch of the bone
  36526. */
  36527. adjustPitch: number;
  36528. /**
  36529. * Used to make an adjustment to the roll of the bone
  36530. */
  36531. adjustRoll: number;
  36532. /**
  36533. * 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)
  36534. */
  36535. slerpAmount: number;
  36536. private _minYaw;
  36537. private _maxYaw;
  36538. private _minPitch;
  36539. private _maxPitch;
  36540. private _minYawSin;
  36541. private _minYawCos;
  36542. private _maxYawSin;
  36543. private _maxYawCos;
  36544. private _midYawConstraint;
  36545. private _minPitchTan;
  36546. private _maxPitchTan;
  36547. private _boneQuat;
  36548. private _slerping;
  36549. private _transformYawPitch;
  36550. private _transformYawPitchInv;
  36551. private _firstFrameSkipped;
  36552. private _yawRange;
  36553. private _fowardAxis;
  36554. /**
  36555. * Gets or sets the minimum yaw angle that the bone can look to
  36556. */
  36557. minYaw: number;
  36558. /**
  36559. * Gets or sets the maximum yaw angle that the bone can look to
  36560. */
  36561. maxYaw: number;
  36562. /**
  36563. * Gets or sets the minimum pitch angle that the bone can look to
  36564. */
  36565. minPitch: number;
  36566. /**
  36567. * Gets or sets the maximum pitch angle that the bone can look to
  36568. */
  36569. maxPitch: number;
  36570. /**
  36571. * Create a BoneLookController
  36572. * @param mesh the mesh that the bone belongs to
  36573. * @param bone the bone that will be looking to the target
  36574. * @param target the target Vector3 to look at
  36575. * @param options optional settings:
  36576. * * maxYaw: the maximum angle the bone will yaw to
  36577. * * minYaw: the minimum angle the bone will yaw to
  36578. * * maxPitch: the maximum angle the bone will pitch to
  36579. * * minPitch: the minimum angle the bone will yaw to
  36580. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36581. * * upAxis: the up axis of the coordinate system
  36582. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36583. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36584. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36585. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36586. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36587. * * adjustRoll: used to make an adjustment to the roll of the bone
  36588. **/
  36589. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36590. maxYaw?: number;
  36591. minYaw?: number;
  36592. maxPitch?: number;
  36593. minPitch?: number;
  36594. slerpAmount?: number;
  36595. upAxis?: Vector3;
  36596. upAxisSpace?: Space;
  36597. yawAxis?: Vector3;
  36598. pitchAxis?: Vector3;
  36599. adjustYaw?: number;
  36600. adjustPitch?: number;
  36601. adjustRoll?: number;
  36602. });
  36603. /**
  36604. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36605. */
  36606. update(): void;
  36607. private _getAngleDiff;
  36608. private _getAngleBetween;
  36609. private _isAngleBetween;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. /**
  36614. * Manage the gamepad inputs to control an arc rotate camera.
  36615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36616. */
  36617. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36618. /**
  36619. * Defines the camera the input is attached to.
  36620. */
  36621. camera: ArcRotateCamera;
  36622. /**
  36623. * Defines the gamepad the input is gathering event from.
  36624. */
  36625. gamepad: Nullable<Gamepad>;
  36626. /**
  36627. * Defines the gamepad rotation sensiblity.
  36628. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36629. */
  36630. gamepadRotationSensibility: number;
  36631. /**
  36632. * Defines the gamepad move sensiblity.
  36633. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36634. */
  36635. gamepadMoveSensibility: number;
  36636. private _onGamepadConnectedObserver;
  36637. private _onGamepadDisconnectedObserver;
  36638. /**
  36639. * Attach the input controls to a specific dom element to get the input from.
  36640. * @param element Defines the element the controls should be listened from
  36641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36642. */
  36643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36644. /**
  36645. * Detach the current controls from the specified dom element.
  36646. * @param element Defines the element to stop listening the inputs from
  36647. */
  36648. detachControl(element: Nullable<HTMLElement>): void;
  36649. /**
  36650. * Update the current camera state depending on the inputs that have been used this frame.
  36651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36652. */
  36653. checkInputs(): void;
  36654. /**
  36655. * Gets the class name of the current intput.
  36656. * @returns the class name
  36657. */
  36658. getClassName(): string;
  36659. /**
  36660. * Get the friendly name associated with the input class.
  36661. * @returns the input friendly name
  36662. */
  36663. getSimpleName(): string;
  36664. }
  36665. }
  36666. declare module BABYLON {
  36667. interface ArcRotateCameraInputsManager {
  36668. /**
  36669. * Add orientation input support to the input manager.
  36670. * @returns the current input manager
  36671. */
  36672. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36673. }
  36674. /**
  36675. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36676. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36677. */
  36678. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36679. /**
  36680. * Defines the camera the input is attached to.
  36681. */
  36682. camera: ArcRotateCamera;
  36683. /**
  36684. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36685. */
  36686. alphaCorrection: number;
  36687. /**
  36688. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36689. */
  36690. gammaCorrection: number;
  36691. private _alpha;
  36692. private _gamma;
  36693. private _dirty;
  36694. private _deviceOrientationHandler;
  36695. /**
  36696. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36697. */
  36698. constructor();
  36699. /**
  36700. * Attach the input controls to a specific dom element to get the input from.
  36701. * @param element Defines the element the controls should be listened from
  36702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36703. */
  36704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36705. /** @hidden */
  36706. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36707. /**
  36708. * Update the current camera state depending on the inputs that have been used this frame.
  36709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36710. */
  36711. checkInputs(): void;
  36712. /**
  36713. * Detach the current controls from the specified dom element.
  36714. * @param element Defines the element to stop listening the inputs from
  36715. */
  36716. detachControl(element: Nullable<HTMLElement>): void;
  36717. /**
  36718. * Gets the class name of the current intput.
  36719. * @returns the class name
  36720. */
  36721. getClassName(): string;
  36722. /**
  36723. * Get the friendly name associated with the input class.
  36724. * @returns the input friendly name
  36725. */
  36726. getSimpleName(): string;
  36727. }
  36728. }
  36729. declare module BABYLON {
  36730. /**
  36731. * Listen to mouse events to control the camera.
  36732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36733. */
  36734. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36735. /**
  36736. * Defines the camera the input is attached to.
  36737. */
  36738. camera: FlyCamera;
  36739. /**
  36740. * Defines if touch is enabled. (Default is true.)
  36741. */
  36742. touchEnabled: boolean;
  36743. /**
  36744. * Defines the buttons associated with the input to handle camera rotation.
  36745. */
  36746. buttons: number[];
  36747. /**
  36748. * Assign buttons for Yaw control.
  36749. */
  36750. buttonsYaw: number[];
  36751. /**
  36752. * Assign buttons for Pitch control.
  36753. */
  36754. buttonsPitch: number[];
  36755. /**
  36756. * Assign buttons for Roll control.
  36757. */
  36758. buttonsRoll: number[];
  36759. /**
  36760. * Detect if any button is being pressed while mouse is moved.
  36761. * -1 = Mouse locked.
  36762. * 0 = Left button.
  36763. * 1 = Middle Button.
  36764. * 2 = Right Button.
  36765. */
  36766. activeButton: number;
  36767. /**
  36768. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36769. * Higher values reduce its sensitivity.
  36770. */
  36771. angularSensibility: number;
  36772. private _mousemoveCallback;
  36773. private _observer;
  36774. private _rollObserver;
  36775. private previousPosition;
  36776. private noPreventDefault;
  36777. private element;
  36778. /**
  36779. * Listen to mouse events to control the camera.
  36780. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36782. */
  36783. constructor(touchEnabled?: boolean);
  36784. /**
  36785. * Attach the mouse control to the HTML DOM element.
  36786. * @param element Defines the element that listens to the input events.
  36787. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36788. */
  36789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36790. /**
  36791. * Detach the current controls from the specified dom element.
  36792. * @param element Defines the element to stop listening the inputs from
  36793. */
  36794. detachControl(element: Nullable<HTMLElement>): void;
  36795. /**
  36796. * Gets the class name of the current input.
  36797. * @returns the class name.
  36798. */
  36799. getClassName(): string;
  36800. /**
  36801. * Get the friendly name associated with the input class.
  36802. * @returns the input's friendly name.
  36803. */
  36804. getSimpleName(): string;
  36805. private _pointerInput;
  36806. private _onMouseMove;
  36807. /**
  36808. * Rotate camera by mouse offset.
  36809. */
  36810. private rotateCamera;
  36811. }
  36812. }
  36813. declare module BABYLON {
  36814. /**
  36815. * Default Inputs manager for the FlyCamera.
  36816. * It groups all the default supported inputs for ease of use.
  36817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36818. */
  36819. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36820. /**
  36821. * Instantiates a new FlyCameraInputsManager.
  36822. * @param camera Defines the camera the inputs belong to.
  36823. */
  36824. constructor(camera: FlyCamera);
  36825. /**
  36826. * Add keyboard input support to the input manager.
  36827. * @returns the new FlyCameraKeyboardMoveInput().
  36828. */
  36829. addKeyboard(): FlyCameraInputsManager;
  36830. /**
  36831. * Add mouse input support to the input manager.
  36832. * @param touchEnabled Enable touch screen support.
  36833. * @returns the new FlyCameraMouseInput().
  36834. */
  36835. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36836. }
  36837. }
  36838. declare module BABYLON {
  36839. /**
  36840. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36841. * such as in a 3D Space Shooter or a Flight Simulator.
  36842. */
  36843. export class FlyCamera extends TargetCamera {
  36844. /**
  36845. * Define the collision ellipsoid of the camera.
  36846. * This is helpful for simulating a camera body, like a player's body.
  36847. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36848. */
  36849. ellipsoid: Vector3;
  36850. /**
  36851. * Define an offset for the position of the ellipsoid around the camera.
  36852. * This can be helpful if the camera is attached away from the player's body center,
  36853. * such as at its head.
  36854. */
  36855. ellipsoidOffset: Vector3;
  36856. /**
  36857. * Enable or disable collisions of the camera with the rest of the scene objects.
  36858. */
  36859. checkCollisions: boolean;
  36860. /**
  36861. * Enable or disable gravity on the camera.
  36862. */
  36863. applyGravity: boolean;
  36864. /**
  36865. * Define the current direction the camera is moving to.
  36866. */
  36867. cameraDirection: Vector3;
  36868. /**
  36869. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36870. * This overrides and empties cameraRotation.
  36871. */
  36872. rotationQuaternion: Quaternion;
  36873. /**
  36874. * Track Roll to maintain the wanted Rolling when looking around.
  36875. */
  36876. _trackRoll: number;
  36877. /**
  36878. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36879. */
  36880. rollCorrect: number;
  36881. /**
  36882. * Mimic a banked turn, Rolling the camera when Yawing.
  36883. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36884. */
  36885. bankedTurn: boolean;
  36886. /**
  36887. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36888. */
  36889. bankedTurnLimit: number;
  36890. /**
  36891. * Value of 0 disables the banked Roll.
  36892. * Value of 1 is equal to the Yaw angle in radians.
  36893. */
  36894. bankedTurnMultiplier: number;
  36895. /**
  36896. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36897. */
  36898. inputs: FlyCameraInputsManager;
  36899. /**
  36900. * Gets the input sensibility for mouse input.
  36901. * Higher values reduce sensitivity.
  36902. */
  36903. /**
  36904. * Sets the input sensibility for a mouse input.
  36905. * Higher values reduce sensitivity.
  36906. */
  36907. angularSensibility: number;
  36908. /**
  36909. * Get the keys for camera movement forward.
  36910. */
  36911. /**
  36912. * Set the keys for camera movement forward.
  36913. */
  36914. keysForward: number[];
  36915. /**
  36916. * Get the keys for camera movement backward.
  36917. */
  36918. keysBackward: number[];
  36919. /**
  36920. * Get the keys for camera movement up.
  36921. */
  36922. /**
  36923. * Set the keys for camera movement up.
  36924. */
  36925. keysUp: number[];
  36926. /**
  36927. * Get the keys for camera movement down.
  36928. */
  36929. /**
  36930. * Set the keys for camera movement down.
  36931. */
  36932. keysDown: number[];
  36933. /**
  36934. * Get the keys for camera movement left.
  36935. */
  36936. /**
  36937. * Set the keys for camera movement left.
  36938. */
  36939. keysLeft: number[];
  36940. /**
  36941. * Set the keys for camera movement right.
  36942. */
  36943. /**
  36944. * Set the keys for camera movement right.
  36945. */
  36946. keysRight: number[];
  36947. /**
  36948. * Event raised when the camera collides with a mesh in the scene.
  36949. */
  36950. onCollide: (collidedMesh: AbstractMesh) => void;
  36951. private _collider;
  36952. private _needMoveForGravity;
  36953. private _oldPosition;
  36954. private _diffPosition;
  36955. private _newPosition;
  36956. /** @hidden */
  36957. _localDirection: Vector3;
  36958. /** @hidden */
  36959. _transformedDirection: Vector3;
  36960. /**
  36961. * Instantiates a FlyCamera.
  36962. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36963. * such as in a 3D Space Shooter or a Flight Simulator.
  36964. * @param name Define the name of the camera in the scene.
  36965. * @param position Define the starting position of the camera in the scene.
  36966. * @param scene Define the scene the camera belongs to.
  36967. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36968. */
  36969. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36970. /**
  36971. * Attach a control to the HTML DOM element.
  36972. * @param element Defines the element that listens to the input events.
  36973. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36974. */
  36975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36976. /**
  36977. * Detach a control from the HTML DOM element.
  36978. * The camera will stop reacting to that input.
  36979. * @param element Defines the element that listens to the input events.
  36980. */
  36981. detachControl(element: HTMLElement): void;
  36982. private _collisionMask;
  36983. /**
  36984. * Get the mask that the camera ignores in collision events.
  36985. */
  36986. /**
  36987. * Set the mask that the camera ignores in collision events.
  36988. */
  36989. collisionMask: number;
  36990. /** @hidden */
  36991. _collideWithWorld(displacement: Vector3): void;
  36992. /** @hidden */
  36993. private _onCollisionPositionChange;
  36994. /** @hidden */
  36995. _checkInputs(): void;
  36996. /** @hidden */
  36997. _decideIfNeedsToMove(): boolean;
  36998. /** @hidden */
  36999. _updatePosition(): void;
  37000. /**
  37001. * Restore the Roll to its target value at the rate specified.
  37002. * @param rate - Higher means slower restoring.
  37003. * @hidden
  37004. */
  37005. restoreRoll(rate: number): void;
  37006. /**
  37007. * Destroy the camera and release the current resources held by it.
  37008. */
  37009. dispose(): void;
  37010. /**
  37011. * Get the current object class name.
  37012. * @returns the class name.
  37013. */
  37014. getClassName(): string;
  37015. }
  37016. }
  37017. declare module BABYLON {
  37018. /**
  37019. * Listen to keyboard events to control the camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: FlyCamera;
  37027. /**
  37028. * The list of keyboard keys used to control the forward move of the camera.
  37029. */
  37030. keysForward: number[];
  37031. /**
  37032. * The list of keyboard keys used to control the backward move of the camera.
  37033. */
  37034. keysBackward: number[];
  37035. /**
  37036. * The list of keyboard keys used to control the forward move of the camera.
  37037. */
  37038. keysUp: number[];
  37039. /**
  37040. * The list of keyboard keys used to control the backward move of the camera.
  37041. */
  37042. keysDown: number[];
  37043. /**
  37044. * The list of keyboard keys used to control the right strafe move of the camera.
  37045. */
  37046. keysRight: number[];
  37047. /**
  37048. * The list of keyboard keys used to control the left strafe move of the camera.
  37049. */
  37050. keysLeft: number[];
  37051. private _keys;
  37052. private _onCanvasBlurObserver;
  37053. private _onKeyboardObserver;
  37054. private _engine;
  37055. private _scene;
  37056. /**
  37057. * Attach the input controls to a specific dom element to get the input from.
  37058. * @param element Defines the element the controls should be listened from
  37059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37060. */
  37061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37062. /**
  37063. * Detach the current controls from the specified dom element.
  37064. * @param element Defines the element to stop listening the inputs from
  37065. */
  37066. detachControl(element: Nullable<HTMLElement>): void;
  37067. /**
  37068. * Gets the class name of the current intput.
  37069. * @returns the class name
  37070. */
  37071. getClassName(): string;
  37072. /** @hidden */
  37073. _onLostFocus(e: FocusEvent): void;
  37074. /**
  37075. * Get the friendly name associated with the input class.
  37076. * @returns the input friendly name
  37077. */
  37078. getSimpleName(): string;
  37079. /**
  37080. * Update the current camera state depending on the inputs that have been used this frame.
  37081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37082. */
  37083. checkInputs(): void;
  37084. }
  37085. }
  37086. declare module BABYLON {
  37087. /**
  37088. * Manage the mouse wheel inputs to control a follow camera.
  37089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37090. */
  37091. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37092. /**
  37093. * Defines the camera the input is attached to.
  37094. */
  37095. camera: FollowCamera;
  37096. /**
  37097. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37098. */
  37099. axisControlRadius: boolean;
  37100. /**
  37101. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37102. */
  37103. axisControlHeight: boolean;
  37104. /**
  37105. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37106. */
  37107. axisControlRotation: boolean;
  37108. /**
  37109. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37110. * relation to mouseWheel events.
  37111. */
  37112. wheelPrecision: number;
  37113. /**
  37114. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37115. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37116. */
  37117. wheelDeltaPercentage: number;
  37118. private _wheel;
  37119. private _observer;
  37120. /**
  37121. * Attach the input controls to a specific dom element to get the input from.
  37122. * @param element Defines the element the controls should be listened from
  37123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37124. */
  37125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37126. /**
  37127. * Detach the current controls from the specified dom element.
  37128. * @param element Defines the element to stop listening the inputs from
  37129. */
  37130. detachControl(element: Nullable<HTMLElement>): void;
  37131. /**
  37132. * Gets the class name of the current intput.
  37133. * @returns the class name
  37134. */
  37135. getClassName(): string;
  37136. /**
  37137. * Get the friendly name associated with the input class.
  37138. * @returns the input friendly name
  37139. */
  37140. getSimpleName(): string;
  37141. }
  37142. }
  37143. declare module BABYLON {
  37144. /**
  37145. * Manage the pointers inputs to control an follow camera.
  37146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37147. */
  37148. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37149. /**
  37150. * Defines the camera the input is attached to.
  37151. */
  37152. camera: FollowCamera;
  37153. /**
  37154. * Gets the class name of the current input.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. /**
  37159. * Defines the pointer angular sensibility along the X axis or how fast is
  37160. * the camera rotating.
  37161. * A negative number will reverse the axis direction.
  37162. */
  37163. angularSensibilityX: number;
  37164. /**
  37165. * Defines the pointer angular sensibility along the Y axis or how fast is
  37166. * the camera rotating.
  37167. * A negative number will reverse the axis direction.
  37168. */
  37169. angularSensibilityY: number;
  37170. /**
  37171. * Defines the pointer pinch precision or how fast is the camera zooming.
  37172. * A negative number will reverse the axis direction.
  37173. */
  37174. pinchPrecision: number;
  37175. /**
  37176. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37177. * from 0.
  37178. * It defines the percentage of current camera.radius to use as delta when
  37179. * pinch zoom is used.
  37180. */
  37181. pinchDeltaPercentage: number;
  37182. /**
  37183. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37184. */
  37185. axisXControlRadius: boolean;
  37186. /**
  37187. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37188. */
  37189. axisXControlHeight: boolean;
  37190. /**
  37191. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37192. */
  37193. axisXControlRotation: boolean;
  37194. /**
  37195. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37196. */
  37197. axisYControlRadius: boolean;
  37198. /**
  37199. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37200. */
  37201. axisYControlHeight: boolean;
  37202. /**
  37203. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37204. */
  37205. axisYControlRotation: boolean;
  37206. /**
  37207. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37208. */
  37209. axisPinchControlRadius: boolean;
  37210. /**
  37211. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37212. */
  37213. axisPinchControlHeight: boolean;
  37214. /**
  37215. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37216. */
  37217. axisPinchControlRotation: boolean;
  37218. /**
  37219. * Log error messages if basic misconfiguration has occurred.
  37220. */
  37221. warningEnable: boolean;
  37222. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37223. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37224. private _warningCounter;
  37225. private _warning;
  37226. }
  37227. }
  37228. declare module BABYLON {
  37229. /**
  37230. * Default Inputs manager for the FollowCamera.
  37231. * It groups all the default supported inputs for ease of use.
  37232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37233. */
  37234. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37235. /**
  37236. * Instantiates a new FollowCameraInputsManager.
  37237. * @param camera Defines the camera the inputs belong to
  37238. */
  37239. constructor(camera: FollowCamera);
  37240. /**
  37241. * Add keyboard input support to the input manager.
  37242. * @returns the current input manager
  37243. */
  37244. addKeyboard(): FollowCameraInputsManager;
  37245. /**
  37246. * Add mouse wheel input support to the input manager.
  37247. * @returns the current input manager
  37248. */
  37249. addMouseWheel(): FollowCameraInputsManager;
  37250. /**
  37251. * Add pointers input support to the input manager.
  37252. * @returns the current input manager
  37253. */
  37254. addPointers(): FollowCameraInputsManager;
  37255. /**
  37256. * Add orientation input support to the input manager.
  37257. * @returns the current input manager
  37258. */
  37259. addVRDeviceOrientation(): FollowCameraInputsManager;
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. /**
  37264. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37265. * an arc rotate version arcFollowCamera are available.
  37266. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37267. */
  37268. export class FollowCamera extends TargetCamera {
  37269. /**
  37270. * Distance the follow camera should follow an object at
  37271. */
  37272. radius: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the axis of rotation
  37275. * (The camera can not get closer).
  37276. * This can help limiting how the Camera is able to move in the scene.
  37277. */
  37278. lowerRadiusLimit: Nullable<number>;
  37279. /**
  37280. * Maximum allowed distance of the camera to the axis of rotation
  37281. * (The camera can not get further).
  37282. * This can help limiting how the Camera is able to move in the scene.
  37283. */
  37284. upperRadiusLimit: Nullable<number>;
  37285. /**
  37286. * Define a rotation offset between the camera and the object it follows
  37287. */
  37288. rotationOffset: number;
  37289. /**
  37290. * Minimum allowed angle to camera position relative to target object.
  37291. * This can help limiting how the Camera is able to move in the scene.
  37292. */
  37293. lowerRotationOffsetLimit: Nullable<number>;
  37294. /**
  37295. * Maximum allowed angle to camera position relative to target object.
  37296. * This can help limiting how the Camera is able to move in the scene.
  37297. */
  37298. upperRotationOffsetLimit: Nullable<number>;
  37299. /**
  37300. * Define a height offset between the camera and the object it follows.
  37301. * It can help following an object from the top (like a car chaing a plane)
  37302. */
  37303. heightOffset: number;
  37304. /**
  37305. * Minimum allowed height of camera position relative to target object.
  37306. * This can help limiting how the Camera is able to move in the scene.
  37307. */
  37308. lowerHeightOffsetLimit: Nullable<number>;
  37309. /**
  37310. * Maximum allowed height of camera position relative to target object.
  37311. * This can help limiting how the Camera is able to move in the scene.
  37312. */
  37313. upperHeightOffsetLimit: Nullable<number>;
  37314. /**
  37315. * Define how fast the camera can accelerate to follow it s target.
  37316. */
  37317. cameraAcceleration: number;
  37318. /**
  37319. * Define the speed limit of the camera following an object.
  37320. */
  37321. maxCameraSpeed: number;
  37322. /**
  37323. * Define the target of the camera.
  37324. */
  37325. lockedTarget: Nullable<AbstractMesh>;
  37326. /**
  37327. * Defines the input associated with the camera.
  37328. */
  37329. inputs: FollowCameraInputsManager;
  37330. /**
  37331. * Instantiates the follow camera.
  37332. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37333. * @param name Define the name of the camera in the scene
  37334. * @param position Define the position of the camera
  37335. * @param scene Define the scene the camera belong to
  37336. * @param lockedTarget Define the target of the camera
  37337. */
  37338. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37339. private _follow;
  37340. /**
  37341. * Attached controls to the current camera.
  37342. * @param element Defines the element the controls should be listened from
  37343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37344. */
  37345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37346. /**
  37347. * Detach the current controls from the camera.
  37348. * The camera will stop reacting to inputs.
  37349. * @param element Defines the element to stop listening the inputs from
  37350. */
  37351. detachControl(element: HTMLElement): void;
  37352. /** @hidden */
  37353. _checkInputs(): void;
  37354. private _checkLimits;
  37355. /**
  37356. * Gets the camera class name.
  37357. * @returns the class name
  37358. */
  37359. getClassName(): string;
  37360. }
  37361. /**
  37362. * Arc Rotate version of the follow camera.
  37363. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37364. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37365. */
  37366. export class ArcFollowCamera extends TargetCamera {
  37367. /** The longitudinal angle of the camera */
  37368. alpha: number;
  37369. /** The latitudinal angle of the camera */
  37370. beta: number;
  37371. /** The radius of the camera from its target */
  37372. radius: number;
  37373. /** Define the camera target (the messh it should follow) */
  37374. target: Nullable<AbstractMesh>;
  37375. private _cartesianCoordinates;
  37376. /**
  37377. * Instantiates a new ArcFollowCamera
  37378. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37379. * @param name Define the name of the camera
  37380. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37381. * @param beta Define the rotation angle of the camera around the elevation axis
  37382. * @param radius Define the radius of the camera from its target point
  37383. * @param target Define the target of the camera
  37384. * @param scene Define the scene the camera belongs to
  37385. */
  37386. constructor(name: string,
  37387. /** The longitudinal angle of the camera */
  37388. alpha: number,
  37389. /** The latitudinal angle of the camera */
  37390. beta: number,
  37391. /** The radius of the camera from its target */
  37392. radius: number,
  37393. /** Define the camera target (the messh it should follow) */
  37394. target: Nullable<AbstractMesh>, scene: Scene);
  37395. private _follow;
  37396. /** @hidden */
  37397. _checkInputs(): void;
  37398. /**
  37399. * Returns the class name of the object.
  37400. * It is mostly used internally for serialization purposes.
  37401. */
  37402. getClassName(): string;
  37403. }
  37404. }
  37405. declare module BABYLON {
  37406. /**
  37407. * Manage the keyboard inputs to control the movement of a follow camera.
  37408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37409. */
  37410. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37411. /**
  37412. * Defines the camera the input is attached to.
  37413. */
  37414. camera: FollowCamera;
  37415. /**
  37416. * Defines the list of key codes associated with the up action (increase heightOffset)
  37417. */
  37418. keysHeightOffsetIncr: number[];
  37419. /**
  37420. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37421. */
  37422. keysHeightOffsetDecr: number[];
  37423. /**
  37424. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37425. */
  37426. keysHeightOffsetModifierAlt: boolean;
  37427. /**
  37428. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37429. */
  37430. keysHeightOffsetModifierCtrl: boolean;
  37431. /**
  37432. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37433. */
  37434. keysHeightOffsetModifierShift: boolean;
  37435. /**
  37436. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37437. */
  37438. keysRotationOffsetIncr: number[];
  37439. /**
  37440. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37441. */
  37442. keysRotationOffsetDecr: number[];
  37443. /**
  37444. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37445. */
  37446. keysRotationOffsetModifierAlt: boolean;
  37447. /**
  37448. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37449. */
  37450. keysRotationOffsetModifierCtrl: boolean;
  37451. /**
  37452. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37453. */
  37454. keysRotationOffsetModifierShift: boolean;
  37455. /**
  37456. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37457. */
  37458. keysRadiusIncr: number[];
  37459. /**
  37460. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37461. */
  37462. keysRadiusDecr: number[];
  37463. /**
  37464. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37465. */
  37466. keysRadiusModifierAlt: boolean;
  37467. /**
  37468. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37469. */
  37470. keysRadiusModifierCtrl: boolean;
  37471. /**
  37472. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37473. */
  37474. keysRadiusModifierShift: boolean;
  37475. /**
  37476. * Defines the rate of change of heightOffset.
  37477. */
  37478. heightSensibility: number;
  37479. /**
  37480. * Defines the rate of change of rotationOffset.
  37481. */
  37482. rotationSensibility: number;
  37483. /**
  37484. * Defines the rate of change of radius.
  37485. */
  37486. radiusSensibility: number;
  37487. private _keys;
  37488. private _ctrlPressed;
  37489. private _altPressed;
  37490. private _shiftPressed;
  37491. private _onCanvasBlurObserver;
  37492. private _onKeyboardObserver;
  37493. private _engine;
  37494. private _scene;
  37495. /**
  37496. * Attach the input controls to a specific dom element to get the input from.
  37497. * @param element Defines the element the controls should be listened from
  37498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37499. */
  37500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37501. /**
  37502. * Detach the current controls from the specified dom element.
  37503. * @param element Defines the element to stop listening the inputs from
  37504. */
  37505. detachControl(element: Nullable<HTMLElement>): void;
  37506. /**
  37507. * Update the current camera state depending on the inputs that have been used this frame.
  37508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37509. */
  37510. checkInputs(): void;
  37511. /**
  37512. * Gets the class name of the current input.
  37513. * @returns the class name
  37514. */
  37515. getClassName(): string;
  37516. /**
  37517. * Get the friendly name associated with the input class.
  37518. * @returns the input friendly name
  37519. */
  37520. getSimpleName(): string;
  37521. /**
  37522. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37523. * allow modification of the heightOffset value.
  37524. */
  37525. private _modifierHeightOffset;
  37526. /**
  37527. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37528. * allow modification of the rotationOffset value.
  37529. */
  37530. private _modifierRotationOffset;
  37531. /**
  37532. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37533. * allow modification of the radius value.
  37534. */
  37535. private _modifierRadius;
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. interface FreeCameraInputsManager {
  37540. /**
  37541. * @hidden
  37542. */
  37543. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37544. /**
  37545. * Add orientation input support to the input manager.
  37546. * @returns the current input manager
  37547. */
  37548. addDeviceOrientation(): FreeCameraInputsManager;
  37549. }
  37550. /**
  37551. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37552. * Screen rotation is taken into account.
  37553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37554. */
  37555. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37556. private _camera;
  37557. private _screenOrientationAngle;
  37558. private _constantTranform;
  37559. private _screenQuaternion;
  37560. private _alpha;
  37561. private _beta;
  37562. private _gamma;
  37563. /**
  37564. * Can be used to detect if a device orientation sensor is availible on a device
  37565. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37566. * @returns a promise that will resolve on orientation change
  37567. */
  37568. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37569. /**
  37570. * @hidden
  37571. */
  37572. _onDeviceOrientationChangedObservable: Observable<void>;
  37573. /**
  37574. * Instantiates a new input
  37575. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37576. */
  37577. constructor();
  37578. /**
  37579. * Define the camera controlled by the input.
  37580. */
  37581. camera: FreeCamera;
  37582. /**
  37583. * Attach the input controls to a specific dom element to get the input from.
  37584. * @param element Defines the element the controls should be listened from
  37585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37586. */
  37587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37588. private _orientationChanged;
  37589. private _deviceOrientation;
  37590. /**
  37591. * Detach the current controls from the specified dom element.
  37592. * @param element Defines the element to stop listening the inputs from
  37593. */
  37594. detachControl(element: Nullable<HTMLElement>): void;
  37595. /**
  37596. * Update the current camera state depending on the inputs that have been used this frame.
  37597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37598. */
  37599. checkInputs(): void;
  37600. /**
  37601. * Gets the class name of the current intput.
  37602. * @returns the class name
  37603. */
  37604. getClassName(): string;
  37605. /**
  37606. * Get the friendly name associated with the input class.
  37607. * @returns the input friendly name
  37608. */
  37609. getSimpleName(): string;
  37610. }
  37611. }
  37612. declare module BABYLON {
  37613. /**
  37614. * Manage the gamepad inputs to control a free camera.
  37615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37616. */
  37617. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37618. /**
  37619. * Define the camera the input is attached to.
  37620. */
  37621. camera: FreeCamera;
  37622. /**
  37623. * Define the Gamepad controlling the input
  37624. */
  37625. gamepad: Nullable<Gamepad>;
  37626. /**
  37627. * Defines the gamepad rotation sensiblity.
  37628. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37629. */
  37630. gamepadAngularSensibility: number;
  37631. /**
  37632. * Defines the gamepad move sensiblity.
  37633. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37634. */
  37635. gamepadMoveSensibility: number;
  37636. private _onGamepadConnectedObserver;
  37637. private _onGamepadDisconnectedObserver;
  37638. private _cameraTransform;
  37639. private _deltaTransform;
  37640. private _vector3;
  37641. private _vector2;
  37642. /**
  37643. * Attach the input controls to a specific dom element to get the input from.
  37644. * @param element Defines the element the controls should be listened from
  37645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37646. */
  37647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37648. /**
  37649. * Detach the current controls from the specified dom element.
  37650. * @param element Defines the element to stop listening the inputs from
  37651. */
  37652. detachControl(element: Nullable<HTMLElement>): void;
  37653. /**
  37654. * Update the current camera state depending on the inputs that have been used this frame.
  37655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37656. */
  37657. checkInputs(): void;
  37658. /**
  37659. * Gets the class name of the current intput.
  37660. * @returns the class name
  37661. */
  37662. getClassName(): string;
  37663. /**
  37664. * Get the friendly name associated with the input class.
  37665. * @returns the input friendly name
  37666. */
  37667. getSimpleName(): string;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. /**
  37672. * Defines the potential axis of a Joystick
  37673. */
  37674. export enum JoystickAxis {
  37675. /** X axis */
  37676. X = 0,
  37677. /** Y axis */
  37678. Y = 1,
  37679. /** Z axis */
  37680. Z = 2
  37681. }
  37682. /**
  37683. * Class used to define virtual joystick (used in touch mode)
  37684. */
  37685. export class VirtualJoystick {
  37686. /**
  37687. * Gets or sets a boolean indicating that left and right values must be inverted
  37688. */
  37689. reverseLeftRight: boolean;
  37690. /**
  37691. * Gets or sets a boolean indicating that up and down values must be inverted
  37692. */
  37693. reverseUpDown: boolean;
  37694. /**
  37695. * Gets the offset value for the position (ie. the change of the position value)
  37696. */
  37697. deltaPosition: Vector3;
  37698. /**
  37699. * Gets a boolean indicating if the virtual joystick was pressed
  37700. */
  37701. pressed: boolean;
  37702. /**
  37703. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37704. */
  37705. static Canvas: Nullable<HTMLCanvasElement>;
  37706. private static _globalJoystickIndex;
  37707. private static vjCanvasContext;
  37708. private static vjCanvasWidth;
  37709. private static vjCanvasHeight;
  37710. private static halfWidth;
  37711. private _action;
  37712. private _axisTargetedByLeftAndRight;
  37713. private _axisTargetedByUpAndDown;
  37714. private _joystickSensibility;
  37715. private _inversedSensibility;
  37716. private _joystickPointerID;
  37717. private _joystickColor;
  37718. private _joystickPointerPos;
  37719. private _joystickPreviousPointerPos;
  37720. private _joystickPointerStartPos;
  37721. private _deltaJoystickVector;
  37722. private _leftJoystick;
  37723. private _touches;
  37724. private _onPointerDownHandlerRef;
  37725. private _onPointerMoveHandlerRef;
  37726. private _onPointerUpHandlerRef;
  37727. private _onResize;
  37728. /**
  37729. * Creates a new virtual joystick
  37730. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37731. */
  37732. constructor(leftJoystick?: boolean);
  37733. /**
  37734. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37735. * @param newJoystickSensibility defines the new sensibility
  37736. */
  37737. setJoystickSensibility(newJoystickSensibility: number): void;
  37738. private _onPointerDown;
  37739. private _onPointerMove;
  37740. private _onPointerUp;
  37741. /**
  37742. * Change the color of the virtual joystick
  37743. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37744. */
  37745. setJoystickColor(newColor: string): void;
  37746. /**
  37747. * Defines a callback to call when the joystick is touched
  37748. * @param action defines the callback
  37749. */
  37750. setActionOnTouch(action: () => any): void;
  37751. /**
  37752. * Defines which axis you'd like to control for left & right
  37753. * @param axis defines the axis to use
  37754. */
  37755. setAxisForLeftRight(axis: JoystickAxis): void;
  37756. /**
  37757. * Defines which axis you'd like to control for up & down
  37758. * @param axis defines the axis to use
  37759. */
  37760. setAxisForUpDown(axis: JoystickAxis): void;
  37761. private _drawVirtualJoystick;
  37762. /**
  37763. * Release internal HTML canvas
  37764. */
  37765. releaseCanvas(): void;
  37766. }
  37767. }
  37768. declare module BABYLON {
  37769. interface FreeCameraInputsManager {
  37770. /**
  37771. * Add virtual joystick input support to the input manager.
  37772. * @returns the current input manager
  37773. */
  37774. addVirtualJoystick(): FreeCameraInputsManager;
  37775. }
  37776. /**
  37777. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37779. */
  37780. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37781. /**
  37782. * Defines the camera the input is attached to.
  37783. */
  37784. camera: FreeCamera;
  37785. private _leftjoystick;
  37786. private _rightjoystick;
  37787. /**
  37788. * Gets the left stick of the virtual joystick.
  37789. * @returns The virtual Joystick
  37790. */
  37791. getLeftJoystick(): VirtualJoystick;
  37792. /**
  37793. * Gets the right stick of the virtual joystick.
  37794. * @returns The virtual Joystick
  37795. */
  37796. getRightJoystick(): VirtualJoystick;
  37797. /**
  37798. * Update the current camera state depending on the inputs that have been used this frame.
  37799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37800. */
  37801. checkInputs(): void;
  37802. /**
  37803. * Attach the input controls to a specific dom element to get the input from.
  37804. * @param element Defines the element the controls should be listened from
  37805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37806. */
  37807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37808. /**
  37809. * Detach the current controls from the specified dom element.
  37810. * @param element Defines the element to stop listening the inputs from
  37811. */
  37812. detachControl(element: Nullable<HTMLElement>): void;
  37813. /**
  37814. * Gets the class name of the current intput.
  37815. * @returns the class name
  37816. */
  37817. getClassName(): string;
  37818. /**
  37819. * Get the friendly name associated with the input class.
  37820. * @returns the input friendly name
  37821. */
  37822. getSimpleName(): string;
  37823. }
  37824. }
  37825. declare module BABYLON {
  37826. /**
  37827. * This represents a FPS type of camera controlled by touch.
  37828. * This is like a universal camera minus the Gamepad controls.
  37829. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37830. */
  37831. export class TouchCamera extends FreeCamera {
  37832. /**
  37833. * Defines the touch sensibility for rotation.
  37834. * The higher the faster.
  37835. */
  37836. touchAngularSensibility: number;
  37837. /**
  37838. * Defines the touch sensibility for move.
  37839. * The higher the faster.
  37840. */
  37841. touchMoveSensibility: number;
  37842. /**
  37843. * Instantiates a new touch camera.
  37844. * This represents a FPS type of camera controlled by touch.
  37845. * This is like a universal camera minus the Gamepad controls.
  37846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37847. * @param name Define the name of the camera in the scene
  37848. * @param position Define the start position of the camera in the scene
  37849. * @param scene Define the scene the camera belongs to
  37850. */
  37851. constructor(name: string, position: Vector3, scene: Scene);
  37852. /**
  37853. * Gets the current object class name.
  37854. * @return the class name
  37855. */
  37856. getClassName(): string;
  37857. /** @hidden */
  37858. _setupInputs(): void;
  37859. }
  37860. }
  37861. declare module BABYLON {
  37862. /**
  37863. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37864. * being tilted forward or back and left or right.
  37865. */
  37866. export class DeviceOrientationCamera extends FreeCamera {
  37867. private _initialQuaternion;
  37868. private _quaternionCache;
  37869. private _tmpDragQuaternion;
  37870. /**
  37871. * Creates a new device orientation camera
  37872. * @param name The name of the camera
  37873. * @param position The start position camera
  37874. * @param scene The scene the camera belongs to
  37875. */
  37876. constructor(name: string, position: Vector3, scene: Scene);
  37877. /**
  37878. * @hidden
  37879. * Disabled pointer input on first orientation sensor update (Default: true)
  37880. */
  37881. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37882. private _dragFactor;
  37883. /**
  37884. * Enabled turning on the y axis when the orientation sensor is active
  37885. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37886. */
  37887. enableHorizontalDragging(dragFactor?: number): void;
  37888. /**
  37889. * Gets the current instance class name ("DeviceOrientationCamera").
  37890. * This helps avoiding instanceof at run time.
  37891. * @returns the class name
  37892. */
  37893. getClassName(): string;
  37894. /**
  37895. * @hidden
  37896. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37897. */
  37898. _checkInputs(): void;
  37899. /**
  37900. * Reset the camera to its default orientation on the specified axis only.
  37901. * @param axis The axis to reset
  37902. */
  37903. resetToCurrentRotation(axis?: Axis): void;
  37904. }
  37905. }
  37906. declare module BABYLON {
  37907. /**
  37908. * Defines supported buttons for XBox360 compatible gamepads
  37909. */
  37910. export enum Xbox360Button {
  37911. /** A */
  37912. A = 0,
  37913. /** B */
  37914. B = 1,
  37915. /** X */
  37916. X = 2,
  37917. /** Y */
  37918. Y = 3,
  37919. /** Start */
  37920. Start = 4,
  37921. /** Back */
  37922. Back = 5,
  37923. /** Left button */
  37924. LB = 6,
  37925. /** Right button */
  37926. RB = 7,
  37927. /** Left stick */
  37928. LeftStick = 8,
  37929. /** Right stick */
  37930. RightStick = 9
  37931. }
  37932. /** Defines values for XBox360 DPad */
  37933. export enum Xbox360Dpad {
  37934. /** Up */
  37935. Up = 0,
  37936. /** Down */
  37937. Down = 1,
  37938. /** Left */
  37939. Left = 2,
  37940. /** Right */
  37941. Right = 3
  37942. }
  37943. /**
  37944. * Defines a XBox360 gamepad
  37945. */
  37946. export class Xbox360Pad extends Gamepad {
  37947. private _leftTrigger;
  37948. private _rightTrigger;
  37949. private _onlefttriggerchanged;
  37950. private _onrighttriggerchanged;
  37951. private _onbuttondown;
  37952. private _onbuttonup;
  37953. private _ondpaddown;
  37954. private _ondpadup;
  37955. /** Observable raised when a button is pressed */
  37956. onButtonDownObservable: Observable<Xbox360Button>;
  37957. /** Observable raised when a button is released */
  37958. onButtonUpObservable: Observable<Xbox360Button>;
  37959. /** Observable raised when a pad is pressed */
  37960. onPadDownObservable: Observable<Xbox360Dpad>;
  37961. /** Observable raised when a pad is released */
  37962. onPadUpObservable: Observable<Xbox360Dpad>;
  37963. private _buttonA;
  37964. private _buttonB;
  37965. private _buttonX;
  37966. private _buttonY;
  37967. private _buttonBack;
  37968. private _buttonStart;
  37969. private _buttonLB;
  37970. private _buttonRB;
  37971. private _buttonLeftStick;
  37972. private _buttonRightStick;
  37973. private _dPadUp;
  37974. private _dPadDown;
  37975. private _dPadLeft;
  37976. private _dPadRight;
  37977. private _isXboxOnePad;
  37978. /**
  37979. * Creates a new XBox360 gamepad object
  37980. * @param id defines the id of this gamepad
  37981. * @param index defines its index
  37982. * @param gamepad defines the internal HTML gamepad object
  37983. * @param xboxOne defines if it is a XBox One gamepad
  37984. */
  37985. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37986. /**
  37987. * Defines the callback to call when left trigger is pressed
  37988. * @param callback defines the callback to use
  37989. */
  37990. onlefttriggerchanged(callback: (value: number) => void): void;
  37991. /**
  37992. * Defines the callback to call when right trigger is pressed
  37993. * @param callback defines the callback to use
  37994. */
  37995. onrighttriggerchanged(callback: (value: number) => void): void;
  37996. /**
  37997. * Gets the left trigger value
  37998. */
  37999. /**
  38000. * Sets the left trigger value
  38001. */
  38002. leftTrigger: number;
  38003. /**
  38004. * Gets the right trigger value
  38005. */
  38006. /**
  38007. * Sets the right trigger value
  38008. */
  38009. rightTrigger: number;
  38010. /**
  38011. * Defines the callback to call when a button is pressed
  38012. * @param callback defines the callback to use
  38013. */
  38014. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38015. /**
  38016. * Defines the callback to call when a button is released
  38017. * @param callback defines the callback to use
  38018. */
  38019. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38020. /**
  38021. * Defines the callback to call when a pad is pressed
  38022. * @param callback defines the callback to use
  38023. */
  38024. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38025. /**
  38026. * Defines the callback to call when a pad is released
  38027. * @param callback defines the callback to use
  38028. */
  38029. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38030. private _setButtonValue;
  38031. private _setDPadValue;
  38032. /**
  38033. * Gets the value of the `A` button
  38034. */
  38035. /**
  38036. * Sets the value of the `A` button
  38037. */
  38038. buttonA: number;
  38039. /**
  38040. * Gets the value of the `B` button
  38041. */
  38042. /**
  38043. * Sets the value of the `B` button
  38044. */
  38045. buttonB: number;
  38046. /**
  38047. * Gets the value of the `X` button
  38048. */
  38049. /**
  38050. * Sets the value of the `X` button
  38051. */
  38052. buttonX: number;
  38053. /**
  38054. * Gets the value of the `Y` button
  38055. */
  38056. /**
  38057. * Sets the value of the `Y` button
  38058. */
  38059. buttonY: number;
  38060. /**
  38061. * Gets the value of the `Start` button
  38062. */
  38063. /**
  38064. * Sets the value of the `Start` button
  38065. */
  38066. buttonStart: number;
  38067. /**
  38068. * Gets the value of the `Back` button
  38069. */
  38070. /**
  38071. * Sets the value of the `Back` button
  38072. */
  38073. buttonBack: number;
  38074. /**
  38075. * Gets the value of the `Left` button
  38076. */
  38077. /**
  38078. * Sets the value of the `Left` button
  38079. */
  38080. buttonLB: number;
  38081. /**
  38082. * Gets the value of the `Right` button
  38083. */
  38084. /**
  38085. * Sets the value of the `Right` button
  38086. */
  38087. buttonRB: number;
  38088. /**
  38089. * Gets the value of the Left joystick
  38090. */
  38091. /**
  38092. * Sets the value of the Left joystick
  38093. */
  38094. buttonLeftStick: number;
  38095. /**
  38096. * Gets the value of the Right joystick
  38097. */
  38098. /**
  38099. * Sets the value of the Right joystick
  38100. */
  38101. buttonRightStick: number;
  38102. /**
  38103. * Gets the value of D-pad up
  38104. */
  38105. /**
  38106. * Sets the value of D-pad up
  38107. */
  38108. dPadUp: number;
  38109. /**
  38110. * Gets the value of D-pad down
  38111. */
  38112. /**
  38113. * Sets the value of D-pad down
  38114. */
  38115. dPadDown: number;
  38116. /**
  38117. * Gets the value of D-pad left
  38118. */
  38119. /**
  38120. * Sets the value of D-pad left
  38121. */
  38122. dPadLeft: number;
  38123. /**
  38124. * Gets the value of D-pad right
  38125. */
  38126. /**
  38127. * Sets the value of D-pad right
  38128. */
  38129. dPadRight: number;
  38130. /**
  38131. * Force the gamepad to synchronize with device values
  38132. */
  38133. update(): void;
  38134. /**
  38135. * Disposes the gamepad
  38136. */
  38137. dispose(): void;
  38138. }
  38139. }
  38140. declare module BABYLON {
  38141. /**
  38142. * Manager for handling gamepads
  38143. */
  38144. export class GamepadManager {
  38145. private _scene?;
  38146. private _babylonGamepads;
  38147. private _oneGamepadConnected;
  38148. /** @hidden */
  38149. _isMonitoring: boolean;
  38150. private _gamepadEventSupported;
  38151. private _gamepadSupport;
  38152. /**
  38153. * observable to be triggered when the gamepad controller has been connected
  38154. */
  38155. onGamepadConnectedObservable: Observable<Gamepad>;
  38156. /**
  38157. * observable to be triggered when the gamepad controller has been disconnected
  38158. */
  38159. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38160. private _onGamepadConnectedEvent;
  38161. private _onGamepadDisconnectedEvent;
  38162. /**
  38163. * Initializes the gamepad manager
  38164. * @param _scene BabylonJS scene
  38165. */
  38166. constructor(_scene?: Scene | undefined);
  38167. /**
  38168. * The gamepads in the game pad manager
  38169. */
  38170. readonly gamepads: Gamepad[];
  38171. /**
  38172. * Get the gamepad controllers based on type
  38173. * @param type The type of gamepad controller
  38174. * @returns Nullable gamepad
  38175. */
  38176. getGamepadByType(type?: number): Nullable<Gamepad>;
  38177. /**
  38178. * Disposes the gamepad manager
  38179. */
  38180. dispose(): void;
  38181. private _addNewGamepad;
  38182. private _startMonitoringGamepads;
  38183. private _stopMonitoringGamepads;
  38184. /** @hidden */
  38185. _checkGamepadsStatus(): void;
  38186. private _updateGamepadObjects;
  38187. }
  38188. }
  38189. declare module BABYLON {
  38190. interface Scene {
  38191. /** @hidden */
  38192. _gamepadManager: Nullable<GamepadManager>;
  38193. /**
  38194. * Gets the gamepad manager associated with the scene
  38195. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38196. */
  38197. gamepadManager: GamepadManager;
  38198. }
  38199. /**
  38200. * Interface representing a free camera inputs manager
  38201. */
  38202. interface FreeCameraInputsManager {
  38203. /**
  38204. * Adds gamepad input support to the FreeCameraInputsManager.
  38205. * @returns the FreeCameraInputsManager
  38206. */
  38207. addGamepad(): FreeCameraInputsManager;
  38208. }
  38209. /**
  38210. * Interface representing an arc rotate camera inputs manager
  38211. */
  38212. interface ArcRotateCameraInputsManager {
  38213. /**
  38214. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38215. * @returns the camera inputs manager
  38216. */
  38217. addGamepad(): ArcRotateCameraInputsManager;
  38218. }
  38219. /**
  38220. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38221. */
  38222. export class GamepadSystemSceneComponent implements ISceneComponent {
  38223. /**
  38224. * The component name helpfull to identify the component in the list of scene components.
  38225. */
  38226. readonly name: string;
  38227. /**
  38228. * The scene the component belongs to.
  38229. */
  38230. scene: Scene;
  38231. /**
  38232. * Creates a new instance of the component for the given scene
  38233. * @param scene Defines the scene to register the component in
  38234. */
  38235. constructor(scene: Scene);
  38236. /**
  38237. * Registers the component in a given scene
  38238. */
  38239. register(): void;
  38240. /**
  38241. * Rebuilds the elements related to this component in case of
  38242. * context lost for instance.
  38243. */
  38244. rebuild(): void;
  38245. /**
  38246. * Disposes the component and the associated ressources
  38247. */
  38248. dispose(): void;
  38249. private _beforeCameraUpdate;
  38250. }
  38251. }
  38252. declare module BABYLON {
  38253. /**
  38254. * 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,
  38255. * which still works and will still be found in many Playgrounds.
  38256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38257. */
  38258. export class UniversalCamera extends TouchCamera {
  38259. /**
  38260. * Defines the gamepad rotation sensiblity.
  38261. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38262. */
  38263. gamepadAngularSensibility: number;
  38264. /**
  38265. * Defines the gamepad move sensiblity.
  38266. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38267. */
  38268. gamepadMoveSensibility: number;
  38269. /**
  38270. * 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,
  38271. * which still works and will still be found in many Playgrounds.
  38272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38273. * @param name Define the name of the camera in the scene
  38274. * @param position Define the start position of the camera in the scene
  38275. * @param scene Define the scene the camera belongs to
  38276. */
  38277. constructor(name: string, position: Vector3, scene: Scene);
  38278. /**
  38279. * Gets the current object class name.
  38280. * @return the class name
  38281. */
  38282. getClassName(): string;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. /**
  38287. * This represents a FPS type of camera. This is only here for back compat purpose.
  38288. * Please use the UniversalCamera instead as both are identical.
  38289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38290. */
  38291. export class GamepadCamera extends UniversalCamera {
  38292. /**
  38293. * Instantiates a new Gamepad Camera
  38294. * This represents a FPS type of camera. This is only here for back compat purpose.
  38295. * Please use the UniversalCamera instead as both are identical.
  38296. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38297. * @param name Define the name of the camera in the scene
  38298. * @param position Define the start position of the camera in the scene
  38299. * @param scene Define the scene the camera belongs to
  38300. */
  38301. constructor(name: string, position: Vector3, scene: Scene);
  38302. /**
  38303. * Gets the current object class name.
  38304. * @return the class name
  38305. */
  38306. getClassName(): string;
  38307. }
  38308. }
  38309. declare module BABYLON {
  38310. /** @hidden */
  38311. export var passPixelShader: {
  38312. name: string;
  38313. shader: string;
  38314. };
  38315. }
  38316. declare module BABYLON {
  38317. /** @hidden */
  38318. export var passCubePixelShader: {
  38319. name: string;
  38320. shader: string;
  38321. };
  38322. }
  38323. declare module BABYLON {
  38324. /**
  38325. * PassPostProcess which produces an output the same as it's input
  38326. */
  38327. export class PassPostProcess extends PostProcess {
  38328. /**
  38329. * Creates the PassPostProcess
  38330. * @param name The name of the effect.
  38331. * @param options The required width/height ratio to downsize to before computing the render pass.
  38332. * @param camera The camera to apply the render pass to.
  38333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38334. * @param engine The engine which the post process will be applied. (default: current engine)
  38335. * @param reusable If the post process can be reused on the same frame. (default: false)
  38336. * @param textureType The type of texture to be used when performing the post processing.
  38337. * @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)
  38338. */
  38339. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38340. }
  38341. /**
  38342. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38343. */
  38344. export class PassCubePostProcess extends PostProcess {
  38345. private _face;
  38346. /**
  38347. * Gets or sets the cube face to display.
  38348. * * 0 is +X
  38349. * * 1 is -X
  38350. * * 2 is +Y
  38351. * * 3 is -Y
  38352. * * 4 is +Z
  38353. * * 5 is -Z
  38354. */
  38355. face: number;
  38356. /**
  38357. * Creates the PassCubePostProcess
  38358. * @param name The name of the effect.
  38359. * @param options The required width/height ratio to downsize to before computing the render pass.
  38360. * @param camera The camera to apply the render pass to.
  38361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38362. * @param engine The engine which the post process will be applied. (default: current engine)
  38363. * @param reusable If the post process can be reused on the same frame. (default: false)
  38364. * @param textureType The type of texture to be used when performing the post processing.
  38365. * @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)
  38366. */
  38367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38368. }
  38369. }
  38370. declare module BABYLON {
  38371. /** @hidden */
  38372. export var anaglyphPixelShader: {
  38373. name: string;
  38374. shader: string;
  38375. };
  38376. }
  38377. declare module BABYLON {
  38378. /**
  38379. * Postprocess used to generate anaglyphic rendering
  38380. */
  38381. export class AnaglyphPostProcess extends PostProcess {
  38382. private _passedProcess;
  38383. /**
  38384. * Creates a new AnaglyphPostProcess
  38385. * @param name defines postprocess name
  38386. * @param options defines creation options or target ratio scale
  38387. * @param rigCameras defines cameras using this postprocess
  38388. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38389. * @param engine defines hosting engine
  38390. * @param reusable defines if the postprocess will be reused multiple times per frame
  38391. */
  38392. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38393. }
  38394. }
  38395. declare module BABYLON {
  38396. /**
  38397. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38399. */
  38400. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38401. /**
  38402. * Creates a new AnaglyphArcRotateCamera
  38403. * @param name defines camera name
  38404. * @param alpha defines alpha angle (in radians)
  38405. * @param beta defines beta angle (in radians)
  38406. * @param radius defines radius
  38407. * @param target defines camera target
  38408. * @param interaxialDistance defines distance between each color axis
  38409. * @param scene defines the hosting scene
  38410. */
  38411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38412. /**
  38413. * Gets camera class name
  38414. * @returns AnaglyphArcRotateCamera
  38415. */
  38416. getClassName(): string;
  38417. }
  38418. }
  38419. declare module BABYLON {
  38420. /**
  38421. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38422. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38423. */
  38424. export class AnaglyphFreeCamera extends FreeCamera {
  38425. /**
  38426. * Creates a new AnaglyphFreeCamera
  38427. * @param name defines camera name
  38428. * @param position defines initial position
  38429. * @param interaxialDistance defines distance between each color axis
  38430. * @param scene defines the hosting scene
  38431. */
  38432. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38433. /**
  38434. * Gets camera class name
  38435. * @returns AnaglyphFreeCamera
  38436. */
  38437. getClassName(): string;
  38438. }
  38439. }
  38440. declare module BABYLON {
  38441. /**
  38442. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38443. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38444. */
  38445. export class AnaglyphGamepadCamera extends GamepadCamera {
  38446. /**
  38447. * Creates a new AnaglyphGamepadCamera
  38448. * @param name defines camera name
  38449. * @param position defines initial position
  38450. * @param interaxialDistance defines distance between each color axis
  38451. * @param scene defines the hosting scene
  38452. */
  38453. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38454. /**
  38455. * Gets camera class name
  38456. * @returns AnaglyphGamepadCamera
  38457. */
  38458. getClassName(): string;
  38459. }
  38460. }
  38461. declare module BABYLON {
  38462. /**
  38463. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38464. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38465. */
  38466. export class AnaglyphUniversalCamera extends UniversalCamera {
  38467. /**
  38468. * Creates a new AnaglyphUniversalCamera
  38469. * @param name defines camera name
  38470. * @param position defines initial position
  38471. * @param interaxialDistance defines distance between each color axis
  38472. * @param scene defines the hosting scene
  38473. */
  38474. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38475. /**
  38476. * Gets camera class name
  38477. * @returns AnaglyphUniversalCamera
  38478. */
  38479. getClassName(): string;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. /** @hidden */
  38484. export var stereoscopicInterlacePixelShader: {
  38485. name: string;
  38486. shader: string;
  38487. };
  38488. }
  38489. declare module BABYLON {
  38490. /**
  38491. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38492. */
  38493. export class StereoscopicInterlacePostProcess extends PostProcess {
  38494. private _stepSize;
  38495. private _passedProcess;
  38496. /**
  38497. * Initializes a StereoscopicInterlacePostProcess
  38498. * @param name The name of the effect.
  38499. * @param rigCameras The rig cameras to be appled to the post process
  38500. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38502. * @param engine The engine which the post process will be applied. (default: current engine)
  38503. * @param reusable If the post process can be reused on the same frame. (default: false)
  38504. */
  38505. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38506. }
  38507. }
  38508. declare module BABYLON {
  38509. /**
  38510. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38511. * @see http://doc.babylonjs.com/features/cameras
  38512. */
  38513. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38514. /**
  38515. * Creates a new StereoscopicArcRotateCamera
  38516. * @param name defines camera name
  38517. * @param alpha defines alpha angle (in radians)
  38518. * @param beta defines beta angle (in radians)
  38519. * @param radius defines radius
  38520. * @param target defines camera target
  38521. * @param interaxialDistance defines distance between each color axis
  38522. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38523. * @param scene defines the hosting scene
  38524. */
  38525. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38526. /**
  38527. * Gets camera class name
  38528. * @returns StereoscopicArcRotateCamera
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /**
  38535. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38536. * @see http://doc.babylonjs.com/features/cameras
  38537. */
  38538. export class StereoscopicFreeCamera extends FreeCamera {
  38539. /**
  38540. * Creates a new StereoscopicFreeCamera
  38541. * @param name defines camera name
  38542. * @param position defines initial position
  38543. * @param interaxialDistance defines distance between each color axis
  38544. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38545. * @param scene defines the hosting scene
  38546. */
  38547. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38548. /**
  38549. * Gets camera class name
  38550. * @returns StereoscopicFreeCamera
  38551. */
  38552. getClassName(): string;
  38553. }
  38554. }
  38555. declare module BABYLON {
  38556. /**
  38557. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38558. * @see http://doc.babylonjs.com/features/cameras
  38559. */
  38560. export class StereoscopicGamepadCamera extends GamepadCamera {
  38561. /**
  38562. * Creates a new StereoscopicGamepadCamera
  38563. * @param name defines camera name
  38564. * @param position defines initial position
  38565. * @param interaxialDistance defines distance between each color axis
  38566. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38567. * @param scene defines the hosting scene
  38568. */
  38569. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38570. /**
  38571. * Gets camera class name
  38572. * @returns StereoscopicGamepadCamera
  38573. */
  38574. getClassName(): string;
  38575. }
  38576. }
  38577. declare module BABYLON {
  38578. /**
  38579. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38580. * @see http://doc.babylonjs.com/features/cameras
  38581. */
  38582. export class StereoscopicUniversalCamera extends UniversalCamera {
  38583. /**
  38584. * Creates a new StereoscopicUniversalCamera
  38585. * @param name defines camera name
  38586. * @param position defines initial position
  38587. * @param interaxialDistance defines distance between each color axis
  38588. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38589. * @param scene defines the hosting scene
  38590. */
  38591. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38592. /**
  38593. * Gets camera class name
  38594. * @returns StereoscopicUniversalCamera
  38595. */
  38596. getClassName(): string;
  38597. }
  38598. }
  38599. declare module BABYLON {
  38600. /**
  38601. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38602. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38603. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38604. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38605. */
  38606. export class VirtualJoysticksCamera extends FreeCamera {
  38607. /**
  38608. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38609. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38610. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38611. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38612. * @param name Define the name of the camera in the scene
  38613. * @param position Define the start position of the camera in the scene
  38614. * @param scene Define the scene the camera belongs to
  38615. */
  38616. constructor(name: string, position: Vector3, scene: Scene);
  38617. /**
  38618. * Gets the current object class name.
  38619. * @return the class name
  38620. */
  38621. getClassName(): string;
  38622. }
  38623. }
  38624. declare module BABYLON {
  38625. /**
  38626. * This represents all the required metrics to create a VR camera.
  38627. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38628. */
  38629. export class VRCameraMetrics {
  38630. /**
  38631. * Define the horizontal resolution off the screen.
  38632. */
  38633. hResolution: number;
  38634. /**
  38635. * Define the vertical resolution off the screen.
  38636. */
  38637. vResolution: number;
  38638. /**
  38639. * Define the horizontal screen size.
  38640. */
  38641. hScreenSize: number;
  38642. /**
  38643. * Define the vertical screen size.
  38644. */
  38645. vScreenSize: number;
  38646. /**
  38647. * Define the vertical screen center position.
  38648. */
  38649. vScreenCenter: number;
  38650. /**
  38651. * Define the distance of the eyes to the screen.
  38652. */
  38653. eyeToScreenDistance: number;
  38654. /**
  38655. * Define the distance between both lenses
  38656. */
  38657. lensSeparationDistance: number;
  38658. /**
  38659. * Define the distance between both viewer's eyes.
  38660. */
  38661. interpupillaryDistance: number;
  38662. /**
  38663. * Define the distortion factor of the VR postprocess.
  38664. * Please, touch with care.
  38665. */
  38666. distortionK: number[];
  38667. /**
  38668. * Define the chromatic aberration correction factors for the VR post process.
  38669. */
  38670. chromaAbCorrection: number[];
  38671. /**
  38672. * Define the scale factor of the post process.
  38673. * The smaller the better but the slower.
  38674. */
  38675. postProcessScaleFactor: number;
  38676. /**
  38677. * Define an offset for the lens center.
  38678. */
  38679. lensCenterOffset: number;
  38680. /**
  38681. * Define if the current vr camera should compensate the distortion of the lense or not.
  38682. */
  38683. compensateDistortion: boolean;
  38684. /**
  38685. * Defines if multiview should be enabled when rendering (Default: false)
  38686. */
  38687. multiviewEnabled: boolean;
  38688. /**
  38689. * Gets the rendering aspect ratio based on the provided resolutions.
  38690. */
  38691. readonly aspectRatio: number;
  38692. /**
  38693. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38694. */
  38695. readonly aspectRatioFov: number;
  38696. /**
  38697. * @hidden
  38698. */
  38699. readonly leftHMatrix: Matrix;
  38700. /**
  38701. * @hidden
  38702. */
  38703. readonly rightHMatrix: Matrix;
  38704. /**
  38705. * @hidden
  38706. */
  38707. readonly leftPreViewMatrix: Matrix;
  38708. /**
  38709. * @hidden
  38710. */
  38711. readonly rightPreViewMatrix: Matrix;
  38712. /**
  38713. * Get the default VRMetrics based on the most generic setup.
  38714. * @returns the default vr metrics
  38715. */
  38716. static GetDefault(): VRCameraMetrics;
  38717. }
  38718. }
  38719. declare module BABYLON {
  38720. /** @hidden */
  38721. export var vrDistortionCorrectionPixelShader: {
  38722. name: string;
  38723. shader: string;
  38724. };
  38725. }
  38726. declare module BABYLON {
  38727. /**
  38728. * VRDistortionCorrectionPostProcess used for mobile VR
  38729. */
  38730. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38731. private _isRightEye;
  38732. private _distortionFactors;
  38733. private _postProcessScaleFactor;
  38734. private _lensCenterOffset;
  38735. private _scaleIn;
  38736. private _scaleFactor;
  38737. private _lensCenter;
  38738. /**
  38739. * Initializes the VRDistortionCorrectionPostProcess
  38740. * @param name The name of the effect.
  38741. * @param camera The camera to apply the render pass to.
  38742. * @param isRightEye If this is for the right eye distortion
  38743. * @param vrMetrics All the required metrics for the VR camera
  38744. */
  38745. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38746. }
  38747. }
  38748. declare module BABYLON {
  38749. /**
  38750. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38752. */
  38753. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38754. /**
  38755. * Creates a new VRDeviceOrientationArcRotateCamera
  38756. * @param name defines camera name
  38757. * @param alpha defines the camera rotation along the logitudinal axis
  38758. * @param beta defines the camera rotation along the latitudinal axis
  38759. * @param radius defines the camera distance from its target
  38760. * @param target defines the camera target
  38761. * @param scene defines the scene the camera belongs to
  38762. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38763. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38764. */
  38765. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38766. /**
  38767. * Gets camera class name
  38768. * @returns VRDeviceOrientationArcRotateCamera
  38769. */
  38770. getClassName(): string;
  38771. }
  38772. }
  38773. declare module BABYLON {
  38774. /**
  38775. * Camera used to simulate VR rendering (based on FreeCamera)
  38776. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38777. */
  38778. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38779. /**
  38780. * Creates a new VRDeviceOrientationFreeCamera
  38781. * @param name defines camera name
  38782. * @param position defines the start position of the camera
  38783. * @param scene defines the scene the camera belongs to
  38784. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38785. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38786. */
  38787. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38788. /**
  38789. * Gets camera class name
  38790. * @returns VRDeviceOrientationFreeCamera
  38791. */
  38792. getClassName(): string;
  38793. }
  38794. }
  38795. declare module BABYLON {
  38796. /**
  38797. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38798. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38799. */
  38800. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38801. /**
  38802. * Creates a new VRDeviceOrientationGamepadCamera
  38803. * @param name defines camera name
  38804. * @param position defines the start position of the camera
  38805. * @param scene defines the scene the camera belongs to
  38806. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38807. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38808. */
  38809. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38810. /**
  38811. * Gets camera class name
  38812. * @returns VRDeviceOrientationGamepadCamera
  38813. */
  38814. getClassName(): string;
  38815. }
  38816. }
  38817. declare module BABYLON {
  38818. /**
  38819. * Base class of materials working in push mode in babylon JS
  38820. * @hidden
  38821. */
  38822. export class PushMaterial extends Material {
  38823. protected _activeEffect: Effect;
  38824. protected _normalMatrix: Matrix;
  38825. /**
  38826. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38827. * This means that the material can keep using a previous shader while a new one is being compiled.
  38828. * This is mostly used when shader parallel compilation is supported (true by default)
  38829. */
  38830. allowShaderHotSwapping: boolean;
  38831. constructor(name: string, scene: Scene);
  38832. getEffect(): Effect;
  38833. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38834. /**
  38835. * Binds the given world matrix to the active effect
  38836. *
  38837. * @param world the matrix to bind
  38838. */
  38839. bindOnlyWorldMatrix(world: Matrix): void;
  38840. /**
  38841. * Binds the given normal matrix to the active effect
  38842. *
  38843. * @param normalMatrix the matrix to bind
  38844. */
  38845. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38846. bind(world: Matrix, mesh?: Mesh): void;
  38847. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38848. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38849. }
  38850. }
  38851. declare module BABYLON {
  38852. /**
  38853. * This groups all the flags used to control the materials channel.
  38854. */
  38855. export class MaterialFlags {
  38856. private static _DiffuseTextureEnabled;
  38857. /**
  38858. * Are diffuse textures enabled in the application.
  38859. */
  38860. static DiffuseTextureEnabled: boolean;
  38861. private static _AmbientTextureEnabled;
  38862. /**
  38863. * Are ambient textures enabled in the application.
  38864. */
  38865. static AmbientTextureEnabled: boolean;
  38866. private static _OpacityTextureEnabled;
  38867. /**
  38868. * Are opacity textures enabled in the application.
  38869. */
  38870. static OpacityTextureEnabled: boolean;
  38871. private static _ReflectionTextureEnabled;
  38872. /**
  38873. * Are reflection textures enabled in the application.
  38874. */
  38875. static ReflectionTextureEnabled: boolean;
  38876. private static _EmissiveTextureEnabled;
  38877. /**
  38878. * Are emissive textures enabled in the application.
  38879. */
  38880. static EmissiveTextureEnabled: boolean;
  38881. private static _SpecularTextureEnabled;
  38882. /**
  38883. * Are specular textures enabled in the application.
  38884. */
  38885. static SpecularTextureEnabled: boolean;
  38886. private static _BumpTextureEnabled;
  38887. /**
  38888. * Are bump textures enabled in the application.
  38889. */
  38890. static BumpTextureEnabled: boolean;
  38891. private static _LightmapTextureEnabled;
  38892. /**
  38893. * Are lightmap textures enabled in the application.
  38894. */
  38895. static LightmapTextureEnabled: boolean;
  38896. private static _RefractionTextureEnabled;
  38897. /**
  38898. * Are refraction textures enabled in the application.
  38899. */
  38900. static RefractionTextureEnabled: boolean;
  38901. private static _ColorGradingTextureEnabled;
  38902. /**
  38903. * Are color grading textures enabled in the application.
  38904. */
  38905. static ColorGradingTextureEnabled: boolean;
  38906. private static _FresnelEnabled;
  38907. /**
  38908. * Are fresnels enabled in the application.
  38909. */
  38910. static FresnelEnabled: boolean;
  38911. private static _ClearCoatTextureEnabled;
  38912. /**
  38913. * Are clear coat textures enabled in the application.
  38914. */
  38915. static ClearCoatTextureEnabled: boolean;
  38916. private static _ClearCoatBumpTextureEnabled;
  38917. /**
  38918. * Are clear coat bump textures enabled in the application.
  38919. */
  38920. static ClearCoatBumpTextureEnabled: boolean;
  38921. private static _ClearCoatTintTextureEnabled;
  38922. /**
  38923. * Are clear coat tint textures enabled in the application.
  38924. */
  38925. static ClearCoatTintTextureEnabled: boolean;
  38926. private static _SheenTextureEnabled;
  38927. /**
  38928. * Are sheen textures enabled in the application.
  38929. */
  38930. static SheenTextureEnabled: boolean;
  38931. private static _AnisotropicTextureEnabled;
  38932. /**
  38933. * Are anisotropic textures enabled in the application.
  38934. */
  38935. static AnisotropicTextureEnabled: boolean;
  38936. private static _ThicknessTextureEnabled;
  38937. /**
  38938. * Are thickness textures enabled in the application.
  38939. */
  38940. static ThicknessTextureEnabled: boolean;
  38941. }
  38942. }
  38943. declare module BABYLON {
  38944. /** @hidden */
  38945. export var defaultFragmentDeclaration: {
  38946. name: string;
  38947. shader: string;
  38948. };
  38949. }
  38950. declare module BABYLON {
  38951. /** @hidden */
  38952. export var defaultUboDeclaration: {
  38953. name: string;
  38954. shader: string;
  38955. };
  38956. }
  38957. declare module BABYLON {
  38958. /** @hidden */
  38959. export var lightFragmentDeclaration: {
  38960. name: string;
  38961. shader: string;
  38962. };
  38963. }
  38964. declare module BABYLON {
  38965. /** @hidden */
  38966. export var lightUboDeclaration: {
  38967. name: string;
  38968. shader: string;
  38969. };
  38970. }
  38971. declare module BABYLON {
  38972. /** @hidden */
  38973. export var lightsFragmentFunctions: {
  38974. name: string;
  38975. shader: string;
  38976. };
  38977. }
  38978. declare module BABYLON {
  38979. /** @hidden */
  38980. export var shadowsFragmentFunctions: {
  38981. name: string;
  38982. shader: string;
  38983. };
  38984. }
  38985. declare module BABYLON {
  38986. /** @hidden */
  38987. export var fresnelFunction: {
  38988. name: string;
  38989. shader: string;
  38990. };
  38991. }
  38992. declare module BABYLON {
  38993. /** @hidden */
  38994. export var reflectionFunction: {
  38995. name: string;
  38996. shader: string;
  38997. };
  38998. }
  38999. declare module BABYLON {
  39000. /** @hidden */
  39001. export var bumpFragmentFunctions: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module BABYLON {
  39007. /** @hidden */
  39008. export var logDepthDeclaration: {
  39009. name: string;
  39010. shader: string;
  39011. };
  39012. }
  39013. declare module BABYLON {
  39014. /** @hidden */
  39015. export var bumpFragment: {
  39016. name: string;
  39017. shader: string;
  39018. };
  39019. }
  39020. declare module BABYLON {
  39021. /** @hidden */
  39022. export var depthPrePass: {
  39023. name: string;
  39024. shader: string;
  39025. };
  39026. }
  39027. declare module BABYLON {
  39028. /** @hidden */
  39029. export var lightFragment: {
  39030. name: string;
  39031. shader: string;
  39032. };
  39033. }
  39034. declare module BABYLON {
  39035. /** @hidden */
  39036. export var logDepthFragment: {
  39037. name: string;
  39038. shader: string;
  39039. };
  39040. }
  39041. declare module BABYLON {
  39042. /** @hidden */
  39043. export var defaultPixelShader: {
  39044. name: string;
  39045. shader: string;
  39046. };
  39047. }
  39048. declare module BABYLON {
  39049. /** @hidden */
  39050. export var defaultVertexDeclaration: {
  39051. name: string;
  39052. shader: string;
  39053. };
  39054. }
  39055. declare module BABYLON {
  39056. /** @hidden */
  39057. export var bumpVertexDeclaration: {
  39058. name: string;
  39059. shader: string;
  39060. };
  39061. }
  39062. declare module BABYLON {
  39063. /** @hidden */
  39064. export var bumpVertex: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module BABYLON {
  39070. /** @hidden */
  39071. export var fogVertex: {
  39072. name: string;
  39073. shader: string;
  39074. };
  39075. }
  39076. declare module BABYLON {
  39077. /** @hidden */
  39078. export var shadowsVertex: {
  39079. name: string;
  39080. shader: string;
  39081. };
  39082. }
  39083. declare module BABYLON {
  39084. /** @hidden */
  39085. export var pointCloudVertex: {
  39086. name: string;
  39087. shader: string;
  39088. };
  39089. }
  39090. declare module BABYLON {
  39091. /** @hidden */
  39092. export var logDepthVertex: {
  39093. name: string;
  39094. shader: string;
  39095. };
  39096. }
  39097. declare module BABYLON {
  39098. /** @hidden */
  39099. export var defaultVertexShader: {
  39100. name: string;
  39101. shader: string;
  39102. };
  39103. }
  39104. declare module BABYLON {
  39105. /** @hidden */
  39106. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39107. MAINUV1: boolean;
  39108. MAINUV2: boolean;
  39109. DIFFUSE: boolean;
  39110. DIFFUSEDIRECTUV: number;
  39111. AMBIENT: boolean;
  39112. AMBIENTDIRECTUV: number;
  39113. OPACITY: boolean;
  39114. OPACITYDIRECTUV: number;
  39115. OPACITYRGB: boolean;
  39116. REFLECTION: boolean;
  39117. EMISSIVE: boolean;
  39118. EMISSIVEDIRECTUV: number;
  39119. SPECULAR: boolean;
  39120. SPECULARDIRECTUV: number;
  39121. BUMP: boolean;
  39122. BUMPDIRECTUV: number;
  39123. PARALLAX: boolean;
  39124. PARALLAXOCCLUSION: boolean;
  39125. SPECULAROVERALPHA: boolean;
  39126. CLIPPLANE: boolean;
  39127. CLIPPLANE2: boolean;
  39128. CLIPPLANE3: boolean;
  39129. CLIPPLANE4: boolean;
  39130. ALPHATEST: boolean;
  39131. DEPTHPREPASS: boolean;
  39132. ALPHAFROMDIFFUSE: boolean;
  39133. POINTSIZE: boolean;
  39134. FOG: boolean;
  39135. SPECULARTERM: boolean;
  39136. DIFFUSEFRESNEL: boolean;
  39137. OPACITYFRESNEL: boolean;
  39138. REFLECTIONFRESNEL: boolean;
  39139. REFRACTIONFRESNEL: boolean;
  39140. EMISSIVEFRESNEL: boolean;
  39141. FRESNEL: boolean;
  39142. NORMAL: boolean;
  39143. UV1: boolean;
  39144. UV2: boolean;
  39145. VERTEXCOLOR: boolean;
  39146. VERTEXALPHA: boolean;
  39147. NUM_BONE_INFLUENCERS: number;
  39148. BonesPerMesh: number;
  39149. BONETEXTURE: boolean;
  39150. INSTANCES: boolean;
  39151. GLOSSINESS: boolean;
  39152. ROUGHNESS: boolean;
  39153. EMISSIVEASILLUMINATION: boolean;
  39154. LINKEMISSIVEWITHDIFFUSE: boolean;
  39155. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39156. LIGHTMAP: boolean;
  39157. LIGHTMAPDIRECTUV: number;
  39158. OBJECTSPACE_NORMALMAP: boolean;
  39159. USELIGHTMAPASSHADOWMAP: boolean;
  39160. REFLECTIONMAP_3D: boolean;
  39161. REFLECTIONMAP_SPHERICAL: boolean;
  39162. REFLECTIONMAP_PLANAR: boolean;
  39163. REFLECTIONMAP_CUBIC: boolean;
  39164. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39165. REFLECTIONMAP_PROJECTION: boolean;
  39166. REFLECTIONMAP_SKYBOX: boolean;
  39167. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39168. REFLECTIONMAP_EXPLICIT: boolean;
  39169. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39170. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39171. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39172. INVERTCUBICMAP: boolean;
  39173. LOGARITHMICDEPTH: boolean;
  39174. REFRACTION: boolean;
  39175. REFRACTIONMAP_3D: boolean;
  39176. REFLECTIONOVERALPHA: boolean;
  39177. TWOSIDEDLIGHTING: boolean;
  39178. SHADOWFLOAT: boolean;
  39179. MORPHTARGETS: boolean;
  39180. MORPHTARGETS_NORMAL: boolean;
  39181. MORPHTARGETS_TANGENT: boolean;
  39182. MORPHTARGETS_UV: boolean;
  39183. NUM_MORPH_INFLUENCERS: number;
  39184. NONUNIFORMSCALING: boolean;
  39185. PREMULTIPLYALPHA: boolean;
  39186. IMAGEPROCESSING: boolean;
  39187. VIGNETTE: boolean;
  39188. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39189. VIGNETTEBLENDMODEOPAQUE: boolean;
  39190. TONEMAPPING: boolean;
  39191. TONEMAPPING_ACES: boolean;
  39192. CONTRAST: boolean;
  39193. COLORCURVES: boolean;
  39194. COLORGRADING: boolean;
  39195. COLORGRADING3D: boolean;
  39196. SAMPLER3DGREENDEPTH: boolean;
  39197. SAMPLER3DBGRMAP: boolean;
  39198. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39199. MULTIVIEW: boolean;
  39200. /**
  39201. * If the reflection texture on this material is in linear color space
  39202. * @hidden
  39203. */
  39204. IS_REFLECTION_LINEAR: boolean;
  39205. /**
  39206. * If the refraction texture on this material is in linear color space
  39207. * @hidden
  39208. */
  39209. IS_REFRACTION_LINEAR: boolean;
  39210. EXPOSURE: boolean;
  39211. constructor();
  39212. setReflectionMode(modeToEnable: string): void;
  39213. }
  39214. /**
  39215. * This is the default material used in Babylon. It is the best trade off between quality
  39216. * and performances.
  39217. * @see http://doc.babylonjs.com/babylon101/materials
  39218. */
  39219. export class StandardMaterial extends PushMaterial {
  39220. private _diffuseTexture;
  39221. /**
  39222. * The basic texture of the material as viewed under a light.
  39223. */
  39224. diffuseTexture: Nullable<BaseTexture>;
  39225. private _ambientTexture;
  39226. /**
  39227. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39228. */
  39229. ambientTexture: Nullable<BaseTexture>;
  39230. private _opacityTexture;
  39231. /**
  39232. * Define the transparency of the material from a texture.
  39233. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39234. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39235. */
  39236. opacityTexture: Nullable<BaseTexture>;
  39237. private _reflectionTexture;
  39238. /**
  39239. * Define the texture used to display the reflection.
  39240. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39241. */
  39242. reflectionTexture: Nullable<BaseTexture>;
  39243. private _emissiveTexture;
  39244. /**
  39245. * Define texture of the material as if self lit.
  39246. * This will be mixed in the final result even in the absence of light.
  39247. */
  39248. emissiveTexture: Nullable<BaseTexture>;
  39249. private _specularTexture;
  39250. /**
  39251. * Define how the color and intensity of the highlight given by the light in the material.
  39252. */
  39253. specularTexture: Nullable<BaseTexture>;
  39254. private _bumpTexture;
  39255. /**
  39256. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39257. * 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.
  39258. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39259. */
  39260. bumpTexture: Nullable<BaseTexture>;
  39261. private _lightmapTexture;
  39262. /**
  39263. * Complex lighting can be computationally expensive to compute at runtime.
  39264. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39265. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39266. */
  39267. lightmapTexture: Nullable<BaseTexture>;
  39268. private _refractionTexture;
  39269. /**
  39270. * Define the texture used to display the refraction.
  39271. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39272. */
  39273. refractionTexture: Nullable<BaseTexture>;
  39274. /**
  39275. * The color of the material lit by the environmental background lighting.
  39276. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39277. */
  39278. ambientColor: Color3;
  39279. /**
  39280. * The basic color of the material as viewed under a light.
  39281. */
  39282. diffuseColor: Color3;
  39283. /**
  39284. * Define how the color and intensity of the highlight given by the light in the material.
  39285. */
  39286. specularColor: Color3;
  39287. /**
  39288. * Define the color of the material as if self lit.
  39289. * This will be mixed in the final result even in the absence of light.
  39290. */
  39291. emissiveColor: Color3;
  39292. /**
  39293. * Defines how sharp are the highlights in the material.
  39294. * The bigger the value the sharper giving a more glossy feeling to the result.
  39295. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39296. */
  39297. specularPower: number;
  39298. private _useAlphaFromDiffuseTexture;
  39299. /**
  39300. * Does the transparency come from the diffuse texture alpha channel.
  39301. */
  39302. useAlphaFromDiffuseTexture: boolean;
  39303. private _useEmissiveAsIllumination;
  39304. /**
  39305. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39306. */
  39307. useEmissiveAsIllumination: boolean;
  39308. private _linkEmissiveWithDiffuse;
  39309. /**
  39310. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39311. * the emissive level when the final color is close to one.
  39312. */
  39313. linkEmissiveWithDiffuse: boolean;
  39314. private _useSpecularOverAlpha;
  39315. /**
  39316. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39317. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39318. */
  39319. useSpecularOverAlpha: boolean;
  39320. private _useReflectionOverAlpha;
  39321. /**
  39322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39324. */
  39325. useReflectionOverAlpha: boolean;
  39326. private _disableLighting;
  39327. /**
  39328. * Does lights from the scene impacts this material.
  39329. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39330. */
  39331. disableLighting: boolean;
  39332. private _useObjectSpaceNormalMap;
  39333. /**
  39334. * Allows using an object space normal map (instead of tangent space).
  39335. */
  39336. useObjectSpaceNormalMap: boolean;
  39337. private _useParallax;
  39338. /**
  39339. * Is parallax enabled or not.
  39340. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39341. */
  39342. useParallax: boolean;
  39343. private _useParallaxOcclusion;
  39344. /**
  39345. * Is parallax occlusion enabled or not.
  39346. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39347. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39348. */
  39349. useParallaxOcclusion: boolean;
  39350. /**
  39351. * 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.
  39352. */
  39353. parallaxScaleBias: number;
  39354. private _roughness;
  39355. /**
  39356. * Helps to define how blurry the reflections should appears in the material.
  39357. */
  39358. roughness: number;
  39359. /**
  39360. * In case of refraction, define the value of the index of refraction.
  39361. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39362. */
  39363. indexOfRefraction: number;
  39364. /**
  39365. * Invert the refraction texture alongside the y axis.
  39366. * It can be useful with procedural textures or probe for instance.
  39367. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39368. */
  39369. invertRefractionY: boolean;
  39370. /**
  39371. * Defines the alpha limits in alpha test mode.
  39372. */
  39373. alphaCutOff: number;
  39374. private _useLightmapAsShadowmap;
  39375. /**
  39376. * In case of light mapping, define whether the map contains light or shadow informations.
  39377. */
  39378. useLightmapAsShadowmap: boolean;
  39379. private _diffuseFresnelParameters;
  39380. /**
  39381. * Define the diffuse fresnel parameters of the material.
  39382. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39383. */
  39384. diffuseFresnelParameters: FresnelParameters;
  39385. private _opacityFresnelParameters;
  39386. /**
  39387. * Define the opacity fresnel parameters of the material.
  39388. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39389. */
  39390. opacityFresnelParameters: FresnelParameters;
  39391. private _reflectionFresnelParameters;
  39392. /**
  39393. * Define the reflection fresnel parameters of the material.
  39394. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39395. */
  39396. reflectionFresnelParameters: FresnelParameters;
  39397. private _refractionFresnelParameters;
  39398. /**
  39399. * Define the refraction fresnel parameters of the material.
  39400. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39401. */
  39402. refractionFresnelParameters: FresnelParameters;
  39403. private _emissiveFresnelParameters;
  39404. /**
  39405. * Define the emissive fresnel parameters of the material.
  39406. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39407. */
  39408. emissiveFresnelParameters: FresnelParameters;
  39409. private _useReflectionFresnelFromSpecular;
  39410. /**
  39411. * If true automatically deducts the fresnels values from the material specularity.
  39412. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39413. */
  39414. useReflectionFresnelFromSpecular: boolean;
  39415. private _useGlossinessFromSpecularMapAlpha;
  39416. /**
  39417. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39418. */
  39419. useGlossinessFromSpecularMapAlpha: boolean;
  39420. private _maxSimultaneousLights;
  39421. /**
  39422. * Defines the maximum number of lights that can be used in the material
  39423. */
  39424. maxSimultaneousLights: number;
  39425. private _invertNormalMapX;
  39426. /**
  39427. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39428. */
  39429. invertNormalMapX: boolean;
  39430. private _invertNormalMapY;
  39431. /**
  39432. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39433. */
  39434. invertNormalMapY: boolean;
  39435. private _twoSidedLighting;
  39436. /**
  39437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39438. */
  39439. twoSidedLighting: boolean;
  39440. /**
  39441. * Default configuration related to image processing available in the standard Material.
  39442. */
  39443. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39444. /**
  39445. * Gets the image processing configuration used either in this material.
  39446. */
  39447. /**
  39448. * Sets the Default image processing configuration used either in the this material.
  39449. *
  39450. * If sets to null, the scene one is in use.
  39451. */
  39452. imageProcessingConfiguration: ImageProcessingConfiguration;
  39453. /**
  39454. * Keep track of the image processing observer to allow dispose and replace.
  39455. */
  39456. private _imageProcessingObserver;
  39457. /**
  39458. * Attaches a new image processing configuration to the Standard Material.
  39459. * @param configuration
  39460. */
  39461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39462. /**
  39463. * Gets wether the color curves effect is enabled.
  39464. */
  39465. /**
  39466. * Sets wether the color curves effect is enabled.
  39467. */
  39468. cameraColorCurvesEnabled: boolean;
  39469. /**
  39470. * Gets wether the color grading effect is enabled.
  39471. */
  39472. /**
  39473. * Gets wether the color grading effect is enabled.
  39474. */
  39475. cameraColorGradingEnabled: boolean;
  39476. /**
  39477. * Gets wether tonemapping is enabled or not.
  39478. */
  39479. /**
  39480. * Sets wether tonemapping is enabled or not
  39481. */
  39482. cameraToneMappingEnabled: boolean;
  39483. /**
  39484. * The camera exposure used on this material.
  39485. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39486. * This corresponds to a photographic exposure.
  39487. */
  39488. /**
  39489. * The camera exposure used on this material.
  39490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39491. * This corresponds to a photographic exposure.
  39492. */
  39493. cameraExposure: number;
  39494. /**
  39495. * Gets The camera contrast used on this material.
  39496. */
  39497. /**
  39498. * Sets The camera contrast used on this material.
  39499. */
  39500. cameraContrast: number;
  39501. /**
  39502. * Gets the Color Grading 2D Lookup Texture.
  39503. */
  39504. /**
  39505. * Sets the Color Grading 2D Lookup Texture.
  39506. */
  39507. cameraColorGradingTexture: Nullable<BaseTexture>;
  39508. /**
  39509. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39510. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39511. * 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;
  39512. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39513. */
  39514. /**
  39515. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39516. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39517. * 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;
  39518. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39519. */
  39520. cameraColorCurves: Nullable<ColorCurves>;
  39521. /**
  39522. * Custom callback helping to override the default shader used in the material.
  39523. */
  39524. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39525. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39526. protected _worldViewProjectionMatrix: Matrix;
  39527. protected _globalAmbientColor: Color3;
  39528. protected _useLogarithmicDepth: boolean;
  39529. /**
  39530. * Instantiates a new standard material.
  39531. * This is the default material used in Babylon. It is the best trade off between quality
  39532. * and performances.
  39533. * @see http://doc.babylonjs.com/babylon101/materials
  39534. * @param name Define the name of the material in the scene
  39535. * @param scene Define the scene the material belong to
  39536. */
  39537. constructor(name: string, scene: Scene);
  39538. /**
  39539. * Gets a boolean indicating that current material needs to register RTT
  39540. */
  39541. readonly hasRenderTargetTextures: boolean;
  39542. /**
  39543. * Gets the current class name of the material e.g. "StandardMaterial"
  39544. * Mainly use in serialization.
  39545. * @returns the class name
  39546. */
  39547. getClassName(): string;
  39548. /**
  39549. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39550. * You can try switching to logarithmic depth.
  39551. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39552. */
  39553. useLogarithmicDepth: boolean;
  39554. /**
  39555. * Specifies if the material will require alpha blending
  39556. * @returns a boolean specifying if alpha blending is needed
  39557. */
  39558. needAlphaBlending(): boolean;
  39559. /**
  39560. * Specifies if this material should be rendered in alpha test mode
  39561. * @returns a boolean specifying if an alpha test is needed.
  39562. */
  39563. needAlphaTesting(): boolean;
  39564. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39565. /**
  39566. * Get the texture used for alpha test purpose.
  39567. * @returns the diffuse texture in case of the standard material.
  39568. */
  39569. getAlphaTestTexture(): Nullable<BaseTexture>;
  39570. /**
  39571. * Get if the submesh is ready to be used and all its information available.
  39572. * Child classes can use it to update shaders
  39573. * @param mesh defines the mesh to check
  39574. * @param subMesh defines which submesh to check
  39575. * @param useInstances specifies that instances should be used
  39576. * @returns a boolean indicating that the submesh is ready or not
  39577. */
  39578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39579. /**
  39580. * Builds the material UBO layouts.
  39581. * Used internally during the effect preparation.
  39582. */
  39583. buildUniformLayout(): void;
  39584. /**
  39585. * Unbinds the material from the mesh
  39586. */
  39587. unbind(): void;
  39588. /**
  39589. * Binds the submesh to this material by preparing the effect and shader to draw
  39590. * @param world defines the world transformation matrix
  39591. * @param mesh defines the mesh containing the submesh
  39592. * @param subMesh defines the submesh to bind the material to
  39593. */
  39594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39595. /**
  39596. * Get the list of animatables in the material.
  39597. * @returns the list of animatables object used in the material
  39598. */
  39599. getAnimatables(): IAnimatable[];
  39600. /**
  39601. * Gets the active textures from the material
  39602. * @returns an array of textures
  39603. */
  39604. getActiveTextures(): BaseTexture[];
  39605. /**
  39606. * Specifies if the material uses a texture
  39607. * @param texture defines the texture to check against the material
  39608. * @returns a boolean specifying if the material uses the texture
  39609. */
  39610. hasTexture(texture: BaseTexture): boolean;
  39611. /**
  39612. * Disposes the material
  39613. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39614. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39615. */
  39616. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39617. /**
  39618. * Makes a duplicate of the material, and gives it a new name
  39619. * @param name defines the new name for the duplicated material
  39620. * @returns the cloned material
  39621. */
  39622. clone(name: string): StandardMaterial;
  39623. /**
  39624. * Serializes this material in a JSON representation
  39625. * @returns the serialized material object
  39626. */
  39627. serialize(): any;
  39628. /**
  39629. * Creates a standard material from parsed material data
  39630. * @param source defines the JSON representation of the material
  39631. * @param scene defines the hosting scene
  39632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39633. * @returns a new standard material
  39634. */
  39635. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39636. /**
  39637. * Are diffuse textures enabled in the application.
  39638. */
  39639. static DiffuseTextureEnabled: boolean;
  39640. /**
  39641. * Are ambient textures enabled in the application.
  39642. */
  39643. static AmbientTextureEnabled: boolean;
  39644. /**
  39645. * Are opacity textures enabled in the application.
  39646. */
  39647. static OpacityTextureEnabled: boolean;
  39648. /**
  39649. * Are reflection textures enabled in the application.
  39650. */
  39651. static ReflectionTextureEnabled: boolean;
  39652. /**
  39653. * Are emissive textures enabled in the application.
  39654. */
  39655. static EmissiveTextureEnabled: boolean;
  39656. /**
  39657. * Are specular textures enabled in the application.
  39658. */
  39659. static SpecularTextureEnabled: boolean;
  39660. /**
  39661. * Are bump textures enabled in the application.
  39662. */
  39663. static BumpTextureEnabled: boolean;
  39664. /**
  39665. * Are lightmap textures enabled in the application.
  39666. */
  39667. static LightmapTextureEnabled: boolean;
  39668. /**
  39669. * Are refraction textures enabled in the application.
  39670. */
  39671. static RefractionTextureEnabled: boolean;
  39672. /**
  39673. * Are color grading textures enabled in the application.
  39674. */
  39675. static ColorGradingTextureEnabled: boolean;
  39676. /**
  39677. * Are fresnels enabled in the application.
  39678. */
  39679. static FresnelEnabled: boolean;
  39680. }
  39681. }
  39682. declare module BABYLON {
  39683. /**
  39684. * A class extending Texture allowing drawing on a texture
  39685. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39686. */
  39687. export class DynamicTexture extends Texture {
  39688. private _generateMipMaps;
  39689. private _canvas;
  39690. private _context;
  39691. private _engine;
  39692. /**
  39693. * Creates a DynamicTexture
  39694. * @param name defines the name of the texture
  39695. * @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
  39696. * @param scene defines the scene where you want the texture
  39697. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39698. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39699. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39700. */
  39701. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39702. /**
  39703. * Get the current class name of the texture useful for serialization or dynamic coding.
  39704. * @returns "DynamicTexture"
  39705. */
  39706. getClassName(): string;
  39707. /**
  39708. * Gets the current state of canRescale
  39709. */
  39710. readonly canRescale: boolean;
  39711. private _recreate;
  39712. /**
  39713. * Scales the texture
  39714. * @param ratio the scale factor to apply to both width and height
  39715. */
  39716. scale(ratio: number): void;
  39717. /**
  39718. * Resizes the texture
  39719. * @param width the new width
  39720. * @param height the new height
  39721. */
  39722. scaleTo(width: number, height: number): void;
  39723. /**
  39724. * Gets the context of the canvas used by the texture
  39725. * @returns the canvas context of the dynamic texture
  39726. */
  39727. getContext(): CanvasRenderingContext2D;
  39728. /**
  39729. * Clears the texture
  39730. */
  39731. clear(): void;
  39732. /**
  39733. * Updates the texture
  39734. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39735. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39736. */
  39737. update(invertY?: boolean, premulAlpha?: boolean): void;
  39738. /**
  39739. * Draws text onto the texture
  39740. * @param text defines the text to be drawn
  39741. * @param x defines the placement of the text from the left
  39742. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39743. * @param font defines the font to be used with font-style, font-size, font-name
  39744. * @param color defines the color used for the text
  39745. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39746. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39747. * @param update defines whether texture is immediately update (default is true)
  39748. */
  39749. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39750. /**
  39751. * Clones the texture
  39752. * @returns the clone of the texture.
  39753. */
  39754. clone(): DynamicTexture;
  39755. /**
  39756. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39757. * @returns a serialized dynamic texture object
  39758. */
  39759. serialize(): any;
  39760. /** @hidden */
  39761. _rebuild(): void;
  39762. }
  39763. }
  39764. declare module BABYLON {
  39765. /** @hidden */
  39766. export var imageProcessingPixelShader: {
  39767. name: string;
  39768. shader: string;
  39769. };
  39770. }
  39771. declare module BABYLON {
  39772. /**
  39773. * ImageProcessingPostProcess
  39774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39775. */
  39776. export class ImageProcessingPostProcess extends PostProcess {
  39777. /**
  39778. * Default configuration related to image processing available in the PBR Material.
  39779. */
  39780. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39781. /**
  39782. * Gets the image processing configuration used either in this material.
  39783. */
  39784. /**
  39785. * Sets the Default image processing configuration used either in the this material.
  39786. *
  39787. * If sets to null, the scene one is in use.
  39788. */
  39789. imageProcessingConfiguration: ImageProcessingConfiguration;
  39790. /**
  39791. * Keep track of the image processing observer to allow dispose and replace.
  39792. */
  39793. private _imageProcessingObserver;
  39794. /**
  39795. * Attaches a new image processing configuration to the PBR Material.
  39796. * @param configuration
  39797. */
  39798. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39799. /**
  39800. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39801. */
  39802. /**
  39803. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39804. */
  39805. colorCurves: Nullable<ColorCurves>;
  39806. /**
  39807. * Gets wether the color curves effect is enabled.
  39808. */
  39809. /**
  39810. * Sets wether the color curves effect is enabled.
  39811. */
  39812. colorCurvesEnabled: boolean;
  39813. /**
  39814. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39815. */
  39816. /**
  39817. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39818. */
  39819. colorGradingTexture: Nullable<BaseTexture>;
  39820. /**
  39821. * Gets wether the color grading effect is enabled.
  39822. */
  39823. /**
  39824. * Gets wether the color grading effect is enabled.
  39825. */
  39826. colorGradingEnabled: boolean;
  39827. /**
  39828. * Gets exposure used in the effect.
  39829. */
  39830. /**
  39831. * Sets exposure used in the effect.
  39832. */
  39833. exposure: number;
  39834. /**
  39835. * Gets wether tonemapping is enabled or not.
  39836. */
  39837. /**
  39838. * Sets wether tonemapping is enabled or not
  39839. */
  39840. toneMappingEnabled: boolean;
  39841. /**
  39842. * Gets the type of tone mapping effect.
  39843. */
  39844. /**
  39845. * Sets the type of tone mapping effect.
  39846. */
  39847. toneMappingType: number;
  39848. /**
  39849. * Gets contrast used in the effect.
  39850. */
  39851. /**
  39852. * Sets contrast used in the effect.
  39853. */
  39854. contrast: number;
  39855. /**
  39856. * Gets Vignette stretch size.
  39857. */
  39858. /**
  39859. * Sets Vignette stretch size.
  39860. */
  39861. vignetteStretch: number;
  39862. /**
  39863. * Gets Vignette centre X Offset.
  39864. */
  39865. /**
  39866. * Sets Vignette centre X Offset.
  39867. */
  39868. vignetteCentreX: number;
  39869. /**
  39870. * Gets Vignette centre Y Offset.
  39871. */
  39872. /**
  39873. * Sets Vignette centre Y Offset.
  39874. */
  39875. vignetteCentreY: number;
  39876. /**
  39877. * Gets Vignette weight or intensity of the vignette effect.
  39878. */
  39879. /**
  39880. * Sets Vignette weight or intensity of the vignette effect.
  39881. */
  39882. vignetteWeight: number;
  39883. /**
  39884. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39885. * if vignetteEnabled is set to true.
  39886. */
  39887. /**
  39888. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39889. * if vignetteEnabled is set to true.
  39890. */
  39891. vignetteColor: Color4;
  39892. /**
  39893. * Gets Camera field of view used by the Vignette effect.
  39894. */
  39895. /**
  39896. * Sets Camera field of view used by the Vignette effect.
  39897. */
  39898. vignetteCameraFov: number;
  39899. /**
  39900. * Gets the vignette blend mode allowing different kind of effect.
  39901. */
  39902. /**
  39903. * Sets the vignette blend mode allowing different kind of effect.
  39904. */
  39905. vignetteBlendMode: number;
  39906. /**
  39907. * Gets wether the vignette effect is enabled.
  39908. */
  39909. /**
  39910. * Sets wether the vignette effect is enabled.
  39911. */
  39912. vignetteEnabled: boolean;
  39913. private _fromLinearSpace;
  39914. /**
  39915. * Gets wether the input of the processing is in Gamma or Linear Space.
  39916. */
  39917. /**
  39918. * Sets wether the input of the processing is in Gamma or Linear Space.
  39919. */
  39920. fromLinearSpace: boolean;
  39921. /**
  39922. * Defines cache preventing GC.
  39923. */
  39924. private _defines;
  39925. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39926. /**
  39927. * "ImageProcessingPostProcess"
  39928. * @returns "ImageProcessingPostProcess"
  39929. */
  39930. getClassName(): string;
  39931. protected _updateParameters(): void;
  39932. dispose(camera?: Camera): void;
  39933. }
  39934. }
  39935. declare module BABYLON {
  39936. /**
  39937. * Class containing static functions to help procedurally build meshes
  39938. */
  39939. export class GroundBuilder {
  39940. /**
  39941. * Creates a ground mesh
  39942. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39943. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39945. * @param name defines the name of the mesh
  39946. * @param options defines the options used to create the mesh
  39947. * @param scene defines the hosting scene
  39948. * @returns the ground mesh
  39949. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39950. */
  39951. static CreateGround(name: string, options: {
  39952. width?: number;
  39953. height?: number;
  39954. subdivisions?: number;
  39955. subdivisionsX?: number;
  39956. subdivisionsY?: number;
  39957. updatable?: boolean;
  39958. }, scene: any): Mesh;
  39959. /**
  39960. * Creates a tiled ground mesh
  39961. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39962. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39963. * * 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
  39964. * * 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
  39965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39966. * @param name defines the name of the mesh
  39967. * @param options defines the options used to create the mesh
  39968. * @param scene defines the hosting scene
  39969. * @returns the tiled ground mesh
  39970. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39971. */
  39972. static CreateTiledGround(name: string, options: {
  39973. xmin: number;
  39974. zmin: number;
  39975. xmax: number;
  39976. zmax: number;
  39977. subdivisions?: {
  39978. w: number;
  39979. h: number;
  39980. };
  39981. precision?: {
  39982. w: number;
  39983. h: number;
  39984. };
  39985. updatable?: boolean;
  39986. }, scene?: Nullable<Scene>): Mesh;
  39987. /**
  39988. * Creates a ground mesh from a height map
  39989. * * The parameter `url` sets the URL of the height map image resource.
  39990. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39991. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39992. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39993. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39994. * * 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.
  39995. * * 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).
  39996. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39998. * @param name defines the name of the mesh
  39999. * @param url defines the url to the height map
  40000. * @param options defines the options used to create the mesh
  40001. * @param scene defines the hosting scene
  40002. * @returns the ground mesh
  40003. * @see https://doc.babylonjs.com/babylon101/height_map
  40004. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40005. */
  40006. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40007. width?: number;
  40008. height?: number;
  40009. subdivisions?: number;
  40010. minHeight?: number;
  40011. maxHeight?: number;
  40012. colorFilter?: Color3;
  40013. alphaFilter?: number;
  40014. updatable?: boolean;
  40015. onReady?: (mesh: GroundMesh) => void;
  40016. }, scene?: Nullable<Scene>): GroundMesh;
  40017. }
  40018. }
  40019. declare module BABYLON {
  40020. /**
  40021. * Class containing static functions to help procedurally build meshes
  40022. */
  40023. export class TorusBuilder {
  40024. /**
  40025. * Creates a torus mesh
  40026. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40027. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40028. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40030. * * 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
  40031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40032. * @param name defines the name of the mesh
  40033. * @param options defines the options used to create the mesh
  40034. * @param scene defines the hosting scene
  40035. * @returns the torus mesh
  40036. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40037. */
  40038. static CreateTorus(name: string, options: {
  40039. diameter?: number;
  40040. thickness?: number;
  40041. tessellation?: number;
  40042. updatable?: boolean;
  40043. sideOrientation?: number;
  40044. frontUVs?: Vector4;
  40045. backUVs?: Vector4;
  40046. }, scene: any): Mesh;
  40047. }
  40048. }
  40049. declare module BABYLON {
  40050. /**
  40051. * Class containing static functions to help procedurally build meshes
  40052. */
  40053. export class CylinderBuilder {
  40054. /**
  40055. * Creates a cylinder or a cone mesh
  40056. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40057. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40058. * * 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.
  40059. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40060. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40061. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40062. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40063. * * 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).
  40064. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40065. * * 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).
  40066. * * 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
  40067. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40068. * * 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
  40069. * * 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.
  40070. * * If `enclose` is false, a ring surface is one element.
  40071. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40072. * * 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
  40073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40074. * * 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
  40075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40076. * @param name defines the name of the mesh
  40077. * @param options defines the options used to create the mesh
  40078. * @param scene defines the hosting scene
  40079. * @returns the cylinder mesh
  40080. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40081. */
  40082. static CreateCylinder(name: string, options: {
  40083. height?: number;
  40084. diameterTop?: number;
  40085. diameterBottom?: number;
  40086. diameter?: number;
  40087. tessellation?: number;
  40088. subdivisions?: number;
  40089. arc?: number;
  40090. faceColors?: Color4[];
  40091. faceUV?: Vector4[];
  40092. updatable?: boolean;
  40093. hasRings?: boolean;
  40094. enclose?: boolean;
  40095. cap?: number;
  40096. sideOrientation?: number;
  40097. frontUVs?: Vector4;
  40098. backUVs?: Vector4;
  40099. }, scene: any): Mesh;
  40100. }
  40101. }
  40102. declare module BABYLON {
  40103. /**
  40104. * Options to modify the vr teleportation behavior.
  40105. */
  40106. export interface VRTeleportationOptions {
  40107. /**
  40108. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40109. */
  40110. floorMeshName?: string;
  40111. /**
  40112. * A list of meshes to be used as the teleportation floor. (default: empty)
  40113. */
  40114. floorMeshes?: Mesh[];
  40115. }
  40116. /**
  40117. * Options to modify the vr experience helper's behavior.
  40118. */
  40119. export interface VRExperienceHelperOptions extends WebVROptions {
  40120. /**
  40121. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40122. */
  40123. createDeviceOrientationCamera?: boolean;
  40124. /**
  40125. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40126. */
  40127. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40128. /**
  40129. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40130. */
  40131. laserToggle?: boolean;
  40132. /**
  40133. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40134. */
  40135. floorMeshes?: Mesh[];
  40136. /**
  40137. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40138. */
  40139. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40140. }
  40141. /**
  40142. * Event containing information after VR has been entered
  40143. */
  40144. export class OnAfterEnteringVRObservableEvent {
  40145. /**
  40146. * If entering vr was successful
  40147. */
  40148. success: boolean;
  40149. }
  40150. /**
  40151. * Helps to quickly add VR support to an existing scene.
  40152. * See http://doc.babylonjs.com/how_to/webvr_helper
  40153. */
  40154. export class VRExperienceHelper {
  40155. /** Options to modify the vr experience helper's behavior. */
  40156. webVROptions: VRExperienceHelperOptions;
  40157. private _scene;
  40158. private _position;
  40159. private _btnVR;
  40160. private _btnVRDisplayed;
  40161. private _webVRsupported;
  40162. private _webVRready;
  40163. private _webVRrequesting;
  40164. private _webVRpresenting;
  40165. private _hasEnteredVR;
  40166. private _fullscreenVRpresenting;
  40167. private _canvas;
  40168. private _webVRCamera;
  40169. private _vrDeviceOrientationCamera;
  40170. private _deviceOrientationCamera;
  40171. private _existingCamera;
  40172. private _onKeyDown;
  40173. private _onVrDisplayPresentChange;
  40174. private _onVRDisplayChanged;
  40175. private _onVRRequestPresentStart;
  40176. private _onVRRequestPresentComplete;
  40177. /**
  40178. * Observable raised right before entering VR.
  40179. */
  40180. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40181. /**
  40182. * Observable raised when entering VR has completed.
  40183. */
  40184. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40185. /**
  40186. * Observable raised when exiting VR.
  40187. */
  40188. onExitingVRObservable: Observable<VRExperienceHelper>;
  40189. /**
  40190. * Observable raised when controller mesh is loaded.
  40191. */
  40192. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40193. /** Return this.onEnteringVRObservable
  40194. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40195. */
  40196. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40197. /** Return this.onExitingVRObservable
  40198. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40199. */
  40200. readonly onExitingVR: Observable<VRExperienceHelper>;
  40201. /** Return this.onControllerMeshLoadedObservable
  40202. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40203. */
  40204. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40205. private _rayLength;
  40206. private _useCustomVRButton;
  40207. private _teleportationRequested;
  40208. private _teleportActive;
  40209. private _floorMeshName;
  40210. private _floorMeshesCollection;
  40211. private _rotationAllowed;
  40212. private _teleportBackwardsVector;
  40213. private _teleportationTarget;
  40214. private _isDefaultTeleportationTarget;
  40215. private _postProcessMove;
  40216. private _teleportationFillColor;
  40217. private _teleportationBorderColor;
  40218. private _rotationAngle;
  40219. private _haloCenter;
  40220. private _cameraGazer;
  40221. private _padSensibilityUp;
  40222. private _padSensibilityDown;
  40223. private _leftController;
  40224. private _rightController;
  40225. /**
  40226. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40227. */
  40228. onNewMeshSelected: Observable<AbstractMesh>;
  40229. /**
  40230. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40231. */
  40232. onNewMeshPicked: Observable<PickingInfo>;
  40233. private _circleEase;
  40234. /**
  40235. * Observable raised before camera teleportation
  40236. */
  40237. onBeforeCameraTeleport: Observable<Vector3>;
  40238. /**
  40239. * Observable raised after camera teleportation
  40240. */
  40241. onAfterCameraTeleport: Observable<Vector3>;
  40242. /**
  40243. * Observable raised when current selected mesh gets unselected
  40244. */
  40245. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40246. private _raySelectionPredicate;
  40247. /**
  40248. * To be optionaly changed by user to define custom ray selection
  40249. */
  40250. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40251. /**
  40252. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40253. */
  40254. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40255. /**
  40256. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40257. */
  40258. teleportationEnabled: boolean;
  40259. private _defaultHeight;
  40260. private _teleportationInitialized;
  40261. private _interactionsEnabled;
  40262. private _interactionsRequested;
  40263. private _displayGaze;
  40264. private _displayLaserPointer;
  40265. /**
  40266. * The mesh used to display where the user is going to teleport.
  40267. */
  40268. /**
  40269. * Sets the mesh to be used to display where the user is going to teleport.
  40270. */
  40271. teleportationTarget: Mesh;
  40272. /**
  40273. * 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
  40274. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40275. * See http://doc.babylonjs.com/resources/baking_transformations
  40276. */
  40277. gazeTrackerMesh: Mesh;
  40278. /**
  40279. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40280. */
  40281. updateGazeTrackerScale: boolean;
  40282. /**
  40283. * If the gaze trackers color should be updated when selecting meshes
  40284. */
  40285. updateGazeTrackerColor: boolean;
  40286. /**
  40287. * The gaze tracking mesh corresponding to the left controller
  40288. */
  40289. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40290. /**
  40291. * The gaze tracking mesh corresponding to the right controller
  40292. */
  40293. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40294. /**
  40295. * If the ray of the gaze should be displayed.
  40296. */
  40297. /**
  40298. * Sets if the ray of the gaze should be displayed.
  40299. */
  40300. displayGaze: boolean;
  40301. /**
  40302. * If the ray of the LaserPointer should be displayed.
  40303. */
  40304. /**
  40305. * Sets if the ray of the LaserPointer should be displayed.
  40306. */
  40307. displayLaserPointer: boolean;
  40308. /**
  40309. * The deviceOrientationCamera used as the camera when not in VR.
  40310. */
  40311. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40312. /**
  40313. * Based on the current WebVR support, returns the current VR camera used.
  40314. */
  40315. readonly currentVRCamera: Nullable<Camera>;
  40316. /**
  40317. * The webVRCamera which is used when in VR.
  40318. */
  40319. readonly webVRCamera: WebVRFreeCamera;
  40320. /**
  40321. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40322. */
  40323. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40324. private readonly _teleportationRequestInitiated;
  40325. /**
  40326. * Defines wether or not Pointer lock should be requested when switching to
  40327. * full screen.
  40328. */
  40329. requestPointerLockOnFullScreen: boolean;
  40330. /**
  40331. * Instantiates a VRExperienceHelper.
  40332. * Helps to quickly add VR support to an existing scene.
  40333. * @param scene The scene the VRExperienceHelper belongs to.
  40334. * @param webVROptions Options to modify the vr experience helper's behavior.
  40335. */
  40336. constructor(scene: Scene,
  40337. /** Options to modify the vr experience helper's behavior. */
  40338. webVROptions?: VRExperienceHelperOptions);
  40339. private _onDefaultMeshLoaded;
  40340. private _onResize;
  40341. private _onFullscreenChange;
  40342. /**
  40343. * Gets a value indicating if we are currently in VR mode.
  40344. */
  40345. readonly isInVRMode: boolean;
  40346. private onVrDisplayPresentChange;
  40347. private onVRDisplayChanged;
  40348. private moveButtonToBottomRight;
  40349. private displayVRButton;
  40350. private updateButtonVisibility;
  40351. private _cachedAngularSensibility;
  40352. /**
  40353. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40354. * Otherwise, will use the fullscreen API.
  40355. */
  40356. enterVR(): void;
  40357. /**
  40358. * Attempt to exit VR, or fullscreen.
  40359. */
  40360. exitVR(): void;
  40361. /**
  40362. * The position of the vr experience helper.
  40363. */
  40364. /**
  40365. * Sets the position of the vr experience helper.
  40366. */
  40367. position: Vector3;
  40368. /**
  40369. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40370. */
  40371. enableInteractions(): void;
  40372. private readonly _noControllerIsActive;
  40373. private beforeRender;
  40374. private _isTeleportationFloor;
  40375. /**
  40376. * Adds a floor mesh to be used for teleportation.
  40377. * @param floorMesh the mesh to be used for teleportation.
  40378. */
  40379. addFloorMesh(floorMesh: Mesh): void;
  40380. /**
  40381. * Removes a floor mesh from being used for teleportation.
  40382. * @param floorMesh the mesh to be removed.
  40383. */
  40384. removeFloorMesh(floorMesh: Mesh): void;
  40385. /**
  40386. * Enables interactions and teleportation using the VR controllers and gaze.
  40387. * @param vrTeleportationOptions options to modify teleportation behavior.
  40388. */
  40389. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40390. private _onNewGamepadConnected;
  40391. private _tryEnableInteractionOnController;
  40392. private _onNewGamepadDisconnected;
  40393. private _enableInteractionOnController;
  40394. private _checkTeleportWithRay;
  40395. private _checkRotate;
  40396. private _checkTeleportBackwards;
  40397. private _enableTeleportationOnController;
  40398. private _createTeleportationCircles;
  40399. private _displayTeleportationTarget;
  40400. private _hideTeleportationTarget;
  40401. private _rotateCamera;
  40402. private _moveTeleportationSelectorTo;
  40403. private _workingVector;
  40404. private _workingQuaternion;
  40405. private _workingMatrix;
  40406. /**
  40407. * Teleports the users feet to the desired location
  40408. * @param location The location where the user's feet should be placed
  40409. */
  40410. teleportCamera(location: Vector3): void;
  40411. private _convertNormalToDirectionOfRay;
  40412. private _castRayAndSelectObject;
  40413. private _notifySelectedMeshUnselected;
  40414. /**
  40415. * Sets the color of the laser ray from the vr controllers.
  40416. * @param color new color for the ray.
  40417. */
  40418. changeLaserColor(color: Color3): void;
  40419. /**
  40420. * Sets the color of the ray from the vr headsets gaze.
  40421. * @param color new color for the ray.
  40422. */
  40423. changeGazeColor(color: Color3): void;
  40424. /**
  40425. * Exits VR and disposes of the vr experience helper
  40426. */
  40427. dispose(): void;
  40428. /**
  40429. * Gets the name of the VRExperienceHelper class
  40430. * @returns "VRExperienceHelper"
  40431. */
  40432. getClassName(): string;
  40433. }
  40434. }
  40435. declare module BABYLON {
  40436. /**
  40437. * Manages an XRSession
  40438. * @see https://doc.babylonjs.com/how_to/webxr
  40439. */
  40440. export class WebXRSessionManager implements IDisposable {
  40441. private scene;
  40442. /**
  40443. * Fires every time a new xrFrame arrives which can be used to update the camera
  40444. */
  40445. onXRFrameObservable: Observable<any>;
  40446. /**
  40447. * Fires when the xr session is ended either by the device or manually done
  40448. */
  40449. onXRSessionEnded: Observable<any>;
  40450. /** @hidden */
  40451. _xrSession: XRSession;
  40452. /** @hidden */
  40453. _frameOfReference: XRFrameOfReference;
  40454. /** @hidden */
  40455. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40456. /** @hidden */
  40457. _currentXRFrame: Nullable<XRFrame>;
  40458. private _xrNavigator;
  40459. private _xrDevice;
  40460. private _tmpMatrix;
  40461. /**
  40462. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40463. * @param scene The scene which the session should be created for
  40464. */
  40465. constructor(scene: Scene);
  40466. /**
  40467. * Initializes the manager
  40468. * After initialization enterXR can be called to start an XR session
  40469. * @returns Promise which resolves after it is initialized
  40470. */
  40471. initializeAsync(): Promise<void>;
  40472. /**
  40473. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40474. * @param sessionCreationOptions xr options to create the session with
  40475. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40476. * @returns Promise which resolves after it enters XR
  40477. */
  40478. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40479. /**
  40480. * Stops the xrSession and restores the renderloop
  40481. * @returns Promise which resolves after it exits XR
  40482. */
  40483. exitXRAsync(): Promise<void>;
  40484. /**
  40485. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40486. * @param ray ray to cast into the environment
  40487. * @returns Promise which resolves with a collision point in the environment if it exists
  40488. */
  40489. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40490. /**
  40491. * Checks if a session would be supported for the creation options specified
  40492. * @param options creation options to check if they are supported
  40493. * @returns true if supported
  40494. */
  40495. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40496. /**
  40497. * @hidden
  40498. * Converts the render layer of xrSession to a render target
  40499. * @param session session to create render target for
  40500. * @param scene scene the new render target should be created for
  40501. */
  40502. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40503. /**
  40504. * Disposes of the session manager
  40505. */
  40506. dispose(): void;
  40507. }
  40508. }
  40509. declare module BABYLON {
  40510. /**
  40511. * WebXR Camera which holds the views for the xrSession
  40512. * @see https://doc.babylonjs.com/how_to/webxr
  40513. */
  40514. export class WebXRCamera extends FreeCamera {
  40515. private static _TmpMatrix;
  40516. /**
  40517. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40518. * @param name the name of the camera
  40519. * @param scene the scene to add the camera to
  40520. */
  40521. constructor(name: string, scene: Scene);
  40522. private _updateNumberOfRigCameras;
  40523. /** @hidden */
  40524. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40525. /**
  40526. * Updates the cameras position from the current pose information of the XR session
  40527. * @param xrSessionManager the session containing pose information
  40528. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40529. */
  40530. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40531. }
  40532. }
  40533. declare module BABYLON {
  40534. /**
  40535. * States of the webXR experience
  40536. */
  40537. export enum WebXRState {
  40538. /**
  40539. * Transitioning to being in XR mode
  40540. */
  40541. ENTERING_XR = 0,
  40542. /**
  40543. * Transitioning to non XR mode
  40544. */
  40545. EXITING_XR = 1,
  40546. /**
  40547. * In XR mode and presenting
  40548. */
  40549. IN_XR = 2,
  40550. /**
  40551. * Not entered XR mode
  40552. */
  40553. NOT_IN_XR = 3
  40554. }
  40555. /**
  40556. * Helper class used to enable XR
  40557. * @see https://doc.babylonjs.com/how_to/webxr
  40558. */
  40559. export class WebXRExperienceHelper implements IDisposable {
  40560. private scene;
  40561. /**
  40562. * 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
  40563. */
  40564. container: AbstractMesh;
  40565. /**
  40566. * Camera used to render xr content
  40567. */
  40568. camera: WebXRCamera;
  40569. /**
  40570. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40571. */
  40572. state: WebXRState;
  40573. private _setState;
  40574. private static _TmpVector;
  40575. /**
  40576. * Fires when the state of the experience helper has changed
  40577. */
  40578. onStateChangedObservable: Observable<WebXRState>;
  40579. /** @hidden */
  40580. _sessionManager: WebXRSessionManager;
  40581. private _nonVRCamera;
  40582. private _originalSceneAutoClear;
  40583. private _supported;
  40584. /**
  40585. * Creates the experience helper
  40586. * @param scene the scene to attach the experience helper to
  40587. * @returns a promise for the experience helper
  40588. */
  40589. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40590. /**
  40591. * Creates a WebXRExperienceHelper
  40592. * @param scene The scene the helper should be created in
  40593. */
  40594. private constructor();
  40595. /**
  40596. * Exits XR mode and returns the scene to its original state
  40597. * @returns promise that resolves after xr mode has exited
  40598. */
  40599. exitXRAsync(): Promise<void>;
  40600. /**
  40601. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40602. * @param sessionCreationOptions options for the XR session
  40603. * @param frameOfReference frame of reference of the XR session
  40604. * @returns promise that resolves after xr mode has entered
  40605. */
  40606. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40607. /**
  40608. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40609. * @param ray ray to cast into the environment
  40610. * @returns Promise which resolves with a collision point in the environment if it exists
  40611. */
  40612. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40613. /**
  40614. * Updates the global position of the camera by moving the camera's container
  40615. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40616. * @param position The desired global position of the camera
  40617. */
  40618. setPositionOfCameraUsingContainer(position: Vector3): void;
  40619. /**
  40620. * Rotates the xr camera by rotating the camera's container around the camera's position
  40621. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40622. * @param rotation the desired quaternion rotation to apply to the camera
  40623. */
  40624. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40625. /**
  40626. * Checks if the creation options are supported by the xr session
  40627. * @param options creation options
  40628. * @returns true if supported
  40629. */
  40630. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40631. /**
  40632. * Disposes of the experience helper
  40633. */
  40634. dispose(): void;
  40635. }
  40636. }
  40637. declare module BABYLON {
  40638. /**
  40639. * Button which can be used to enter a different mode of XR
  40640. */
  40641. export class WebXREnterExitUIButton {
  40642. /** button element */
  40643. element: HTMLElement;
  40644. /** XR initialization options for the button */
  40645. initializationOptions: XRSessionCreationOptions;
  40646. /**
  40647. * Creates a WebXREnterExitUIButton
  40648. * @param element button element
  40649. * @param initializationOptions XR initialization options for the button
  40650. */
  40651. constructor(
  40652. /** button element */
  40653. element: HTMLElement,
  40654. /** XR initialization options for the button */
  40655. initializationOptions: XRSessionCreationOptions);
  40656. /**
  40657. * Overwritable function which can be used to update the button's visuals when the state changes
  40658. * @param activeButton the current active button in the UI
  40659. */
  40660. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40661. }
  40662. /**
  40663. * Options to create the webXR UI
  40664. */
  40665. export class WebXREnterExitUIOptions {
  40666. /**
  40667. * Context to enter xr with
  40668. */
  40669. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40670. /**
  40671. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40672. */
  40673. customButtons?: Array<WebXREnterExitUIButton>;
  40674. }
  40675. /**
  40676. * UI to allow the user to enter/exit XR mode
  40677. */
  40678. export class WebXREnterExitUI implements IDisposable {
  40679. private scene;
  40680. private _overlay;
  40681. private _buttons;
  40682. private _activeButton;
  40683. /**
  40684. * Fired every time the active button is changed.
  40685. *
  40686. * When xr is entered via a button that launches xr that button will be the callback parameter
  40687. *
  40688. * When exiting xr the callback parameter will be null)
  40689. */
  40690. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40691. /**
  40692. * Creates UI to allow the user to enter/exit XR mode
  40693. * @param scene the scene to add the ui to
  40694. * @param helper the xr experience helper to enter/exit xr with
  40695. * @param options options to configure the UI
  40696. * @returns the created ui
  40697. */
  40698. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40699. private constructor();
  40700. private _updateButtons;
  40701. /**
  40702. * Disposes of the object
  40703. */
  40704. dispose(): void;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * Represents an XR input
  40710. */
  40711. export class WebXRController {
  40712. /**
  40713. * 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
  40714. */
  40715. grip?: AbstractMesh;
  40716. /**
  40717. * Pointer which can be used to select objects or attach a visible laser to
  40718. */
  40719. pointer: AbstractMesh;
  40720. /**
  40721. * Creates the controller
  40722. * @see https://doc.babylonjs.com/how_to/webxr
  40723. * @param scene the scene which the controller should be associated to
  40724. */
  40725. constructor(scene: Scene);
  40726. /**
  40727. * Disposes of the object
  40728. */
  40729. dispose(): void;
  40730. }
  40731. /**
  40732. * XR input used to track XR inputs such as controllers/rays
  40733. */
  40734. export class WebXRInput implements IDisposable {
  40735. private helper;
  40736. /**
  40737. * XR controllers being tracked
  40738. */
  40739. controllers: Array<WebXRController>;
  40740. private _tmpMatrix;
  40741. private _frameObserver;
  40742. /**
  40743. * Initializes the WebXRInput
  40744. * @param helper experience helper which the input should be created for
  40745. */
  40746. constructor(helper: WebXRExperienceHelper);
  40747. /**
  40748. * Disposes of the object
  40749. */
  40750. dispose(): void;
  40751. }
  40752. }
  40753. declare module BABYLON {
  40754. /**
  40755. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40756. */
  40757. export class WebXRManagedOutputCanvas implements IDisposable {
  40758. private _canvas;
  40759. /**
  40760. * xrpresent context of the canvas which can be used to display/mirror xr content
  40761. */
  40762. canvasContext: Nullable<WebGLRenderingContext>;
  40763. /**
  40764. * Initializes the canvas to be added/removed upon entering/exiting xr
  40765. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40766. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40767. */
  40768. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40769. /**
  40770. * Disposes of the object
  40771. */
  40772. dispose(): void;
  40773. private _setManagedOutputCanvas;
  40774. private _addCanvas;
  40775. private _removeCanvas;
  40776. }
  40777. }
  40778. declare module BABYLON {
  40779. /**
  40780. * Contains an array of blocks representing the octree
  40781. */
  40782. export interface IOctreeContainer<T> {
  40783. /**
  40784. * Blocks within the octree
  40785. */
  40786. blocks: Array<OctreeBlock<T>>;
  40787. }
  40788. /**
  40789. * Class used to store a cell in an octree
  40790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40791. */
  40792. export class OctreeBlock<T> {
  40793. /**
  40794. * Gets the content of the current block
  40795. */
  40796. entries: T[];
  40797. /**
  40798. * Gets the list of block children
  40799. */
  40800. blocks: Array<OctreeBlock<T>>;
  40801. private _depth;
  40802. private _maxDepth;
  40803. private _capacity;
  40804. private _minPoint;
  40805. private _maxPoint;
  40806. private _boundingVectors;
  40807. private _creationFunc;
  40808. /**
  40809. * Creates a new block
  40810. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40811. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40812. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40813. * @param depth defines the current depth of this block in the octree
  40814. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40815. * @param creationFunc defines a callback to call when an element is added to the block
  40816. */
  40817. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40818. /**
  40819. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40820. */
  40821. readonly capacity: number;
  40822. /**
  40823. * Gets the minimum vector (in world space) of the block's bounding box
  40824. */
  40825. readonly minPoint: Vector3;
  40826. /**
  40827. * Gets the maximum vector (in world space) of the block's bounding box
  40828. */
  40829. readonly maxPoint: Vector3;
  40830. /**
  40831. * Add a new element to this block
  40832. * @param entry defines the element to add
  40833. */
  40834. addEntry(entry: T): void;
  40835. /**
  40836. * Remove an element from this block
  40837. * @param entry defines the element to remove
  40838. */
  40839. removeEntry(entry: T): void;
  40840. /**
  40841. * Add an array of elements to this block
  40842. * @param entries defines the array of elements to add
  40843. */
  40844. addEntries(entries: T[]): void;
  40845. /**
  40846. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40847. * @param frustumPlanes defines the frustum planes to test
  40848. * @param selection defines the array to store current content if selection is positive
  40849. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40850. */
  40851. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40852. /**
  40853. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40854. * @param sphereCenter defines the bounding sphere center
  40855. * @param sphereRadius defines the bounding sphere radius
  40856. * @param selection defines the array to store current content if selection is positive
  40857. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40858. */
  40859. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40860. /**
  40861. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40862. * @param ray defines the ray to test with
  40863. * @param selection defines the array to store current content if selection is positive
  40864. */
  40865. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40866. /**
  40867. * Subdivide the content into child blocks (this block will then be empty)
  40868. */
  40869. createInnerBlocks(): void;
  40870. /**
  40871. * @hidden
  40872. */
  40873. 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;
  40874. }
  40875. }
  40876. declare module BABYLON {
  40877. /**
  40878. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40880. */
  40881. export class Octree<T> {
  40882. /** 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.) */
  40883. maxDepth: number;
  40884. /**
  40885. * Blocks within the octree containing objects
  40886. */
  40887. blocks: Array<OctreeBlock<T>>;
  40888. /**
  40889. * Content stored in the octree
  40890. */
  40891. dynamicContent: T[];
  40892. private _maxBlockCapacity;
  40893. private _selectionContent;
  40894. private _creationFunc;
  40895. /**
  40896. * Creates a octree
  40897. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40898. * @param creationFunc function to be used to instatiate the octree
  40899. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40900. * @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.)
  40901. */
  40902. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40903. /** 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.) */
  40904. maxDepth?: number);
  40905. /**
  40906. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40907. * @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);
  40908. * @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);
  40909. * @param entries meshes to be added to the octree blocks
  40910. */
  40911. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40912. /**
  40913. * Adds a mesh to the octree
  40914. * @param entry Mesh to add to the octree
  40915. */
  40916. addMesh(entry: T): void;
  40917. /**
  40918. * Remove an element from the octree
  40919. * @param entry defines the element to remove
  40920. */
  40921. removeMesh(entry: T): void;
  40922. /**
  40923. * Selects an array of meshes within the frustum
  40924. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40925. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40926. * @returns array of meshes within the frustum
  40927. */
  40928. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40929. /**
  40930. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40931. * @param sphereCenter defines the bounding sphere center
  40932. * @param sphereRadius defines the bounding sphere radius
  40933. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40934. * @returns an array of objects that intersect the sphere
  40935. */
  40936. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40937. /**
  40938. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40939. * @param ray defines the ray to test with
  40940. * @returns array of intersected objects
  40941. */
  40942. intersectsRay(ray: Ray): SmartArray<T>;
  40943. /**
  40944. * Adds a mesh into the octree block if it intersects the block
  40945. */
  40946. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40947. /**
  40948. * Adds a submesh into the octree block if it intersects the block
  40949. */
  40950. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40951. }
  40952. }
  40953. declare module BABYLON {
  40954. interface Scene {
  40955. /**
  40956. * @hidden
  40957. * Backing Filed
  40958. */
  40959. _selectionOctree: Octree<AbstractMesh>;
  40960. /**
  40961. * Gets the octree used to boost mesh selection (picking)
  40962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40963. */
  40964. selectionOctree: Octree<AbstractMesh>;
  40965. /**
  40966. * Creates or updates the octree used to boost selection (picking)
  40967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40968. * @param maxCapacity defines the maximum capacity per leaf
  40969. * @param maxDepth defines the maximum depth of the octree
  40970. * @returns an octree of AbstractMesh
  40971. */
  40972. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40973. }
  40974. interface AbstractMesh {
  40975. /**
  40976. * @hidden
  40977. * Backing Field
  40978. */
  40979. _submeshesOctree: Octree<SubMesh>;
  40980. /**
  40981. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40982. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40983. * @param maxCapacity defines the maximum size of each block (64 by default)
  40984. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40985. * @returns the new octree
  40986. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40988. */
  40989. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40990. }
  40991. /**
  40992. * Defines the octree scene component responsible to manage any octrees
  40993. * in a given scene.
  40994. */
  40995. export class OctreeSceneComponent {
  40996. /**
  40997. * The component name help to identify the component in the list of scene components.
  40998. */
  40999. readonly name: string;
  41000. /**
  41001. * The scene the component belongs to.
  41002. */
  41003. scene: Scene;
  41004. /**
  41005. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41006. */
  41007. readonly checksIsEnabled: boolean;
  41008. /**
  41009. * Creates a new instance of the component for the given scene
  41010. * @param scene Defines the scene to register the component in
  41011. */
  41012. constructor(scene: Scene);
  41013. /**
  41014. * Registers the component in a given scene
  41015. */
  41016. register(): void;
  41017. /**
  41018. * Return the list of active meshes
  41019. * @returns the list of active meshes
  41020. */
  41021. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41022. /**
  41023. * Return the list of active sub meshes
  41024. * @param mesh The mesh to get the candidates sub meshes from
  41025. * @returns the list of active sub meshes
  41026. */
  41027. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41028. private _tempRay;
  41029. /**
  41030. * Return the list of sub meshes intersecting with a given local ray
  41031. * @param mesh defines the mesh to find the submesh for
  41032. * @param localRay defines the ray in local space
  41033. * @returns the list of intersecting sub meshes
  41034. */
  41035. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41036. /**
  41037. * Return the list of sub meshes colliding with a collider
  41038. * @param mesh defines the mesh to find the submesh for
  41039. * @param collider defines the collider to evaluate the collision against
  41040. * @returns the list of colliding sub meshes
  41041. */
  41042. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41043. /**
  41044. * Rebuilds the elements related to this component in case of
  41045. * context lost for instance.
  41046. */
  41047. rebuild(): void;
  41048. /**
  41049. * Disposes the component and the associated ressources.
  41050. */
  41051. dispose(): void;
  41052. }
  41053. }
  41054. declare module BABYLON {
  41055. /**
  41056. * Renders a layer on top of an existing scene
  41057. */
  41058. export class UtilityLayerRenderer implements IDisposable {
  41059. /** the original scene that will be rendered on top of */
  41060. originalScene: Scene;
  41061. private _pointerCaptures;
  41062. private _lastPointerEvents;
  41063. private static _DefaultUtilityLayer;
  41064. private static _DefaultKeepDepthUtilityLayer;
  41065. private _sharedGizmoLight;
  41066. private _renderCamera;
  41067. /**
  41068. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41069. * @returns the camera that is used when rendering the utility layer
  41070. */
  41071. getRenderCamera(): Nullable<Camera>;
  41072. /**
  41073. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41074. * @param cam the camera that should be used when rendering the utility layer
  41075. */
  41076. setRenderCamera(cam: Nullable<Camera>): void;
  41077. /**
  41078. * @hidden
  41079. * Light which used by gizmos to get light shading
  41080. */
  41081. _getSharedGizmoLight(): HemisphericLight;
  41082. /**
  41083. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41084. */
  41085. pickUtilitySceneFirst: boolean;
  41086. /**
  41087. * 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)
  41088. */
  41089. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41090. /**
  41091. * 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)
  41092. */
  41093. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41094. /**
  41095. * The scene that is rendered on top of the original scene
  41096. */
  41097. utilityLayerScene: Scene;
  41098. /**
  41099. * If the utility layer should automatically be rendered on top of existing scene
  41100. */
  41101. shouldRender: boolean;
  41102. /**
  41103. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41104. */
  41105. onlyCheckPointerDownEvents: boolean;
  41106. /**
  41107. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41108. */
  41109. processAllEvents: boolean;
  41110. /**
  41111. * Observable raised when the pointer move from the utility layer scene to the main scene
  41112. */
  41113. onPointerOutObservable: Observable<number>;
  41114. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41115. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41116. private _afterRenderObserver;
  41117. private _sceneDisposeObserver;
  41118. private _originalPointerObserver;
  41119. /**
  41120. * Instantiates a UtilityLayerRenderer
  41121. * @param originalScene the original scene that will be rendered on top of
  41122. * @param handleEvents boolean indicating if the utility layer should handle events
  41123. */
  41124. constructor(
  41125. /** the original scene that will be rendered on top of */
  41126. originalScene: Scene, handleEvents?: boolean);
  41127. private _notifyObservers;
  41128. /**
  41129. * Renders the utility layers scene on top of the original scene
  41130. */
  41131. render(): void;
  41132. /**
  41133. * Disposes of the renderer
  41134. */
  41135. dispose(): void;
  41136. private _updateCamera;
  41137. }
  41138. }
  41139. declare module BABYLON {
  41140. /**
  41141. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41142. */
  41143. export class Gizmo implements IDisposable {
  41144. /** The utility layer the gizmo will be added to */
  41145. gizmoLayer: UtilityLayerRenderer;
  41146. /**
  41147. * The root mesh of the gizmo
  41148. */
  41149. _rootMesh: Mesh;
  41150. private _attachedMesh;
  41151. /**
  41152. * Ratio for the scale of the gizmo (Default: 1)
  41153. */
  41154. scaleRatio: number;
  41155. /**
  41156. * If a custom mesh has been set (Default: false)
  41157. */
  41158. protected _customMeshSet: boolean;
  41159. /**
  41160. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41161. * * When set, interactions will be enabled
  41162. */
  41163. attachedMesh: Nullable<AbstractMesh>;
  41164. /**
  41165. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41166. * @param mesh The mesh to replace the default mesh of the gizmo
  41167. */
  41168. setCustomMesh(mesh: Mesh): void;
  41169. /**
  41170. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41171. */
  41172. updateGizmoRotationToMatchAttachedMesh: boolean;
  41173. /**
  41174. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41175. */
  41176. updateGizmoPositionToMatchAttachedMesh: boolean;
  41177. /**
  41178. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41179. */
  41180. protected _updateScale: boolean;
  41181. protected _interactionsEnabled: boolean;
  41182. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41183. private _beforeRenderObserver;
  41184. private _tempVector;
  41185. /**
  41186. * Creates a gizmo
  41187. * @param gizmoLayer The utility layer the gizmo will be added to
  41188. */
  41189. constructor(
  41190. /** The utility layer the gizmo will be added to */
  41191. gizmoLayer?: UtilityLayerRenderer);
  41192. /**
  41193. * Updates the gizmo to match the attached mesh's position/rotation
  41194. */
  41195. protected _update(): void;
  41196. /**
  41197. * Disposes of the gizmo
  41198. */
  41199. dispose(): void;
  41200. }
  41201. }
  41202. declare module BABYLON {
  41203. /**
  41204. * Single plane drag gizmo
  41205. */
  41206. export class PlaneDragGizmo extends Gizmo {
  41207. /**
  41208. * Drag behavior responsible for the gizmos dragging interactions
  41209. */
  41210. dragBehavior: PointerDragBehavior;
  41211. private _pointerObserver;
  41212. /**
  41213. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41214. */
  41215. snapDistance: number;
  41216. /**
  41217. * Event that fires each time the gizmo snaps to a new location.
  41218. * * snapDistance is the the change in distance
  41219. */
  41220. onSnapObservable: Observable<{
  41221. snapDistance: number;
  41222. }>;
  41223. private _plane;
  41224. private _coloredMaterial;
  41225. private _hoverMaterial;
  41226. private _isEnabled;
  41227. private _parent;
  41228. /** @hidden */
  41229. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41230. /** @hidden */
  41231. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41232. /**
  41233. * Creates a PlaneDragGizmo
  41234. * @param gizmoLayer The utility layer the gizmo will be added to
  41235. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41236. * @param color The color of the gizmo
  41237. */
  41238. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41240. /**
  41241. * If the gizmo is enabled
  41242. */
  41243. isEnabled: boolean;
  41244. /**
  41245. * Disposes of the gizmo
  41246. */
  41247. dispose(): void;
  41248. }
  41249. }
  41250. declare module BABYLON {
  41251. /**
  41252. * Gizmo that enables dragging a mesh along 3 axis
  41253. */
  41254. export class PositionGizmo extends Gizmo {
  41255. /**
  41256. * Internal gizmo used for interactions on the x axis
  41257. */
  41258. xGizmo: AxisDragGizmo;
  41259. /**
  41260. * Internal gizmo used for interactions on the y axis
  41261. */
  41262. yGizmo: AxisDragGizmo;
  41263. /**
  41264. * Internal gizmo used for interactions on the z axis
  41265. */
  41266. zGizmo: AxisDragGizmo;
  41267. /**
  41268. * Internal gizmo used for interactions on the yz plane
  41269. */
  41270. xPlaneGizmo: PlaneDragGizmo;
  41271. /**
  41272. * Internal gizmo used for interactions on the xz plane
  41273. */
  41274. yPlaneGizmo: PlaneDragGizmo;
  41275. /**
  41276. * Internal gizmo used for interactions on the xy plane
  41277. */
  41278. zPlaneGizmo: PlaneDragGizmo;
  41279. /**
  41280. * private variables
  41281. */
  41282. private _meshAttached;
  41283. private _updateGizmoRotationToMatchAttachedMesh;
  41284. private _snapDistance;
  41285. private _scaleRatio;
  41286. /** Fires an event when any of it's sub gizmos are dragged */
  41287. onDragStartObservable: Observable<unknown>;
  41288. /** Fires an event when any of it's sub gizmos are released from dragging */
  41289. onDragEndObservable: Observable<unknown>;
  41290. /**
  41291. * If set to true, planar drag is enabled
  41292. */
  41293. private _planarGizmoEnabled;
  41294. attachedMesh: Nullable<AbstractMesh>;
  41295. /**
  41296. * Creates a PositionGizmo
  41297. * @param gizmoLayer The utility layer the gizmo will be added to
  41298. */
  41299. constructor(gizmoLayer?: UtilityLayerRenderer);
  41300. /**
  41301. * If the planar drag gizmo is enabled
  41302. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41303. */
  41304. planarGizmoEnabled: boolean;
  41305. updateGizmoRotationToMatchAttachedMesh: boolean;
  41306. /**
  41307. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41308. */
  41309. snapDistance: number;
  41310. /**
  41311. * Ratio for the scale of the gizmo (Default: 1)
  41312. */
  41313. scaleRatio: number;
  41314. /**
  41315. * Disposes of the gizmo
  41316. */
  41317. dispose(): void;
  41318. /**
  41319. * CustomMeshes are not supported by this gizmo
  41320. * @param mesh The mesh to replace the default mesh of the gizmo
  41321. */
  41322. setCustomMesh(mesh: Mesh): void;
  41323. }
  41324. }
  41325. declare module BABYLON {
  41326. /**
  41327. * Single axis drag gizmo
  41328. */
  41329. export class AxisDragGizmo extends Gizmo {
  41330. /**
  41331. * Drag behavior responsible for the gizmos dragging interactions
  41332. */
  41333. dragBehavior: PointerDragBehavior;
  41334. private _pointerObserver;
  41335. /**
  41336. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41337. */
  41338. snapDistance: number;
  41339. /**
  41340. * Event that fires each time the gizmo snaps to a new location.
  41341. * * snapDistance is the the change in distance
  41342. */
  41343. onSnapObservable: Observable<{
  41344. snapDistance: number;
  41345. }>;
  41346. private _isEnabled;
  41347. private _parent;
  41348. private _arrow;
  41349. private _coloredMaterial;
  41350. private _hoverMaterial;
  41351. /** @hidden */
  41352. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41353. /** @hidden */
  41354. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41355. /**
  41356. * Creates an AxisDragGizmo
  41357. * @param gizmoLayer The utility layer the gizmo will be added to
  41358. * @param dragAxis The axis which the gizmo will be able to drag on
  41359. * @param color The color of the gizmo
  41360. */
  41361. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41363. /**
  41364. * If the gizmo is enabled
  41365. */
  41366. isEnabled: boolean;
  41367. /**
  41368. * Disposes of the gizmo
  41369. */
  41370. dispose(): void;
  41371. }
  41372. }
  41373. declare module BABYLON.Debug {
  41374. /**
  41375. * The Axes viewer will show 3 axes in a specific point in space
  41376. */
  41377. export class AxesViewer {
  41378. private _xAxis;
  41379. private _yAxis;
  41380. private _zAxis;
  41381. private _scaleLinesFactor;
  41382. private _instanced;
  41383. /**
  41384. * Gets the hosting scene
  41385. */
  41386. scene: Scene;
  41387. /**
  41388. * Gets or sets a number used to scale line length
  41389. */
  41390. scaleLines: number;
  41391. /** Gets the node hierarchy used to render x-axis */
  41392. readonly xAxis: TransformNode;
  41393. /** Gets the node hierarchy used to render y-axis */
  41394. readonly yAxis: TransformNode;
  41395. /** Gets the node hierarchy used to render z-axis */
  41396. readonly zAxis: TransformNode;
  41397. /**
  41398. * Creates a new AxesViewer
  41399. * @param scene defines the hosting scene
  41400. * @param scaleLines defines a number used to scale line length (1 by default)
  41401. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41402. * @param xAxis defines the node hierarchy used to render the x-axis
  41403. * @param yAxis defines the node hierarchy used to render the y-axis
  41404. * @param zAxis defines the node hierarchy used to render the z-axis
  41405. */
  41406. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41407. /**
  41408. * Force the viewer to update
  41409. * @param position defines the position of the viewer
  41410. * @param xaxis defines the x axis of the viewer
  41411. * @param yaxis defines the y axis of the viewer
  41412. * @param zaxis defines the z axis of the viewer
  41413. */
  41414. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41415. /**
  41416. * Creates an instance of this axes viewer.
  41417. * @returns a new axes viewer with instanced meshes
  41418. */
  41419. createInstance(): AxesViewer;
  41420. /** Releases resources */
  41421. dispose(): void;
  41422. private static _SetRenderingGroupId;
  41423. }
  41424. }
  41425. declare module BABYLON.Debug {
  41426. /**
  41427. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41428. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41429. */
  41430. export class BoneAxesViewer extends AxesViewer {
  41431. /**
  41432. * Gets or sets the target mesh where to display the axes viewer
  41433. */
  41434. mesh: Nullable<Mesh>;
  41435. /**
  41436. * Gets or sets the target bone where to display the axes viewer
  41437. */
  41438. bone: Nullable<Bone>;
  41439. /** Gets current position */
  41440. pos: Vector3;
  41441. /** Gets direction of X axis */
  41442. xaxis: Vector3;
  41443. /** Gets direction of Y axis */
  41444. yaxis: Vector3;
  41445. /** Gets direction of Z axis */
  41446. zaxis: Vector3;
  41447. /**
  41448. * Creates a new BoneAxesViewer
  41449. * @param scene defines the hosting scene
  41450. * @param bone defines the target bone
  41451. * @param mesh defines the target mesh
  41452. * @param scaleLines defines a scaling factor for line length (1 by default)
  41453. */
  41454. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41455. /**
  41456. * Force the viewer to update
  41457. */
  41458. update(): void;
  41459. /** Releases resources */
  41460. dispose(): void;
  41461. }
  41462. }
  41463. declare module BABYLON {
  41464. /**
  41465. * Interface used to define scene explorer extensibility option
  41466. */
  41467. export interface IExplorerExtensibilityOption {
  41468. /**
  41469. * Define the option label
  41470. */
  41471. label: string;
  41472. /**
  41473. * Defines the action to execute on click
  41474. */
  41475. action: (entity: any) => void;
  41476. }
  41477. /**
  41478. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41479. */
  41480. export interface IExplorerExtensibilityGroup {
  41481. /**
  41482. * Defines a predicate to test if a given type mut be extended
  41483. */
  41484. predicate: (entity: any) => boolean;
  41485. /**
  41486. * Gets the list of options added to a type
  41487. */
  41488. entries: IExplorerExtensibilityOption[];
  41489. }
  41490. /**
  41491. * Interface used to define the options to use to create the Inspector
  41492. */
  41493. export interface IInspectorOptions {
  41494. /**
  41495. * Display in overlay mode (default: false)
  41496. */
  41497. overlay?: boolean;
  41498. /**
  41499. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41500. */
  41501. globalRoot?: HTMLElement;
  41502. /**
  41503. * Display the Scene explorer
  41504. */
  41505. showExplorer?: boolean;
  41506. /**
  41507. * Display the property inspector
  41508. */
  41509. showInspector?: boolean;
  41510. /**
  41511. * Display in embed mode (both panes on the right)
  41512. */
  41513. embedMode?: boolean;
  41514. /**
  41515. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41516. */
  41517. handleResize?: boolean;
  41518. /**
  41519. * Allow the panes to popup (default: true)
  41520. */
  41521. enablePopup?: boolean;
  41522. /**
  41523. * Allow the panes to be closed by users (default: true)
  41524. */
  41525. enableClose?: boolean;
  41526. /**
  41527. * Optional list of extensibility entries
  41528. */
  41529. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41530. /**
  41531. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41532. */
  41533. inspectorURL?: string;
  41534. }
  41535. interface Scene {
  41536. /**
  41537. * @hidden
  41538. * Backing field
  41539. */
  41540. _debugLayer: DebugLayer;
  41541. /**
  41542. * Gets the debug layer (aka Inspector) associated with the scene
  41543. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41544. */
  41545. debugLayer: DebugLayer;
  41546. }
  41547. /**
  41548. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41549. * what is happening in your scene
  41550. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41551. */
  41552. export class DebugLayer {
  41553. /**
  41554. * Define the url to get the inspector script from.
  41555. * By default it uses the babylonjs CDN.
  41556. * @ignoreNaming
  41557. */
  41558. static InspectorURL: string;
  41559. private _scene;
  41560. private BJSINSPECTOR;
  41561. /**
  41562. * Observable triggered when a property is changed through the inspector.
  41563. */
  41564. onPropertyChangedObservable: Observable<{
  41565. object: any;
  41566. property: string;
  41567. value: any;
  41568. initialValue: any;
  41569. }>;
  41570. /**
  41571. * Instantiates a new debug layer.
  41572. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41573. * what is happening in your scene
  41574. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41575. * @param scene Defines the scene to inspect
  41576. */
  41577. constructor(scene: Scene);
  41578. /** Creates the inspector window. */
  41579. private _createInspector;
  41580. /**
  41581. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41582. * @param entity defines the entity to select
  41583. * @param lineContainerTitle defines the specific block to highlight
  41584. */
  41585. select(entity: any, lineContainerTitle?: string): void;
  41586. /** Get the inspector from bundle or global */
  41587. private _getGlobalInspector;
  41588. /**
  41589. * Get if the inspector is visible or not.
  41590. * @returns true if visible otherwise, false
  41591. */
  41592. isVisible(): boolean;
  41593. /**
  41594. * Hide the inspector and close its window.
  41595. */
  41596. hide(): void;
  41597. /**
  41598. * Launch the debugLayer.
  41599. * @param config Define the configuration of the inspector
  41600. * @return a promise fulfilled when the debug layer is visible
  41601. */
  41602. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41603. }
  41604. }
  41605. declare module BABYLON {
  41606. /**
  41607. * Class containing static functions to help procedurally build meshes
  41608. */
  41609. export class BoxBuilder {
  41610. /**
  41611. * Creates a box mesh
  41612. * * The parameter `size` sets the size (float) of each box side (default 1)
  41613. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41614. * * 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)
  41615. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41617. * * 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
  41618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41619. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41620. * @param name defines the name of the mesh
  41621. * @param options defines the options used to create the mesh
  41622. * @param scene defines the hosting scene
  41623. * @returns the box mesh
  41624. */
  41625. static CreateBox(name: string, options: {
  41626. size?: number;
  41627. width?: number;
  41628. height?: number;
  41629. depth?: number;
  41630. faceUV?: Vector4[];
  41631. faceColors?: Color4[];
  41632. sideOrientation?: number;
  41633. frontUVs?: Vector4;
  41634. backUVs?: Vector4;
  41635. wrap?: boolean;
  41636. topBaseAt?: number;
  41637. bottomBaseAt?: number;
  41638. updatable?: boolean;
  41639. }, scene?: Nullable<Scene>): Mesh;
  41640. }
  41641. }
  41642. declare module BABYLON {
  41643. /**
  41644. * Class containing static functions to help procedurally build meshes
  41645. */
  41646. export class SphereBuilder {
  41647. /**
  41648. * Creates a sphere mesh
  41649. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41650. * * 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`)
  41651. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41652. * * 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
  41653. * * 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)
  41654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41655. * * 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
  41656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41657. * @param name defines the name of the mesh
  41658. * @param options defines the options used to create the mesh
  41659. * @param scene defines the hosting scene
  41660. * @returns the sphere mesh
  41661. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41662. */
  41663. static CreateSphere(name: string, options: {
  41664. segments?: number;
  41665. diameter?: number;
  41666. diameterX?: number;
  41667. diameterY?: number;
  41668. diameterZ?: number;
  41669. arc?: number;
  41670. slice?: number;
  41671. sideOrientation?: number;
  41672. frontUVs?: Vector4;
  41673. backUVs?: Vector4;
  41674. updatable?: boolean;
  41675. }, scene: any): Mesh;
  41676. }
  41677. }
  41678. declare module BABYLON.Debug {
  41679. /**
  41680. * Used to show the physics impostor around the specific mesh
  41681. */
  41682. export class PhysicsViewer {
  41683. /** @hidden */
  41684. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41685. /** @hidden */
  41686. protected _meshes: Array<Nullable<AbstractMesh>>;
  41687. /** @hidden */
  41688. protected _scene: Nullable<Scene>;
  41689. /** @hidden */
  41690. protected _numMeshes: number;
  41691. /** @hidden */
  41692. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41693. private _renderFunction;
  41694. private _utilityLayer;
  41695. private _debugBoxMesh;
  41696. private _debugSphereMesh;
  41697. private _debugCylinderMesh;
  41698. private _debugMaterial;
  41699. private _debugMeshMeshes;
  41700. /**
  41701. * Creates a new PhysicsViewer
  41702. * @param scene defines the hosting scene
  41703. */
  41704. constructor(scene: Scene);
  41705. /** @hidden */
  41706. protected _updateDebugMeshes(): void;
  41707. /**
  41708. * Renders a specified physic impostor
  41709. * @param impostor defines the impostor to render
  41710. * @param targetMesh defines the mesh represented by the impostor
  41711. * @returns the new debug mesh used to render the impostor
  41712. */
  41713. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41714. /**
  41715. * Hides a specified physic impostor
  41716. * @param impostor defines the impostor to hide
  41717. */
  41718. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41719. private _getDebugMaterial;
  41720. private _getDebugBoxMesh;
  41721. private _getDebugSphereMesh;
  41722. private _getDebugCylinderMesh;
  41723. private _getDebugMeshMesh;
  41724. private _getDebugMesh;
  41725. /** Releases all resources */
  41726. dispose(): void;
  41727. }
  41728. }
  41729. declare module BABYLON {
  41730. /**
  41731. * Class containing static functions to help procedurally build meshes
  41732. */
  41733. export class LinesBuilder {
  41734. /**
  41735. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41736. * * 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
  41737. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41738. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41739. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41740. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41741. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41742. * * 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
  41743. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41746. * @param name defines the name of the new line system
  41747. * @param options defines the options used to create the line system
  41748. * @param scene defines the hosting scene
  41749. * @returns a new line system mesh
  41750. */
  41751. static CreateLineSystem(name: string, options: {
  41752. lines: Vector3[][];
  41753. updatable?: boolean;
  41754. instance?: Nullable<LinesMesh>;
  41755. colors?: Nullable<Color4[][]>;
  41756. useVertexAlpha?: boolean;
  41757. }, scene: Nullable<Scene>): LinesMesh;
  41758. /**
  41759. * Creates a line mesh
  41760. * 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
  41761. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41762. * * The parameter `points` is an array successive Vector3
  41763. * * 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
  41764. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41765. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41766. * * When updating an instance, remember that only point positions can change, not the number of points
  41767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41769. * @param name defines the name of the new line system
  41770. * @param options defines the options used to create the line system
  41771. * @param scene defines the hosting scene
  41772. * @returns a new line mesh
  41773. */
  41774. static CreateLines(name: string, options: {
  41775. points: Vector3[];
  41776. updatable?: boolean;
  41777. instance?: Nullable<LinesMesh>;
  41778. colors?: Color4[];
  41779. useVertexAlpha?: boolean;
  41780. }, scene?: Nullable<Scene>): LinesMesh;
  41781. /**
  41782. * Creates a dashed line mesh
  41783. * * 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
  41784. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41785. * * The parameter `points` is an array successive Vector3
  41786. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41787. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41788. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41789. * * 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
  41790. * * When updating an instance, remember that only point positions can change, not the number of points
  41791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41792. * @param name defines the name of the mesh
  41793. * @param options defines the options used to create the mesh
  41794. * @param scene defines the hosting scene
  41795. * @returns the dashed line mesh
  41796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41797. */
  41798. static CreateDashedLines(name: string, options: {
  41799. points: Vector3[];
  41800. dashSize?: number;
  41801. gapSize?: number;
  41802. dashNb?: number;
  41803. updatable?: boolean;
  41804. instance?: LinesMesh;
  41805. }, scene?: Nullable<Scene>): LinesMesh;
  41806. }
  41807. }
  41808. declare module BABYLON {
  41809. /**
  41810. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41811. * in order to better appreciate the issue one might have.
  41812. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41813. */
  41814. export class RayHelper {
  41815. /**
  41816. * Defines the ray we are currently tryin to visualize.
  41817. */
  41818. ray: Nullable<Ray>;
  41819. private _renderPoints;
  41820. private _renderLine;
  41821. private _renderFunction;
  41822. private _scene;
  41823. private _updateToMeshFunction;
  41824. private _attachedToMesh;
  41825. private _meshSpaceDirection;
  41826. private _meshSpaceOrigin;
  41827. /**
  41828. * Helper function to create a colored helper in a scene in one line.
  41829. * @param ray Defines the ray we are currently tryin to visualize
  41830. * @param scene Defines the scene the ray is used in
  41831. * @param color Defines the color we want to see the ray in
  41832. * @returns The newly created ray helper.
  41833. */
  41834. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41835. /**
  41836. * Instantiate a new ray helper.
  41837. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41838. * in order to better appreciate the issue one might have.
  41839. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41840. * @param ray Defines the ray we are currently tryin to visualize
  41841. */
  41842. constructor(ray: Ray);
  41843. /**
  41844. * Shows the ray we are willing to debug.
  41845. * @param scene Defines the scene the ray needs to be rendered in
  41846. * @param color Defines the color the ray needs to be rendered in
  41847. */
  41848. show(scene: Scene, color?: Color3): void;
  41849. /**
  41850. * Hides the ray we are debugging.
  41851. */
  41852. hide(): void;
  41853. private _render;
  41854. /**
  41855. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41856. * @param mesh Defines the mesh we want the helper attached to
  41857. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41858. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41859. * @param length Defines the length of the ray
  41860. */
  41861. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41862. /**
  41863. * Detach the ray helper from the mesh it has previously been attached to.
  41864. */
  41865. detachFromMesh(): void;
  41866. private _updateToMesh;
  41867. /**
  41868. * Dispose the helper and release its associated resources.
  41869. */
  41870. dispose(): void;
  41871. }
  41872. }
  41873. declare module BABYLON.Debug {
  41874. /**
  41875. * Class used to render a debug view of a given skeleton
  41876. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41877. */
  41878. export class SkeletonViewer {
  41879. /** defines the skeleton to render */
  41880. skeleton: Skeleton;
  41881. /** defines the mesh attached to the skeleton */
  41882. mesh: AbstractMesh;
  41883. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41884. autoUpdateBonesMatrices: boolean;
  41885. /** defines the rendering group id to use with the viewer */
  41886. renderingGroupId: number;
  41887. /** Gets or sets the color used to render the skeleton */
  41888. color: Color3;
  41889. private _scene;
  41890. private _debugLines;
  41891. private _debugMesh;
  41892. private _isEnabled;
  41893. private _renderFunction;
  41894. private _utilityLayer;
  41895. /**
  41896. * Returns the mesh used to render the bones
  41897. */
  41898. readonly debugMesh: Nullable<LinesMesh>;
  41899. /**
  41900. * Creates a new SkeletonViewer
  41901. * @param skeleton defines the skeleton to render
  41902. * @param mesh defines the mesh attached to the skeleton
  41903. * @param scene defines the hosting scene
  41904. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41905. * @param renderingGroupId defines the rendering group id to use with the viewer
  41906. */
  41907. constructor(
  41908. /** defines the skeleton to render */
  41909. skeleton: Skeleton,
  41910. /** defines the mesh attached to the skeleton */
  41911. mesh: AbstractMesh, scene: Scene,
  41912. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41913. autoUpdateBonesMatrices?: boolean,
  41914. /** defines the rendering group id to use with the viewer */
  41915. renderingGroupId?: number);
  41916. /** Gets or sets a boolean indicating if the viewer is enabled */
  41917. isEnabled: boolean;
  41918. private _getBonePosition;
  41919. private _getLinesForBonesWithLength;
  41920. private _getLinesForBonesNoLength;
  41921. /** Update the viewer to sync with current skeleton state */
  41922. update(): void;
  41923. /** Release associated resources */
  41924. dispose(): void;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * Options to create the null engine
  41930. */
  41931. export class NullEngineOptions {
  41932. /**
  41933. * Render width (Default: 512)
  41934. */
  41935. renderWidth: number;
  41936. /**
  41937. * Render height (Default: 256)
  41938. */
  41939. renderHeight: number;
  41940. /**
  41941. * Texture size (Default: 512)
  41942. */
  41943. textureSize: number;
  41944. /**
  41945. * If delta time between frames should be constant
  41946. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41947. */
  41948. deterministicLockstep: boolean;
  41949. /**
  41950. * Maximum about of steps between frames (Default: 4)
  41951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41952. */
  41953. lockstepMaxSteps: number;
  41954. }
  41955. /**
  41956. * The null engine class provides support for headless version of babylon.js.
  41957. * This can be used in server side scenario or for testing purposes
  41958. */
  41959. export class NullEngine extends Engine {
  41960. private _options;
  41961. /**
  41962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41963. */
  41964. isDeterministicLockStep(): boolean;
  41965. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41966. getLockstepMaxSteps(): number;
  41967. /**
  41968. * Sets hardware scaling, used to save performance if needed
  41969. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41970. */
  41971. getHardwareScalingLevel(): number;
  41972. constructor(options?: NullEngineOptions);
  41973. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41974. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41975. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41976. getRenderWidth(useScreen?: boolean): number;
  41977. getRenderHeight(useScreen?: boolean): number;
  41978. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41979. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41980. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41981. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41982. bindSamplers(effect: Effect): void;
  41983. enableEffect(effect: Effect): void;
  41984. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41985. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41986. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41987. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41988. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41989. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41990. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41991. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41992. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41993. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41994. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41995. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41996. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41997. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41998. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41999. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42000. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42001. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42002. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42003. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42004. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42005. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42006. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42007. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42008. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42009. bindBuffers(vertexBuffers: {
  42010. [key: string]: VertexBuffer;
  42011. }, indexBuffer: DataBuffer, effect: Effect): void;
  42012. wipeCaches(bruteForce?: boolean): void;
  42013. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42014. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42015. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42016. /** @hidden */
  42017. _createTexture(): WebGLTexture;
  42018. /** @hidden */
  42019. _releaseTexture(texture: InternalTexture): void;
  42020. 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;
  42021. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42022. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42023. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42024. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42025. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42026. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42027. areAllEffectsReady(): boolean;
  42028. /**
  42029. * @hidden
  42030. * Get the current error code of the webGL context
  42031. * @returns the error code
  42032. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42033. */
  42034. getError(): number;
  42035. /** @hidden */
  42036. _getUnpackAlignement(): number;
  42037. /** @hidden */
  42038. _unpackFlipY(value: boolean): void;
  42039. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42040. /**
  42041. * Updates a dynamic vertex buffer.
  42042. * @param vertexBuffer the vertex buffer to update
  42043. * @param data the data used to update the vertex buffer
  42044. * @param byteOffset the byte offset of the data (optional)
  42045. * @param byteLength the byte length of the data (optional)
  42046. */
  42047. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42048. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42049. /** @hidden */
  42050. _bindTexture(channel: number, texture: InternalTexture): void;
  42051. /** @hidden */
  42052. _releaseBuffer(buffer: DataBuffer): boolean;
  42053. releaseEffects(): void;
  42054. displayLoadingUI(): void;
  42055. hideLoadingUI(): void;
  42056. /** @hidden */
  42057. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42058. /** @hidden */
  42059. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42060. /** @hidden */
  42061. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42062. /** @hidden */
  42063. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42064. }
  42065. }
  42066. declare module BABYLON {
  42067. /** @hidden */
  42068. export class _OcclusionDataStorage {
  42069. /** @hidden */
  42070. occlusionInternalRetryCounter: number;
  42071. /** @hidden */
  42072. isOcclusionQueryInProgress: boolean;
  42073. /** @hidden */
  42074. isOccluded: boolean;
  42075. /** @hidden */
  42076. occlusionRetryCount: number;
  42077. /** @hidden */
  42078. occlusionType: number;
  42079. /** @hidden */
  42080. occlusionQueryAlgorithmType: number;
  42081. }
  42082. interface Engine {
  42083. /**
  42084. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42085. * @return the new query
  42086. */
  42087. createQuery(): WebGLQuery;
  42088. /**
  42089. * Delete and release a webGL query
  42090. * @param query defines the query to delete
  42091. * @return the current engine
  42092. */
  42093. deleteQuery(query: WebGLQuery): Engine;
  42094. /**
  42095. * Check if a given query has resolved and got its value
  42096. * @param query defines the query to check
  42097. * @returns true if the query got its value
  42098. */
  42099. isQueryResultAvailable(query: WebGLQuery): boolean;
  42100. /**
  42101. * Gets the value of a given query
  42102. * @param query defines the query to check
  42103. * @returns the value of the query
  42104. */
  42105. getQueryResult(query: WebGLQuery): number;
  42106. /**
  42107. * Initiates an occlusion query
  42108. * @param algorithmType defines the algorithm to use
  42109. * @param query defines the query to use
  42110. * @returns the current engine
  42111. * @see http://doc.babylonjs.com/features/occlusionquery
  42112. */
  42113. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42114. /**
  42115. * Ends an occlusion query
  42116. * @see http://doc.babylonjs.com/features/occlusionquery
  42117. * @param algorithmType defines the algorithm to use
  42118. * @returns the current engine
  42119. */
  42120. endOcclusionQuery(algorithmType: number): Engine;
  42121. /**
  42122. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42123. * Please note that only one query can be issued at a time
  42124. * @returns a time token used to track the time span
  42125. */
  42126. startTimeQuery(): Nullable<_TimeToken>;
  42127. /**
  42128. * Ends a time query
  42129. * @param token defines the token used to measure the time span
  42130. * @returns the time spent (in ns)
  42131. */
  42132. endTimeQuery(token: _TimeToken): int;
  42133. /** @hidden */
  42134. _currentNonTimestampToken: Nullable<_TimeToken>;
  42135. /** @hidden */
  42136. _createTimeQuery(): WebGLQuery;
  42137. /** @hidden */
  42138. _deleteTimeQuery(query: WebGLQuery): void;
  42139. /** @hidden */
  42140. _getGlAlgorithmType(algorithmType: number): number;
  42141. /** @hidden */
  42142. _getTimeQueryResult(query: WebGLQuery): any;
  42143. /** @hidden */
  42144. _getTimeQueryAvailability(query: WebGLQuery): any;
  42145. }
  42146. interface AbstractMesh {
  42147. /**
  42148. * Backing filed
  42149. * @hidden
  42150. */
  42151. __occlusionDataStorage: _OcclusionDataStorage;
  42152. /**
  42153. * Access property
  42154. * @hidden
  42155. */
  42156. _occlusionDataStorage: _OcclusionDataStorage;
  42157. /**
  42158. * 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.
  42159. * The default value is -1 which means don't break the query and wait till the result
  42160. * @see http://doc.babylonjs.com/features/occlusionquery
  42161. */
  42162. occlusionRetryCount: number;
  42163. /**
  42164. * 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:
  42165. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42166. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42167. * * 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.
  42168. * @see http://doc.babylonjs.com/features/occlusionquery
  42169. */
  42170. occlusionType: number;
  42171. /**
  42172. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42173. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42174. * * 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.
  42175. * @see http://doc.babylonjs.com/features/occlusionquery
  42176. */
  42177. occlusionQueryAlgorithmType: number;
  42178. /**
  42179. * 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
  42180. * @see http://doc.babylonjs.com/features/occlusionquery
  42181. */
  42182. isOccluded: boolean;
  42183. /**
  42184. * Flag to check the progress status of the query
  42185. * @see http://doc.babylonjs.com/features/occlusionquery
  42186. */
  42187. isOcclusionQueryInProgress: boolean;
  42188. }
  42189. }
  42190. declare module BABYLON {
  42191. /** @hidden */
  42192. export var _forceTransformFeedbackToBundle: boolean;
  42193. interface Engine {
  42194. /**
  42195. * Creates a webGL transform feedback object
  42196. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42197. * @returns the webGL transform feedback object
  42198. */
  42199. createTransformFeedback(): WebGLTransformFeedback;
  42200. /**
  42201. * Delete a webGL transform feedback object
  42202. * @param value defines the webGL transform feedback object to delete
  42203. */
  42204. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42205. /**
  42206. * Bind a webGL transform feedback object to the webgl context
  42207. * @param value defines the webGL transform feedback object to bind
  42208. */
  42209. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42210. /**
  42211. * Begins a transform feedback operation
  42212. * @param usePoints defines if points or triangles must be used
  42213. */
  42214. beginTransformFeedback(usePoints: boolean): void;
  42215. /**
  42216. * Ends a transform feedback operation
  42217. */
  42218. endTransformFeedback(): void;
  42219. /**
  42220. * Specify the varyings to use with transform feedback
  42221. * @param program defines the associated webGL program
  42222. * @param value defines the list of strings representing the varying names
  42223. */
  42224. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42225. /**
  42226. * Bind a webGL buffer for a transform feedback operation
  42227. * @param value defines the webGL buffer to bind
  42228. */
  42229. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42230. }
  42231. }
  42232. declare module BABYLON {
  42233. /**
  42234. * Creation options of the multi render target texture.
  42235. */
  42236. export interface IMultiRenderTargetOptions {
  42237. /**
  42238. * Define if the texture needs to create mip maps after render.
  42239. */
  42240. generateMipMaps?: boolean;
  42241. /**
  42242. * Define the types of all the draw buffers we want to create
  42243. */
  42244. types?: number[];
  42245. /**
  42246. * Define the sampling modes of all the draw buffers we want to create
  42247. */
  42248. samplingModes?: number[];
  42249. /**
  42250. * Define if a depth buffer is required
  42251. */
  42252. generateDepthBuffer?: boolean;
  42253. /**
  42254. * Define if a stencil buffer is required
  42255. */
  42256. generateStencilBuffer?: boolean;
  42257. /**
  42258. * Define if a depth texture is required instead of a depth buffer
  42259. */
  42260. generateDepthTexture?: boolean;
  42261. /**
  42262. * Define the number of desired draw buffers
  42263. */
  42264. textureCount?: number;
  42265. /**
  42266. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42267. */
  42268. doNotChangeAspectRatio?: boolean;
  42269. /**
  42270. * Define the default type of the buffers we are creating
  42271. */
  42272. defaultType?: number;
  42273. }
  42274. /**
  42275. * A multi render target, like a render target provides the ability to render to a texture.
  42276. * Unlike the render target, it can render to several draw buffers in one draw.
  42277. * This is specially interesting in deferred rendering or for any effects requiring more than
  42278. * just one color from a single pass.
  42279. */
  42280. export class MultiRenderTarget extends RenderTargetTexture {
  42281. private _internalTextures;
  42282. private _textures;
  42283. private _multiRenderTargetOptions;
  42284. /**
  42285. * Get if draw buffers are currently supported by the used hardware and browser.
  42286. */
  42287. readonly isSupported: boolean;
  42288. /**
  42289. * Get the list of textures generated by the multi render target.
  42290. */
  42291. readonly textures: Texture[];
  42292. /**
  42293. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42294. */
  42295. readonly depthTexture: Texture;
  42296. /**
  42297. * Set the wrapping mode on U of all the textures we are rendering to.
  42298. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42299. */
  42300. wrapU: number;
  42301. /**
  42302. * Set the wrapping mode on V of all the textures we are rendering to.
  42303. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42304. */
  42305. wrapV: number;
  42306. /**
  42307. * Instantiate a new multi render target texture.
  42308. * A multi render target, like a render target provides the ability to render to a texture.
  42309. * Unlike the render target, it can render to several draw buffers in one draw.
  42310. * This is specially interesting in deferred rendering or for any effects requiring more than
  42311. * just one color from a single pass.
  42312. * @param name Define the name of the texture
  42313. * @param size Define the size of the buffers to render to
  42314. * @param count Define the number of target we are rendering into
  42315. * @param scene Define the scene the texture belongs to
  42316. * @param options Define the options used to create the multi render target
  42317. */
  42318. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42319. /** @hidden */
  42320. _rebuild(): void;
  42321. private _createInternalTextures;
  42322. private _createTextures;
  42323. /**
  42324. * Define the number of samples used if MSAA is enabled.
  42325. */
  42326. samples: number;
  42327. /**
  42328. * Resize all the textures in the multi render target.
  42329. * Be carrefull as it will recreate all the data in the new texture.
  42330. * @param size Define the new size
  42331. */
  42332. resize(size: any): void;
  42333. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42334. /**
  42335. * Dispose the render targets and their associated resources
  42336. */
  42337. dispose(): void;
  42338. /**
  42339. * Release all the underlying texture used as draw buffers.
  42340. */
  42341. releaseInternalTextures(): void;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. interface Engine {
  42346. /**
  42347. * Unbind a list of render target textures from the webGL context
  42348. * This is used only when drawBuffer extension or webGL2 are active
  42349. * @param textures defines the render target textures to unbind
  42350. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42351. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42352. */
  42353. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42354. /**
  42355. * Create a multi render target texture
  42356. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42357. * @param size defines the size of the texture
  42358. * @param options defines the creation options
  42359. * @returns the cube texture as an InternalTexture
  42360. */
  42361. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42362. /**
  42363. * Update the sample count for a given multiple render target texture
  42364. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42365. * @param textures defines the textures to update
  42366. * @param samples defines the sample count to set
  42367. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42368. */
  42369. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /**
  42374. * Gather the list of clipboard event types as constants.
  42375. */
  42376. export class ClipboardEventTypes {
  42377. /**
  42378. * The clipboard event is fired when a copy command is active (pressed).
  42379. */
  42380. static readonly COPY: number;
  42381. /**
  42382. * The clipboard event is fired when a cut command is active (pressed).
  42383. */
  42384. static readonly CUT: number;
  42385. /**
  42386. * The clipboard event is fired when a paste command is active (pressed).
  42387. */
  42388. static readonly PASTE: number;
  42389. }
  42390. /**
  42391. * This class is used to store clipboard related info for the onClipboardObservable event.
  42392. */
  42393. export class ClipboardInfo {
  42394. /**
  42395. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42396. */
  42397. type: number;
  42398. /**
  42399. * Defines the related dom event
  42400. */
  42401. event: ClipboardEvent;
  42402. /**
  42403. *Creates an instance of ClipboardInfo.
  42404. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42405. * @param event Defines the related dom event
  42406. */
  42407. constructor(
  42408. /**
  42409. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42410. */
  42411. type: number,
  42412. /**
  42413. * Defines the related dom event
  42414. */
  42415. event: ClipboardEvent);
  42416. /**
  42417. * Get the clipboard event's type from the keycode.
  42418. * @param keyCode Defines the keyCode for the current keyboard event.
  42419. * @return {number}
  42420. */
  42421. static GetTypeFromCharacter(keyCode: number): number;
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /**
  42426. * Class used to represent data loading progression
  42427. */
  42428. export class SceneLoaderProgressEvent {
  42429. /** defines if data length to load can be evaluated */
  42430. readonly lengthComputable: boolean;
  42431. /** defines the loaded data length */
  42432. readonly loaded: number;
  42433. /** defines the data length to load */
  42434. readonly total: number;
  42435. /**
  42436. * Create a new progress event
  42437. * @param lengthComputable defines if data length to load can be evaluated
  42438. * @param loaded defines the loaded data length
  42439. * @param total defines the data length to load
  42440. */
  42441. constructor(
  42442. /** defines if data length to load can be evaluated */
  42443. lengthComputable: boolean,
  42444. /** defines the loaded data length */
  42445. loaded: number,
  42446. /** defines the data length to load */
  42447. total: number);
  42448. /**
  42449. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42450. * @param event defines the source event
  42451. * @returns a new SceneLoaderProgressEvent
  42452. */
  42453. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42454. }
  42455. /**
  42456. * Interface used by SceneLoader plugins to define supported file extensions
  42457. */
  42458. export interface ISceneLoaderPluginExtensions {
  42459. /**
  42460. * Defines the list of supported extensions
  42461. */
  42462. [extension: string]: {
  42463. isBinary: boolean;
  42464. };
  42465. }
  42466. /**
  42467. * Interface used by SceneLoader plugin factory
  42468. */
  42469. export interface ISceneLoaderPluginFactory {
  42470. /**
  42471. * Defines the name of the factory
  42472. */
  42473. name: string;
  42474. /**
  42475. * Function called to create a new plugin
  42476. * @return the new plugin
  42477. */
  42478. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42479. /**
  42480. * Boolean indicating if the plugin can direct load specific data
  42481. */
  42482. canDirectLoad?: (data: string) => boolean;
  42483. }
  42484. /**
  42485. * Interface used to define a SceneLoader plugin
  42486. */
  42487. export interface ISceneLoaderPlugin {
  42488. /**
  42489. * The friendly name of this plugin.
  42490. */
  42491. name: string;
  42492. /**
  42493. * The file extensions supported by this plugin.
  42494. */
  42495. extensions: string | ISceneLoaderPluginExtensions;
  42496. /**
  42497. * Import meshes into a scene.
  42498. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42499. * @param scene The scene to import into
  42500. * @param data The data to import
  42501. * @param rootUrl The root url for scene and resources
  42502. * @param meshes The meshes array to import into
  42503. * @param particleSystems The particle systems array to import into
  42504. * @param skeletons The skeletons array to import into
  42505. * @param onError The callback when import fails
  42506. * @returns True if successful or false otherwise
  42507. */
  42508. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42509. /**
  42510. * Load into a scene.
  42511. * @param scene The scene to load into
  42512. * @param data The data to import
  42513. * @param rootUrl The root url for scene and resources
  42514. * @param onError The callback when import fails
  42515. * @returns true if successful or false otherwise
  42516. */
  42517. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42518. /**
  42519. * The callback that returns true if the data can be directly loaded.
  42520. */
  42521. canDirectLoad?: (data: string) => boolean;
  42522. /**
  42523. * The callback that allows custom handling of the root url based on the response url.
  42524. */
  42525. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42526. /**
  42527. * Load into an asset container.
  42528. * @param scene The scene to load into
  42529. * @param data The data to import
  42530. * @param rootUrl The root url for scene and resources
  42531. * @param onError The callback when import fails
  42532. * @returns The loaded asset container
  42533. */
  42534. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42535. }
  42536. /**
  42537. * Interface used to define an async SceneLoader plugin
  42538. */
  42539. export interface ISceneLoaderPluginAsync {
  42540. /**
  42541. * The friendly name of this plugin.
  42542. */
  42543. name: string;
  42544. /**
  42545. * The file extensions supported by this plugin.
  42546. */
  42547. extensions: string | ISceneLoaderPluginExtensions;
  42548. /**
  42549. * Import meshes into a scene.
  42550. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42551. * @param scene The scene to import into
  42552. * @param data The data to import
  42553. * @param rootUrl The root url for scene and resources
  42554. * @param onProgress The callback when the load progresses
  42555. * @param fileName Defines the name of the file to load
  42556. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42557. */
  42558. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42559. meshes: AbstractMesh[];
  42560. particleSystems: IParticleSystem[];
  42561. skeletons: Skeleton[];
  42562. animationGroups: AnimationGroup[];
  42563. }>;
  42564. /**
  42565. * Load into a scene.
  42566. * @param scene The scene to load into
  42567. * @param data The data to import
  42568. * @param rootUrl The root url for scene and resources
  42569. * @param onProgress The callback when the load progresses
  42570. * @param fileName Defines the name of the file to load
  42571. * @returns Nothing
  42572. */
  42573. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42574. /**
  42575. * The callback that returns true if the data can be directly loaded.
  42576. */
  42577. canDirectLoad?: (data: string) => boolean;
  42578. /**
  42579. * The callback that allows custom handling of the root url based on the response url.
  42580. */
  42581. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42582. /**
  42583. * Load into an asset container.
  42584. * @param scene The scene to load into
  42585. * @param data The data to import
  42586. * @param rootUrl The root url for scene and resources
  42587. * @param onProgress The callback when the load progresses
  42588. * @param fileName Defines the name of the file to load
  42589. * @returns The loaded asset container
  42590. */
  42591. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42592. }
  42593. /**
  42594. * Class used to load scene from various file formats using registered plugins
  42595. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42596. */
  42597. export class SceneLoader {
  42598. /**
  42599. * No logging while loading
  42600. */
  42601. static readonly NO_LOGGING: number;
  42602. /**
  42603. * Minimal logging while loading
  42604. */
  42605. static readonly MINIMAL_LOGGING: number;
  42606. /**
  42607. * Summary logging while loading
  42608. */
  42609. static readonly SUMMARY_LOGGING: number;
  42610. /**
  42611. * Detailled logging while loading
  42612. */
  42613. static readonly DETAILED_LOGGING: number;
  42614. /**
  42615. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42616. */
  42617. static ForceFullSceneLoadingForIncremental: boolean;
  42618. /**
  42619. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42620. */
  42621. static ShowLoadingScreen: boolean;
  42622. /**
  42623. * Defines the current logging level (while loading the scene)
  42624. * @ignorenaming
  42625. */
  42626. static loggingLevel: number;
  42627. /**
  42628. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42629. */
  42630. static CleanBoneMatrixWeights: boolean;
  42631. /**
  42632. * Event raised when a plugin is used to load a scene
  42633. */
  42634. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42635. private static _registeredPlugins;
  42636. private static _getDefaultPlugin;
  42637. private static _getPluginForExtension;
  42638. private static _getPluginForDirectLoad;
  42639. private static _getPluginForFilename;
  42640. private static _getDirectLoad;
  42641. private static _loadData;
  42642. private static _getFileInfo;
  42643. /**
  42644. * Gets a plugin that can load the given extension
  42645. * @param extension defines the extension to load
  42646. * @returns a plugin or null if none works
  42647. */
  42648. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42649. /**
  42650. * Gets a boolean indicating that the given extension can be loaded
  42651. * @param extension defines the extension to load
  42652. * @returns true if the extension is supported
  42653. */
  42654. static IsPluginForExtensionAvailable(extension: string): boolean;
  42655. /**
  42656. * Adds a new plugin to the list of registered plugins
  42657. * @param plugin defines the plugin to add
  42658. */
  42659. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42660. /**
  42661. * Import meshes into a scene
  42662. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42663. * @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)
  42664. * @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)
  42665. * @param scene the instance of BABYLON.Scene to append to
  42666. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42667. * @param onProgress a callback with a progress event for each file being loaded
  42668. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42669. * @param pluginExtension the extension used to determine the plugin
  42670. * @returns The loaded plugin
  42671. */
  42672. 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>;
  42673. /**
  42674. * Import meshes into a scene
  42675. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42676. * @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)
  42677. * @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)
  42678. * @param scene the instance of BABYLON.Scene to append to
  42679. * @param onProgress a callback with a progress event for each file being loaded
  42680. * @param pluginExtension the extension used to determine the plugin
  42681. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42682. */
  42683. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42684. meshes: AbstractMesh[];
  42685. particleSystems: IParticleSystem[];
  42686. skeletons: Skeleton[];
  42687. animationGroups: AnimationGroup[];
  42688. }>;
  42689. /**
  42690. * Load a scene
  42691. * @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)
  42692. * @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)
  42693. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42694. * @param onSuccess a callback with the scene when import succeeds
  42695. * @param onProgress a callback with a progress event for each file being loaded
  42696. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42697. * @param pluginExtension the extension used to determine the plugin
  42698. * @returns The loaded plugin
  42699. */
  42700. 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>;
  42701. /**
  42702. * Load a scene
  42703. * @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)
  42704. * @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)
  42705. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42706. * @param onProgress a callback with a progress event for each file being loaded
  42707. * @param pluginExtension the extension used to determine the plugin
  42708. * @returns The loaded scene
  42709. */
  42710. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42711. /**
  42712. * Append a scene
  42713. * @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)
  42714. * @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)
  42715. * @param scene is the instance of BABYLON.Scene to append to
  42716. * @param onSuccess a callback with the scene when import succeeds
  42717. * @param onProgress a callback with a progress event for each file being loaded
  42718. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42719. * @param pluginExtension the extension used to determine the plugin
  42720. * @returns The loaded plugin
  42721. */
  42722. 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>;
  42723. /**
  42724. * Append a scene
  42725. * @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)
  42726. * @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)
  42727. * @param scene is the instance of BABYLON.Scene to append to
  42728. * @param onProgress a callback with a progress event for each file being loaded
  42729. * @param pluginExtension the extension used to determine the plugin
  42730. * @returns The given scene
  42731. */
  42732. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42733. /**
  42734. * Load a scene into an asset container
  42735. * @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)
  42736. * @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)
  42737. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42738. * @param onSuccess a callback with the scene when import succeeds
  42739. * @param onProgress a callback with a progress event for each file being loaded
  42740. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42741. * @param pluginExtension the extension used to determine the plugin
  42742. * @returns The loaded plugin
  42743. */
  42744. 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>;
  42745. /**
  42746. * Load a scene into an asset container
  42747. * @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)
  42748. * @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)
  42749. * @param scene is the instance of Scene to append to
  42750. * @param onProgress a callback with a progress event for each file being loaded
  42751. * @param pluginExtension the extension used to determine the plugin
  42752. * @returns The loaded asset container
  42753. */
  42754. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42755. }
  42756. }
  42757. declare module BABYLON {
  42758. /**
  42759. * Google Daydream controller
  42760. */
  42761. export class DaydreamController extends WebVRController {
  42762. /**
  42763. * Base Url for the controller model.
  42764. */
  42765. static MODEL_BASE_URL: string;
  42766. /**
  42767. * File name for the controller model.
  42768. */
  42769. static MODEL_FILENAME: string;
  42770. /**
  42771. * Gamepad Id prefix used to identify Daydream Controller.
  42772. */
  42773. static readonly GAMEPAD_ID_PREFIX: string;
  42774. /**
  42775. * Creates a new DaydreamController from a gamepad
  42776. * @param vrGamepad the gamepad that the controller should be created from
  42777. */
  42778. constructor(vrGamepad: any);
  42779. /**
  42780. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42781. * @param scene scene in which to add meshes
  42782. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42783. */
  42784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42785. /**
  42786. * Called once for each button that changed state since the last frame
  42787. * @param buttonIdx Which button index changed
  42788. * @param state New state of the button
  42789. * @param changes Which properties on the state changed since last frame
  42790. */
  42791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42792. }
  42793. }
  42794. declare module BABYLON {
  42795. /**
  42796. * Gear VR Controller
  42797. */
  42798. export class GearVRController extends WebVRController {
  42799. /**
  42800. * Base Url for the controller model.
  42801. */
  42802. static MODEL_BASE_URL: string;
  42803. /**
  42804. * File name for the controller model.
  42805. */
  42806. static MODEL_FILENAME: string;
  42807. /**
  42808. * Gamepad Id prefix used to identify this controller.
  42809. */
  42810. static readonly GAMEPAD_ID_PREFIX: string;
  42811. private readonly _buttonIndexToObservableNameMap;
  42812. /**
  42813. * Creates a new GearVRController from a gamepad
  42814. * @param vrGamepad the gamepad that the controller should be created from
  42815. */
  42816. constructor(vrGamepad: any);
  42817. /**
  42818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42819. * @param scene scene in which to add meshes
  42820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42821. */
  42822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42823. /**
  42824. * Called once for each button that changed state since the last frame
  42825. * @param buttonIdx Which button index changed
  42826. * @param state New state of the button
  42827. * @param changes Which properties on the state changed since last frame
  42828. */
  42829. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42830. }
  42831. }
  42832. declare module BABYLON {
  42833. /**
  42834. * Generic Controller
  42835. */
  42836. export class GenericController extends WebVRController {
  42837. /**
  42838. * Base Url for the controller model.
  42839. */
  42840. static readonly MODEL_BASE_URL: string;
  42841. /**
  42842. * File name for the controller model.
  42843. */
  42844. static readonly MODEL_FILENAME: string;
  42845. /**
  42846. * Creates a new GenericController from a gamepad
  42847. * @param vrGamepad the gamepad that the controller should be created from
  42848. */
  42849. constructor(vrGamepad: any);
  42850. /**
  42851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42852. * @param scene scene in which to add meshes
  42853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42854. */
  42855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42856. /**
  42857. * Called once for each button that changed state since the last frame
  42858. * @param buttonIdx Which button index changed
  42859. * @param state New state of the button
  42860. * @param changes Which properties on the state changed since last frame
  42861. */
  42862. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42863. }
  42864. }
  42865. declare module BABYLON {
  42866. /**
  42867. * Oculus Touch Controller
  42868. */
  42869. export class OculusTouchController extends WebVRController {
  42870. /**
  42871. * Base Url for the controller model.
  42872. */
  42873. static MODEL_BASE_URL: string;
  42874. /**
  42875. * File name for the left controller model.
  42876. */
  42877. static MODEL_LEFT_FILENAME: string;
  42878. /**
  42879. * File name for the right controller model.
  42880. */
  42881. static MODEL_RIGHT_FILENAME: string;
  42882. /**
  42883. * Base Url for the Quest controller model.
  42884. */
  42885. static QUEST_MODEL_BASE_URL: string;
  42886. /**
  42887. * @hidden
  42888. * If the controllers are running on a device that needs the updated Quest controller models
  42889. */
  42890. static _IsQuest: boolean;
  42891. /**
  42892. * Fired when the secondary trigger on this controller is modified
  42893. */
  42894. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42895. /**
  42896. * Fired when the thumb rest on this controller is modified
  42897. */
  42898. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42899. /**
  42900. * Creates a new OculusTouchController from a gamepad
  42901. * @param vrGamepad the gamepad that the controller should be created from
  42902. */
  42903. constructor(vrGamepad: any);
  42904. /**
  42905. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42906. * @param scene scene in which to add meshes
  42907. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42908. */
  42909. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42910. /**
  42911. * Fired when the A button on this controller is modified
  42912. */
  42913. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42914. /**
  42915. * Fired when the B button on this controller is modified
  42916. */
  42917. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42918. /**
  42919. * Fired when the X button on this controller is modified
  42920. */
  42921. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42922. /**
  42923. * Fired when the Y button on this controller is modified
  42924. */
  42925. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42926. /**
  42927. * Called once for each button that changed state since the last frame
  42928. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42929. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42930. * 2) secondary trigger (same)
  42931. * 3) A (right) X (left), touch, pressed = value
  42932. * 4) B / Y
  42933. * 5) thumb rest
  42934. * @param buttonIdx Which button index changed
  42935. * @param state New state of the button
  42936. * @param changes Which properties on the state changed since last frame
  42937. */
  42938. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42939. }
  42940. }
  42941. declare module BABYLON {
  42942. /**
  42943. * Vive Controller
  42944. */
  42945. export class ViveController extends WebVRController {
  42946. /**
  42947. * Base Url for the controller model.
  42948. */
  42949. static MODEL_BASE_URL: string;
  42950. /**
  42951. * File name for the controller model.
  42952. */
  42953. static MODEL_FILENAME: string;
  42954. /**
  42955. * Creates a new ViveController from a gamepad
  42956. * @param vrGamepad the gamepad that the controller should be created from
  42957. */
  42958. constructor(vrGamepad: any);
  42959. /**
  42960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42961. * @param scene scene in which to add meshes
  42962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42963. */
  42964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42965. /**
  42966. * Fired when the left button on this controller is modified
  42967. */
  42968. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42969. /**
  42970. * Fired when the right button on this controller is modified
  42971. */
  42972. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42973. /**
  42974. * Fired when the menu button on this controller is modified
  42975. */
  42976. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42977. /**
  42978. * Called once for each button that changed state since the last frame
  42979. * Vive mapping:
  42980. * 0: touchpad
  42981. * 1: trigger
  42982. * 2: left AND right buttons
  42983. * 3: menu button
  42984. * @param buttonIdx Which button index changed
  42985. * @param state New state of the button
  42986. * @param changes Which properties on the state changed since last frame
  42987. */
  42988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42989. }
  42990. }
  42991. declare module BABYLON {
  42992. /**
  42993. * Defines the WindowsMotionController object that the state of the windows motion controller
  42994. */
  42995. export class WindowsMotionController extends WebVRController {
  42996. /**
  42997. * The base url used to load the left and right controller models
  42998. */
  42999. static MODEL_BASE_URL: string;
  43000. /**
  43001. * The name of the left controller model file
  43002. */
  43003. static MODEL_LEFT_FILENAME: string;
  43004. /**
  43005. * The name of the right controller model file
  43006. */
  43007. static MODEL_RIGHT_FILENAME: string;
  43008. /**
  43009. * The controller name prefix for this controller type
  43010. */
  43011. static readonly GAMEPAD_ID_PREFIX: string;
  43012. /**
  43013. * The controller id pattern for this controller type
  43014. */
  43015. private static readonly GAMEPAD_ID_PATTERN;
  43016. private _loadedMeshInfo;
  43017. private readonly _mapping;
  43018. /**
  43019. * Fired when the trackpad on this controller is clicked
  43020. */
  43021. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43022. /**
  43023. * Fired when the trackpad on this controller is modified
  43024. */
  43025. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43026. /**
  43027. * The current x and y values of this controller's trackpad
  43028. */
  43029. trackpad: StickValues;
  43030. /**
  43031. * Creates a new WindowsMotionController from a gamepad
  43032. * @param vrGamepad the gamepad that the controller should be created from
  43033. */
  43034. constructor(vrGamepad: any);
  43035. /**
  43036. * Fired when the trigger on this controller is modified
  43037. */
  43038. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43039. /**
  43040. * Fired when the menu button on this controller is modified
  43041. */
  43042. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43043. /**
  43044. * Fired when the grip button on this controller is modified
  43045. */
  43046. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43047. /**
  43048. * Fired when the thumbstick button on this controller is modified
  43049. */
  43050. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43051. /**
  43052. * Fired when the touchpad button on this controller is modified
  43053. */
  43054. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43055. /**
  43056. * Fired when the touchpad values on this controller are modified
  43057. */
  43058. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43059. private _updateTrackpad;
  43060. /**
  43061. * Called once per frame by the engine.
  43062. */
  43063. update(): void;
  43064. /**
  43065. * Called once for each button that changed state since the last frame
  43066. * @param buttonIdx Which button index changed
  43067. * @param state New state of the button
  43068. * @param changes Which properties on the state changed since last frame
  43069. */
  43070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43071. /**
  43072. * Moves the buttons on the controller mesh based on their current state
  43073. * @param buttonName the name of the button to move
  43074. * @param buttonValue the value of the button which determines the buttons new position
  43075. */
  43076. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43077. /**
  43078. * Moves the axis on the controller mesh based on its current state
  43079. * @param axis the index of the axis
  43080. * @param axisValue the value of the axis which determines the meshes new position
  43081. * @hidden
  43082. */
  43083. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43084. /**
  43085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43086. * @param scene scene in which to add meshes
  43087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43088. */
  43089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43090. /**
  43091. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43092. * can be transformed by button presses and axes values, based on this._mapping.
  43093. *
  43094. * @param scene scene in which the meshes exist
  43095. * @param meshes list of meshes that make up the controller model to process
  43096. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43097. */
  43098. private processModel;
  43099. private createMeshInfo;
  43100. /**
  43101. * Gets the ray of the controller in the direction the controller is pointing
  43102. * @param length the length the resulting ray should be
  43103. * @returns a ray in the direction the controller is pointing
  43104. */
  43105. getForwardRay(length?: number): Ray;
  43106. /**
  43107. * Disposes of the controller
  43108. */
  43109. dispose(): void;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * Class containing static functions to help procedurally build meshes
  43115. */
  43116. export class PolyhedronBuilder {
  43117. /**
  43118. * Creates a polyhedron mesh
  43119. * * 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
  43120. * * The parameter `size` (positive float, default 1) sets the polygon size
  43121. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43122. * * 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`
  43123. * * 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
  43124. * * 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)`)
  43125. * * 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
  43126. * * 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
  43127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43128. * * 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
  43129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43130. * @param name defines the name of the mesh
  43131. * @param options defines the options used to create the mesh
  43132. * @param scene defines the hosting scene
  43133. * @returns the polyhedron mesh
  43134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43135. */
  43136. static CreatePolyhedron(name: string, options: {
  43137. type?: number;
  43138. size?: number;
  43139. sizeX?: number;
  43140. sizeY?: number;
  43141. sizeZ?: number;
  43142. custom?: any;
  43143. faceUV?: Vector4[];
  43144. faceColors?: Color4[];
  43145. flat?: boolean;
  43146. updatable?: boolean;
  43147. sideOrientation?: number;
  43148. frontUVs?: Vector4;
  43149. backUVs?: Vector4;
  43150. }, scene?: Nullable<Scene>): Mesh;
  43151. }
  43152. }
  43153. declare module BABYLON {
  43154. /**
  43155. * Gizmo that enables scaling a mesh along 3 axis
  43156. */
  43157. export class ScaleGizmo extends Gizmo {
  43158. /**
  43159. * Internal gizmo used for interactions on the x axis
  43160. */
  43161. xGizmo: AxisScaleGizmo;
  43162. /**
  43163. * Internal gizmo used for interactions on the y axis
  43164. */
  43165. yGizmo: AxisScaleGizmo;
  43166. /**
  43167. * Internal gizmo used for interactions on the z axis
  43168. */
  43169. zGizmo: AxisScaleGizmo;
  43170. /**
  43171. * Internal gizmo used to scale all axis equally
  43172. */
  43173. uniformScaleGizmo: AxisScaleGizmo;
  43174. private _meshAttached;
  43175. private _updateGizmoRotationToMatchAttachedMesh;
  43176. private _snapDistance;
  43177. private _scaleRatio;
  43178. private _uniformScalingMesh;
  43179. private _octahedron;
  43180. /** Fires an event when any of it's sub gizmos are dragged */
  43181. onDragStartObservable: Observable<unknown>;
  43182. /** Fires an event when any of it's sub gizmos are released from dragging */
  43183. onDragEndObservable: Observable<unknown>;
  43184. attachedMesh: Nullable<AbstractMesh>;
  43185. /**
  43186. * Creates a ScaleGizmo
  43187. * @param gizmoLayer The utility layer the gizmo will be added to
  43188. */
  43189. constructor(gizmoLayer?: UtilityLayerRenderer);
  43190. updateGizmoRotationToMatchAttachedMesh: boolean;
  43191. /**
  43192. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43193. */
  43194. snapDistance: number;
  43195. /**
  43196. * Ratio for the scale of the gizmo (Default: 1)
  43197. */
  43198. scaleRatio: number;
  43199. /**
  43200. * Disposes of the gizmo
  43201. */
  43202. dispose(): void;
  43203. }
  43204. }
  43205. declare module BABYLON {
  43206. /**
  43207. * Single axis scale gizmo
  43208. */
  43209. export class AxisScaleGizmo extends Gizmo {
  43210. /**
  43211. * Drag behavior responsible for the gizmos dragging interactions
  43212. */
  43213. dragBehavior: PointerDragBehavior;
  43214. private _pointerObserver;
  43215. /**
  43216. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43217. */
  43218. snapDistance: number;
  43219. /**
  43220. * Event that fires each time the gizmo snaps to a new location.
  43221. * * snapDistance is the the change in distance
  43222. */
  43223. onSnapObservable: Observable<{
  43224. snapDistance: number;
  43225. }>;
  43226. /**
  43227. * If the scaling operation should be done on all axis (default: false)
  43228. */
  43229. uniformScaling: boolean;
  43230. private _isEnabled;
  43231. private _parent;
  43232. private _arrow;
  43233. private _coloredMaterial;
  43234. private _hoverMaterial;
  43235. /**
  43236. * Creates an AxisScaleGizmo
  43237. * @param gizmoLayer The utility layer the gizmo will be added to
  43238. * @param dragAxis The axis which the gizmo will be able to scale on
  43239. * @param color The color of the gizmo
  43240. */
  43241. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43243. /**
  43244. * If the gizmo is enabled
  43245. */
  43246. isEnabled: boolean;
  43247. /**
  43248. * Disposes of the gizmo
  43249. */
  43250. dispose(): void;
  43251. /**
  43252. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43253. * @param mesh The mesh to replace the default mesh of the gizmo
  43254. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43255. */
  43256. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43257. }
  43258. }
  43259. declare module BABYLON {
  43260. /**
  43261. * Bounding box gizmo
  43262. */
  43263. export class BoundingBoxGizmo extends Gizmo {
  43264. private _lineBoundingBox;
  43265. private _rotateSpheresParent;
  43266. private _scaleBoxesParent;
  43267. private _boundingDimensions;
  43268. private _renderObserver;
  43269. private _pointerObserver;
  43270. private _scaleDragSpeed;
  43271. private _tmpQuaternion;
  43272. private _tmpVector;
  43273. private _tmpRotationMatrix;
  43274. /**
  43275. * 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)
  43276. */
  43277. ignoreChildren: boolean;
  43278. /**
  43279. * 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)
  43280. */
  43281. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43282. /**
  43283. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43284. */
  43285. rotationSphereSize: number;
  43286. /**
  43287. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43288. */
  43289. scaleBoxSize: number;
  43290. /**
  43291. * 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)
  43292. */
  43293. fixedDragMeshScreenSize: boolean;
  43294. /**
  43295. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43296. */
  43297. fixedDragMeshScreenSizeDistanceFactor: number;
  43298. /**
  43299. * Fired when a rotation sphere or scale box is dragged
  43300. */
  43301. onDragStartObservable: Observable<{}>;
  43302. /**
  43303. * Fired when a scale box is dragged
  43304. */
  43305. onScaleBoxDragObservable: Observable<{}>;
  43306. /**
  43307. * Fired when a scale box drag is ended
  43308. */
  43309. onScaleBoxDragEndObservable: Observable<{}>;
  43310. /**
  43311. * Fired when a rotation sphere is dragged
  43312. */
  43313. onRotationSphereDragObservable: Observable<{}>;
  43314. /**
  43315. * Fired when a rotation sphere drag is ended
  43316. */
  43317. onRotationSphereDragEndObservable: Observable<{}>;
  43318. /**
  43319. * 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)
  43320. */
  43321. scalePivot: Nullable<Vector3>;
  43322. /**
  43323. * Mesh used as a pivot to rotate the attached mesh
  43324. */
  43325. private _anchorMesh;
  43326. private _existingMeshScale;
  43327. private _dragMesh;
  43328. private pointerDragBehavior;
  43329. private coloredMaterial;
  43330. private hoverColoredMaterial;
  43331. /**
  43332. * Sets the color of the bounding box gizmo
  43333. * @param color the color to set
  43334. */
  43335. setColor(color: Color3): void;
  43336. /**
  43337. * Creates an BoundingBoxGizmo
  43338. * @param gizmoLayer The utility layer the gizmo will be added to
  43339. * @param color The color of the gizmo
  43340. */
  43341. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43342. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43343. private _selectNode;
  43344. /**
  43345. * Updates the bounding box information for the Gizmo
  43346. */
  43347. updateBoundingBox(): void;
  43348. private _updateRotationSpheres;
  43349. private _updateScaleBoxes;
  43350. /**
  43351. * Enables rotation on the specified axis and disables rotation on the others
  43352. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43353. */
  43354. setEnabledRotationAxis(axis: string): void;
  43355. /**
  43356. * Enables/disables scaling
  43357. * @param enable if scaling should be enabled
  43358. */
  43359. setEnabledScaling(enable: boolean): void;
  43360. private _updateDummy;
  43361. /**
  43362. * Enables a pointer drag behavior on the bounding box of the gizmo
  43363. */
  43364. enableDragBehavior(): void;
  43365. /**
  43366. * Disposes of the gizmo
  43367. */
  43368. dispose(): void;
  43369. /**
  43370. * 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)
  43371. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43372. * @returns the bounding box mesh with the passed in mesh as a child
  43373. */
  43374. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43375. /**
  43376. * CustomMeshes are not supported by this gizmo
  43377. * @param mesh The mesh to replace the default mesh of the gizmo
  43378. */
  43379. setCustomMesh(mesh: Mesh): void;
  43380. }
  43381. }
  43382. declare module BABYLON {
  43383. /**
  43384. * Single plane rotation gizmo
  43385. */
  43386. export class PlaneRotationGizmo extends Gizmo {
  43387. /**
  43388. * Drag behavior responsible for the gizmos dragging interactions
  43389. */
  43390. dragBehavior: PointerDragBehavior;
  43391. private _pointerObserver;
  43392. /**
  43393. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43394. */
  43395. snapDistance: number;
  43396. /**
  43397. * Event that fires each time the gizmo snaps to a new location.
  43398. * * snapDistance is the the change in distance
  43399. */
  43400. onSnapObservable: Observable<{
  43401. snapDistance: number;
  43402. }>;
  43403. private _isEnabled;
  43404. private _parent;
  43405. /**
  43406. * Creates a PlaneRotationGizmo
  43407. * @param gizmoLayer The utility layer the gizmo will be added to
  43408. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43409. * @param color The color of the gizmo
  43410. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43411. */
  43412. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43414. /**
  43415. * If the gizmo is enabled
  43416. */
  43417. isEnabled: boolean;
  43418. /**
  43419. * Disposes of the gizmo
  43420. */
  43421. dispose(): void;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * Gizmo that enables rotating a mesh along 3 axis
  43427. */
  43428. export class RotationGizmo extends Gizmo {
  43429. /**
  43430. * Internal gizmo used for interactions on the x axis
  43431. */
  43432. xGizmo: PlaneRotationGizmo;
  43433. /**
  43434. * Internal gizmo used for interactions on the y axis
  43435. */
  43436. yGizmo: PlaneRotationGizmo;
  43437. /**
  43438. * Internal gizmo used for interactions on the z axis
  43439. */
  43440. zGizmo: PlaneRotationGizmo;
  43441. /** Fires an event when any of it's sub gizmos are dragged */
  43442. onDragStartObservable: Observable<unknown>;
  43443. /** Fires an event when any of it's sub gizmos are released from dragging */
  43444. onDragEndObservable: Observable<unknown>;
  43445. private _meshAttached;
  43446. attachedMesh: Nullable<AbstractMesh>;
  43447. /**
  43448. * Creates a RotationGizmo
  43449. * @param gizmoLayer The utility layer the gizmo will be added to
  43450. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43451. */
  43452. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43453. updateGizmoRotationToMatchAttachedMesh: boolean;
  43454. /**
  43455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43456. */
  43457. snapDistance: number;
  43458. /**
  43459. * Ratio for the scale of the gizmo (Default: 1)
  43460. */
  43461. scaleRatio: number;
  43462. /**
  43463. * Disposes of the gizmo
  43464. */
  43465. dispose(): void;
  43466. /**
  43467. * CustomMeshes are not supported by this gizmo
  43468. * @param mesh The mesh to replace the default mesh of the gizmo
  43469. */
  43470. setCustomMesh(mesh: Mesh): void;
  43471. }
  43472. }
  43473. declare module BABYLON {
  43474. /**
  43475. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43476. */
  43477. export class GizmoManager implements IDisposable {
  43478. private scene;
  43479. /**
  43480. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43481. */
  43482. gizmos: {
  43483. positionGizmo: Nullable<PositionGizmo>;
  43484. rotationGizmo: Nullable<RotationGizmo>;
  43485. scaleGizmo: Nullable<ScaleGizmo>;
  43486. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43487. };
  43488. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43489. clearGizmoOnEmptyPointerEvent: boolean;
  43490. /** Fires an event when the manager is attached to a mesh */
  43491. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43492. private _gizmosEnabled;
  43493. private _pointerObserver;
  43494. private _attachedMesh;
  43495. private _boundingBoxColor;
  43496. private _defaultUtilityLayer;
  43497. private _defaultKeepDepthUtilityLayer;
  43498. /**
  43499. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43500. */
  43501. boundingBoxDragBehavior: SixDofDragBehavior;
  43502. /**
  43503. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43504. */
  43505. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43506. /**
  43507. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43508. */
  43509. usePointerToAttachGizmos: boolean;
  43510. /**
  43511. * Utility layer that the bounding box gizmo belongs to
  43512. */
  43513. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43514. /**
  43515. * Utility layer that all gizmos besides bounding box belong to
  43516. */
  43517. readonly utilityLayer: UtilityLayerRenderer;
  43518. /**
  43519. * Instatiates a gizmo manager
  43520. * @param scene the scene to overlay the gizmos on top of
  43521. */
  43522. constructor(scene: Scene);
  43523. /**
  43524. * Attaches a set of gizmos to the specified mesh
  43525. * @param mesh The mesh the gizmo's should be attached to
  43526. */
  43527. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43528. /**
  43529. * If the position gizmo is enabled
  43530. */
  43531. positionGizmoEnabled: boolean;
  43532. /**
  43533. * If the rotation gizmo is enabled
  43534. */
  43535. rotationGizmoEnabled: boolean;
  43536. /**
  43537. * If the scale gizmo is enabled
  43538. */
  43539. scaleGizmoEnabled: boolean;
  43540. /**
  43541. * If the boundingBox gizmo is enabled
  43542. */
  43543. boundingBoxGizmoEnabled: boolean;
  43544. /**
  43545. * Disposes of the gizmo manager
  43546. */
  43547. dispose(): void;
  43548. }
  43549. }
  43550. declare module BABYLON {
  43551. /**
  43552. * A directional light is defined by a direction (what a surprise!).
  43553. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43554. * 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.
  43555. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43556. */
  43557. export class DirectionalLight extends ShadowLight {
  43558. private _shadowFrustumSize;
  43559. /**
  43560. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43561. */
  43562. /**
  43563. * Specifies a fix frustum size for the shadow generation.
  43564. */
  43565. shadowFrustumSize: number;
  43566. private _shadowOrthoScale;
  43567. /**
  43568. * Gets the shadow projection scale against the optimal computed one.
  43569. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43570. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43571. */
  43572. /**
  43573. * Sets the shadow projection scale against the optimal computed one.
  43574. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43575. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43576. */
  43577. shadowOrthoScale: number;
  43578. /**
  43579. * Automatically compute the projection matrix to best fit (including all the casters)
  43580. * on each frame.
  43581. */
  43582. autoUpdateExtends: boolean;
  43583. private _orthoLeft;
  43584. private _orthoRight;
  43585. private _orthoTop;
  43586. private _orthoBottom;
  43587. /**
  43588. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43589. * The directional light is emitted from everywhere in the given direction.
  43590. * It can cast shadows.
  43591. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43592. * @param name The friendly name of the light
  43593. * @param direction The direction of the light
  43594. * @param scene The scene the light belongs to
  43595. */
  43596. constructor(name: string, direction: Vector3, scene: Scene);
  43597. /**
  43598. * Returns the string "DirectionalLight".
  43599. * @return The class name
  43600. */
  43601. getClassName(): string;
  43602. /**
  43603. * Returns the integer 1.
  43604. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43605. */
  43606. getTypeID(): number;
  43607. /**
  43608. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43609. * Returns the DirectionalLight Shadow projection matrix.
  43610. */
  43611. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43612. /**
  43613. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43614. * Returns the DirectionalLight Shadow projection matrix.
  43615. */
  43616. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43617. /**
  43618. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43619. * Returns the DirectionalLight Shadow projection matrix.
  43620. */
  43621. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43622. protected _buildUniformLayout(): void;
  43623. /**
  43624. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43625. * @param effect The effect to update
  43626. * @param lightIndex The index of the light in the effect to update
  43627. * @returns The directional light
  43628. */
  43629. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43630. /**
  43631. * Gets the minZ used for shadow according to both the scene and the light.
  43632. *
  43633. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43634. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43635. * @param activeCamera The camera we are returning the min for
  43636. * @returns the depth min z
  43637. */
  43638. getDepthMinZ(activeCamera: Camera): number;
  43639. /**
  43640. * Gets the maxZ used for shadow according to both the scene and the light.
  43641. *
  43642. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43643. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43644. * @param activeCamera The camera we are returning the max for
  43645. * @returns the depth max z
  43646. */
  43647. getDepthMaxZ(activeCamera: Camera): number;
  43648. /**
  43649. * Prepares the list of defines specific to the light type.
  43650. * @param defines the list of defines
  43651. * @param lightIndex defines the index of the light for the effect
  43652. */
  43653. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43654. }
  43655. }
  43656. declare module BABYLON {
  43657. /**
  43658. * Class containing static functions to help procedurally build meshes
  43659. */
  43660. export class HemisphereBuilder {
  43661. /**
  43662. * Creates a hemisphere mesh
  43663. * @param name defines the name of the mesh
  43664. * @param options defines the options used to create the mesh
  43665. * @param scene defines the hosting scene
  43666. * @returns the hemisphere mesh
  43667. */
  43668. static CreateHemisphere(name: string, options: {
  43669. segments?: number;
  43670. diameter?: number;
  43671. sideOrientation?: number;
  43672. }, scene: any): Mesh;
  43673. }
  43674. }
  43675. declare module BABYLON {
  43676. /**
  43677. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43678. * These values define a cone of light starting from the position, emitting toward the direction.
  43679. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43680. * and the exponent defines the speed of the decay of the light with distance (reach).
  43681. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43682. */
  43683. export class SpotLight extends ShadowLight {
  43684. private _angle;
  43685. private _innerAngle;
  43686. private _cosHalfAngle;
  43687. private _lightAngleScale;
  43688. private _lightAngleOffset;
  43689. /**
  43690. * Gets the cone angle of the spot light in Radians.
  43691. */
  43692. /**
  43693. * Sets the cone angle of the spot light in Radians.
  43694. */
  43695. angle: number;
  43696. /**
  43697. * Only used in gltf falloff mode, this defines the angle where
  43698. * the directional falloff will start before cutting at angle which could be seen
  43699. * as outer angle.
  43700. */
  43701. /**
  43702. * Only used in gltf falloff mode, this defines the angle where
  43703. * the directional falloff will start before cutting at angle which could be seen
  43704. * as outer angle.
  43705. */
  43706. innerAngle: number;
  43707. private _shadowAngleScale;
  43708. /**
  43709. * Allows scaling the angle of the light for shadow generation only.
  43710. */
  43711. /**
  43712. * Allows scaling the angle of the light for shadow generation only.
  43713. */
  43714. shadowAngleScale: number;
  43715. /**
  43716. * The light decay speed with the distance from the emission spot.
  43717. */
  43718. exponent: number;
  43719. private _projectionTextureMatrix;
  43720. /**
  43721. * Allows reading the projecton texture
  43722. */
  43723. readonly projectionTextureMatrix: Matrix;
  43724. protected _projectionTextureLightNear: number;
  43725. /**
  43726. * Gets the near clip of the Spotlight for texture projection.
  43727. */
  43728. /**
  43729. * Sets the near clip of the Spotlight for texture projection.
  43730. */
  43731. projectionTextureLightNear: number;
  43732. protected _projectionTextureLightFar: number;
  43733. /**
  43734. * Gets the far clip of the Spotlight for texture projection.
  43735. */
  43736. /**
  43737. * Sets the far clip of the Spotlight for texture projection.
  43738. */
  43739. projectionTextureLightFar: number;
  43740. protected _projectionTextureUpDirection: Vector3;
  43741. /**
  43742. * Gets the Up vector of the Spotlight for texture projection.
  43743. */
  43744. /**
  43745. * Sets the Up vector of the Spotlight for texture projection.
  43746. */
  43747. projectionTextureUpDirection: Vector3;
  43748. private _projectionTexture;
  43749. /**
  43750. * Gets the projection texture of the light.
  43751. */
  43752. /**
  43753. * Sets the projection texture of the light.
  43754. */
  43755. projectionTexture: Nullable<BaseTexture>;
  43756. private _projectionTextureViewLightDirty;
  43757. private _projectionTextureProjectionLightDirty;
  43758. private _projectionTextureDirty;
  43759. private _projectionTextureViewTargetVector;
  43760. private _projectionTextureViewLightMatrix;
  43761. private _projectionTextureProjectionLightMatrix;
  43762. private _projectionTextureScalingMatrix;
  43763. /**
  43764. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43765. * It can cast shadows.
  43766. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43767. * @param name The light friendly name
  43768. * @param position The position of the spot light in the scene
  43769. * @param direction The direction of the light in the scene
  43770. * @param angle The cone angle of the light in Radians
  43771. * @param exponent The light decay speed with the distance from the emission spot
  43772. * @param scene The scene the lights belongs to
  43773. */
  43774. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43775. /**
  43776. * Returns the string "SpotLight".
  43777. * @returns the class name
  43778. */
  43779. getClassName(): string;
  43780. /**
  43781. * Returns the integer 2.
  43782. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43783. */
  43784. getTypeID(): number;
  43785. /**
  43786. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43787. */
  43788. protected _setDirection(value: Vector3): void;
  43789. /**
  43790. * Overrides the position setter to recompute the projection texture view light Matrix.
  43791. */
  43792. protected _setPosition(value: Vector3): void;
  43793. /**
  43794. * 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.
  43795. * Returns the SpotLight.
  43796. */
  43797. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43798. protected _computeProjectionTextureViewLightMatrix(): void;
  43799. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43800. /**
  43801. * Main function for light texture projection matrix computing.
  43802. */
  43803. protected _computeProjectionTextureMatrix(): void;
  43804. protected _buildUniformLayout(): void;
  43805. private _computeAngleValues;
  43806. /**
  43807. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43808. * @param effect The effect to update
  43809. * @param lightIndex The index of the light in the effect to update
  43810. * @returns The spot light
  43811. */
  43812. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43813. /**
  43814. * Disposes the light and the associated resources.
  43815. */
  43816. dispose(): void;
  43817. /**
  43818. * Prepares the list of defines specific to the light type.
  43819. * @param defines the list of defines
  43820. * @param lightIndex defines the index of the light for the effect
  43821. */
  43822. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43823. }
  43824. }
  43825. declare module BABYLON {
  43826. /**
  43827. * Gizmo that enables viewing a light
  43828. */
  43829. export class LightGizmo extends Gizmo {
  43830. private _lightMesh;
  43831. private _material;
  43832. private cachedPosition;
  43833. private cachedForward;
  43834. /**
  43835. * Creates a LightGizmo
  43836. * @param gizmoLayer The utility layer the gizmo will be added to
  43837. */
  43838. constructor(gizmoLayer?: UtilityLayerRenderer);
  43839. private _light;
  43840. /**
  43841. * The light that the gizmo is attached to
  43842. */
  43843. light: Nullable<Light>;
  43844. /**
  43845. * @hidden
  43846. * Updates the gizmo to match the attached mesh's position/rotation
  43847. */
  43848. protected _update(): void;
  43849. private static _Scale;
  43850. /**
  43851. * Creates the lines for a light mesh
  43852. */
  43853. private static _createLightLines;
  43854. /**
  43855. * Disposes of the light gizmo
  43856. */
  43857. dispose(): void;
  43858. private static _CreateHemisphericLightMesh;
  43859. private static _CreatePointLightMesh;
  43860. private static _CreateSpotLightMesh;
  43861. private static _CreateDirectionalLightMesh;
  43862. }
  43863. }
  43864. declare module BABYLON {
  43865. /** @hidden */
  43866. export var backgroundFragmentDeclaration: {
  43867. name: string;
  43868. shader: string;
  43869. };
  43870. }
  43871. declare module BABYLON {
  43872. /** @hidden */
  43873. export var backgroundUboDeclaration: {
  43874. name: string;
  43875. shader: string;
  43876. };
  43877. }
  43878. declare module BABYLON {
  43879. /** @hidden */
  43880. export var backgroundPixelShader: {
  43881. name: string;
  43882. shader: string;
  43883. };
  43884. }
  43885. declare module BABYLON {
  43886. /** @hidden */
  43887. export var backgroundVertexDeclaration: {
  43888. name: string;
  43889. shader: string;
  43890. };
  43891. }
  43892. declare module BABYLON {
  43893. /** @hidden */
  43894. export var backgroundVertexShader: {
  43895. name: string;
  43896. shader: string;
  43897. };
  43898. }
  43899. declare module BABYLON {
  43900. /**
  43901. * Background material used to create an efficient environement around your scene.
  43902. */
  43903. export class BackgroundMaterial extends PushMaterial {
  43904. /**
  43905. * Standard reflectance value at parallel view angle.
  43906. */
  43907. static StandardReflectance0: number;
  43908. /**
  43909. * Standard reflectance value at grazing angle.
  43910. */
  43911. static StandardReflectance90: number;
  43912. protected _primaryColor: Color3;
  43913. /**
  43914. * Key light Color (multiply against the environement texture)
  43915. */
  43916. primaryColor: Color3;
  43917. protected __perceptualColor: Nullable<Color3>;
  43918. /**
  43919. * Experimental Internal Use Only.
  43920. *
  43921. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43922. * This acts as a helper to set the primary color to a more "human friendly" value.
  43923. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43924. * output color as close as possible from the chosen value.
  43925. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43926. * part of lighting setup.)
  43927. */
  43928. _perceptualColor: Nullable<Color3>;
  43929. protected _primaryColorShadowLevel: float;
  43930. /**
  43931. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43932. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43933. */
  43934. primaryColorShadowLevel: float;
  43935. protected _primaryColorHighlightLevel: float;
  43936. /**
  43937. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43938. * The primary color is used at the level chosen to define what the white area would look.
  43939. */
  43940. primaryColorHighlightLevel: float;
  43941. protected _reflectionTexture: Nullable<BaseTexture>;
  43942. /**
  43943. * Reflection Texture used in the material.
  43944. * Should be author in a specific way for the best result (refer to the documentation).
  43945. */
  43946. reflectionTexture: Nullable<BaseTexture>;
  43947. protected _reflectionBlur: float;
  43948. /**
  43949. * Reflection Texture level of blur.
  43950. *
  43951. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43952. * texture twice.
  43953. */
  43954. reflectionBlur: float;
  43955. protected _diffuseTexture: Nullable<BaseTexture>;
  43956. /**
  43957. * Diffuse Texture used in the material.
  43958. * Should be author in a specific way for the best result (refer to the documentation).
  43959. */
  43960. diffuseTexture: Nullable<BaseTexture>;
  43961. protected _shadowLights: Nullable<IShadowLight[]>;
  43962. /**
  43963. * Specify the list of lights casting shadow on the material.
  43964. * All scene shadow lights will be included if null.
  43965. */
  43966. shadowLights: Nullable<IShadowLight[]>;
  43967. protected _shadowLevel: float;
  43968. /**
  43969. * Helps adjusting the shadow to a softer level if required.
  43970. * 0 means black shadows and 1 means no shadows.
  43971. */
  43972. shadowLevel: float;
  43973. protected _sceneCenter: Vector3;
  43974. /**
  43975. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43976. * It is usually zero but might be interesting to modify according to your setup.
  43977. */
  43978. sceneCenter: Vector3;
  43979. protected _opacityFresnel: boolean;
  43980. /**
  43981. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43982. * This helps ensuring a nice transition when the camera goes under the ground.
  43983. */
  43984. opacityFresnel: boolean;
  43985. protected _reflectionFresnel: boolean;
  43986. /**
  43987. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43988. * This helps adding a mirror texture on the ground.
  43989. */
  43990. reflectionFresnel: boolean;
  43991. protected _reflectionFalloffDistance: number;
  43992. /**
  43993. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43994. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43995. */
  43996. reflectionFalloffDistance: number;
  43997. protected _reflectionAmount: number;
  43998. /**
  43999. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44000. */
  44001. reflectionAmount: number;
  44002. protected _reflectionReflectance0: number;
  44003. /**
  44004. * This specifies the weight of the reflection at grazing angle.
  44005. */
  44006. reflectionReflectance0: number;
  44007. protected _reflectionReflectance90: number;
  44008. /**
  44009. * This specifies the weight of the reflection at a perpendicular point of view.
  44010. */
  44011. reflectionReflectance90: number;
  44012. /**
  44013. * Sets the reflection reflectance fresnel values according to the default standard
  44014. * empirically know to work well :-)
  44015. */
  44016. reflectionStandardFresnelWeight: number;
  44017. protected _useRGBColor: boolean;
  44018. /**
  44019. * Helps to directly use the maps channels instead of their level.
  44020. */
  44021. useRGBColor: boolean;
  44022. protected _enableNoise: boolean;
  44023. /**
  44024. * This helps reducing the banding effect that could occur on the background.
  44025. */
  44026. enableNoise: boolean;
  44027. /**
  44028. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44029. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44030. * Recommended to be keep at 1.0 except for special cases.
  44031. */
  44032. fovMultiplier: number;
  44033. private _fovMultiplier;
  44034. /**
  44035. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44036. */
  44037. useEquirectangularFOV: boolean;
  44038. private _maxSimultaneousLights;
  44039. /**
  44040. * Number of Simultaneous lights allowed on the material.
  44041. */
  44042. maxSimultaneousLights: int;
  44043. /**
  44044. * Default configuration related to image processing available in the Background Material.
  44045. */
  44046. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44047. /**
  44048. * Keep track of the image processing observer to allow dispose and replace.
  44049. */
  44050. private _imageProcessingObserver;
  44051. /**
  44052. * Attaches a new image processing configuration to the PBR Material.
  44053. * @param configuration (if null the scene configuration will be use)
  44054. */
  44055. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44056. /**
  44057. * Gets the image processing configuration used either in this material.
  44058. */
  44059. /**
  44060. * Sets the Default image processing configuration used either in the this material.
  44061. *
  44062. * If sets to null, the scene one is in use.
  44063. */
  44064. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44065. /**
  44066. * Gets wether the color curves effect is enabled.
  44067. */
  44068. /**
  44069. * Sets wether the color curves effect is enabled.
  44070. */
  44071. cameraColorCurvesEnabled: boolean;
  44072. /**
  44073. * Gets wether the color grading effect is enabled.
  44074. */
  44075. /**
  44076. * Gets wether the color grading effect is enabled.
  44077. */
  44078. cameraColorGradingEnabled: boolean;
  44079. /**
  44080. * Gets wether tonemapping is enabled or not.
  44081. */
  44082. /**
  44083. * Sets wether tonemapping is enabled or not
  44084. */
  44085. cameraToneMappingEnabled: boolean;
  44086. /**
  44087. * The camera exposure used on this material.
  44088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44089. * This corresponds to a photographic exposure.
  44090. */
  44091. /**
  44092. * The camera exposure used on this material.
  44093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44094. * This corresponds to a photographic exposure.
  44095. */
  44096. cameraExposure: float;
  44097. /**
  44098. * Gets The camera contrast used on this material.
  44099. */
  44100. /**
  44101. * Sets The camera contrast used on this material.
  44102. */
  44103. cameraContrast: float;
  44104. /**
  44105. * Gets the Color Grading 2D Lookup Texture.
  44106. */
  44107. /**
  44108. * Sets the Color Grading 2D Lookup Texture.
  44109. */
  44110. cameraColorGradingTexture: Nullable<BaseTexture>;
  44111. /**
  44112. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44113. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44114. * 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;
  44115. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44116. */
  44117. /**
  44118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44120. * 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;
  44121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44122. */
  44123. cameraColorCurves: Nullable<ColorCurves>;
  44124. /**
  44125. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44126. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44127. */
  44128. switchToBGR: boolean;
  44129. private _renderTargets;
  44130. private _reflectionControls;
  44131. private _white;
  44132. private _primaryShadowColor;
  44133. private _primaryHighlightColor;
  44134. /**
  44135. * Instantiates a Background Material in the given scene
  44136. * @param name The friendly name of the material
  44137. * @param scene The scene to add the material to
  44138. */
  44139. constructor(name: string, scene: Scene);
  44140. /**
  44141. * Gets a boolean indicating that current material needs to register RTT
  44142. */
  44143. readonly hasRenderTargetTextures: boolean;
  44144. /**
  44145. * The entire material has been created in order to prevent overdraw.
  44146. * @returns false
  44147. */
  44148. needAlphaTesting(): boolean;
  44149. /**
  44150. * The entire material has been created in order to prevent overdraw.
  44151. * @returns true if blending is enable
  44152. */
  44153. needAlphaBlending(): boolean;
  44154. /**
  44155. * Checks wether the material is ready to be rendered for a given mesh.
  44156. * @param mesh The mesh to render
  44157. * @param subMesh The submesh to check against
  44158. * @param useInstances Specify wether or not the material is used with instances
  44159. * @returns true if all the dependencies are ready (Textures, Effects...)
  44160. */
  44161. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44162. /**
  44163. * Compute the primary color according to the chosen perceptual color.
  44164. */
  44165. private _computePrimaryColorFromPerceptualColor;
  44166. /**
  44167. * Compute the highlights and shadow colors according to their chosen levels.
  44168. */
  44169. private _computePrimaryColors;
  44170. /**
  44171. * Build the uniform buffer used in the material.
  44172. */
  44173. buildUniformLayout(): void;
  44174. /**
  44175. * Unbind the material.
  44176. */
  44177. unbind(): void;
  44178. /**
  44179. * Bind only the world matrix to the material.
  44180. * @param world The world matrix to bind.
  44181. */
  44182. bindOnlyWorldMatrix(world: Matrix): void;
  44183. /**
  44184. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44185. * @param world The world matrix to bind.
  44186. * @param subMesh The submesh to bind for.
  44187. */
  44188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44189. /**
  44190. * Dispose the material.
  44191. * @param forceDisposeEffect Force disposal of the associated effect.
  44192. * @param forceDisposeTextures Force disposal of the associated textures.
  44193. */
  44194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44195. /**
  44196. * Clones the material.
  44197. * @param name The cloned name.
  44198. * @returns The cloned material.
  44199. */
  44200. clone(name: string): BackgroundMaterial;
  44201. /**
  44202. * Serializes the current material to its JSON representation.
  44203. * @returns The JSON representation.
  44204. */
  44205. serialize(): any;
  44206. /**
  44207. * Gets the class name of the material
  44208. * @returns "BackgroundMaterial"
  44209. */
  44210. getClassName(): string;
  44211. /**
  44212. * Parse a JSON input to create back a background material.
  44213. * @param source The JSON data to parse
  44214. * @param scene The scene to create the parsed material in
  44215. * @param rootUrl The root url of the assets the material depends upon
  44216. * @returns the instantiated BackgroundMaterial.
  44217. */
  44218. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44219. }
  44220. }
  44221. declare module BABYLON {
  44222. /**
  44223. * Represents the different options available during the creation of
  44224. * a Environment helper.
  44225. *
  44226. * This can control the default ground, skybox and image processing setup of your scene.
  44227. */
  44228. export interface IEnvironmentHelperOptions {
  44229. /**
  44230. * Specifies wether or not to create a ground.
  44231. * True by default.
  44232. */
  44233. createGround: boolean;
  44234. /**
  44235. * Specifies the ground size.
  44236. * 15 by default.
  44237. */
  44238. groundSize: number;
  44239. /**
  44240. * The texture used on the ground for the main color.
  44241. * Comes from the BabylonJS CDN by default.
  44242. *
  44243. * Remarks: Can be either a texture or a url.
  44244. */
  44245. groundTexture: string | BaseTexture;
  44246. /**
  44247. * The color mixed in the ground texture by default.
  44248. * BabylonJS clearColor by default.
  44249. */
  44250. groundColor: Color3;
  44251. /**
  44252. * Specifies the ground opacity.
  44253. * 1 by default.
  44254. */
  44255. groundOpacity: number;
  44256. /**
  44257. * Enables the ground to receive shadows.
  44258. * True by default.
  44259. */
  44260. enableGroundShadow: boolean;
  44261. /**
  44262. * Helps preventing the shadow to be fully black on the ground.
  44263. * 0.5 by default.
  44264. */
  44265. groundShadowLevel: number;
  44266. /**
  44267. * Creates a mirror texture attach to the ground.
  44268. * false by default.
  44269. */
  44270. enableGroundMirror: boolean;
  44271. /**
  44272. * Specifies the ground mirror size ratio.
  44273. * 0.3 by default as the default kernel is 64.
  44274. */
  44275. groundMirrorSizeRatio: number;
  44276. /**
  44277. * Specifies the ground mirror blur kernel size.
  44278. * 64 by default.
  44279. */
  44280. groundMirrorBlurKernel: number;
  44281. /**
  44282. * Specifies the ground mirror visibility amount.
  44283. * 1 by default
  44284. */
  44285. groundMirrorAmount: number;
  44286. /**
  44287. * Specifies the ground mirror reflectance weight.
  44288. * This uses the standard weight of the background material to setup the fresnel effect
  44289. * of the mirror.
  44290. * 1 by default.
  44291. */
  44292. groundMirrorFresnelWeight: number;
  44293. /**
  44294. * Specifies the ground mirror Falloff distance.
  44295. * This can helps reducing the size of the reflection.
  44296. * 0 by Default.
  44297. */
  44298. groundMirrorFallOffDistance: number;
  44299. /**
  44300. * Specifies the ground mirror texture type.
  44301. * Unsigned Int by Default.
  44302. */
  44303. groundMirrorTextureType: number;
  44304. /**
  44305. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44306. * the shown objects.
  44307. */
  44308. groundYBias: number;
  44309. /**
  44310. * Specifies wether or not to create a skybox.
  44311. * True by default.
  44312. */
  44313. createSkybox: boolean;
  44314. /**
  44315. * Specifies the skybox size.
  44316. * 20 by default.
  44317. */
  44318. skyboxSize: number;
  44319. /**
  44320. * The texture used on the skybox for the main color.
  44321. * Comes from the BabylonJS CDN by default.
  44322. *
  44323. * Remarks: Can be either a texture or a url.
  44324. */
  44325. skyboxTexture: string | BaseTexture;
  44326. /**
  44327. * The color mixed in the skybox texture by default.
  44328. * BabylonJS clearColor by default.
  44329. */
  44330. skyboxColor: Color3;
  44331. /**
  44332. * The background rotation around the Y axis of the scene.
  44333. * This helps aligning the key lights of your scene with the background.
  44334. * 0 by default.
  44335. */
  44336. backgroundYRotation: number;
  44337. /**
  44338. * Compute automatically the size of the elements to best fit with the scene.
  44339. */
  44340. sizeAuto: boolean;
  44341. /**
  44342. * Default position of the rootMesh if autoSize is not true.
  44343. */
  44344. rootPosition: Vector3;
  44345. /**
  44346. * Sets up the image processing in the scene.
  44347. * true by default.
  44348. */
  44349. setupImageProcessing: boolean;
  44350. /**
  44351. * The texture used as your environment texture in the scene.
  44352. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44353. *
  44354. * Remarks: Can be either a texture or a url.
  44355. */
  44356. environmentTexture: string | BaseTexture;
  44357. /**
  44358. * The value of the exposure to apply to the scene.
  44359. * 0.6 by default if setupImageProcessing is true.
  44360. */
  44361. cameraExposure: number;
  44362. /**
  44363. * The value of the contrast to apply to the scene.
  44364. * 1.6 by default if setupImageProcessing is true.
  44365. */
  44366. cameraContrast: number;
  44367. /**
  44368. * Specifies wether or not tonemapping should be enabled in the scene.
  44369. * true by default if setupImageProcessing is true.
  44370. */
  44371. toneMappingEnabled: boolean;
  44372. }
  44373. /**
  44374. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44375. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44376. * It also helps with the default setup of your imageProcessing configuration.
  44377. */
  44378. export class EnvironmentHelper {
  44379. /**
  44380. * Default ground texture URL.
  44381. */
  44382. private static _groundTextureCDNUrl;
  44383. /**
  44384. * Default skybox texture URL.
  44385. */
  44386. private static _skyboxTextureCDNUrl;
  44387. /**
  44388. * Default environment texture URL.
  44389. */
  44390. private static _environmentTextureCDNUrl;
  44391. /**
  44392. * Creates the default options for the helper.
  44393. */
  44394. private static _getDefaultOptions;
  44395. private _rootMesh;
  44396. /**
  44397. * Gets the root mesh created by the helper.
  44398. */
  44399. readonly rootMesh: Mesh;
  44400. private _skybox;
  44401. /**
  44402. * Gets the skybox created by the helper.
  44403. */
  44404. readonly skybox: Nullable<Mesh>;
  44405. private _skyboxTexture;
  44406. /**
  44407. * Gets the skybox texture created by the helper.
  44408. */
  44409. readonly skyboxTexture: Nullable<BaseTexture>;
  44410. private _skyboxMaterial;
  44411. /**
  44412. * Gets the skybox material created by the helper.
  44413. */
  44414. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44415. private _ground;
  44416. /**
  44417. * Gets the ground mesh created by the helper.
  44418. */
  44419. readonly ground: Nullable<Mesh>;
  44420. private _groundTexture;
  44421. /**
  44422. * Gets the ground texture created by the helper.
  44423. */
  44424. readonly groundTexture: Nullable<BaseTexture>;
  44425. private _groundMirror;
  44426. /**
  44427. * Gets the ground mirror created by the helper.
  44428. */
  44429. readonly groundMirror: Nullable<MirrorTexture>;
  44430. /**
  44431. * Gets the ground mirror render list to helps pushing the meshes
  44432. * you wish in the ground reflection.
  44433. */
  44434. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44435. private _groundMaterial;
  44436. /**
  44437. * Gets the ground material created by the helper.
  44438. */
  44439. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44440. /**
  44441. * Stores the creation options.
  44442. */
  44443. private readonly _scene;
  44444. private _options;
  44445. /**
  44446. * This observable will be notified with any error during the creation of the environment,
  44447. * mainly texture creation errors.
  44448. */
  44449. onErrorObservable: Observable<{
  44450. message?: string;
  44451. exception?: any;
  44452. }>;
  44453. /**
  44454. * constructor
  44455. * @param options Defines the options we want to customize the helper
  44456. * @param scene The scene to add the material to
  44457. */
  44458. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44459. /**
  44460. * Updates the background according to the new options
  44461. * @param options
  44462. */
  44463. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44464. /**
  44465. * Sets the primary color of all the available elements.
  44466. * @param color the main color to affect to the ground and the background
  44467. */
  44468. setMainColor(color: Color3): void;
  44469. /**
  44470. * Setup the image processing according to the specified options.
  44471. */
  44472. private _setupImageProcessing;
  44473. /**
  44474. * Setup the environment texture according to the specified options.
  44475. */
  44476. private _setupEnvironmentTexture;
  44477. /**
  44478. * Setup the background according to the specified options.
  44479. */
  44480. private _setupBackground;
  44481. /**
  44482. * Get the scene sizes according to the setup.
  44483. */
  44484. private _getSceneSize;
  44485. /**
  44486. * Setup the ground according to the specified options.
  44487. */
  44488. private _setupGround;
  44489. /**
  44490. * Setup the ground material according to the specified options.
  44491. */
  44492. private _setupGroundMaterial;
  44493. /**
  44494. * Setup the ground diffuse texture according to the specified options.
  44495. */
  44496. private _setupGroundDiffuseTexture;
  44497. /**
  44498. * Setup the ground mirror texture according to the specified options.
  44499. */
  44500. private _setupGroundMirrorTexture;
  44501. /**
  44502. * Setup the ground to receive the mirror texture.
  44503. */
  44504. private _setupMirrorInGroundMaterial;
  44505. /**
  44506. * Setup the skybox according to the specified options.
  44507. */
  44508. private _setupSkybox;
  44509. /**
  44510. * Setup the skybox material according to the specified options.
  44511. */
  44512. private _setupSkyboxMaterial;
  44513. /**
  44514. * Setup the skybox reflection texture according to the specified options.
  44515. */
  44516. private _setupSkyboxReflectionTexture;
  44517. private _errorHandler;
  44518. /**
  44519. * Dispose all the elements created by the Helper.
  44520. */
  44521. dispose(): void;
  44522. }
  44523. }
  44524. declare module BABYLON {
  44525. /**
  44526. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44527. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44528. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44529. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44530. */
  44531. export class PhotoDome extends TransformNode {
  44532. /**
  44533. * Define the image as a Monoscopic panoramic 360 image.
  44534. */
  44535. static readonly MODE_MONOSCOPIC: number;
  44536. /**
  44537. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44538. */
  44539. static readonly MODE_TOPBOTTOM: number;
  44540. /**
  44541. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44542. */
  44543. static readonly MODE_SIDEBYSIDE: number;
  44544. private _useDirectMapping;
  44545. /**
  44546. * The texture being displayed on the sphere
  44547. */
  44548. protected _photoTexture: Texture;
  44549. /**
  44550. * Gets or sets the texture being displayed on the sphere
  44551. */
  44552. photoTexture: Texture;
  44553. /**
  44554. * Observable raised when an error occured while loading the 360 image
  44555. */
  44556. onLoadErrorObservable: Observable<string>;
  44557. /**
  44558. * The skybox material
  44559. */
  44560. protected _material: BackgroundMaterial;
  44561. /**
  44562. * The surface used for the skybox
  44563. */
  44564. protected _mesh: Mesh;
  44565. /**
  44566. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44567. * Also see the options.resolution property.
  44568. */
  44569. fovMultiplier: number;
  44570. private _imageMode;
  44571. /**
  44572. * Gets or set the current video mode for the video. It can be:
  44573. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44574. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44575. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44576. */
  44577. imageMode: number;
  44578. /**
  44579. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44580. * @param name Element's name, child elements will append suffixes for their own names.
  44581. * @param urlsOfPhoto defines the url of the photo to display
  44582. * @param options defines an object containing optional or exposed sub element properties
  44583. * @param onError defines a callback called when an error occured while loading the texture
  44584. */
  44585. constructor(name: string, urlOfPhoto: string, options: {
  44586. resolution?: number;
  44587. size?: number;
  44588. useDirectMapping?: boolean;
  44589. faceForward?: boolean;
  44590. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44591. private _onBeforeCameraRenderObserver;
  44592. private _changeImageMode;
  44593. /**
  44594. * Releases resources associated with this node.
  44595. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44596. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44597. */
  44598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44599. }
  44600. }
  44601. declare module BABYLON {
  44602. /** @hidden */
  44603. export var rgbdDecodePixelShader: {
  44604. name: string;
  44605. shader: string;
  44606. };
  44607. }
  44608. declare module BABYLON {
  44609. /**
  44610. * Class used to host texture specific utilities
  44611. */
  44612. export class BRDFTextureTools {
  44613. /**
  44614. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44615. * @param texture the texture to expand.
  44616. */
  44617. private static _ExpandDefaultBRDFTexture;
  44618. /**
  44619. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44620. * @param scene defines the hosting scene
  44621. * @returns the environment BRDF texture
  44622. */
  44623. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44624. private static _environmentBRDFBase64Texture;
  44625. }
  44626. }
  44627. declare module BABYLON {
  44628. /**
  44629. * @hidden
  44630. */
  44631. export interface IMaterialClearCoatDefines {
  44632. CLEARCOAT: boolean;
  44633. CLEARCOAT_DEFAULTIOR: boolean;
  44634. CLEARCOAT_TEXTURE: boolean;
  44635. CLEARCOAT_TEXTUREDIRECTUV: number;
  44636. CLEARCOAT_BUMP: boolean;
  44637. CLEARCOAT_BUMPDIRECTUV: number;
  44638. CLEARCOAT_TINT: boolean;
  44639. CLEARCOAT_TINT_TEXTURE: boolean;
  44640. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44641. /** @hidden */
  44642. _areTexturesDirty: boolean;
  44643. }
  44644. /**
  44645. * Define the code related to the clear coat parameters of the pbr material.
  44646. */
  44647. export class PBRClearCoatConfiguration {
  44648. /**
  44649. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44650. * The default fits with a polyurethane material.
  44651. */
  44652. private static readonly _DefaultIndexOfRefraction;
  44653. private _isEnabled;
  44654. /**
  44655. * Defines if the clear coat is enabled in the material.
  44656. */
  44657. isEnabled: boolean;
  44658. /**
  44659. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44660. */
  44661. intensity: number;
  44662. /**
  44663. * Defines the clear coat layer roughness.
  44664. */
  44665. roughness: number;
  44666. private _indexOfRefraction;
  44667. /**
  44668. * Defines the index of refraction of the clear coat.
  44669. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44670. * The default fits with a polyurethane material.
  44671. * Changing the default value is more performance intensive.
  44672. */
  44673. indexOfRefraction: number;
  44674. private _texture;
  44675. /**
  44676. * Stores the clear coat values in a texture.
  44677. */
  44678. texture: Nullable<BaseTexture>;
  44679. private _bumpTexture;
  44680. /**
  44681. * Define the clear coat specific bump texture.
  44682. */
  44683. bumpTexture: Nullable<BaseTexture>;
  44684. private _isTintEnabled;
  44685. /**
  44686. * Defines if the clear coat tint is enabled in the material.
  44687. */
  44688. isTintEnabled: boolean;
  44689. /**
  44690. * Defines the clear coat tint of the material.
  44691. * This is only use if tint is enabled
  44692. */
  44693. tintColor: Color3;
  44694. /**
  44695. * Defines the distance at which the tint color should be found in the
  44696. * clear coat media.
  44697. * This is only use if tint is enabled
  44698. */
  44699. tintColorAtDistance: number;
  44700. /**
  44701. * Defines the clear coat layer thickness.
  44702. * This is only use if tint is enabled
  44703. */
  44704. tintThickness: number;
  44705. private _tintTexture;
  44706. /**
  44707. * Stores the clear tint values in a texture.
  44708. * rgb is tint
  44709. * a is a thickness factor
  44710. */
  44711. tintTexture: Nullable<BaseTexture>;
  44712. /** @hidden */
  44713. private _internalMarkAllSubMeshesAsTexturesDirty;
  44714. /** @hidden */
  44715. _markAllSubMeshesAsTexturesDirty(): void;
  44716. /**
  44717. * Instantiate a new istance of clear coat configuration.
  44718. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44719. */
  44720. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44721. /**
  44722. * Gets wehter the submesh is ready to be used or not.
  44723. * @param defines the list of "defines" to update.
  44724. * @param scene defines the scene the material belongs to.
  44725. * @param engine defines the engine the material belongs to.
  44726. * @param disableBumpMap defines wether the material disables bump or not.
  44727. * @returns - boolean indicating that the submesh is ready or not.
  44728. */
  44729. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44730. /**
  44731. * Checks to see if a texture is used in the material.
  44732. * @param defines the list of "defines" to update.
  44733. * @param scene defines the scene to the material belongs to.
  44734. */
  44735. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44736. /**
  44737. * Binds the material data.
  44738. * @param uniformBuffer defines the Uniform buffer to fill in.
  44739. * @param scene defines the scene the material belongs to.
  44740. * @param engine defines the engine the material belongs to.
  44741. * @param disableBumpMap defines wether the material disables bump or not.
  44742. * @param isFrozen defines wether the material is frozen or not.
  44743. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44744. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44745. */
  44746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44747. /**
  44748. * Checks to see if a texture is used in the material.
  44749. * @param texture - Base texture to use.
  44750. * @returns - Boolean specifying if a texture is used in the material.
  44751. */
  44752. hasTexture(texture: BaseTexture): boolean;
  44753. /**
  44754. * Returns an array of the actively used textures.
  44755. * @param activeTextures Array of BaseTextures
  44756. */
  44757. getActiveTextures(activeTextures: BaseTexture[]): void;
  44758. /**
  44759. * Returns the animatable textures.
  44760. * @param animatables Array of animatable textures.
  44761. */
  44762. getAnimatables(animatables: IAnimatable[]): void;
  44763. /**
  44764. * Disposes the resources of the material.
  44765. * @param forceDisposeTextures - Forces the disposal of all textures.
  44766. */
  44767. dispose(forceDisposeTextures?: boolean): void;
  44768. /**
  44769. * Get the current class name of the texture useful for serialization or dynamic coding.
  44770. * @returns "PBRClearCoatConfiguration"
  44771. */
  44772. getClassName(): string;
  44773. /**
  44774. * Add fallbacks to the effect fallbacks list.
  44775. * @param defines defines the Base texture to use.
  44776. * @param fallbacks defines the current fallback list.
  44777. * @param currentRank defines the current fallback rank.
  44778. * @returns the new fallback rank.
  44779. */
  44780. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44781. /**
  44782. * Add the required uniforms to the current list.
  44783. * @param uniforms defines the current uniform list.
  44784. */
  44785. static AddUniforms(uniforms: string[]): void;
  44786. /**
  44787. * Add the required samplers to the current list.
  44788. * @param samplers defines the current sampler list.
  44789. */
  44790. static AddSamplers(samplers: string[]): void;
  44791. /**
  44792. * Add the required uniforms to the current buffer.
  44793. * @param uniformBuffer defines the current uniform buffer.
  44794. */
  44795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44796. /**
  44797. * Makes a duplicate of the current configuration into another one.
  44798. * @param clearCoatConfiguration define the config where to copy the info
  44799. */
  44800. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44801. /**
  44802. * Serializes this clear coat configuration.
  44803. * @returns - An object with the serialized config.
  44804. */
  44805. serialize(): any;
  44806. /**
  44807. * Parses a anisotropy Configuration from a serialized object.
  44808. * @param source - Serialized object.
  44809. * @param scene Defines the scene we are parsing for
  44810. * @param rootUrl Defines the rootUrl to load from
  44811. */
  44812. parse(source: any, scene: Scene, rootUrl: string): void;
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * @hidden
  44818. */
  44819. export interface IMaterialAnisotropicDefines {
  44820. ANISOTROPIC: boolean;
  44821. ANISOTROPIC_TEXTURE: boolean;
  44822. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44823. MAINUV1: boolean;
  44824. _areTexturesDirty: boolean;
  44825. _needUVs: boolean;
  44826. }
  44827. /**
  44828. * Define the code related to the anisotropic parameters of the pbr material.
  44829. */
  44830. export class PBRAnisotropicConfiguration {
  44831. private _isEnabled;
  44832. /**
  44833. * Defines if the anisotropy is enabled in the material.
  44834. */
  44835. isEnabled: boolean;
  44836. /**
  44837. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44838. */
  44839. intensity: number;
  44840. /**
  44841. * Defines if the effect is along the tangents, bitangents or in between.
  44842. * By default, the effect is "strectching" the highlights along the tangents.
  44843. */
  44844. direction: Vector2;
  44845. private _texture;
  44846. /**
  44847. * Stores the anisotropy values in a texture.
  44848. * rg is direction (like normal from -1 to 1)
  44849. * b is a intensity
  44850. */
  44851. texture: Nullable<BaseTexture>;
  44852. /** @hidden */
  44853. private _internalMarkAllSubMeshesAsTexturesDirty;
  44854. /** @hidden */
  44855. _markAllSubMeshesAsTexturesDirty(): void;
  44856. /**
  44857. * Instantiate a new istance of anisotropy configuration.
  44858. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44859. */
  44860. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44861. /**
  44862. * Specifies that the submesh is ready to be used.
  44863. * @param defines the list of "defines" to update.
  44864. * @param scene defines the scene the material belongs to.
  44865. * @returns - boolean indicating that the submesh is ready or not.
  44866. */
  44867. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44868. /**
  44869. * Checks to see if a texture is used in the material.
  44870. * @param defines the list of "defines" to update.
  44871. * @param mesh the mesh we are preparing the defines for.
  44872. * @param scene defines the scene the material belongs to.
  44873. */
  44874. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44875. /**
  44876. * Binds the material data.
  44877. * @param uniformBuffer defines the Uniform buffer to fill in.
  44878. * @param scene defines the scene the material belongs to.
  44879. * @param isFrozen defines wether the material is frozen or not.
  44880. */
  44881. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44882. /**
  44883. * Checks to see if a texture is used in the material.
  44884. * @param texture - Base texture to use.
  44885. * @returns - Boolean specifying if a texture is used in the material.
  44886. */
  44887. hasTexture(texture: BaseTexture): boolean;
  44888. /**
  44889. * Returns an array of the actively used textures.
  44890. * @param activeTextures Array of BaseTextures
  44891. */
  44892. getActiveTextures(activeTextures: BaseTexture[]): void;
  44893. /**
  44894. * Returns the animatable textures.
  44895. * @param animatables Array of animatable textures.
  44896. */
  44897. getAnimatables(animatables: IAnimatable[]): void;
  44898. /**
  44899. * Disposes the resources of the material.
  44900. * @param forceDisposeTextures - Forces the disposal of all textures.
  44901. */
  44902. dispose(forceDisposeTextures?: boolean): void;
  44903. /**
  44904. * Get the current class name of the texture useful for serialization or dynamic coding.
  44905. * @returns "PBRAnisotropicConfiguration"
  44906. */
  44907. getClassName(): string;
  44908. /**
  44909. * Add fallbacks to the effect fallbacks list.
  44910. * @param defines defines the Base texture to use.
  44911. * @param fallbacks defines the current fallback list.
  44912. * @param currentRank defines the current fallback rank.
  44913. * @returns the new fallback rank.
  44914. */
  44915. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44916. /**
  44917. * Add the required uniforms to the current list.
  44918. * @param uniforms defines the current uniform list.
  44919. */
  44920. static AddUniforms(uniforms: string[]): void;
  44921. /**
  44922. * Add the required uniforms to the current buffer.
  44923. * @param uniformBuffer defines the current uniform buffer.
  44924. */
  44925. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44926. /**
  44927. * Add the required samplers to the current list.
  44928. * @param samplers defines the current sampler list.
  44929. */
  44930. static AddSamplers(samplers: string[]): void;
  44931. /**
  44932. * Makes a duplicate of the current configuration into another one.
  44933. * @param anisotropicConfiguration define the config where to copy the info
  44934. */
  44935. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44936. /**
  44937. * Serializes this anisotropy configuration.
  44938. * @returns - An object with the serialized config.
  44939. */
  44940. serialize(): any;
  44941. /**
  44942. * Parses a anisotropy Configuration from a serialized object.
  44943. * @param source - Serialized object.
  44944. * @param scene Defines the scene we are parsing for
  44945. * @param rootUrl Defines the rootUrl to load from
  44946. */
  44947. parse(source: any, scene: Scene, rootUrl: string): void;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. /**
  44952. * @hidden
  44953. */
  44954. export interface IMaterialBRDFDefines {
  44955. BRDF_V_HEIGHT_CORRELATED: boolean;
  44956. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44957. SPHERICAL_HARMONICS: boolean;
  44958. /** @hidden */
  44959. _areMiscDirty: boolean;
  44960. }
  44961. /**
  44962. * Define the code related to the BRDF parameters of the pbr material.
  44963. */
  44964. export class PBRBRDFConfiguration {
  44965. /**
  44966. * Default value used for the energy conservation.
  44967. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44968. */
  44969. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44970. /**
  44971. * Default value used for the Smith Visibility Height Correlated mode.
  44972. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44973. */
  44974. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44975. /**
  44976. * Default value used for the IBL diffuse part.
  44977. * This can help switching back to the polynomials mode globally which is a tiny bit
  44978. * less GPU intensive at the drawback of a lower quality.
  44979. */
  44980. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44981. private _useEnergyConservation;
  44982. /**
  44983. * Defines if the material uses energy conservation.
  44984. */
  44985. useEnergyConservation: boolean;
  44986. private _useSmithVisibilityHeightCorrelated;
  44987. /**
  44988. * LEGACY Mode set to false
  44989. * Defines if the material uses height smith correlated visibility term.
  44990. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44991. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44992. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44993. * Not relying on height correlated will also disable energy conservation.
  44994. */
  44995. useSmithVisibilityHeightCorrelated: boolean;
  44996. private _useSphericalHarmonics;
  44997. /**
  44998. * LEGACY Mode set to false
  44999. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45000. * diffuse part of the IBL.
  45001. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45002. * to the ground truth.
  45003. */
  45004. useSphericalHarmonics: boolean;
  45005. /** @hidden */
  45006. private _internalMarkAllSubMeshesAsMiscDirty;
  45007. /** @hidden */
  45008. _markAllSubMeshesAsMiscDirty(): void;
  45009. /**
  45010. * Instantiate a new istance of clear coat configuration.
  45011. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45012. */
  45013. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45014. /**
  45015. * Checks to see if a texture is used in the material.
  45016. * @param defines the list of "defines" to update.
  45017. */
  45018. prepareDefines(defines: IMaterialBRDFDefines): void;
  45019. /**
  45020. * Get the current class name of the texture useful for serialization or dynamic coding.
  45021. * @returns "PBRClearCoatConfiguration"
  45022. */
  45023. getClassName(): string;
  45024. /**
  45025. * Makes a duplicate of the current configuration into another one.
  45026. * @param brdfConfiguration define the config where to copy the info
  45027. */
  45028. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45029. /**
  45030. * Serializes this BRDF configuration.
  45031. * @returns - An object with the serialized config.
  45032. */
  45033. serialize(): any;
  45034. /**
  45035. * Parses a anisotropy Configuration from a serialized object.
  45036. * @param source - Serialized object.
  45037. * @param scene Defines the scene we are parsing for
  45038. * @param rootUrl Defines the rootUrl to load from
  45039. */
  45040. parse(source: any, scene: Scene, rootUrl: string): void;
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. /**
  45045. * @hidden
  45046. */
  45047. export interface IMaterialSheenDefines {
  45048. SHEEN: boolean;
  45049. SHEEN_TEXTURE: boolean;
  45050. SHEEN_TEXTUREDIRECTUV: number;
  45051. SHEEN_LINKWITHALBEDO: boolean;
  45052. /** @hidden */
  45053. _areTexturesDirty: boolean;
  45054. }
  45055. /**
  45056. * Define the code related to the Sheen parameters of the pbr material.
  45057. */
  45058. export class PBRSheenConfiguration {
  45059. private _isEnabled;
  45060. /**
  45061. * Defines if the material uses sheen.
  45062. */
  45063. isEnabled: boolean;
  45064. private _linkSheenWithAlbedo;
  45065. /**
  45066. * Defines if the sheen is linked to the sheen color.
  45067. */
  45068. linkSheenWithAlbedo: boolean;
  45069. /**
  45070. * Defines the sheen intensity.
  45071. */
  45072. intensity: number;
  45073. /**
  45074. * Defines the sheen color.
  45075. */
  45076. color: Color3;
  45077. private _texture;
  45078. /**
  45079. * Stores the sheen tint values in a texture.
  45080. * rgb is tint
  45081. * a is a intensity
  45082. */
  45083. texture: Nullable<BaseTexture>;
  45084. /** @hidden */
  45085. private _internalMarkAllSubMeshesAsTexturesDirty;
  45086. /** @hidden */
  45087. _markAllSubMeshesAsTexturesDirty(): void;
  45088. /**
  45089. * Instantiate a new istance of clear coat configuration.
  45090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45091. */
  45092. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45093. /**
  45094. * Specifies that the submesh is ready to be used.
  45095. * @param defines the list of "defines" to update.
  45096. * @param scene defines the scene the material belongs to.
  45097. * @returns - boolean indicating that the submesh is ready or not.
  45098. */
  45099. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45100. /**
  45101. * Checks to see if a texture is used in the material.
  45102. * @param defines the list of "defines" to update.
  45103. * @param scene defines the scene the material belongs to.
  45104. */
  45105. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45106. /**
  45107. * Binds the material data.
  45108. * @param uniformBuffer defines the Uniform buffer to fill in.
  45109. * @param scene defines the scene the material belongs to.
  45110. * @param isFrozen defines wether the material is frozen or not.
  45111. */
  45112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45113. /**
  45114. * Checks to see if a texture is used in the material.
  45115. * @param texture - Base texture to use.
  45116. * @returns - Boolean specifying if a texture is used in the material.
  45117. */
  45118. hasTexture(texture: BaseTexture): boolean;
  45119. /**
  45120. * Returns an array of the actively used textures.
  45121. * @param activeTextures Array of BaseTextures
  45122. */
  45123. getActiveTextures(activeTextures: BaseTexture[]): void;
  45124. /**
  45125. * Returns the animatable textures.
  45126. * @param animatables Array of animatable textures.
  45127. */
  45128. getAnimatables(animatables: IAnimatable[]): void;
  45129. /**
  45130. * Disposes the resources of the material.
  45131. * @param forceDisposeTextures - Forces the disposal of all textures.
  45132. */
  45133. dispose(forceDisposeTextures?: boolean): void;
  45134. /**
  45135. * Get the current class name of the texture useful for serialization or dynamic coding.
  45136. * @returns "PBRSheenConfiguration"
  45137. */
  45138. getClassName(): string;
  45139. /**
  45140. * Add fallbacks to the effect fallbacks list.
  45141. * @param defines defines the Base texture to use.
  45142. * @param fallbacks defines the current fallback list.
  45143. * @param currentRank defines the current fallback rank.
  45144. * @returns the new fallback rank.
  45145. */
  45146. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45147. /**
  45148. * Add the required uniforms to the current list.
  45149. * @param uniforms defines the current uniform list.
  45150. */
  45151. static AddUniforms(uniforms: string[]): void;
  45152. /**
  45153. * Add the required uniforms to the current buffer.
  45154. * @param uniformBuffer defines the current uniform buffer.
  45155. */
  45156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45157. /**
  45158. * Add the required samplers to the current list.
  45159. * @param samplers defines the current sampler list.
  45160. */
  45161. static AddSamplers(samplers: string[]): void;
  45162. /**
  45163. * Makes a duplicate of the current configuration into another one.
  45164. * @param sheenConfiguration define the config where to copy the info
  45165. */
  45166. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45167. /**
  45168. * Serializes this BRDF configuration.
  45169. * @returns - An object with the serialized config.
  45170. */
  45171. serialize(): any;
  45172. /**
  45173. * Parses a anisotropy Configuration from a serialized object.
  45174. * @param source - Serialized object.
  45175. * @param scene Defines the scene we are parsing for
  45176. * @param rootUrl Defines the rootUrl to load from
  45177. */
  45178. parse(source: any, scene: Scene, rootUrl: string): void;
  45179. }
  45180. }
  45181. declare module BABYLON {
  45182. /**
  45183. * @hidden
  45184. */
  45185. export interface IMaterialSubSurfaceDefines {
  45186. SUBSURFACE: boolean;
  45187. SS_REFRACTION: boolean;
  45188. SS_TRANSLUCENCY: boolean;
  45189. SS_SCATERRING: boolean;
  45190. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45191. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45192. SS_REFRACTIONMAP_3D: boolean;
  45193. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45194. SS_LODINREFRACTIONALPHA: boolean;
  45195. SS_GAMMAREFRACTION: boolean;
  45196. SS_RGBDREFRACTION: boolean;
  45197. SS_LINEARSPECULARREFRACTION: boolean;
  45198. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45199. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45200. /** @hidden */
  45201. _areTexturesDirty: boolean;
  45202. }
  45203. /**
  45204. * Define the code related to the sub surface parameters of the pbr material.
  45205. */
  45206. export class PBRSubSurfaceConfiguration {
  45207. private _isRefractionEnabled;
  45208. /**
  45209. * Defines if the refraction is enabled in the material.
  45210. */
  45211. isRefractionEnabled: boolean;
  45212. private _isTranslucencyEnabled;
  45213. /**
  45214. * Defines if the translucency is enabled in the material.
  45215. */
  45216. isTranslucencyEnabled: boolean;
  45217. private _isScatteringEnabled;
  45218. /**
  45219. * Defines the refraction intensity of the material.
  45220. * The refraction when enabled replaces the Diffuse part of the material.
  45221. * The intensity helps transitionning between diffuse and refraction.
  45222. */
  45223. refractionIntensity: number;
  45224. /**
  45225. * Defines the translucency intensity of the material.
  45226. * When translucency has been enabled, this defines how much of the "translucency"
  45227. * is addded to the diffuse part of the material.
  45228. */
  45229. translucencyIntensity: number;
  45230. /**
  45231. * Defines the scattering intensity of the material.
  45232. * When scattering has been enabled, this defines how much of the "scattered light"
  45233. * is addded to the diffuse part of the material.
  45234. */
  45235. scatteringIntensity: number;
  45236. private _thicknessTexture;
  45237. /**
  45238. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45239. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45240. * 0 would mean minimumThickness
  45241. * 1 would mean maximumThickness
  45242. * The other channels might be use as a mask to vary the different effects intensity.
  45243. */
  45244. thicknessTexture: Nullable<BaseTexture>;
  45245. private _refractionTexture;
  45246. /**
  45247. * Defines the texture to use for refraction.
  45248. */
  45249. refractionTexture: Nullable<BaseTexture>;
  45250. private _indexOfRefraction;
  45251. /**
  45252. * Defines the index of refraction used in the material.
  45253. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45254. */
  45255. indexOfRefraction: number;
  45256. private _invertRefractionY;
  45257. /**
  45258. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45259. */
  45260. invertRefractionY: boolean;
  45261. private _linkRefractionWithTransparency;
  45262. /**
  45263. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45264. * Materials half opaque for instance using refraction could benefit from this control.
  45265. */
  45266. linkRefractionWithTransparency: boolean;
  45267. /**
  45268. * Defines the minimum thickness stored in the thickness map.
  45269. * If no thickness map is defined, this value will be used to simulate thickness.
  45270. */
  45271. minimumThickness: number;
  45272. /**
  45273. * Defines the maximum thickness stored in the thickness map.
  45274. */
  45275. maximumThickness: number;
  45276. /**
  45277. * Defines the volume tint of the material.
  45278. * This is used for both translucency and scattering.
  45279. */
  45280. tintColor: Color3;
  45281. /**
  45282. * Defines the distance at which the tint color should be found in the media.
  45283. * This is used for refraction only.
  45284. */
  45285. tintColorAtDistance: number;
  45286. /**
  45287. * Defines how far each channel transmit through the media.
  45288. * It is defined as a color to simplify it selection.
  45289. */
  45290. diffusionDistance: Color3;
  45291. private _useMaskFromThicknessTexture;
  45292. /**
  45293. * Stores the intensity of the different subsurface effects in the thickness texture.
  45294. * * the green channel is the translucency intensity.
  45295. * * the blue channel is the scattering intensity.
  45296. * * the alpha channel is the refraction intensity.
  45297. */
  45298. useMaskFromThicknessTexture: boolean;
  45299. /** @hidden */
  45300. private _internalMarkAllSubMeshesAsTexturesDirty;
  45301. /** @hidden */
  45302. _markAllSubMeshesAsTexturesDirty(): void;
  45303. /**
  45304. * Instantiate a new istance of sub surface configuration.
  45305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45306. */
  45307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45308. /**
  45309. * Gets wehter the submesh is ready to be used or not.
  45310. * @param defines the list of "defines" to update.
  45311. * @param scene defines the scene the material belongs to.
  45312. * @returns - boolean indicating that the submesh is ready or not.
  45313. */
  45314. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45315. /**
  45316. * Checks to see if a texture is used in the material.
  45317. * @param defines the list of "defines" to update.
  45318. * @param scene defines the scene to the material belongs to.
  45319. */
  45320. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45321. /**
  45322. * Binds the material data.
  45323. * @param uniformBuffer defines the Uniform buffer to fill in.
  45324. * @param scene defines the scene the material belongs to.
  45325. * @param engine defines the engine the material belongs to.
  45326. * @param isFrozen defines wether the material is frozen or not.
  45327. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45328. */
  45329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45330. /**
  45331. * Unbinds the material from the mesh.
  45332. * @param activeEffect defines the effect that should be unbound from.
  45333. * @returns true if unbound, otherwise false
  45334. */
  45335. unbind(activeEffect: Effect): boolean;
  45336. /**
  45337. * Returns the texture used for refraction or null if none is used.
  45338. * @param scene defines the scene the material belongs to.
  45339. * @returns - Refraction texture if present. If no refraction texture and refraction
  45340. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45341. */
  45342. private _getRefractionTexture;
  45343. /**
  45344. * Returns true if alpha blending should be disabled.
  45345. */
  45346. readonly disableAlphaBlending: boolean;
  45347. /**
  45348. * Fills the list of render target textures.
  45349. * @param renderTargets the list of render targets to update
  45350. */
  45351. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45352. /**
  45353. * Checks to see if a texture is used in the material.
  45354. * @param texture - Base texture to use.
  45355. * @returns - Boolean specifying if a texture is used in the material.
  45356. */
  45357. hasTexture(texture: BaseTexture): boolean;
  45358. /**
  45359. * Gets a boolean indicating that current material needs to register RTT
  45360. * @returns true if this uses a render target otherwise false.
  45361. */
  45362. hasRenderTargetTextures(): boolean;
  45363. /**
  45364. * Returns an array of the actively used textures.
  45365. * @param activeTextures Array of BaseTextures
  45366. */
  45367. getActiveTextures(activeTextures: BaseTexture[]): void;
  45368. /**
  45369. * Returns the animatable textures.
  45370. * @param animatables Array of animatable textures.
  45371. */
  45372. getAnimatables(animatables: IAnimatable[]): void;
  45373. /**
  45374. * Disposes the resources of the material.
  45375. * @param forceDisposeTextures - Forces the disposal of all textures.
  45376. */
  45377. dispose(forceDisposeTextures?: boolean): void;
  45378. /**
  45379. * Get the current class name of the texture useful for serialization or dynamic coding.
  45380. * @returns "PBRSubSurfaceConfiguration"
  45381. */
  45382. getClassName(): string;
  45383. /**
  45384. * Add fallbacks to the effect fallbacks list.
  45385. * @param defines defines the Base texture to use.
  45386. * @param fallbacks defines the current fallback list.
  45387. * @param currentRank defines the current fallback rank.
  45388. * @returns the new fallback rank.
  45389. */
  45390. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45391. /**
  45392. * Add the required uniforms to the current list.
  45393. * @param uniforms defines the current uniform list.
  45394. */
  45395. static AddUniforms(uniforms: string[]): void;
  45396. /**
  45397. * Add the required samplers to the current list.
  45398. * @param samplers defines the current sampler list.
  45399. */
  45400. static AddSamplers(samplers: string[]): void;
  45401. /**
  45402. * Add the required uniforms to the current buffer.
  45403. * @param uniformBuffer defines the current uniform buffer.
  45404. */
  45405. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45406. /**
  45407. * Makes a duplicate of the current configuration into another one.
  45408. * @param configuration define the config where to copy the info
  45409. */
  45410. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45411. /**
  45412. * Serializes this Sub Surface configuration.
  45413. * @returns - An object with the serialized config.
  45414. */
  45415. serialize(): any;
  45416. /**
  45417. * Parses a anisotropy Configuration from a serialized object.
  45418. * @param source - Serialized object.
  45419. * @param scene Defines the scene we are parsing for
  45420. * @param rootUrl Defines the rootUrl to load from
  45421. */
  45422. parse(source: any, scene: Scene, rootUrl: string): void;
  45423. }
  45424. }
  45425. declare module BABYLON {
  45426. /** @hidden */
  45427. export var pbrFragmentDeclaration: {
  45428. name: string;
  45429. shader: string;
  45430. };
  45431. }
  45432. declare module BABYLON {
  45433. /** @hidden */
  45434. export var pbrUboDeclaration: {
  45435. name: string;
  45436. shader: string;
  45437. };
  45438. }
  45439. declare module BABYLON {
  45440. /** @hidden */
  45441. export var pbrFragmentExtraDeclaration: {
  45442. name: string;
  45443. shader: string;
  45444. };
  45445. }
  45446. declare module BABYLON {
  45447. /** @hidden */
  45448. export var pbrFragmentSamplersDeclaration: {
  45449. name: string;
  45450. shader: string;
  45451. };
  45452. }
  45453. declare module BABYLON {
  45454. /** @hidden */
  45455. export var pbrHelperFunctions: {
  45456. name: string;
  45457. shader: string;
  45458. };
  45459. }
  45460. declare module BABYLON {
  45461. /** @hidden */
  45462. export var harmonicsFunctions: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module BABYLON {
  45468. /** @hidden */
  45469. export var pbrDirectLightingSetupFunctions: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module BABYLON {
  45475. /** @hidden */
  45476. export var pbrDirectLightingFalloffFunctions: {
  45477. name: string;
  45478. shader: string;
  45479. };
  45480. }
  45481. declare module BABYLON {
  45482. /** @hidden */
  45483. export var pbrBRDFFunctions: {
  45484. name: string;
  45485. shader: string;
  45486. };
  45487. }
  45488. declare module BABYLON {
  45489. /** @hidden */
  45490. export var pbrDirectLightingFunctions: {
  45491. name: string;
  45492. shader: string;
  45493. };
  45494. }
  45495. declare module BABYLON {
  45496. /** @hidden */
  45497. export var pbrIBLFunctions: {
  45498. name: string;
  45499. shader: string;
  45500. };
  45501. }
  45502. declare module BABYLON {
  45503. /** @hidden */
  45504. export var pbrDebug: {
  45505. name: string;
  45506. shader: string;
  45507. };
  45508. }
  45509. declare module BABYLON {
  45510. /** @hidden */
  45511. export var pbrPixelShader: {
  45512. name: string;
  45513. shader: string;
  45514. };
  45515. }
  45516. declare module BABYLON {
  45517. /** @hidden */
  45518. export var pbrVertexDeclaration: {
  45519. name: string;
  45520. shader: string;
  45521. };
  45522. }
  45523. declare module BABYLON {
  45524. /** @hidden */
  45525. export var pbrVertexShader: {
  45526. name: string;
  45527. shader: string;
  45528. };
  45529. }
  45530. declare module BABYLON {
  45531. /**
  45532. * Manages the defines for the PBR Material.
  45533. * @hidden
  45534. */
  45535. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45536. PBR: boolean;
  45537. MAINUV1: boolean;
  45538. MAINUV2: boolean;
  45539. UV1: boolean;
  45540. UV2: boolean;
  45541. ALBEDO: boolean;
  45542. ALBEDODIRECTUV: number;
  45543. VERTEXCOLOR: boolean;
  45544. AMBIENT: boolean;
  45545. AMBIENTDIRECTUV: number;
  45546. AMBIENTINGRAYSCALE: boolean;
  45547. OPACITY: boolean;
  45548. VERTEXALPHA: boolean;
  45549. OPACITYDIRECTUV: number;
  45550. OPACITYRGB: boolean;
  45551. ALPHATEST: boolean;
  45552. DEPTHPREPASS: boolean;
  45553. ALPHABLEND: boolean;
  45554. ALPHAFROMALBEDO: boolean;
  45555. ALPHATESTVALUE: string;
  45556. SPECULAROVERALPHA: boolean;
  45557. RADIANCEOVERALPHA: boolean;
  45558. ALPHAFRESNEL: boolean;
  45559. LINEARALPHAFRESNEL: boolean;
  45560. PREMULTIPLYALPHA: boolean;
  45561. EMISSIVE: boolean;
  45562. EMISSIVEDIRECTUV: number;
  45563. REFLECTIVITY: boolean;
  45564. REFLECTIVITYDIRECTUV: number;
  45565. SPECULARTERM: boolean;
  45566. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45567. MICROSURFACEAUTOMATIC: boolean;
  45568. LODBASEDMICROSFURACE: boolean;
  45569. MICROSURFACEMAP: boolean;
  45570. MICROSURFACEMAPDIRECTUV: number;
  45571. METALLICWORKFLOW: boolean;
  45572. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45573. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45574. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45575. AOSTOREINMETALMAPRED: boolean;
  45576. ENVIRONMENTBRDF: boolean;
  45577. ENVIRONMENTBRDF_RGBD: boolean;
  45578. NORMAL: boolean;
  45579. TANGENT: boolean;
  45580. BUMP: boolean;
  45581. BUMPDIRECTUV: number;
  45582. OBJECTSPACE_NORMALMAP: boolean;
  45583. PARALLAX: boolean;
  45584. PARALLAXOCCLUSION: boolean;
  45585. NORMALXYSCALE: boolean;
  45586. LIGHTMAP: boolean;
  45587. LIGHTMAPDIRECTUV: number;
  45588. USELIGHTMAPASSHADOWMAP: boolean;
  45589. GAMMALIGHTMAP: boolean;
  45590. REFLECTION: boolean;
  45591. REFLECTIONMAP_3D: boolean;
  45592. REFLECTIONMAP_SPHERICAL: boolean;
  45593. REFLECTIONMAP_PLANAR: boolean;
  45594. REFLECTIONMAP_CUBIC: boolean;
  45595. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45596. REFLECTIONMAP_PROJECTION: boolean;
  45597. REFLECTIONMAP_SKYBOX: boolean;
  45598. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45599. REFLECTIONMAP_EXPLICIT: boolean;
  45600. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45601. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45602. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45603. INVERTCUBICMAP: boolean;
  45604. USESPHERICALFROMREFLECTIONMAP: boolean;
  45605. USEIRRADIANCEMAP: boolean;
  45606. SPHERICAL_HARMONICS: boolean;
  45607. USESPHERICALINVERTEX: boolean;
  45608. REFLECTIONMAP_OPPOSITEZ: boolean;
  45609. LODINREFLECTIONALPHA: boolean;
  45610. GAMMAREFLECTION: boolean;
  45611. RGBDREFLECTION: boolean;
  45612. LINEARSPECULARREFLECTION: boolean;
  45613. RADIANCEOCCLUSION: boolean;
  45614. HORIZONOCCLUSION: boolean;
  45615. INSTANCES: boolean;
  45616. NUM_BONE_INFLUENCERS: number;
  45617. BonesPerMesh: number;
  45618. BONETEXTURE: boolean;
  45619. NONUNIFORMSCALING: boolean;
  45620. MORPHTARGETS: boolean;
  45621. MORPHTARGETS_NORMAL: boolean;
  45622. MORPHTARGETS_TANGENT: boolean;
  45623. MORPHTARGETS_UV: boolean;
  45624. NUM_MORPH_INFLUENCERS: number;
  45625. IMAGEPROCESSING: boolean;
  45626. VIGNETTE: boolean;
  45627. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45628. VIGNETTEBLENDMODEOPAQUE: boolean;
  45629. TONEMAPPING: boolean;
  45630. TONEMAPPING_ACES: boolean;
  45631. CONTRAST: boolean;
  45632. COLORCURVES: boolean;
  45633. COLORGRADING: boolean;
  45634. COLORGRADING3D: boolean;
  45635. SAMPLER3DGREENDEPTH: boolean;
  45636. SAMPLER3DBGRMAP: boolean;
  45637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45638. EXPOSURE: boolean;
  45639. MULTIVIEW: boolean;
  45640. USEPHYSICALLIGHTFALLOFF: boolean;
  45641. USEGLTFLIGHTFALLOFF: boolean;
  45642. TWOSIDEDLIGHTING: boolean;
  45643. SHADOWFLOAT: boolean;
  45644. CLIPPLANE: boolean;
  45645. CLIPPLANE2: boolean;
  45646. CLIPPLANE3: boolean;
  45647. CLIPPLANE4: boolean;
  45648. POINTSIZE: boolean;
  45649. FOG: boolean;
  45650. LOGARITHMICDEPTH: boolean;
  45651. FORCENORMALFORWARD: boolean;
  45652. SPECULARAA: boolean;
  45653. CLEARCOAT: boolean;
  45654. CLEARCOAT_DEFAULTIOR: boolean;
  45655. CLEARCOAT_TEXTURE: boolean;
  45656. CLEARCOAT_TEXTUREDIRECTUV: number;
  45657. CLEARCOAT_BUMP: boolean;
  45658. CLEARCOAT_BUMPDIRECTUV: number;
  45659. CLEARCOAT_TINT: boolean;
  45660. CLEARCOAT_TINT_TEXTURE: boolean;
  45661. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45662. ANISOTROPIC: boolean;
  45663. ANISOTROPIC_TEXTURE: boolean;
  45664. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45665. BRDF_V_HEIGHT_CORRELATED: boolean;
  45666. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45667. SHEEN: boolean;
  45668. SHEEN_TEXTURE: boolean;
  45669. SHEEN_TEXTUREDIRECTUV: number;
  45670. SHEEN_LINKWITHALBEDO: boolean;
  45671. SUBSURFACE: boolean;
  45672. SS_REFRACTION: boolean;
  45673. SS_TRANSLUCENCY: boolean;
  45674. SS_SCATERRING: boolean;
  45675. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45676. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45677. SS_REFRACTIONMAP_3D: boolean;
  45678. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45679. SS_LODINREFRACTIONALPHA: boolean;
  45680. SS_GAMMAREFRACTION: boolean;
  45681. SS_RGBDREFRACTION: boolean;
  45682. SS_LINEARSPECULARREFRACTION: boolean;
  45683. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45684. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45685. UNLIT: boolean;
  45686. DEBUGMODE: number;
  45687. /**
  45688. * Initializes the PBR Material defines.
  45689. */
  45690. constructor();
  45691. /**
  45692. * Resets the PBR Material defines.
  45693. */
  45694. reset(): void;
  45695. }
  45696. /**
  45697. * The Physically based material base class of BJS.
  45698. *
  45699. * This offers the main features of a standard PBR material.
  45700. * For more information, please refer to the documentation :
  45701. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45702. */
  45703. export abstract class PBRBaseMaterial extends PushMaterial {
  45704. /**
  45705. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45706. */
  45707. static readonly PBRMATERIAL_OPAQUE: number;
  45708. /**
  45709. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45710. */
  45711. static readonly PBRMATERIAL_ALPHATEST: number;
  45712. /**
  45713. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45714. */
  45715. static readonly PBRMATERIAL_ALPHABLEND: number;
  45716. /**
  45717. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45718. * They are also discarded below the alpha cutoff threshold to improve performances.
  45719. */
  45720. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45721. /**
  45722. * Defines the default value of how much AO map is occluding the analytical lights
  45723. * (point spot...).
  45724. */
  45725. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45726. /**
  45727. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45728. */
  45729. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45730. /**
  45731. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45732. * to enhance interoperability with other engines.
  45733. */
  45734. static readonly LIGHTFALLOFF_GLTF: number;
  45735. /**
  45736. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45737. * to enhance interoperability with other materials.
  45738. */
  45739. static readonly LIGHTFALLOFF_STANDARD: number;
  45740. /**
  45741. * Intensity of the direct lights e.g. the four lights available in your scene.
  45742. * This impacts both the direct diffuse and specular highlights.
  45743. */
  45744. protected _directIntensity: number;
  45745. /**
  45746. * Intensity of the emissive part of the material.
  45747. * This helps controlling the emissive effect without modifying the emissive color.
  45748. */
  45749. protected _emissiveIntensity: number;
  45750. /**
  45751. * Intensity of the environment e.g. how much the environment will light the object
  45752. * either through harmonics for rough material or through the refelction for shiny ones.
  45753. */
  45754. protected _environmentIntensity: number;
  45755. /**
  45756. * This is a special control allowing the reduction of the specular highlights coming from the
  45757. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45758. */
  45759. protected _specularIntensity: number;
  45760. /**
  45761. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45762. */
  45763. private _lightingInfos;
  45764. /**
  45765. * Debug Control allowing disabling the bump map on this material.
  45766. */
  45767. protected _disableBumpMap: boolean;
  45768. /**
  45769. * AKA Diffuse Texture in standard nomenclature.
  45770. */
  45771. protected _albedoTexture: Nullable<BaseTexture>;
  45772. /**
  45773. * AKA Occlusion Texture in other nomenclature.
  45774. */
  45775. protected _ambientTexture: Nullable<BaseTexture>;
  45776. /**
  45777. * AKA Occlusion Texture Intensity in other nomenclature.
  45778. */
  45779. protected _ambientTextureStrength: number;
  45780. /**
  45781. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45782. * 1 means it completely occludes it
  45783. * 0 mean it has no impact
  45784. */
  45785. protected _ambientTextureImpactOnAnalyticalLights: number;
  45786. /**
  45787. * Stores the alpha values in a texture.
  45788. */
  45789. protected _opacityTexture: Nullable<BaseTexture>;
  45790. /**
  45791. * Stores the reflection values in a texture.
  45792. */
  45793. protected _reflectionTexture: Nullable<BaseTexture>;
  45794. /**
  45795. * Stores the emissive values in a texture.
  45796. */
  45797. protected _emissiveTexture: Nullable<BaseTexture>;
  45798. /**
  45799. * AKA Specular texture in other nomenclature.
  45800. */
  45801. protected _reflectivityTexture: Nullable<BaseTexture>;
  45802. /**
  45803. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45804. */
  45805. protected _metallicTexture: Nullable<BaseTexture>;
  45806. /**
  45807. * Specifies the metallic scalar of the metallic/roughness workflow.
  45808. * Can also be used to scale the metalness values of the metallic texture.
  45809. */
  45810. protected _metallic: Nullable<number>;
  45811. /**
  45812. * Specifies the roughness scalar of the metallic/roughness workflow.
  45813. * Can also be used to scale the roughness values of the metallic texture.
  45814. */
  45815. protected _roughness: Nullable<number>;
  45816. /**
  45817. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45818. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45819. */
  45820. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45821. /**
  45822. * Stores surface normal data used to displace a mesh in a texture.
  45823. */
  45824. protected _bumpTexture: Nullable<BaseTexture>;
  45825. /**
  45826. * Stores the pre-calculated light information of a mesh in a texture.
  45827. */
  45828. protected _lightmapTexture: Nullable<BaseTexture>;
  45829. /**
  45830. * The color of a material in ambient lighting.
  45831. */
  45832. protected _ambientColor: Color3;
  45833. /**
  45834. * AKA Diffuse Color in other nomenclature.
  45835. */
  45836. protected _albedoColor: Color3;
  45837. /**
  45838. * AKA Specular Color in other nomenclature.
  45839. */
  45840. protected _reflectivityColor: Color3;
  45841. /**
  45842. * The color applied when light is reflected from a material.
  45843. */
  45844. protected _reflectionColor: Color3;
  45845. /**
  45846. * The color applied when light is emitted from a material.
  45847. */
  45848. protected _emissiveColor: Color3;
  45849. /**
  45850. * AKA Glossiness in other nomenclature.
  45851. */
  45852. protected _microSurface: number;
  45853. /**
  45854. * Specifies that the material will use the light map as a show map.
  45855. */
  45856. protected _useLightmapAsShadowmap: boolean;
  45857. /**
  45858. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45859. * makes the reflect vector face the model (under horizon).
  45860. */
  45861. protected _useHorizonOcclusion: boolean;
  45862. /**
  45863. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45864. * too much the area relying on ambient texture to define their ambient occlusion.
  45865. */
  45866. protected _useRadianceOcclusion: boolean;
  45867. /**
  45868. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45869. */
  45870. protected _useAlphaFromAlbedoTexture: boolean;
  45871. /**
  45872. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45873. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45874. */
  45875. protected _useSpecularOverAlpha: boolean;
  45876. /**
  45877. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45878. */
  45879. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45880. /**
  45881. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45882. */
  45883. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45884. /**
  45885. * Specifies if the metallic texture contains the roughness information in its green channel.
  45886. */
  45887. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45888. /**
  45889. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45890. */
  45891. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45892. /**
  45893. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45894. */
  45895. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45896. /**
  45897. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45898. */
  45899. protected _useAmbientInGrayScale: boolean;
  45900. /**
  45901. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45902. * The material will try to infer what glossiness each pixel should be.
  45903. */
  45904. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45905. /**
  45906. * Defines the falloff type used in this material.
  45907. * It by default is Physical.
  45908. */
  45909. protected _lightFalloff: number;
  45910. /**
  45911. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45912. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45913. */
  45914. protected _useRadianceOverAlpha: boolean;
  45915. /**
  45916. * Allows using an object space normal map (instead of tangent space).
  45917. */
  45918. protected _useObjectSpaceNormalMap: boolean;
  45919. /**
  45920. * Allows using the bump map in parallax mode.
  45921. */
  45922. protected _useParallax: boolean;
  45923. /**
  45924. * Allows using the bump map in parallax occlusion mode.
  45925. */
  45926. protected _useParallaxOcclusion: boolean;
  45927. /**
  45928. * Controls the scale bias of the parallax mode.
  45929. */
  45930. protected _parallaxScaleBias: number;
  45931. /**
  45932. * If sets to true, disables all the lights affecting the material.
  45933. */
  45934. protected _disableLighting: boolean;
  45935. /**
  45936. * Number of Simultaneous lights allowed on the material.
  45937. */
  45938. protected _maxSimultaneousLights: number;
  45939. /**
  45940. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45941. */
  45942. protected _invertNormalMapX: boolean;
  45943. /**
  45944. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45945. */
  45946. protected _invertNormalMapY: boolean;
  45947. /**
  45948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45949. */
  45950. protected _twoSidedLighting: boolean;
  45951. /**
  45952. * Defines the alpha limits in alpha test mode.
  45953. */
  45954. protected _alphaCutOff: number;
  45955. /**
  45956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45957. */
  45958. protected _forceAlphaTest: boolean;
  45959. /**
  45960. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45961. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45962. */
  45963. protected _useAlphaFresnel: boolean;
  45964. /**
  45965. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45966. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45967. */
  45968. protected _useLinearAlphaFresnel: boolean;
  45969. /**
  45970. * The transparency mode of the material.
  45971. */
  45972. protected _transparencyMode: Nullable<number>;
  45973. /**
  45974. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45975. * from cos thetav and roughness:
  45976. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45977. */
  45978. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45979. /**
  45980. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45981. */
  45982. protected _forceIrradianceInFragment: boolean;
  45983. /**
  45984. * Force normal to face away from face.
  45985. */
  45986. protected _forceNormalForward: boolean;
  45987. /**
  45988. * Enables specular anti aliasing in the PBR shader.
  45989. * It will both interacts on the Geometry for analytical and IBL lighting.
  45990. * It also prefilter the roughness map based on the bump values.
  45991. */
  45992. protected _enableSpecularAntiAliasing: boolean;
  45993. /**
  45994. * Default configuration related to image processing available in the PBR Material.
  45995. */
  45996. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45997. /**
  45998. * Keep track of the image processing observer to allow dispose and replace.
  45999. */
  46000. private _imageProcessingObserver;
  46001. /**
  46002. * Attaches a new image processing configuration to the PBR Material.
  46003. * @param configuration
  46004. */
  46005. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46006. /**
  46007. * Stores the available render targets.
  46008. */
  46009. private _renderTargets;
  46010. /**
  46011. * Sets the global ambient color for the material used in lighting calculations.
  46012. */
  46013. private _globalAmbientColor;
  46014. /**
  46015. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46016. */
  46017. private _useLogarithmicDepth;
  46018. /**
  46019. * If set to true, no lighting calculations will be applied.
  46020. */
  46021. private _unlit;
  46022. private _debugMode;
  46023. /**
  46024. * @hidden
  46025. * This is reserved for the inspector.
  46026. * Defines the material debug mode.
  46027. * It helps seeing only some components of the material while troubleshooting.
  46028. */
  46029. debugMode: number;
  46030. /**
  46031. * @hidden
  46032. * This is reserved for the inspector.
  46033. * Specify from where on screen the debug mode should start.
  46034. * The value goes from -1 (full screen) to 1 (not visible)
  46035. * It helps with side by side comparison against the final render
  46036. * This defaults to -1
  46037. */
  46038. private debugLimit;
  46039. /**
  46040. * @hidden
  46041. * This is reserved for the inspector.
  46042. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46043. * You can use the factor to better multiply the final value.
  46044. */
  46045. private debugFactor;
  46046. /**
  46047. * Defines the clear coat layer parameters for the material.
  46048. */
  46049. readonly clearCoat: PBRClearCoatConfiguration;
  46050. /**
  46051. * Defines the anisotropic parameters for the material.
  46052. */
  46053. readonly anisotropy: PBRAnisotropicConfiguration;
  46054. /**
  46055. * Defines the BRDF parameters for the material.
  46056. */
  46057. readonly brdf: PBRBRDFConfiguration;
  46058. /**
  46059. * Defines the Sheen parameters for the material.
  46060. */
  46061. readonly sheen: PBRSheenConfiguration;
  46062. /**
  46063. * Defines the SubSurface parameters for the material.
  46064. */
  46065. readonly subSurface: PBRSubSurfaceConfiguration;
  46066. /**
  46067. * Custom callback helping to override the default shader used in the material.
  46068. */
  46069. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46070. /**
  46071. * Instantiates a new PBRMaterial instance.
  46072. *
  46073. * @param name The material name
  46074. * @param scene The scene the material will be use in.
  46075. */
  46076. constructor(name: string, scene: Scene);
  46077. /**
  46078. * Gets a boolean indicating that current material needs to register RTT
  46079. */
  46080. readonly hasRenderTargetTextures: boolean;
  46081. /**
  46082. * Gets the name of the material class.
  46083. */
  46084. getClassName(): string;
  46085. /**
  46086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46087. */
  46088. /**
  46089. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46090. */
  46091. useLogarithmicDepth: boolean;
  46092. /**
  46093. * Gets the current transparency mode.
  46094. */
  46095. /**
  46096. * Sets the transparency mode of the material.
  46097. *
  46098. * | Value | Type | Description |
  46099. * | ----- | ----------------------------------- | ----------- |
  46100. * | 0 | OPAQUE | |
  46101. * | 1 | ALPHATEST | |
  46102. * | 2 | ALPHABLEND | |
  46103. * | 3 | ALPHATESTANDBLEND | |
  46104. *
  46105. */
  46106. transparencyMode: Nullable<number>;
  46107. /**
  46108. * Returns true if alpha blending should be disabled.
  46109. */
  46110. private readonly _disableAlphaBlending;
  46111. /**
  46112. * Specifies whether or not this material should be rendered in alpha blend mode.
  46113. */
  46114. needAlphaBlending(): boolean;
  46115. /**
  46116. * Specifies if the mesh will require alpha blending.
  46117. * @param mesh - BJS mesh.
  46118. */
  46119. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46120. /**
  46121. * Specifies whether or not this material should be rendered in alpha test mode.
  46122. */
  46123. needAlphaTesting(): boolean;
  46124. /**
  46125. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46126. */
  46127. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46128. /**
  46129. * Gets the texture used for the alpha test.
  46130. */
  46131. getAlphaTestTexture(): Nullable<BaseTexture>;
  46132. /**
  46133. * Specifies that the submesh is ready to be used.
  46134. * @param mesh - BJS mesh.
  46135. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46136. * @param useInstances - Specifies that instances should be used.
  46137. * @returns - boolean indicating that the submesh is ready or not.
  46138. */
  46139. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46140. /**
  46141. * Specifies if the material uses metallic roughness workflow.
  46142. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46143. */
  46144. isMetallicWorkflow(): boolean;
  46145. private _prepareEffect;
  46146. private _prepareDefines;
  46147. /**
  46148. * Force shader compilation
  46149. */
  46150. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46151. clipPlane: boolean;
  46152. }>): void;
  46153. /**
  46154. * Initializes the uniform buffer layout for the shader.
  46155. */
  46156. buildUniformLayout(): void;
  46157. /**
  46158. * Unbinds the material from the mesh
  46159. */
  46160. unbind(): void;
  46161. /**
  46162. * Binds the submesh data.
  46163. * @param world - The world matrix.
  46164. * @param mesh - The BJS mesh.
  46165. * @param subMesh - A submesh of the BJS mesh.
  46166. */
  46167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46168. /**
  46169. * Returns the animatable textures.
  46170. * @returns - Array of animatable textures.
  46171. */
  46172. getAnimatables(): IAnimatable[];
  46173. /**
  46174. * Returns the texture used for reflections.
  46175. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46176. */
  46177. private _getReflectionTexture;
  46178. /**
  46179. * Returns an array of the actively used textures.
  46180. * @returns - Array of BaseTextures
  46181. */
  46182. getActiveTextures(): BaseTexture[];
  46183. /**
  46184. * Checks to see if a texture is used in the material.
  46185. * @param texture - Base texture to use.
  46186. * @returns - Boolean specifying if a texture is used in the material.
  46187. */
  46188. hasTexture(texture: BaseTexture): boolean;
  46189. /**
  46190. * Disposes the resources of the material.
  46191. * @param forceDisposeEffect - Forces the disposal of effects.
  46192. * @param forceDisposeTextures - Forces the disposal of all textures.
  46193. */
  46194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46195. }
  46196. }
  46197. declare module BABYLON {
  46198. /**
  46199. * The Physically based material of BJS.
  46200. *
  46201. * This offers the main features of a standard PBR material.
  46202. * For more information, please refer to the documentation :
  46203. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46204. */
  46205. export class PBRMaterial extends PBRBaseMaterial {
  46206. /**
  46207. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46208. */
  46209. static readonly PBRMATERIAL_OPAQUE: number;
  46210. /**
  46211. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46212. */
  46213. static readonly PBRMATERIAL_ALPHATEST: number;
  46214. /**
  46215. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46216. */
  46217. static readonly PBRMATERIAL_ALPHABLEND: number;
  46218. /**
  46219. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46220. * They are also discarded below the alpha cutoff threshold to improve performances.
  46221. */
  46222. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46223. /**
  46224. * Defines the default value of how much AO map is occluding the analytical lights
  46225. * (point spot...).
  46226. */
  46227. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46228. /**
  46229. * Intensity of the direct lights e.g. the four lights available in your scene.
  46230. * This impacts both the direct diffuse and specular highlights.
  46231. */
  46232. directIntensity: number;
  46233. /**
  46234. * Intensity of the emissive part of the material.
  46235. * This helps controlling the emissive effect without modifying the emissive color.
  46236. */
  46237. emissiveIntensity: number;
  46238. /**
  46239. * Intensity of the environment e.g. how much the environment will light the object
  46240. * either through harmonics for rough material or through the refelction for shiny ones.
  46241. */
  46242. environmentIntensity: number;
  46243. /**
  46244. * This is a special control allowing the reduction of the specular highlights coming from the
  46245. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46246. */
  46247. specularIntensity: number;
  46248. /**
  46249. * Debug Control allowing disabling the bump map on this material.
  46250. */
  46251. disableBumpMap: boolean;
  46252. /**
  46253. * AKA Diffuse Texture in standard nomenclature.
  46254. */
  46255. albedoTexture: BaseTexture;
  46256. /**
  46257. * AKA Occlusion Texture in other nomenclature.
  46258. */
  46259. ambientTexture: BaseTexture;
  46260. /**
  46261. * AKA Occlusion Texture Intensity in other nomenclature.
  46262. */
  46263. ambientTextureStrength: number;
  46264. /**
  46265. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46266. * 1 means it completely occludes it
  46267. * 0 mean it has no impact
  46268. */
  46269. ambientTextureImpactOnAnalyticalLights: number;
  46270. /**
  46271. * Stores the alpha values in a texture.
  46272. */
  46273. opacityTexture: BaseTexture;
  46274. /**
  46275. * Stores the reflection values in a texture.
  46276. */
  46277. reflectionTexture: Nullable<BaseTexture>;
  46278. /**
  46279. * Stores the emissive values in a texture.
  46280. */
  46281. emissiveTexture: BaseTexture;
  46282. /**
  46283. * AKA Specular texture in other nomenclature.
  46284. */
  46285. reflectivityTexture: BaseTexture;
  46286. /**
  46287. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46288. */
  46289. metallicTexture: BaseTexture;
  46290. /**
  46291. * Specifies the metallic scalar of the metallic/roughness workflow.
  46292. * Can also be used to scale the metalness values of the metallic texture.
  46293. */
  46294. metallic: Nullable<number>;
  46295. /**
  46296. * Specifies the roughness scalar of the metallic/roughness workflow.
  46297. * Can also be used to scale the roughness values of the metallic texture.
  46298. */
  46299. roughness: Nullable<number>;
  46300. /**
  46301. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46302. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46303. */
  46304. microSurfaceTexture: BaseTexture;
  46305. /**
  46306. * Stores surface normal data used to displace a mesh in a texture.
  46307. */
  46308. bumpTexture: BaseTexture;
  46309. /**
  46310. * Stores the pre-calculated light information of a mesh in a texture.
  46311. */
  46312. lightmapTexture: BaseTexture;
  46313. /**
  46314. * Stores the refracted light information in a texture.
  46315. */
  46316. refractionTexture: Nullable<BaseTexture>;
  46317. /**
  46318. * The color of a material in ambient lighting.
  46319. */
  46320. ambientColor: Color3;
  46321. /**
  46322. * AKA Diffuse Color in other nomenclature.
  46323. */
  46324. albedoColor: Color3;
  46325. /**
  46326. * AKA Specular Color in other nomenclature.
  46327. */
  46328. reflectivityColor: Color3;
  46329. /**
  46330. * The color reflected from the material.
  46331. */
  46332. reflectionColor: Color3;
  46333. /**
  46334. * The color emitted from the material.
  46335. */
  46336. emissiveColor: Color3;
  46337. /**
  46338. * AKA Glossiness in other nomenclature.
  46339. */
  46340. microSurface: number;
  46341. /**
  46342. * source material index of refraction (IOR)' / 'destination material IOR.
  46343. */
  46344. indexOfRefraction: number;
  46345. /**
  46346. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46347. */
  46348. invertRefractionY: boolean;
  46349. /**
  46350. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46351. * Materials half opaque for instance using refraction could benefit from this control.
  46352. */
  46353. linkRefractionWithTransparency: boolean;
  46354. /**
  46355. * If true, the light map contains occlusion information instead of lighting info.
  46356. */
  46357. useLightmapAsShadowmap: boolean;
  46358. /**
  46359. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46360. */
  46361. useAlphaFromAlbedoTexture: boolean;
  46362. /**
  46363. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46364. */
  46365. forceAlphaTest: boolean;
  46366. /**
  46367. * Defines the alpha limits in alpha test mode.
  46368. */
  46369. alphaCutOff: number;
  46370. /**
  46371. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46372. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46373. */
  46374. useSpecularOverAlpha: boolean;
  46375. /**
  46376. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46377. */
  46378. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46379. /**
  46380. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46381. */
  46382. useRoughnessFromMetallicTextureAlpha: boolean;
  46383. /**
  46384. * Specifies if the metallic texture contains the roughness information in its green channel.
  46385. */
  46386. useRoughnessFromMetallicTextureGreen: boolean;
  46387. /**
  46388. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46389. */
  46390. useMetallnessFromMetallicTextureBlue: boolean;
  46391. /**
  46392. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46393. */
  46394. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46395. /**
  46396. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46397. */
  46398. useAmbientInGrayScale: boolean;
  46399. /**
  46400. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46401. * The material will try to infer what glossiness each pixel should be.
  46402. */
  46403. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46404. /**
  46405. * BJS is using an harcoded light falloff based on a manually sets up range.
  46406. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46407. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46408. */
  46409. /**
  46410. * BJS is using an harcoded light falloff based on a manually sets up range.
  46411. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46412. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46413. */
  46414. usePhysicalLightFalloff: boolean;
  46415. /**
  46416. * In order to support the falloff compatibility with gltf, a special mode has been added
  46417. * to reproduce the gltf light falloff.
  46418. */
  46419. /**
  46420. * In order to support the falloff compatibility with gltf, a special mode has been added
  46421. * to reproduce the gltf light falloff.
  46422. */
  46423. useGLTFLightFalloff: boolean;
  46424. /**
  46425. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46426. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46427. */
  46428. useRadianceOverAlpha: boolean;
  46429. /**
  46430. * Allows using an object space normal map (instead of tangent space).
  46431. */
  46432. useObjectSpaceNormalMap: boolean;
  46433. /**
  46434. * Allows using the bump map in parallax mode.
  46435. */
  46436. useParallax: boolean;
  46437. /**
  46438. * Allows using the bump map in parallax occlusion mode.
  46439. */
  46440. useParallaxOcclusion: boolean;
  46441. /**
  46442. * Controls the scale bias of the parallax mode.
  46443. */
  46444. parallaxScaleBias: number;
  46445. /**
  46446. * If sets to true, disables all the lights affecting the material.
  46447. */
  46448. disableLighting: boolean;
  46449. /**
  46450. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46451. */
  46452. forceIrradianceInFragment: boolean;
  46453. /**
  46454. * Number of Simultaneous lights allowed on the material.
  46455. */
  46456. maxSimultaneousLights: number;
  46457. /**
  46458. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46459. */
  46460. invertNormalMapX: boolean;
  46461. /**
  46462. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46463. */
  46464. invertNormalMapY: boolean;
  46465. /**
  46466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46467. */
  46468. twoSidedLighting: boolean;
  46469. /**
  46470. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46471. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46472. */
  46473. useAlphaFresnel: boolean;
  46474. /**
  46475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46476. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46477. */
  46478. useLinearAlphaFresnel: boolean;
  46479. /**
  46480. * Let user defines the brdf lookup texture used for IBL.
  46481. * A default 8bit version is embedded but you could point at :
  46482. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46483. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46484. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46485. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46486. */
  46487. environmentBRDFTexture: Nullable<BaseTexture>;
  46488. /**
  46489. * Force normal to face away from face.
  46490. */
  46491. forceNormalForward: boolean;
  46492. /**
  46493. * Enables specular anti aliasing in the PBR shader.
  46494. * It will both interacts on the Geometry for analytical and IBL lighting.
  46495. * It also prefilter the roughness map based on the bump values.
  46496. */
  46497. enableSpecularAntiAliasing: boolean;
  46498. /**
  46499. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46500. * makes the reflect vector face the model (under horizon).
  46501. */
  46502. useHorizonOcclusion: boolean;
  46503. /**
  46504. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46505. * too much the area relying on ambient texture to define their ambient occlusion.
  46506. */
  46507. useRadianceOcclusion: boolean;
  46508. /**
  46509. * If set to true, no lighting calculations will be applied.
  46510. */
  46511. unlit: boolean;
  46512. /**
  46513. * Gets the image processing configuration used either in this material.
  46514. */
  46515. /**
  46516. * Sets the Default image processing configuration used either in the this material.
  46517. *
  46518. * If sets to null, the scene one is in use.
  46519. */
  46520. imageProcessingConfiguration: ImageProcessingConfiguration;
  46521. /**
  46522. * Gets wether the color curves effect is enabled.
  46523. */
  46524. /**
  46525. * Sets wether the color curves effect is enabled.
  46526. */
  46527. cameraColorCurvesEnabled: boolean;
  46528. /**
  46529. * Gets wether the color grading effect is enabled.
  46530. */
  46531. /**
  46532. * Gets wether the color grading effect is enabled.
  46533. */
  46534. cameraColorGradingEnabled: boolean;
  46535. /**
  46536. * Gets wether tonemapping is enabled or not.
  46537. */
  46538. /**
  46539. * Sets wether tonemapping is enabled or not
  46540. */
  46541. cameraToneMappingEnabled: boolean;
  46542. /**
  46543. * The camera exposure used on this material.
  46544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46545. * This corresponds to a photographic exposure.
  46546. */
  46547. /**
  46548. * The camera exposure used on this material.
  46549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46550. * This corresponds to a photographic exposure.
  46551. */
  46552. cameraExposure: number;
  46553. /**
  46554. * Gets The camera contrast used on this material.
  46555. */
  46556. /**
  46557. * Sets The camera contrast used on this material.
  46558. */
  46559. cameraContrast: number;
  46560. /**
  46561. * Gets the Color Grading 2D Lookup Texture.
  46562. */
  46563. /**
  46564. * Sets the Color Grading 2D Lookup Texture.
  46565. */
  46566. cameraColorGradingTexture: Nullable<BaseTexture>;
  46567. /**
  46568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46570. * 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;
  46571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46572. */
  46573. /**
  46574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46576. * 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;
  46577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46578. */
  46579. cameraColorCurves: Nullable<ColorCurves>;
  46580. /**
  46581. * Instantiates a new PBRMaterial instance.
  46582. *
  46583. * @param name The material name
  46584. * @param scene The scene the material will be use in.
  46585. */
  46586. constructor(name: string, scene: Scene);
  46587. /**
  46588. * Returns the name of this material class.
  46589. */
  46590. getClassName(): string;
  46591. /**
  46592. * Makes a duplicate of the current material.
  46593. * @param name - name to use for the new material.
  46594. */
  46595. clone(name: string): PBRMaterial;
  46596. /**
  46597. * Serializes this PBR Material.
  46598. * @returns - An object with the serialized material.
  46599. */
  46600. serialize(): any;
  46601. /**
  46602. * Parses a PBR Material from a serialized object.
  46603. * @param source - Serialized object.
  46604. * @param scene - BJS scene instance.
  46605. * @param rootUrl - url for the scene object
  46606. * @returns - PBRMaterial
  46607. */
  46608. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46609. }
  46610. }
  46611. declare module BABYLON {
  46612. /**
  46613. * Direct draw surface info
  46614. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46615. */
  46616. export interface DDSInfo {
  46617. /**
  46618. * Width of the texture
  46619. */
  46620. width: number;
  46621. /**
  46622. * Width of the texture
  46623. */
  46624. height: number;
  46625. /**
  46626. * Number of Mipmaps for the texture
  46627. * @see https://en.wikipedia.org/wiki/Mipmap
  46628. */
  46629. mipmapCount: number;
  46630. /**
  46631. * If the textures format is a known fourCC format
  46632. * @see https://www.fourcc.org/
  46633. */
  46634. isFourCC: boolean;
  46635. /**
  46636. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46637. */
  46638. isRGB: boolean;
  46639. /**
  46640. * If the texture is a lumincance format
  46641. */
  46642. isLuminance: boolean;
  46643. /**
  46644. * If this is a cube texture
  46645. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46646. */
  46647. isCube: boolean;
  46648. /**
  46649. * If the texture is a compressed format eg. FOURCC_DXT1
  46650. */
  46651. isCompressed: boolean;
  46652. /**
  46653. * The dxgiFormat of the texture
  46654. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46655. */
  46656. dxgiFormat: number;
  46657. /**
  46658. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46659. */
  46660. textureType: number;
  46661. /**
  46662. * Sphericle polynomial created for the dds texture
  46663. */
  46664. sphericalPolynomial?: SphericalPolynomial;
  46665. }
  46666. /**
  46667. * Class used to provide DDS decompression tools
  46668. */
  46669. export class DDSTools {
  46670. /**
  46671. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46672. */
  46673. static StoreLODInAlphaChannel: boolean;
  46674. /**
  46675. * Gets DDS information from an array buffer
  46676. * @param arrayBuffer defines the array buffer to read data from
  46677. * @returns the DDS information
  46678. */
  46679. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46680. private static _FloatView;
  46681. private static _Int32View;
  46682. private static _ToHalfFloat;
  46683. private static _FromHalfFloat;
  46684. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46685. private static _GetHalfFloatRGBAArrayBuffer;
  46686. private static _GetFloatRGBAArrayBuffer;
  46687. private static _GetFloatAsUIntRGBAArrayBuffer;
  46688. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46689. private static _GetRGBAArrayBuffer;
  46690. private static _ExtractLongWordOrder;
  46691. private static _GetRGBArrayBuffer;
  46692. private static _GetLuminanceArrayBuffer;
  46693. /**
  46694. * Uploads DDS Levels to a Babylon Texture
  46695. * @hidden
  46696. */
  46697. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46698. }
  46699. interface Engine {
  46700. /**
  46701. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46702. * @param rootUrl defines the url where the file to load is located
  46703. * @param scene defines the current scene
  46704. * @param lodScale defines scale to apply to the mip map selection
  46705. * @param lodOffset defines offset to apply to the mip map selection
  46706. * @param onLoad defines an optional callback raised when the texture is loaded
  46707. * @param onError defines an optional callback raised if there is an issue to load the texture
  46708. * @param format defines the format of the data
  46709. * @param forcedExtension defines the extension to use to pick the right loader
  46710. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46711. * @returns the cube texture as an InternalTexture
  46712. */
  46713. 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;
  46714. }
  46715. }
  46716. declare module BABYLON {
  46717. /**
  46718. * Implementation of the DDS Texture Loader.
  46719. * @hidden
  46720. */
  46721. export class _DDSTextureLoader implements IInternalTextureLoader {
  46722. /**
  46723. * Defines wether the loader supports cascade loading the different faces.
  46724. */
  46725. readonly supportCascades: boolean;
  46726. /**
  46727. * This returns if the loader support the current file information.
  46728. * @param extension defines the file extension of the file being loaded
  46729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46730. * @param fallback defines the fallback internal texture if any
  46731. * @param isBase64 defines whether the texture is encoded as a base64
  46732. * @param isBuffer defines whether the texture data are stored as a buffer
  46733. * @returns true if the loader can load the specified file
  46734. */
  46735. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46736. /**
  46737. * Transform the url before loading if required.
  46738. * @param rootUrl the url of the texture
  46739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46740. * @returns the transformed texture
  46741. */
  46742. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46743. /**
  46744. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46745. * @param rootUrl the url of the texture
  46746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46747. * @returns the fallback texture
  46748. */
  46749. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46750. /**
  46751. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46752. * @param data contains the texture data
  46753. * @param texture defines the BabylonJS internal texture
  46754. * @param createPolynomials will be true if polynomials have been requested
  46755. * @param onLoad defines the callback to trigger once the texture is ready
  46756. * @param onError defines the callback to trigger in case of error
  46757. */
  46758. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46759. /**
  46760. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46761. * @param data contains the texture data
  46762. * @param texture defines the BabylonJS internal texture
  46763. * @param callback defines the method to call once ready to upload
  46764. */
  46765. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46766. }
  46767. }
  46768. declare module BABYLON {
  46769. /** @hidden */
  46770. export var rgbdEncodePixelShader: {
  46771. name: string;
  46772. shader: string;
  46773. };
  46774. }
  46775. declare module BABYLON {
  46776. /**
  46777. * Raw texture data and descriptor sufficient for WebGL texture upload
  46778. */
  46779. export interface EnvironmentTextureInfo {
  46780. /**
  46781. * Version of the environment map
  46782. */
  46783. version: number;
  46784. /**
  46785. * Width of image
  46786. */
  46787. width: number;
  46788. /**
  46789. * Irradiance information stored in the file.
  46790. */
  46791. irradiance: any;
  46792. /**
  46793. * Specular information stored in the file.
  46794. */
  46795. specular: any;
  46796. }
  46797. /**
  46798. * Sets of helpers addressing the serialization and deserialization of environment texture
  46799. * stored in a BabylonJS env file.
  46800. * Those files are usually stored as .env files.
  46801. */
  46802. export class EnvironmentTextureTools {
  46803. /**
  46804. * Magic number identifying the env file.
  46805. */
  46806. private static _MagicBytes;
  46807. /**
  46808. * Gets the environment info from an env file.
  46809. * @param data The array buffer containing the .env bytes.
  46810. * @returns the environment file info (the json header) if successfully parsed.
  46811. */
  46812. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46813. /**
  46814. * Creates an environment texture from a loaded cube texture.
  46815. * @param texture defines the cube texture to convert in env file
  46816. * @return a promise containing the environment data if succesfull.
  46817. */
  46818. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46819. /**
  46820. * Creates a JSON representation of the spherical data.
  46821. * @param texture defines the texture containing the polynomials
  46822. * @return the JSON representation of the spherical info
  46823. */
  46824. private static _CreateEnvTextureIrradiance;
  46825. /**
  46826. * Uploads the texture info contained in the env file to the GPU.
  46827. * @param texture defines the internal texture to upload to
  46828. * @param arrayBuffer defines the buffer cotaining the data to load
  46829. * @param info defines the texture info retrieved through the GetEnvInfo method
  46830. * @returns a promise
  46831. */
  46832. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46833. /**
  46834. * Uploads the levels of image data to the GPU.
  46835. * @param texture defines the internal texture to upload to
  46836. * @param imageData defines the array buffer views of image data [mipmap][face]
  46837. * @returns a promise
  46838. */
  46839. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46840. /**
  46841. * Uploads spherical polynomials information to the texture.
  46842. * @param texture defines the texture we are trying to upload the information to
  46843. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46844. */
  46845. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46846. /** @hidden */
  46847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46848. }
  46849. }
  46850. declare module BABYLON {
  46851. /**
  46852. * Implementation of the ENV Texture Loader.
  46853. * @hidden
  46854. */
  46855. export class _ENVTextureLoader implements IInternalTextureLoader {
  46856. /**
  46857. * Defines wether the loader supports cascade loading the different faces.
  46858. */
  46859. readonly supportCascades: boolean;
  46860. /**
  46861. * This returns if the loader support the current file information.
  46862. * @param extension defines the file extension of the file being loaded
  46863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46864. * @param fallback defines the fallback internal texture if any
  46865. * @param isBase64 defines whether the texture is encoded as a base64
  46866. * @param isBuffer defines whether the texture data are stored as a buffer
  46867. * @returns true if the loader can load the specified file
  46868. */
  46869. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46870. /**
  46871. * Transform the url before loading if required.
  46872. * @param rootUrl the url of the texture
  46873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46874. * @returns the transformed texture
  46875. */
  46876. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46877. /**
  46878. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46879. * @param rootUrl the url of the texture
  46880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46881. * @returns the fallback texture
  46882. */
  46883. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46884. /**
  46885. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46886. * @param data contains the texture data
  46887. * @param texture defines the BabylonJS internal texture
  46888. * @param createPolynomials will be true if polynomials have been requested
  46889. * @param onLoad defines the callback to trigger once the texture is ready
  46890. * @param onError defines the callback to trigger in case of error
  46891. */
  46892. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46893. /**
  46894. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46895. * @param data contains the texture data
  46896. * @param texture defines the BabylonJS internal texture
  46897. * @param callback defines the method to call once ready to upload
  46898. */
  46899. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46900. }
  46901. }
  46902. declare module BABYLON {
  46903. /**
  46904. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46905. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46906. */
  46907. export class KhronosTextureContainer {
  46908. /** contents of the KTX container file */
  46909. arrayBuffer: any;
  46910. private static HEADER_LEN;
  46911. private static COMPRESSED_2D;
  46912. private static COMPRESSED_3D;
  46913. private static TEX_2D;
  46914. private static TEX_3D;
  46915. /**
  46916. * Gets the openGL type
  46917. */
  46918. glType: number;
  46919. /**
  46920. * Gets the openGL type size
  46921. */
  46922. glTypeSize: number;
  46923. /**
  46924. * Gets the openGL format
  46925. */
  46926. glFormat: number;
  46927. /**
  46928. * Gets the openGL internal format
  46929. */
  46930. glInternalFormat: number;
  46931. /**
  46932. * Gets the base internal format
  46933. */
  46934. glBaseInternalFormat: number;
  46935. /**
  46936. * Gets image width in pixel
  46937. */
  46938. pixelWidth: number;
  46939. /**
  46940. * Gets image height in pixel
  46941. */
  46942. pixelHeight: number;
  46943. /**
  46944. * Gets image depth in pixels
  46945. */
  46946. pixelDepth: number;
  46947. /**
  46948. * Gets the number of array elements
  46949. */
  46950. numberOfArrayElements: number;
  46951. /**
  46952. * Gets the number of faces
  46953. */
  46954. numberOfFaces: number;
  46955. /**
  46956. * Gets the number of mipmap levels
  46957. */
  46958. numberOfMipmapLevels: number;
  46959. /**
  46960. * Gets the bytes of key value data
  46961. */
  46962. bytesOfKeyValueData: number;
  46963. /**
  46964. * Gets the load type
  46965. */
  46966. loadType: number;
  46967. /**
  46968. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46969. */
  46970. isInvalid: boolean;
  46971. /**
  46972. * Creates a new KhronosTextureContainer
  46973. * @param arrayBuffer contents of the KTX container file
  46974. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46975. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46976. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46977. */
  46978. constructor(
  46979. /** contents of the KTX container file */
  46980. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46981. /**
  46982. * Uploads KTX content to a Babylon Texture.
  46983. * It is assumed that the texture has already been created & is currently bound
  46984. * @hidden
  46985. */
  46986. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46987. private _upload2DCompressedLevels;
  46988. }
  46989. }
  46990. declare module BABYLON {
  46991. /**
  46992. * Implementation of the KTX Texture Loader.
  46993. * @hidden
  46994. */
  46995. export class _KTXTextureLoader implements IInternalTextureLoader {
  46996. /**
  46997. * Defines wether the loader supports cascade loading the different faces.
  46998. */
  46999. readonly supportCascades: boolean;
  47000. /**
  47001. * This returns if the loader support the current file information.
  47002. * @param extension defines the file extension of the file being loaded
  47003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47004. * @param fallback defines the fallback internal texture if any
  47005. * @param isBase64 defines whether the texture is encoded as a base64
  47006. * @param isBuffer defines whether the texture data are stored as a buffer
  47007. * @returns true if the loader can load the specified file
  47008. */
  47009. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47010. /**
  47011. * Transform the url before loading if required.
  47012. * @param rootUrl the url of the texture
  47013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47014. * @returns the transformed texture
  47015. */
  47016. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47017. /**
  47018. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47019. * @param rootUrl the url of the texture
  47020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47021. * @returns the fallback texture
  47022. */
  47023. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47024. /**
  47025. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47026. * @param data contains the texture data
  47027. * @param texture defines the BabylonJS internal texture
  47028. * @param createPolynomials will be true if polynomials have been requested
  47029. * @param onLoad defines the callback to trigger once the texture is ready
  47030. * @param onError defines the callback to trigger in case of error
  47031. */
  47032. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47033. /**
  47034. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47035. * @param data contains the texture data
  47036. * @param texture defines the BabylonJS internal texture
  47037. * @param callback defines the method to call once ready to upload
  47038. */
  47039. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47040. }
  47041. }
  47042. declare module BABYLON {
  47043. /** @hidden */
  47044. export var _forceSceneHelpersToBundle: boolean;
  47045. interface Scene {
  47046. /**
  47047. * Creates a default light for the scene.
  47048. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47049. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47050. */
  47051. createDefaultLight(replace?: boolean): void;
  47052. /**
  47053. * Creates a default camera for the scene.
  47054. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47055. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47056. * @param replace has default false, when true replaces the active camera in the scene
  47057. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47058. */
  47059. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47060. /**
  47061. * Creates a default camera and a default light.
  47062. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47063. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47064. * @param replace has the default false, when true replaces the active camera/light in the scene
  47065. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47066. */
  47067. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47068. /**
  47069. * Creates a new sky box
  47070. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47071. * @param environmentTexture defines the texture to use as environment texture
  47072. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47073. * @param scale defines the overall scale of the skybox
  47074. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47075. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47076. * @returns a new mesh holding the sky box
  47077. */
  47078. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47079. /**
  47080. * Creates a new environment
  47081. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47082. * @param options defines the options you can use to configure the environment
  47083. * @returns the new EnvironmentHelper
  47084. */
  47085. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47086. /**
  47087. * Creates a new VREXperienceHelper
  47088. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47089. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47090. * @returns a new VREXperienceHelper
  47091. */
  47092. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47093. /**
  47094. * Creates a new XREXperienceHelper
  47095. * @see http://doc.babylonjs.com/how_to/webxr
  47096. * @returns a promise for a new XREXperienceHelper
  47097. */
  47098. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47099. }
  47100. }
  47101. declare module BABYLON {
  47102. /**
  47103. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47104. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47105. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47106. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47107. */
  47108. export class VideoDome extends TransformNode {
  47109. /**
  47110. * Define the video source as a Monoscopic panoramic 360 video.
  47111. */
  47112. static readonly MODE_MONOSCOPIC: number;
  47113. /**
  47114. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47115. */
  47116. static readonly MODE_TOPBOTTOM: number;
  47117. /**
  47118. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47119. */
  47120. static readonly MODE_SIDEBYSIDE: number;
  47121. private _useDirectMapping;
  47122. /**
  47123. * The video texture being displayed on the sphere
  47124. */
  47125. protected _videoTexture: VideoTexture;
  47126. /**
  47127. * Gets the video texture being displayed on the sphere
  47128. */
  47129. readonly videoTexture: VideoTexture;
  47130. /**
  47131. * The skybox material
  47132. */
  47133. protected _material: BackgroundMaterial;
  47134. /**
  47135. * The surface used for the skybox
  47136. */
  47137. protected _mesh: Mesh;
  47138. /**
  47139. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47140. * Also see the options.resolution property.
  47141. */
  47142. fovMultiplier: number;
  47143. private _videoMode;
  47144. /**
  47145. * Gets or set the current video mode for the video. It can be:
  47146. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47147. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47148. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47149. */
  47150. videoMode: number;
  47151. /**
  47152. * Oberserver used in Stereoscopic VR Mode.
  47153. */
  47154. private _onBeforeCameraRenderObserver;
  47155. /**
  47156. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47157. * @param name Element's name, child elements will append suffixes for their own names.
  47158. * @param urlsOrVideo defines the url(s) or the video element to use
  47159. * @param options An object containing optional or exposed sub element properties
  47160. */
  47161. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47162. resolution?: number;
  47163. clickToPlay?: boolean;
  47164. autoPlay?: boolean;
  47165. loop?: boolean;
  47166. size?: number;
  47167. poster?: string;
  47168. faceForward?: boolean;
  47169. useDirectMapping?: boolean;
  47170. }, scene: Scene);
  47171. private _changeVideoMode;
  47172. /**
  47173. * Releases resources associated with this node.
  47174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47176. */
  47177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47178. }
  47179. }
  47180. declare module BABYLON {
  47181. /**
  47182. * This class can be used to get instrumentation data from a Babylon engine
  47183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47184. */
  47185. export class EngineInstrumentation implements IDisposable {
  47186. /**
  47187. * Define the instrumented engine.
  47188. */
  47189. engine: Engine;
  47190. private _captureGPUFrameTime;
  47191. private _gpuFrameTimeToken;
  47192. private _gpuFrameTime;
  47193. private _captureShaderCompilationTime;
  47194. private _shaderCompilationTime;
  47195. private _onBeginFrameObserver;
  47196. private _onEndFrameObserver;
  47197. private _onBeforeShaderCompilationObserver;
  47198. private _onAfterShaderCompilationObserver;
  47199. /**
  47200. * Gets the perf counter used for GPU frame time
  47201. */
  47202. readonly gpuFrameTimeCounter: PerfCounter;
  47203. /**
  47204. * Gets the GPU frame time capture status
  47205. */
  47206. /**
  47207. * Enable or disable the GPU frame time capture
  47208. */
  47209. captureGPUFrameTime: boolean;
  47210. /**
  47211. * Gets the perf counter used for shader compilation time
  47212. */
  47213. readonly shaderCompilationTimeCounter: PerfCounter;
  47214. /**
  47215. * Gets the shader compilation time capture status
  47216. */
  47217. /**
  47218. * Enable or disable the shader compilation time capture
  47219. */
  47220. captureShaderCompilationTime: boolean;
  47221. /**
  47222. * Instantiates a new engine instrumentation.
  47223. * This class can be used to get instrumentation data from a Babylon engine
  47224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47225. * @param engine Defines the engine to instrument
  47226. */
  47227. constructor(
  47228. /**
  47229. * Define the instrumented engine.
  47230. */
  47231. engine: Engine);
  47232. /**
  47233. * Dispose and release associated resources.
  47234. */
  47235. dispose(): void;
  47236. }
  47237. }
  47238. declare module BABYLON {
  47239. /**
  47240. * This class can be used to get instrumentation data from a Babylon engine
  47241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47242. */
  47243. export class SceneInstrumentation implements IDisposable {
  47244. /**
  47245. * Defines the scene to instrument
  47246. */
  47247. scene: Scene;
  47248. private _captureActiveMeshesEvaluationTime;
  47249. private _activeMeshesEvaluationTime;
  47250. private _captureRenderTargetsRenderTime;
  47251. private _renderTargetsRenderTime;
  47252. private _captureFrameTime;
  47253. private _frameTime;
  47254. private _captureRenderTime;
  47255. private _renderTime;
  47256. private _captureInterFrameTime;
  47257. private _interFrameTime;
  47258. private _captureParticlesRenderTime;
  47259. private _particlesRenderTime;
  47260. private _captureSpritesRenderTime;
  47261. private _spritesRenderTime;
  47262. private _capturePhysicsTime;
  47263. private _physicsTime;
  47264. private _captureAnimationsTime;
  47265. private _animationsTime;
  47266. private _captureCameraRenderTime;
  47267. private _cameraRenderTime;
  47268. private _onBeforeActiveMeshesEvaluationObserver;
  47269. private _onAfterActiveMeshesEvaluationObserver;
  47270. private _onBeforeRenderTargetsRenderObserver;
  47271. private _onAfterRenderTargetsRenderObserver;
  47272. private _onAfterRenderObserver;
  47273. private _onBeforeDrawPhaseObserver;
  47274. private _onAfterDrawPhaseObserver;
  47275. private _onBeforeAnimationsObserver;
  47276. private _onBeforeParticlesRenderingObserver;
  47277. private _onAfterParticlesRenderingObserver;
  47278. private _onBeforeSpritesRenderingObserver;
  47279. private _onAfterSpritesRenderingObserver;
  47280. private _onBeforePhysicsObserver;
  47281. private _onAfterPhysicsObserver;
  47282. private _onAfterAnimationsObserver;
  47283. private _onBeforeCameraRenderObserver;
  47284. private _onAfterCameraRenderObserver;
  47285. /**
  47286. * Gets the perf counter used for active meshes evaluation time
  47287. */
  47288. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47289. /**
  47290. * Gets the active meshes evaluation time capture status
  47291. */
  47292. /**
  47293. * Enable or disable the active meshes evaluation time capture
  47294. */
  47295. captureActiveMeshesEvaluationTime: boolean;
  47296. /**
  47297. * Gets the perf counter used for render targets render time
  47298. */
  47299. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47300. /**
  47301. * Gets the render targets render time capture status
  47302. */
  47303. /**
  47304. * Enable or disable the render targets render time capture
  47305. */
  47306. captureRenderTargetsRenderTime: boolean;
  47307. /**
  47308. * Gets the perf counter used for particles render time
  47309. */
  47310. readonly particlesRenderTimeCounter: PerfCounter;
  47311. /**
  47312. * Gets the particles render time capture status
  47313. */
  47314. /**
  47315. * Enable or disable the particles render time capture
  47316. */
  47317. captureParticlesRenderTime: boolean;
  47318. /**
  47319. * Gets the perf counter used for sprites render time
  47320. */
  47321. readonly spritesRenderTimeCounter: PerfCounter;
  47322. /**
  47323. * Gets the sprites render time capture status
  47324. */
  47325. /**
  47326. * Enable or disable the sprites render time capture
  47327. */
  47328. captureSpritesRenderTime: boolean;
  47329. /**
  47330. * Gets the perf counter used for physics time
  47331. */
  47332. readonly physicsTimeCounter: PerfCounter;
  47333. /**
  47334. * Gets the physics time capture status
  47335. */
  47336. /**
  47337. * Enable or disable the physics time capture
  47338. */
  47339. capturePhysicsTime: boolean;
  47340. /**
  47341. * Gets the perf counter used for animations time
  47342. */
  47343. readonly animationsTimeCounter: PerfCounter;
  47344. /**
  47345. * Gets the animations time capture status
  47346. */
  47347. /**
  47348. * Enable or disable the animations time capture
  47349. */
  47350. captureAnimationsTime: boolean;
  47351. /**
  47352. * Gets the perf counter used for frame time capture
  47353. */
  47354. readonly frameTimeCounter: PerfCounter;
  47355. /**
  47356. * Gets the frame time capture status
  47357. */
  47358. /**
  47359. * Enable or disable the frame time capture
  47360. */
  47361. captureFrameTime: boolean;
  47362. /**
  47363. * Gets the perf counter used for inter-frames time capture
  47364. */
  47365. readonly interFrameTimeCounter: PerfCounter;
  47366. /**
  47367. * Gets the inter-frames time capture status
  47368. */
  47369. /**
  47370. * Enable or disable the inter-frames time capture
  47371. */
  47372. captureInterFrameTime: boolean;
  47373. /**
  47374. * Gets the perf counter used for render time capture
  47375. */
  47376. readonly renderTimeCounter: PerfCounter;
  47377. /**
  47378. * Gets the render time capture status
  47379. */
  47380. /**
  47381. * Enable or disable the render time capture
  47382. */
  47383. captureRenderTime: boolean;
  47384. /**
  47385. * Gets the perf counter used for camera render time capture
  47386. */
  47387. readonly cameraRenderTimeCounter: PerfCounter;
  47388. /**
  47389. * Gets the camera render time capture status
  47390. */
  47391. /**
  47392. * Enable or disable the camera render time capture
  47393. */
  47394. captureCameraRenderTime: boolean;
  47395. /**
  47396. * Gets the perf counter used for draw calls
  47397. */
  47398. readonly drawCallsCounter: PerfCounter;
  47399. /**
  47400. * Instantiates a new scene instrumentation.
  47401. * This class can be used to get instrumentation data from a Babylon engine
  47402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47403. * @param scene Defines the scene to instrument
  47404. */
  47405. constructor(
  47406. /**
  47407. * Defines the scene to instrument
  47408. */
  47409. scene: Scene);
  47410. /**
  47411. * Dispose and release associated resources.
  47412. */
  47413. dispose(): void;
  47414. }
  47415. }
  47416. declare module BABYLON {
  47417. /** @hidden */
  47418. export var glowMapGenerationPixelShader: {
  47419. name: string;
  47420. shader: string;
  47421. };
  47422. }
  47423. declare module BABYLON {
  47424. /** @hidden */
  47425. export var glowMapGenerationVertexShader: {
  47426. name: string;
  47427. shader: string;
  47428. };
  47429. }
  47430. declare module BABYLON {
  47431. /**
  47432. * Effect layer options. This helps customizing the behaviour
  47433. * of the effect layer.
  47434. */
  47435. export interface IEffectLayerOptions {
  47436. /**
  47437. * Multiplication factor apply to the canvas size to compute the render target size
  47438. * used to generated the objects (the smaller the faster).
  47439. */
  47440. mainTextureRatio: number;
  47441. /**
  47442. * Enforces a fixed size texture to ensure effect stability across devices.
  47443. */
  47444. mainTextureFixedSize?: number;
  47445. /**
  47446. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47447. */
  47448. alphaBlendingMode: number;
  47449. /**
  47450. * The camera attached to the layer.
  47451. */
  47452. camera: Nullable<Camera>;
  47453. /**
  47454. * The rendering group to draw the layer in.
  47455. */
  47456. renderingGroupId: number;
  47457. }
  47458. /**
  47459. * The effect layer Helps adding post process effect blended with the main pass.
  47460. *
  47461. * This can be for instance use to generate glow or higlight effects on the scene.
  47462. *
  47463. * The effect layer class can not be used directly and is intented to inherited from to be
  47464. * customized per effects.
  47465. */
  47466. export abstract class EffectLayer {
  47467. private _vertexBuffers;
  47468. private _indexBuffer;
  47469. private _cachedDefines;
  47470. private _effectLayerMapGenerationEffect;
  47471. private _effectLayerOptions;
  47472. private _mergeEffect;
  47473. protected _scene: Scene;
  47474. protected _engine: Engine;
  47475. protected _maxSize: number;
  47476. protected _mainTextureDesiredSize: ISize;
  47477. protected _mainTexture: RenderTargetTexture;
  47478. protected _shouldRender: boolean;
  47479. protected _postProcesses: PostProcess[];
  47480. protected _textures: BaseTexture[];
  47481. protected _emissiveTextureAndColor: {
  47482. texture: Nullable<BaseTexture>;
  47483. color: Color4;
  47484. };
  47485. /**
  47486. * The name of the layer
  47487. */
  47488. name: string;
  47489. /**
  47490. * The clear color of the texture used to generate the glow map.
  47491. */
  47492. neutralColor: Color4;
  47493. /**
  47494. * Specifies wether the highlight layer is enabled or not.
  47495. */
  47496. isEnabled: boolean;
  47497. /**
  47498. * Gets the camera attached to the layer.
  47499. */
  47500. readonly camera: Nullable<Camera>;
  47501. /**
  47502. * Gets the rendering group id the layer should render in.
  47503. */
  47504. readonly renderingGroupId: number;
  47505. /**
  47506. * An event triggered when the effect layer has been disposed.
  47507. */
  47508. onDisposeObservable: Observable<EffectLayer>;
  47509. /**
  47510. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47511. */
  47512. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47513. /**
  47514. * An event triggered when the generated texture is being merged in the scene.
  47515. */
  47516. onBeforeComposeObservable: Observable<EffectLayer>;
  47517. /**
  47518. * An event triggered when the generated texture has been merged in the scene.
  47519. */
  47520. onAfterComposeObservable: Observable<EffectLayer>;
  47521. /**
  47522. * An event triggered when the efffect layer changes its size.
  47523. */
  47524. onSizeChangedObservable: Observable<EffectLayer>;
  47525. /** @hidden */
  47526. static _SceneComponentInitialization: (scene: Scene) => void;
  47527. /**
  47528. * Instantiates a new effect Layer and references it in the scene.
  47529. * @param name The name of the layer
  47530. * @param scene The scene to use the layer in
  47531. */
  47532. constructor(
  47533. /** The Friendly of the effect in the scene */
  47534. name: string, scene: Scene);
  47535. /**
  47536. * Get the effect name of the layer.
  47537. * @return The effect name
  47538. */
  47539. abstract getEffectName(): string;
  47540. /**
  47541. * Checks for the readiness of the element composing the layer.
  47542. * @param subMesh the mesh to check for
  47543. * @param useInstances specify wether or not to use instances to render the mesh
  47544. * @return true if ready otherwise, false
  47545. */
  47546. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47547. /**
  47548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47549. * @returns true if the effect requires stencil during the main canvas render pass.
  47550. */
  47551. abstract needStencil(): boolean;
  47552. /**
  47553. * Create the merge effect. This is the shader use to blit the information back
  47554. * to the main canvas at the end of the scene rendering.
  47555. * @returns The effect containing the shader used to merge the effect on the main canvas
  47556. */
  47557. protected abstract _createMergeEffect(): Effect;
  47558. /**
  47559. * Creates the render target textures and post processes used in the effect layer.
  47560. */
  47561. protected abstract _createTextureAndPostProcesses(): void;
  47562. /**
  47563. * Implementation specific of rendering the generating effect on the main canvas.
  47564. * @param effect The effect used to render through
  47565. */
  47566. protected abstract _internalRender(effect: Effect): void;
  47567. /**
  47568. * Sets the required values for both the emissive texture and and the main color.
  47569. */
  47570. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47571. /**
  47572. * Free any resources and references associated to a mesh.
  47573. * Internal use
  47574. * @param mesh The mesh to free.
  47575. */
  47576. abstract _disposeMesh(mesh: Mesh): void;
  47577. /**
  47578. * Serializes this layer (Glow or Highlight for example)
  47579. * @returns a serialized layer object
  47580. */
  47581. abstract serialize?(): any;
  47582. /**
  47583. * Initializes the effect layer with the required options.
  47584. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47585. */
  47586. protected _init(options: Partial<IEffectLayerOptions>): void;
  47587. /**
  47588. * Generates the index buffer of the full screen quad blending to the main canvas.
  47589. */
  47590. private _generateIndexBuffer;
  47591. /**
  47592. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47593. */
  47594. private _generateVertexBuffer;
  47595. /**
  47596. * Sets the main texture desired size which is the closest power of two
  47597. * of the engine canvas size.
  47598. */
  47599. private _setMainTextureSize;
  47600. /**
  47601. * Creates the main texture for the effect layer.
  47602. */
  47603. protected _createMainTexture(): void;
  47604. /**
  47605. * Adds specific effects defines.
  47606. * @param defines The defines to add specifics to.
  47607. */
  47608. protected _addCustomEffectDefines(defines: string[]): void;
  47609. /**
  47610. * Checks for the readiness of the element composing the layer.
  47611. * @param subMesh the mesh to check for
  47612. * @param useInstances specify wether or not to use instances to render the mesh
  47613. * @param emissiveTexture the associated emissive texture used to generate the glow
  47614. * @return true if ready otherwise, false
  47615. */
  47616. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47617. /**
  47618. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47619. */
  47620. render(): void;
  47621. /**
  47622. * Determine if a given mesh will be used in the current effect.
  47623. * @param mesh mesh to test
  47624. * @returns true if the mesh will be used
  47625. */
  47626. hasMesh(mesh: AbstractMesh): boolean;
  47627. /**
  47628. * Returns true if the layer contains information to display, otherwise false.
  47629. * @returns true if the glow layer should be rendered
  47630. */
  47631. shouldRender(): boolean;
  47632. /**
  47633. * Returns true if the mesh should render, otherwise false.
  47634. * @param mesh The mesh to render
  47635. * @returns true if it should render otherwise false
  47636. */
  47637. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47638. /**
  47639. * Returns true if the mesh can be rendered, otherwise false.
  47640. * @param mesh The mesh to render
  47641. * @param material The material used on the mesh
  47642. * @returns true if it can be rendered otherwise false
  47643. */
  47644. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47645. /**
  47646. * Returns true if the mesh should render, otherwise false.
  47647. * @param mesh The mesh to render
  47648. * @returns true if it should render otherwise false
  47649. */
  47650. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47651. /**
  47652. * Renders the submesh passed in parameter to the generation map.
  47653. */
  47654. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47655. /**
  47656. * Rebuild the required buffers.
  47657. * @hidden Internal use only.
  47658. */
  47659. _rebuild(): void;
  47660. /**
  47661. * Dispose only the render target textures and post process.
  47662. */
  47663. private _disposeTextureAndPostProcesses;
  47664. /**
  47665. * Dispose the highlight layer and free resources.
  47666. */
  47667. dispose(): void;
  47668. /**
  47669. * Gets the class name of the effect layer
  47670. * @returns the string with the class name of the effect layer
  47671. */
  47672. getClassName(): string;
  47673. /**
  47674. * Creates an effect layer from parsed effect layer data
  47675. * @param parsedEffectLayer defines effect layer data
  47676. * @param scene defines the current scene
  47677. * @param rootUrl defines the root URL containing the effect layer information
  47678. * @returns a parsed effect Layer
  47679. */
  47680. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47681. }
  47682. }
  47683. declare module BABYLON {
  47684. interface AbstractScene {
  47685. /**
  47686. * The list of effect layers (highlights/glow) added to the scene
  47687. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47688. * @see http://doc.babylonjs.com/how_to/glow_layer
  47689. */
  47690. effectLayers: Array<EffectLayer>;
  47691. /**
  47692. * Removes the given effect layer from this scene.
  47693. * @param toRemove defines the effect layer to remove
  47694. * @returns the index of the removed effect layer
  47695. */
  47696. removeEffectLayer(toRemove: EffectLayer): number;
  47697. /**
  47698. * Adds the given effect layer to this scene
  47699. * @param newEffectLayer defines the effect layer to add
  47700. */
  47701. addEffectLayer(newEffectLayer: EffectLayer): void;
  47702. }
  47703. /**
  47704. * Defines the layer scene component responsible to manage any effect layers
  47705. * in a given scene.
  47706. */
  47707. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47708. /**
  47709. * The component name helpfull to identify the component in the list of scene components.
  47710. */
  47711. readonly name: string;
  47712. /**
  47713. * The scene the component belongs to.
  47714. */
  47715. scene: Scene;
  47716. private _engine;
  47717. private _renderEffects;
  47718. private _needStencil;
  47719. private _previousStencilState;
  47720. /**
  47721. * Creates a new instance of the component for the given scene
  47722. * @param scene Defines the scene to register the component in
  47723. */
  47724. constructor(scene: Scene);
  47725. /**
  47726. * Registers the component in a given scene
  47727. */
  47728. register(): void;
  47729. /**
  47730. * Rebuilds the elements related to this component in case of
  47731. * context lost for instance.
  47732. */
  47733. rebuild(): void;
  47734. /**
  47735. * Serializes the component data to the specified json object
  47736. * @param serializationObject The object to serialize to
  47737. */
  47738. serialize(serializationObject: any): void;
  47739. /**
  47740. * Adds all the elements from the container to the scene
  47741. * @param container the container holding the elements
  47742. */
  47743. addFromContainer(container: AbstractScene): void;
  47744. /**
  47745. * Removes all the elements in the container from the scene
  47746. * @param container contains the elements to remove
  47747. * @param dispose if the removed element should be disposed (default: false)
  47748. */
  47749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47750. /**
  47751. * Disposes the component and the associated ressources.
  47752. */
  47753. dispose(): void;
  47754. private _isReadyForMesh;
  47755. private _renderMainTexture;
  47756. private _setStencil;
  47757. private _setStencilBack;
  47758. private _draw;
  47759. private _drawCamera;
  47760. private _drawRenderingGroup;
  47761. }
  47762. }
  47763. declare module BABYLON {
  47764. /** @hidden */
  47765. export var glowMapMergePixelShader: {
  47766. name: string;
  47767. shader: string;
  47768. };
  47769. }
  47770. declare module BABYLON {
  47771. /** @hidden */
  47772. export var glowMapMergeVertexShader: {
  47773. name: string;
  47774. shader: string;
  47775. };
  47776. }
  47777. declare module BABYLON {
  47778. interface AbstractScene {
  47779. /**
  47780. * Return a the first highlight layer of the scene with a given name.
  47781. * @param name The name of the highlight layer to look for.
  47782. * @return The highlight layer if found otherwise null.
  47783. */
  47784. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47785. }
  47786. /**
  47787. * Glow layer options. This helps customizing the behaviour
  47788. * of the glow layer.
  47789. */
  47790. export interface IGlowLayerOptions {
  47791. /**
  47792. * Multiplication factor apply to the canvas size to compute the render target size
  47793. * used to generated the glowing objects (the smaller the faster).
  47794. */
  47795. mainTextureRatio: number;
  47796. /**
  47797. * Enforces a fixed size texture to ensure resize independant blur.
  47798. */
  47799. mainTextureFixedSize?: number;
  47800. /**
  47801. * How big is the kernel of the blur texture.
  47802. */
  47803. blurKernelSize: number;
  47804. /**
  47805. * The camera attached to the layer.
  47806. */
  47807. camera: Nullable<Camera>;
  47808. /**
  47809. * Enable MSAA by chosing the number of samples.
  47810. */
  47811. mainTextureSamples?: number;
  47812. /**
  47813. * The rendering group to draw the layer in.
  47814. */
  47815. renderingGroupId: number;
  47816. }
  47817. /**
  47818. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47819. *
  47820. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47821. * glowy meshes to your scene.
  47822. *
  47823. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47824. */
  47825. export class GlowLayer extends EffectLayer {
  47826. /**
  47827. * Effect Name of the layer.
  47828. */
  47829. static readonly EffectName: string;
  47830. /**
  47831. * The default blur kernel size used for the glow.
  47832. */
  47833. static DefaultBlurKernelSize: number;
  47834. /**
  47835. * The default texture size ratio used for the glow.
  47836. */
  47837. static DefaultTextureRatio: number;
  47838. /**
  47839. * Sets the kernel size of the blur.
  47840. */
  47841. /**
  47842. * Gets the kernel size of the blur.
  47843. */
  47844. blurKernelSize: number;
  47845. /**
  47846. * Sets the glow intensity.
  47847. */
  47848. /**
  47849. * Gets the glow intensity.
  47850. */
  47851. intensity: number;
  47852. private _options;
  47853. private _intensity;
  47854. private _horizontalBlurPostprocess1;
  47855. private _verticalBlurPostprocess1;
  47856. private _horizontalBlurPostprocess2;
  47857. private _verticalBlurPostprocess2;
  47858. private _blurTexture1;
  47859. private _blurTexture2;
  47860. private _postProcesses1;
  47861. private _postProcesses2;
  47862. private _includedOnlyMeshes;
  47863. private _excludedMeshes;
  47864. /**
  47865. * Callback used to let the user override the color selection on a per mesh basis
  47866. */
  47867. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47868. /**
  47869. * Callback used to let the user override the texture selection on a per mesh basis
  47870. */
  47871. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47872. /**
  47873. * Instantiates a new glow Layer and references it to the scene.
  47874. * @param name The name of the layer
  47875. * @param scene The scene to use the layer in
  47876. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47877. */
  47878. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47879. /**
  47880. * Get the effect name of the layer.
  47881. * @return The effect name
  47882. */
  47883. getEffectName(): string;
  47884. /**
  47885. * Create the merge effect. This is the shader use to blit the information back
  47886. * to the main canvas at the end of the scene rendering.
  47887. */
  47888. protected _createMergeEffect(): Effect;
  47889. /**
  47890. * Creates the render target textures and post processes used in the glow layer.
  47891. */
  47892. protected _createTextureAndPostProcesses(): void;
  47893. /**
  47894. * Checks for the readiness of the element composing the layer.
  47895. * @param subMesh the mesh to check for
  47896. * @param useInstances specify wether or not to use instances to render the mesh
  47897. * @param emissiveTexture the associated emissive texture used to generate the glow
  47898. * @return true if ready otherwise, false
  47899. */
  47900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47901. /**
  47902. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47903. */
  47904. needStencil(): boolean;
  47905. /**
  47906. * Returns true if the mesh can be rendered, otherwise false.
  47907. * @param mesh The mesh to render
  47908. * @param material The material used on the mesh
  47909. * @returns true if it can be rendered otherwise false
  47910. */
  47911. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47912. /**
  47913. * Implementation specific of rendering the generating effect on the main canvas.
  47914. * @param effect The effect used to render through
  47915. */
  47916. protected _internalRender(effect: Effect): void;
  47917. /**
  47918. * Sets the required values for both the emissive texture and and the main color.
  47919. */
  47920. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47921. /**
  47922. * Returns true if the mesh should render, otherwise false.
  47923. * @param mesh The mesh to render
  47924. * @returns true if it should render otherwise false
  47925. */
  47926. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47927. /**
  47928. * Adds specific effects defines.
  47929. * @param defines The defines to add specifics to.
  47930. */
  47931. protected _addCustomEffectDefines(defines: string[]): void;
  47932. /**
  47933. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47934. * @param mesh The mesh to exclude from the glow layer
  47935. */
  47936. addExcludedMesh(mesh: Mesh): void;
  47937. /**
  47938. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47939. * @param mesh The mesh to remove
  47940. */
  47941. removeExcludedMesh(mesh: Mesh): void;
  47942. /**
  47943. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47944. * @param mesh The mesh to include in the glow layer
  47945. */
  47946. addIncludedOnlyMesh(mesh: Mesh): void;
  47947. /**
  47948. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47949. * @param mesh The mesh to remove
  47950. */
  47951. removeIncludedOnlyMesh(mesh: Mesh): void;
  47952. /**
  47953. * Determine if a given mesh will be used in the glow layer
  47954. * @param mesh The mesh to test
  47955. * @returns true if the mesh will be highlighted by the current glow layer
  47956. */
  47957. hasMesh(mesh: AbstractMesh): boolean;
  47958. /**
  47959. * Free any resources and references associated to a mesh.
  47960. * Internal use
  47961. * @param mesh The mesh to free.
  47962. * @hidden
  47963. */
  47964. _disposeMesh(mesh: Mesh): void;
  47965. /**
  47966. * Gets the class name of the effect layer
  47967. * @returns the string with the class name of the effect layer
  47968. */
  47969. getClassName(): string;
  47970. /**
  47971. * Serializes this glow layer
  47972. * @returns a serialized glow layer object
  47973. */
  47974. serialize(): any;
  47975. /**
  47976. * Creates a Glow Layer from parsed glow layer data
  47977. * @param parsedGlowLayer defines glow layer data
  47978. * @param scene defines the current scene
  47979. * @param rootUrl defines the root URL containing the glow layer information
  47980. * @returns a parsed Glow Layer
  47981. */
  47982. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47983. }
  47984. }
  47985. declare module BABYLON {
  47986. /** @hidden */
  47987. export var glowBlurPostProcessPixelShader: {
  47988. name: string;
  47989. shader: string;
  47990. };
  47991. }
  47992. declare module BABYLON {
  47993. interface AbstractScene {
  47994. /**
  47995. * Return a the first highlight layer of the scene with a given name.
  47996. * @param name The name of the highlight layer to look for.
  47997. * @return The highlight layer if found otherwise null.
  47998. */
  47999. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48000. }
  48001. /**
  48002. * Highlight layer options. This helps customizing the behaviour
  48003. * of the highlight layer.
  48004. */
  48005. export interface IHighlightLayerOptions {
  48006. /**
  48007. * Multiplication factor apply to the canvas size to compute the render target size
  48008. * used to generated the glowing objects (the smaller the faster).
  48009. */
  48010. mainTextureRatio: number;
  48011. /**
  48012. * Enforces a fixed size texture to ensure resize independant blur.
  48013. */
  48014. mainTextureFixedSize?: number;
  48015. /**
  48016. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48017. * of the picture to blur (the smaller the faster).
  48018. */
  48019. blurTextureSizeRatio: number;
  48020. /**
  48021. * How big in texel of the blur texture is the vertical blur.
  48022. */
  48023. blurVerticalSize: number;
  48024. /**
  48025. * How big in texel of the blur texture is the horizontal blur.
  48026. */
  48027. blurHorizontalSize: number;
  48028. /**
  48029. * Alpha blending mode used to apply the blur. Default is combine.
  48030. */
  48031. alphaBlendingMode: number;
  48032. /**
  48033. * The camera attached to the layer.
  48034. */
  48035. camera: Nullable<Camera>;
  48036. /**
  48037. * Should we display highlight as a solid stroke?
  48038. */
  48039. isStroke?: boolean;
  48040. /**
  48041. * The rendering group to draw the layer in.
  48042. */
  48043. renderingGroupId: number;
  48044. }
  48045. /**
  48046. * The highlight layer Helps adding a glow effect around a mesh.
  48047. *
  48048. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48049. * glowy meshes to your scene.
  48050. *
  48051. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48052. */
  48053. export class HighlightLayer extends EffectLayer {
  48054. name: string;
  48055. /**
  48056. * Effect Name of the highlight layer.
  48057. */
  48058. static readonly EffectName: string;
  48059. /**
  48060. * The neutral color used during the preparation of the glow effect.
  48061. * This is black by default as the blend operation is a blend operation.
  48062. */
  48063. static NeutralColor: Color4;
  48064. /**
  48065. * Stencil value used for glowing meshes.
  48066. */
  48067. static GlowingMeshStencilReference: number;
  48068. /**
  48069. * Stencil value used for the other meshes in the scene.
  48070. */
  48071. static NormalMeshStencilReference: number;
  48072. /**
  48073. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48074. */
  48075. innerGlow: boolean;
  48076. /**
  48077. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48078. */
  48079. outerGlow: boolean;
  48080. /**
  48081. * Specifies the horizontal size of the blur.
  48082. */
  48083. /**
  48084. * Gets the horizontal size of the blur.
  48085. */
  48086. blurHorizontalSize: number;
  48087. /**
  48088. * Specifies the vertical size of the blur.
  48089. */
  48090. /**
  48091. * Gets the vertical size of the blur.
  48092. */
  48093. blurVerticalSize: number;
  48094. /**
  48095. * An event triggered when the highlight layer is being blurred.
  48096. */
  48097. onBeforeBlurObservable: Observable<HighlightLayer>;
  48098. /**
  48099. * An event triggered when the highlight layer has been blurred.
  48100. */
  48101. onAfterBlurObservable: Observable<HighlightLayer>;
  48102. private _instanceGlowingMeshStencilReference;
  48103. private _options;
  48104. private _downSamplePostprocess;
  48105. private _horizontalBlurPostprocess;
  48106. private _verticalBlurPostprocess;
  48107. private _blurTexture;
  48108. private _meshes;
  48109. private _excludedMeshes;
  48110. /**
  48111. * Instantiates a new highlight Layer and references it to the scene..
  48112. * @param name The name of the layer
  48113. * @param scene The scene to use the layer in
  48114. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48115. */
  48116. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48117. /**
  48118. * Get the effect name of the layer.
  48119. * @return The effect name
  48120. */
  48121. getEffectName(): string;
  48122. /**
  48123. * Create the merge effect. This is the shader use to blit the information back
  48124. * to the main canvas at the end of the scene rendering.
  48125. */
  48126. protected _createMergeEffect(): Effect;
  48127. /**
  48128. * Creates the render target textures and post processes used in the highlight layer.
  48129. */
  48130. protected _createTextureAndPostProcesses(): void;
  48131. /**
  48132. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48133. */
  48134. needStencil(): boolean;
  48135. /**
  48136. * Checks for the readiness of the element composing the layer.
  48137. * @param subMesh the mesh to check for
  48138. * @param useInstances specify wether or not to use instances to render the mesh
  48139. * @param emissiveTexture the associated emissive texture used to generate the glow
  48140. * @return true if ready otherwise, false
  48141. */
  48142. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48143. /**
  48144. * Implementation specific of rendering the generating effect on the main canvas.
  48145. * @param effect The effect used to render through
  48146. */
  48147. protected _internalRender(effect: Effect): void;
  48148. /**
  48149. * Returns true if the layer contains information to display, otherwise false.
  48150. */
  48151. shouldRender(): boolean;
  48152. /**
  48153. * Returns true if the mesh should render, otherwise false.
  48154. * @param mesh The mesh to render
  48155. * @returns true if it should render otherwise false
  48156. */
  48157. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48158. /**
  48159. * Sets the required values for both the emissive texture and and the main color.
  48160. */
  48161. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48162. /**
  48163. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48164. * @param mesh The mesh to exclude from the highlight layer
  48165. */
  48166. addExcludedMesh(mesh: Mesh): void;
  48167. /**
  48168. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48169. * @param mesh The mesh to highlight
  48170. */
  48171. removeExcludedMesh(mesh: Mesh): void;
  48172. /**
  48173. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48174. * @param mesh mesh to test
  48175. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48176. */
  48177. hasMesh(mesh: AbstractMesh): boolean;
  48178. /**
  48179. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48180. * @param mesh The mesh to highlight
  48181. * @param color The color of the highlight
  48182. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48183. */
  48184. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48185. /**
  48186. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48187. * @param mesh The mesh to highlight
  48188. */
  48189. removeMesh(mesh: Mesh): void;
  48190. /**
  48191. * Force the stencil to the normal expected value for none glowing parts
  48192. */
  48193. private _defaultStencilReference;
  48194. /**
  48195. * Free any resources and references associated to a mesh.
  48196. * Internal use
  48197. * @param mesh The mesh to free.
  48198. * @hidden
  48199. */
  48200. _disposeMesh(mesh: Mesh): void;
  48201. /**
  48202. * Dispose the highlight layer and free resources.
  48203. */
  48204. dispose(): void;
  48205. /**
  48206. * Gets the class name of the effect layer
  48207. * @returns the string with the class name of the effect layer
  48208. */
  48209. getClassName(): string;
  48210. /**
  48211. * Serializes this Highlight layer
  48212. * @returns a serialized Highlight layer object
  48213. */
  48214. serialize(): any;
  48215. /**
  48216. * Creates a Highlight layer from parsed Highlight layer data
  48217. * @param parsedHightlightLayer defines the Highlight layer data
  48218. * @param scene defines the current scene
  48219. * @param rootUrl defines the root URL containing the Highlight layer information
  48220. * @returns a parsed Highlight layer
  48221. */
  48222. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48223. }
  48224. }
  48225. declare module BABYLON {
  48226. interface AbstractScene {
  48227. /**
  48228. * The list of layers (background and foreground) of the scene
  48229. */
  48230. layers: Array<Layer>;
  48231. }
  48232. /**
  48233. * Defines the layer scene component responsible to manage any layers
  48234. * in a given scene.
  48235. */
  48236. export class LayerSceneComponent implements ISceneComponent {
  48237. /**
  48238. * The component name helpfull to identify the component in the list of scene components.
  48239. */
  48240. readonly name: string;
  48241. /**
  48242. * The scene the component belongs to.
  48243. */
  48244. scene: Scene;
  48245. private _engine;
  48246. /**
  48247. * Creates a new instance of the component for the given scene
  48248. * @param scene Defines the scene to register the component in
  48249. */
  48250. constructor(scene: Scene);
  48251. /**
  48252. * Registers the component in a given scene
  48253. */
  48254. register(): void;
  48255. /**
  48256. * Rebuilds the elements related to this component in case of
  48257. * context lost for instance.
  48258. */
  48259. rebuild(): void;
  48260. /**
  48261. * Disposes the component and the associated ressources.
  48262. */
  48263. dispose(): void;
  48264. private _draw;
  48265. private _drawCameraPredicate;
  48266. private _drawCameraBackground;
  48267. private _drawCameraForeground;
  48268. private _drawRenderTargetPredicate;
  48269. private _drawRenderTargetBackground;
  48270. private _drawRenderTargetForeground;
  48271. /**
  48272. * Adds all the elements from the container to the scene
  48273. * @param container the container holding the elements
  48274. */
  48275. addFromContainer(container: AbstractScene): void;
  48276. /**
  48277. * Removes all the elements in the container from the scene
  48278. * @param container contains the elements to remove
  48279. * @param dispose if the removed element should be disposed (default: false)
  48280. */
  48281. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48282. }
  48283. }
  48284. declare module BABYLON {
  48285. /** @hidden */
  48286. export var layerPixelShader: {
  48287. name: string;
  48288. shader: string;
  48289. };
  48290. }
  48291. declare module BABYLON {
  48292. /** @hidden */
  48293. export var layerVertexShader: {
  48294. name: string;
  48295. shader: string;
  48296. };
  48297. }
  48298. declare module BABYLON {
  48299. /**
  48300. * This represents a full screen 2d layer.
  48301. * This can be useful to display a picture in the background of your scene for instance.
  48302. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48303. */
  48304. export class Layer {
  48305. /**
  48306. * Define the name of the layer.
  48307. */
  48308. name: string;
  48309. /**
  48310. * Define the texture the layer should display.
  48311. */
  48312. texture: Nullable<Texture>;
  48313. /**
  48314. * Is the layer in background or foreground.
  48315. */
  48316. isBackground: boolean;
  48317. /**
  48318. * Define the color of the layer (instead of texture).
  48319. */
  48320. color: Color4;
  48321. /**
  48322. * Define the scale of the layer in order to zoom in out of the texture.
  48323. */
  48324. scale: Vector2;
  48325. /**
  48326. * Define an offset for the layer in order to shift the texture.
  48327. */
  48328. offset: Vector2;
  48329. /**
  48330. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48331. */
  48332. alphaBlendingMode: number;
  48333. /**
  48334. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48335. * Alpha test will not mix with the background color in case of transparency.
  48336. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48337. */
  48338. alphaTest: boolean;
  48339. /**
  48340. * Define a mask to restrict the layer to only some of the scene cameras.
  48341. */
  48342. layerMask: number;
  48343. /**
  48344. * Define the list of render target the layer is visible into.
  48345. */
  48346. renderTargetTextures: RenderTargetTexture[];
  48347. /**
  48348. * Define if the layer is only used in renderTarget or if it also
  48349. * renders in the main frame buffer of the canvas.
  48350. */
  48351. renderOnlyInRenderTargetTextures: boolean;
  48352. private _scene;
  48353. private _vertexBuffers;
  48354. private _indexBuffer;
  48355. private _effect;
  48356. private _alphaTestEffect;
  48357. /**
  48358. * An event triggered when the layer is disposed.
  48359. */
  48360. onDisposeObservable: Observable<Layer>;
  48361. private _onDisposeObserver;
  48362. /**
  48363. * Back compatibility with callback before the onDisposeObservable existed.
  48364. * The set callback will be triggered when the layer has been disposed.
  48365. */
  48366. onDispose: () => void;
  48367. /**
  48368. * An event triggered before rendering the scene
  48369. */
  48370. onBeforeRenderObservable: Observable<Layer>;
  48371. private _onBeforeRenderObserver;
  48372. /**
  48373. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48374. * The set callback will be triggered just before rendering the layer.
  48375. */
  48376. onBeforeRender: () => void;
  48377. /**
  48378. * An event triggered after rendering the scene
  48379. */
  48380. onAfterRenderObservable: Observable<Layer>;
  48381. private _onAfterRenderObserver;
  48382. /**
  48383. * Back compatibility with callback before the onAfterRenderObservable existed.
  48384. * The set callback will be triggered just after rendering the layer.
  48385. */
  48386. onAfterRender: () => void;
  48387. /**
  48388. * Instantiates a new layer.
  48389. * This represents a full screen 2d layer.
  48390. * This can be useful to display a picture in the background of your scene for instance.
  48391. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48392. * @param name Define the name of the layer in the scene
  48393. * @param imgUrl Define the url of the texture to display in the layer
  48394. * @param scene Define the scene the layer belongs to
  48395. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48396. * @param color Defines a color for the layer
  48397. */
  48398. constructor(
  48399. /**
  48400. * Define the name of the layer.
  48401. */
  48402. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48403. private _createIndexBuffer;
  48404. /** @hidden */
  48405. _rebuild(): void;
  48406. /**
  48407. * Renders the layer in the scene.
  48408. */
  48409. render(): void;
  48410. /**
  48411. * Disposes and releases the associated ressources.
  48412. */
  48413. dispose(): void;
  48414. }
  48415. }
  48416. declare module BABYLON {
  48417. /** @hidden */
  48418. export var lensFlarePixelShader: {
  48419. name: string;
  48420. shader: string;
  48421. };
  48422. }
  48423. declare module BABYLON {
  48424. /** @hidden */
  48425. export var lensFlareVertexShader: {
  48426. name: string;
  48427. shader: string;
  48428. };
  48429. }
  48430. declare module BABYLON {
  48431. /**
  48432. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48433. * It is usually composed of several `lensFlare`.
  48434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48435. */
  48436. export class LensFlareSystem {
  48437. /**
  48438. * Define the name of the lens flare system
  48439. */
  48440. name: string;
  48441. /**
  48442. * List of lens flares used in this system.
  48443. */
  48444. lensFlares: LensFlare[];
  48445. /**
  48446. * Define a limit from the border the lens flare can be visible.
  48447. */
  48448. borderLimit: number;
  48449. /**
  48450. * Define a viewport border we do not want to see the lens flare in.
  48451. */
  48452. viewportBorder: number;
  48453. /**
  48454. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48455. */
  48456. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48457. /**
  48458. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48459. */
  48460. layerMask: number;
  48461. /**
  48462. * Define the id of the lens flare system in the scene.
  48463. * (equal to name by default)
  48464. */
  48465. id: string;
  48466. private _scene;
  48467. private _emitter;
  48468. private _vertexBuffers;
  48469. private _indexBuffer;
  48470. private _effect;
  48471. private _positionX;
  48472. private _positionY;
  48473. private _isEnabled;
  48474. /** @hidden */
  48475. static _SceneComponentInitialization: (scene: Scene) => void;
  48476. /**
  48477. * Instantiates a lens flare system.
  48478. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48479. * It is usually composed of several `lensFlare`.
  48480. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48481. * @param name Define the name of the lens flare system in the scene
  48482. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48483. * @param scene Define the scene the lens flare system belongs to
  48484. */
  48485. constructor(
  48486. /**
  48487. * Define the name of the lens flare system
  48488. */
  48489. name: string, emitter: any, scene: Scene);
  48490. /**
  48491. * Define if the lens flare system is enabled.
  48492. */
  48493. isEnabled: boolean;
  48494. /**
  48495. * Get the scene the effects belongs to.
  48496. * @returns the scene holding the lens flare system
  48497. */
  48498. getScene(): Scene;
  48499. /**
  48500. * Get the emitter of the lens flare system.
  48501. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48502. * @returns the emitter of the lens flare system
  48503. */
  48504. getEmitter(): any;
  48505. /**
  48506. * Set the emitter of the lens flare system.
  48507. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48508. * @param newEmitter Define the new emitter of the system
  48509. */
  48510. setEmitter(newEmitter: any): void;
  48511. /**
  48512. * Get the lens flare system emitter position.
  48513. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48514. * @returns the position
  48515. */
  48516. getEmitterPosition(): Vector3;
  48517. /**
  48518. * @hidden
  48519. */
  48520. computeEffectivePosition(globalViewport: Viewport): boolean;
  48521. /** @hidden */
  48522. _isVisible(): boolean;
  48523. /**
  48524. * @hidden
  48525. */
  48526. render(): boolean;
  48527. /**
  48528. * Dispose and release the lens flare with its associated resources.
  48529. */
  48530. dispose(): void;
  48531. /**
  48532. * Parse a lens flare system from a JSON repressentation
  48533. * @param parsedLensFlareSystem Define the JSON to parse
  48534. * @param scene Define the scene the parsed system should be instantiated in
  48535. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48536. * @returns the parsed system
  48537. */
  48538. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48539. /**
  48540. * Serialize the current Lens Flare System into a JSON representation.
  48541. * @returns the serialized JSON
  48542. */
  48543. serialize(): any;
  48544. }
  48545. }
  48546. declare module BABYLON {
  48547. /**
  48548. * This represents one of the lens effect in a `lensFlareSystem`.
  48549. * It controls one of the indiviual texture used in the effect.
  48550. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48551. */
  48552. export class LensFlare {
  48553. /**
  48554. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48555. */
  48556. size: number;
  48557. /**
  48558. * 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.
  48559. */
  48560. position: number;
  48561. /**
  48562. * Define the lens color.
  48563. */
  48564. color: Color3;
  48565. /**
  48566. * Define the lens texture.
  48567. */
  48568. texture: Nullable<Texture>;
  48569. /**
  48570. * Define the alpha mode to render this particular lens.
  48571. */
  48572. alphaMode: number;
  48573. private _system;
  48574. /**
  48575. * Creates a new Lens Flare.
  48576. * This represents one of the lens effect in a `lensFlareSystem`.
  48577. * It controls one of the indiviual texture used in the effect.
  48578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48579. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48580. * @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.
  48581. * @param color Define the lens color
  48582. * @param imgUrl Define the lens texture url
  48583. * @param system Define the `lensFlareSystem` this flare is part of
  48584. * @returns The newly created Lens Flare
  48585. */
  48586. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48587. /**
  48588. * Instantiates a new Lens Flare.
  48589. * This represents one of the lens effect in a `lensFlareSystem`.
  48590. * It controls one of the indiviual texture used in the effect.
  48591. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48592. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48593. * @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.
  48594. * @param color Define the lens color
  48595. * @param imgUrl Define the lens texture url
  48596. * @param system Define the `lensFlareSystem` this flare is part of
  48597. */
  48598. constructor(
  48599. /**
  48600. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48601. */
  48602. size: number,
  48603. /**
  48604. * 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.
  48605. */
  48606. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48607. /**
  48608. * Dispose and release the lens flare with its associated resources.
  48609. */
  48610. dispose(): void;
  48611. }
  48612. }
  48613. declare module BABYLON {
  48614. interface AbstractScene {
  48615. /**
  48616. * The list of lens flare system added to the scene
  48617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48618. */
  48619. lensFlareSystems: Array<LensFlareSystem>;
  48620. /**
  48621. * Removes the given lens flare system from this scene.
  48622. * @param toRemove The lens flare system to remove
  48623. * @returns The index of the removed lens flare system
  48624. */
  48625. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48626. /**
  48627. * Adds the given lens flare system to this scene
  48628. * @param newLensFlareSystem The lens flare system to add
  48629. */
  48630. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48631. /**
  48632. * Gets a lens flare system using its name
  48633. * @param name defines the name to look for
  48634. * @returns the lens flare system or null if not found
  48635. */
  48636. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48637. /**
  48638. * Gets a lens flare system using its id
  48639. * @param id defines the id to look for
  48640. * @returns the lens flare system or null if not found
  48641. */
  48642. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48643. }
  48644. /**
  48645. * Defines the lens flare scene component responsible to manage any lens flares
  48646. * in a given scene.
  48647. */
  48648. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48649. /**
  48650. * The component name helpfull to identify the component in the list of scene components.
  48651. */
  48652. readonly name: string;
  48653. /**
  48654. * The scene the component belongs to.
  48655. */
  48656. scene: Scene;
  48657. /**
  48658. * Creates a new instance of the component for the given scene
  48659. * @param scene Defines the scene to register the component in
  48660. */
  48661. constructor(scene: Scene);
  48662. /**
  48663. * Registers the component in a given scene
  48664. */
  48665. register(): void;
  48666. /**
  48667. * Rebuilds the elements related to this component in case of
  48668. * context lost for instance.
  48669. */
  48670. rebuild(): void;
  48671. /**
  48672. * Adds all the elements from the container to the scene
  48673. * @param container the container holding the elements
  48674. */
  48675. addFromContainer(container: AbstractScene): void;
  48676. /**
  48677. * Removes all the elements in the container from the scene
  48678. * @param container contains the elements to remove
  48679. * @param dispose if the removed element should be disposed (default: false)
  48680. */
  48681. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48682. /**
  48683. * Serializes the component data to the specified json object
  48684. * @param serializationObject The object to serialize to
  48685. */
  48686. serialize(serializationObject: any): void;
  48687. /**
  48688. * Disposes the component and the associated ressources.
  48689. */
  48690. dispose(): void;
  48691. private _draw;
  48692. }
  48693. }
  48694. declare module BABYLON {
  48695. /**
  48696. * Defines the shadow generator component responsible to manage any shadow generators
  48697. * in a given scene.
  48698. */
  48699. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48700. /**
  48701. * The component name helpfull to identify the component in the list of scene components.
  48702. */
  48703. readonly name: string;
  48704. /**
  48705. * The scene the component belongs to.
  48706. */
  48707. scene: Scene;
  48708. /**
  48709. * Creates a new instance of the component for the given scene
  48710. * @param scene Defines the scene to register the component in
  48711. */
  48712. constructor(scene: Scene);
  48713. /**
  48714. * Registers the component in a given scene
  48715. */
  48716. register(): void;
  48717. /**
  48718. * Rebuilds the elements related to this component in case of
  48719. * context lost for instance.
  48720. */
  48721. rebuild(): void;
  48722. /**
  48723. * Serializes the component data to the specified json object
  48724. * @param serializationObject The object to serialize to
  48725. */
  48726. serialize(serializationObject: any): void;
  48727. /**
  48728. * Adds all the elements from the container to the scene
  48729. * @param container the container holding the elements
  48730. */
  48731. addFromContainer(container: AbstractScene): void;
  48732. /**
  48733. * Removes all the elements in the container from the scene
  48734. * @param container contains the elements to remove
  48735. * @param dispose if the removed element should be disposed (default: false)
  48736. */
  48737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48738. /**
  48739. * Rebuilds the elements related to this component in case of
  48740. * context lost for instance.
  48741. */
  48742. dispose(): void;
  48743. private _gatherRenderTargets;
  48744. }
  48745. }
  48746. declare module BABYLON {
  48747. /**
  48748. * A point light is a light defined by an unique point in world space.
  48749. * The light is emitted in every direction from this point.
  48750. * A good example of a point light is a standard light bulb.
  48751. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48752. */
  48753. export class PointLight extends ShadowLight {
  48754. private _shadowAngle;
  48755. /**
  48756. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48757. * This specifies what angle the shadow will use to be created.
  48758. *
  48759. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48760. */
  48761. /**
  48762. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48763. * This specifies what angle the shadow will use to be created.
  48764. *
  48765. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48766. */
  48767. shadowAngle: number;
  48768. /**
  48769. * Gets the direction if it has been set.
  48770. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48771. */
  48772. /**
  48773. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48774. */
  48775. direction: Vector3;
  48776. /**
  48777. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48778. * A PointLight emits the light in every direction.
  48779. * It can cast shadows.
  48780. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48781. * ```javascript
  48782. * var pointLight = new PointLight("pl", camera.position, scene);
  48783. * ```
  48784. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48785. * @param name The light friendly name
  48786. * @param position The position of the point light in the scene
  48787. * @param scene The scene the lights belongs to
  48788. */
  48789. constructor(name: string, position: Vector3, scene: Scene);
  48790. /**
  48791. * Returns the string "PointLight"
  48792. * @returns the class name
  48793. */
  48794. getClassName(): string;
  48795. /**
  48796. * Returns the integer 0.
  48797. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48798. */
  48799. getTypeID(): number;
  48800. /**
  48801. * Specifies wether or not the shadowmap should be a cube texture.
  48802. * @returns true if the shadowmap needs to be a cube texture.
  48803. */
  48804. needCube(): boolean;
  48805. /**
  48806. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48807. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48808. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48809. */
  48810. getShadowDirection(faceIndex?: number): Vector3;
  48811. /**
  48812. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48813. * - fov = PI / 2
  48814. * - aspect ratio : 1.0
  48815. * - z-near and far equal to the active camera minZ and maxZ.
  48816. * Returns the PointLight.
  48817. */
  48818. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48819. protected _buildUniformLayout(): void;
  48820. /**
  48821. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48822. * @param effect The effect to update
  48823. * @param lightIndex The index of the light in the effect to update
  48824. * @returns The point light
  48825. */
  48826. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48827. /**
  48828. * Prepares the list of defines specific to the light type.
  48829. * @param defines the list of defines
  48830. * @param lightIndex defines the index of the light for the effect
  48831. */
  48832. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48833. }
  48834. }
  48835. declare module BABYLON {
  48836. /**
  48837. * Header information of HDR texture files.
  48838. */
  48839. export interface HDRInfo {
  48840. /**
  48841. * The height of the texture in pixels.
  48842. */
  48843. height: number;
  48844. /**
  48845. * The width of the texture in pixels.
  48846. */
  48847. width: number;
  48848. /**
  48849. * The index of the beginning of the data in the binary file.
  48850. */
  48851. dataPosition: number;
  48852. }
  48853. /**
  48854. * This groups tools to convert HDR texture to native colors array.
  48855. */
  48856. export class HDRTools {
  48857. private static Ldexp;
  48858. private static Rgbe2float;
  48859. private static readStringLine;
  48860. /**
  48861. * Reads header information from an RGBE texture stored in a native array.
  48862. * More information on this format are available here:
  48863. * https://en.wikipedia.org/wiki/RGBE_image_format
  48864. *
  48865. * @param uint8array The binary file stored in native array.
  48866. * @return The header information.
  48867. */
  48868. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48869. /**
  48870. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48871. * This RGBE texture needs to store the information as a panorama.
  48872. *
  48873. * More information on this format are available here:
  48874. * https://en.wikipedia.org/wiki/RGBE_image_format
  48875. *
  48876. * @param buffer The binary file stored in an array buffer.
  48877. * @param size The expected size of the extracted cubemap.
  48878. * @return The Cube Map information.
  48879. */
  48880. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48881. /**
  48882. * Returns the pixels data extracted from an RGBE texture.
  48883. * This pixels will be stored left to right up to down in the R G B order in one array.
  48884. *
  48885. * More information on this format are available here:
  48886. * https://en.wikipedia.org/wiki/RGBE_image_format
  48887. *
  48888. * @param uint8array The binary file stored in an array buffer.
  48889. * @param hdrInfo The header information of the file.
  48890. * @return The pixels data in RGB right to left up to down order.
  48891. */
  48892. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48893. private static RGBE_ReadPixels_RLE;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /**
  48898. * This represents a texture coming from an HDR input.
  48899. *
  48900. * The only supported format is currently panorama picture stored in RGBE format.
  48901. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48902. */
  48903. export class HDRCubeTexture extends BaseTexture {
  48904. private static _facesMapping;
  48905. private _generateHarmonics;
  48906. private _noMipmap;
  48907. private _textureMatrix;
  48908. private _size;
  48909. private _onLoad;
  48910. private _onError;
  48911. /**
  48912. * The texture URL.
  48913. */
  48914. url: string;
  48915. /**
  48916. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48917. */
  48918. coordinatesMode: number;
  48919. protected _isBlocking: boolean;
  48920. /**
  48921. * Sets wether or not the texture is blocking during loading.
  48922. */
  48923. /**
  48924. * Gets wether or not the texture is blocking during loading.
  48925. */
  48926. isBlocking: boolean;
  48927. protected _rotationY: number;
  48928. /**
  48929. * Sets texture matrix rotation angle around Y axis in radians.
  48930. */
  48931. /**
  48932. * Gets texture matrix rotation angle around Y axis radians.
  48933. */
  48934. rotationY: number;
  48935. /**
  48936. * Gets or sets the center of the bounding box associated with the cube texture
  48937. * It must define where the camera used to render the texture was set
  48938. */
  48939. boundingBoxPosition: Vector3;
  48940. private _boundingBoxSize;
  48941. /**
  48942. * Gets or sets the size of the bounding box associated with the cube texture
  48943. * When defined, the cubemap will switch to local mode
  48944. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48945. * @example https://www.babylonjs-playground.com/#RNASML
  48946. */
  48947. boundingBoxSize: Vector3;
  48948. /**
  48949. * Instantiates an HDRTexture from the following parameters.
  48950. *
  48951. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48952. * @param scene The scene the texture will be used in
  48953. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48954. * @param noMipmap Forces to not generate the mipmap if true
  48955. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48956. * @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)
  48957. * @param reserved Reserved flag for internal use.
  48958. */
  48959. 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>);
  48960. /**
  48961. * Get the current class name of the texture useful for serialization or dynamic coding.
  48962. * @returns "HDRCubeTexture"
  48963. */
  48964. getClassName(): string;
  48965. /**
  48966. * Occurs when the file is raw .hdr file.
  48967. */
  48968. private loadTexture;
  48969. clone(): HDRCubeTexture;
  48970. delayLoad(): void;
  48971. /**
  48972. * Get the texture reflection matrix used to rotate/transform the reflection.
  48973. * @returns the reflection matrix
  48974. */
  48975. getReflectionTextureMatrix(): Matrix;
  48976. /**
  48977. * Set the texture reflection matrix used to rotate/transform the reflection.
  48978. * @param value Define the reflection matrix to set
  48979. */
  48980. setReflectionTextureMatrix(value: Matrix): void;
  48981. /**
  48982. * Parses a JSON representation of an HDR Texture in order to create the texture
  48983. * @param parsedTexture Define the JSON representation
  48984. * @param scene Define the scene the texture should be created in
  48985. * @param rootUrl Define the root url in case we need to load relative dependencies
  48986. * @returns the newly created texture after parsing
  48987. */
  48988. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48989. serialize(): any;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * Class used to control physics engine
  48995. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48996. */
  48997. export class PhysicsEngine implements IPhysicsEngine {
  48998. private _physicsPlugin;
  48999. /**
  49000. * Global value used to control the smallest number supported by the simulation
  49001. */
  49002. static Epsilon: number;
  49003. private _impostors;
  49004. private _joints;
  49005. /**
  49006. * Gets the gravity vector used by the simulation
  49007. */
  49008. gravity: Vector3;
  49009. /**
  49010. * Factory used to create the default physics plugin.
  49011. * @returns The default physics plugin
  49012. */
  49013. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49014. /**
  49015. * Creates a new Physics Engine
  49016. * @param gravity defines the gravity vector used by the simulation
  49017. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49018. */
  49019. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49020. /**
  49021. * Sets the gravity vector used by the simulation
  49022. * @param gravity defines the gravity vector to use
  49023. */
  49024. setGravity(gravity: Vector3): void;
  49025. /**
  49026. * Set the time step of the physics engine.
  49027. * Default is 1/60.
  49028. * To slow it down, enter 1/600 for example.
  49029. * To speed it up, 1/30
  49030. * @param newTimeStep defines the new timestep to apply to this world.
  49031. */
  49032. setTimeStep(newTimeStep?: number): void;
  49033. /**
  49034. * Get the time step of the physics engine.
  49035. * @returns the current time step
  49036. */
  49037. getTimeStep(): number;
  49038. /**
  49039. * Release all resources
  49040. */
  49041. dispose(): void;
  49042. /**
  49043. * Gets the name of the current physics plugin
  49044. * @returns the name of the plugin
  49045. */
  49046. getPhysicsPluginName(): string;
  49047. /**
  49048. * Adding a new impostor for the impostor tracking.
  49049. * This will be done by the impostor itself.
  49050. * @param impostor the impostor to add
  49051. */
  49052. addImpostor(impostor: PhysicsImpostor): void;
  49053. /**
  49054. * Remove an impostor from the engine.
  49055. * This impostor and its mesh will not longer be updated by the physics engine.
  49056. * @param impostor the impostor to remove
  49057. */
  49058. removeImpostor(impostor: PhysicsImpostor): void;
  49059. /**
  49060. * Add a joint to the physics engine
  49061. * @param mainImpostor defines the main impostor to which the joint is added.
  49062. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49063. * @param joint defines the joint that will connect both impostors.
  49064. */
  49065. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49066. /**
  49067. * Removes a joint from the simulation
  49068. * @param mainImpostor defines the impostor used with the joint
  49069. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49070. * @param joint defines the joint to remove
  49071. */
  49072. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49073. /**
  49074. * Called by the scene. No need to call it.
  49075. * @param delta defines the timespam between frames
  49076. */
  49077. _step(delta: number): void;
  49078. /**
  49079. * Gets the current plugin used to run the simulation
  49080. * @returns current plugin
  49081. */
  49082. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49083. /**
  49084. * Gets the list of physic impostors
  49085. * @returns an array of PhysicsImpostor
  49086. */
  49087. getImpostors(): Array<PhysicsImpostor>;
  49088. /**
  49089. * Gets the impostor for a physics enabled object
  49090. * @param object defines the object impersonated by the impostor
  49091. * @returns the PhysicsImpostor or null if not found
  49092. */
  49093. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49094. /**
  49095. * Gets the impostor for a physics body object
  49096. * @param body defines physics body used by the impostor
  49097. * @returns the PhysicsImpostor or null if not found
  49098. */
  49099. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49100. /**
  49101. * Does a raycast in the physics world
  49102. * @param from when should the ray start?
  49103. * @param to when should the ray end?
  49104. * @returns PhysicsRaycastResult
  49105. */
  49106. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49107. }
  49108. }
  49109. declare module BABYLON {
  49110. /** @hidden */
  49111. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49112. private _useDeltaForWorldStep;
  49113. world: any;
  49114. name: string;
  49115. private _physicsMaterials;
  49116. private _fixedTimeStep;
  49117. private _cannonRaycastResult;
  49118. private _raycastResult;
  49119. private _physicsBodysToRemoveAfterStep;
  49120. BJSCANNON: any;
  49121. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49122. setGravity(gravity: Vector3): void;
  49123. setTimeStep(timeStep: number): void;
  49124. getTimeStep(): number;
  49125. executeStep(delta: number): void;
  49126. private _removeMarkedPhysicsBodiesFromWorld;
  49127. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49128. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49129. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49130. private _processChildMeshes;
  49131. removePhysicsBody(impostor: PhysicsImpostor): void;
  49132. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49133. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49134. private _addMaterial;
  49135. private _checkWithEpsilon;
  49136. private _createShape;
  49137. private _createHeightmap;
  49138. private _minus90X;
  49139. private _plus90X;
  49140. private _tmpPosition;
  49141. private _tmpDeltaPosition;
  49142. private _tmpUnityRotation;
  49143. private _updatePhysicsBodyTransformation;
  49144. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49145. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49146. isSupported(): boolean;
  49147. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49148. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49149. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49150. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49151. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49152. getBodyMass(impostor: PhysicsImpostor): number;
  49153. getBodyFriction(impostor: PhysicsImpostor): number;
  49154. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49155. getBodyRestitution(impostor: PhysicsImpostor): number;
  49156. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49157. sleepBody(impostor: PhysicsImpostor): void;
  49158. wakeUpBody(impostor: PhysicsImpostor): void;
  49159. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49160. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49161. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49162. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49163. getRadius(impostor: PhysicsImpostor): number;
  49164. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49165. dispose(): void;
  49166. private _extendNamespace;
  49167. /**
  49168. * Does a raycast in the physics world
  49169. * @param from when should the ray start?
  49170. * @param to when should the ray end?
  49171. * @returns PhysicsRaycastResult
  49172. */
  49173. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49174. }
  49175. }
  49176. declare module BABYLON {
  49177. /** @hidden */
  49178. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49179. world: any;
  49180. name: string;
  49181. BJSOIMO: any;
  49182. private _raycastResult;
  49183. constructor(iterations?: number, oimoInjection?: any);
  49184. setGravity(gravity: Vector3): void;
  49185. setTimeStep(timeStep: number): void;
  49186. getTimeStep(): number;
  49187. private _tmpImpostorsArray;
  49188. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49189. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49190. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49191. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49192. private _tmpPositionVector;
  49193. removePhysicsBody(impostor: PhysicsImpostor): void;
  49194. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49195. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49196. isSupported(): boolean;
  49197. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49198. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49199. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49200. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49201. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49202. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49203. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49204. getBodyMass(impostor: PhysicsImpostor): number;
  49205. getBodyFriction(impostor: PhysicsImpostor): number;
  49206. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49207. getBodyRestitution(impostor: PhysicsImpostor): number;
  49208. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49209. sleepBody(impostor: PhysicsImpostor): void;
  49210. wakeUpBody(impostor: PhysicsImpostor): void;
  49211. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49212. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49213. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49214. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49215. getRadius(impostor: PhysicsImpostor): number;
  49216. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49217. dispose(): void;
  49218. /**
  49219. * Does a raycast in the physics world
  49220. * @param from when should the ray start?
  49221. * @param to when should the ray end?
  49222. * @returns PhysicsRaycastResult
  49223. */
  49224. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49225. }
  49226. }
  49227. declare module BABYLON {
  49228. /**
  49229. * Class containing static functions to help procedurally build meshes
  49230. */
  49231. export class RibbonBuilder {
  49232. /**
  49233. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49234. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49235. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49236. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49237. * * 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
  49238. * * 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
  49239. * * 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
  49240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49241. * * 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
  49242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49243. * * 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
  49244. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49245. * * 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
  49246. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49248. * @param name defines the name of the mesh
  49249. * @param options defines the options used to create the mesh
  49250. * @param scene defines the hosting scene
  49251. * @returns the ribbon mesh
  49252. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49254. */
  49255. static CreateRibbon(name: string, options: {
  49256. pathArray: Vector3[][];
  49257. closeArray?: boolean;
  49258. closePath?: boolean;
  49259. offset?: number;
  49260. updatable?: boolean;
  49261. sideOrientation?: number;
  49262. frontUVs?: Vector4;
  49263. backUVs?: Vector4;
  49264. instance?: Mesh;
  49265. invertUV?: boolean;
  49266. uvs?: Vector2[];
  49267. colors?: Color4[];
  49268. }, scene?: Nullable<Scene>): Mesh;
  49269. }
  49270. }
  49271. declare module BABYLON {
  49272. /**
  49273. * Class containing static functions to help procedurally build meshes
  49274. */
  49275. export class ShapeBuilder {
  49276. /**
  49277. * 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.
  49278. * * 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.
  49279. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49280. * * 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.
  49281. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49282. * * 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
  49283. * * 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
  49284. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49286. * * 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
  49287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49289. * @param name defines the name of the mesh
  49290. * @param options defines the options used to create the mesh
  49291. * @param scene defines the hosting scene
  49292. * @returns the extruded shape mesh
  49293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49295. */
  49296. static ExtrudeShape(name: string, options: {
  49297. shape: Vector3[];
  49298. path: Vector3[];
  49299. scale?: number;
  49300. rotation?: number;
  49301. cap?: number;
  49302. updatable?: boolean;
  49303. sideOrientation?: number;
  49304. frontUVs?: Vector4;
  49305. backUVs?: Vector4;
  49306. instance?: Mesh;
  49307. invertUV?: boolean;
  49308. }, scene?: Nullable<Scene>): Mesh;
  49309. /**
  49310. * Creates an custom extruded shape mesh.
  49311. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49312. * * 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.
  49313. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49314. * * 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
  49315. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49316. * * 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
  49317. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49318. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49319. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49320. * * 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
  49321. * * 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
  49322. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49324. * * 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
  49325. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49327. * @param name defines the name of the mesh
  49328. * @param options defines the options used to create the mesh
  49329. * @param scene defines the hosting scene
  49330. * @returns the custom extruded shape mesh
  49331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49334. */
  49335. static ExtrudeShapeCustom(name: string, options: {
  49336. shape: Vector3[];
  49337. path: Vector3[];
  49338. scaleFunction?: any;
  49339. rotationFunction?: any;
  49340. ribbonCloseArray?: boolean;
  49341. ribbonClosePath?: boolean;
  49342. cap?: number;
  49343. updatable?: boolean;
  49344. sideOrientation?: number;
  49345. frontUVs?: Vector4;
  49346. backUVs?: Vector4;
  49347. instance?: Mesh;
  49348. invertUV?: boolean;
  49349. }, scene?: Nullable<Scene>): Mesh;
  49350. private static _ExtrudeShapeGeneric;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * AmmoJS Physics plugin
  49356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49357. * @see https://github.com/kripken/ammo.js/
  49358. */
  49359. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49360. private _useDeltaForWorldStep;
  49361. /**
  49362. * Reference to the Ammo library
  49363. */
  49364. bjsAMMO: any;
  49365. /**
  49366. * Created ammoJS world which physics bodies are added to
  49367. */
  49368. world: any;
  49369. /**
  49370. * Name of the plugin
  49371. */
  49372. name: string;
  49373. private _timeStep;
  49374. private _fixedTimeStep;
  49375. private _maxSteps;
  49376. private _tmpQuaternion;
  49377. private _tmpAmmoTransform;
  49378. private _tmpAmmoQuaternion;
  49379. private _tmpAmmoConcreteContactResultCallback;
  49380. private _collisionConfiguration;
  49381. private _dispatcher;
  49382. private _overlappingPairCache;
  49383. private _solver;
  49384. private _softBodySolver;
  49385. private _tmpAmmoVectorA;
  49386. private _tmpAmmoVectorB;
  49387. private _tmpAmmoVectorC;
  49388. private _tmpAmmoVectorD;
  49389. private _tmpContactCallbackResult;
  49390. private _tmpAmmoVectorRCA;
  49391. private _tmpAmmoVectorRCB;
  49392. private _raycastResult;
  49393. private static readonly DISABLE_COLLISION_FLAG;
  49394. private static readonly KINEMATIC_FLAG;
  49395. private static readonly DISABLE_DEACTIVATION_FLAG;
  49396. /**
  49397. * Initializes the ammoJS plugin
  49398. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49399. * @param ammoInjection can be used to inject your own ammo reference
  49400. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49401. */
  49402. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49403. /**
  49404. * Sets the gravity of the physics world (m/(s^2))
  49405. * @param gravity Gravity to set
  49406. */
  49407. setGravity(gravity: Vector3): void;
  49408. /**
  49409. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49410. * @param timeStep timestep to use in seconds
  49411. */
  49412. setTimeStep(timeStep: number): void;
  49413. /**
  49414. * 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)
  49415. * @param fixedTimeStep fixedTimeStep to use in seconds
  49416. */
  49417. setFixedTimeStep(fixedTimeStep: number): void;
  49418. /**
  49419. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49420. * @param maxSteps the maximum number of steps by the physics engine per frame
  49421. */
  49422. setMaxSteps(maxSteps: number): void;
  49423. /**
  49424. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49425. * @returns the current timestep in seconds
  49426. */
  49427. getTimeStep(): number;
  49428. private _isImpostorInContact;
  49429. private _isImpostorPairInContact;
  49430. private _stepSimulation;
  49431. /**
  49432. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49433. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49434. * After the step the babylon meshes are set to the position of the physics imposters
  49435. * @param delta amount of time to step forward
  49436. * @param impostors array of imposters to update before/after the step
  49437. */
  49438. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49439. /**
  49440. * Update babylon mesh to match physics world object
  49441. * @param impostor imposter to match
  49442. */
  49443. private _afterSoftStep;
  49444. /**
  49445. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49446. * @param impostor imposter to match
  49447. */
  49448. private _ropeStep;
  49449. /**
  49450. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49451. * @param impostor imposter to match
  49452. */
  49453. private _softbodyOrClothStep;
  49454. private _tmpVector;
  49455. private _tmpMatrix;
  49456. /**
  49457. * Applies an impulse on the imposter
  49458. * @param impostor imposter to apply impulse to
  49459. * @param force amount of force to be applied to the imposter
  49460. * @param contactPoint the location to apply the impulse on the imposter
  49461. */
  49462. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49463. /**
  49464. * Applies a force on the imposter
  49465. * @param impostor imposter to apply force
  49466. * @param force amount of force to be applied to the imposter
  49467. * @param contactPoint the location to apply the force on the imposter
  49468. */
  49469. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49470. /**
  49471. * Creates a physics body using the plugin
  49472. * @param impostor the imposter to create the physics body on
  49473. */
  49474. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49475. /**
  49476. * Removes the physics body from the imposter and disposes of the body's memory
  49477. * @param impostor imposter to remove the physics body from
  49478. */
  49479. removePhysicsBody(impostor: PhysicsImpostor): void;
  49480. /**
  49481. * Generates a joint
  49482. * @param impostorJoint the imposter joint to create the joint with
  49483. */
  49484. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49485. /**
  49486. * Removes a joint
  49487. * @param impostorJoint the imposter joint to remove the joint from
  49488. */
  49489. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49490. private _addMeshVerts;
  49491. /**
  49492. * Initialise the soft body vertices to match its object's (mesh) vertices
  49493. * Softbody vertices (nodes) are in world space and to match this
  49494. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49495. * @param impostor to create the softbody for
  49496. */
  49497. private _softVertexData;
  49498. /**
  49499. * Create an impostor's soft body
  49500. * @param impostor to create the softbody for
  49501. */
  49502. private _createSoftbody;
  49503. /**
  49504. * Create cloth for an impostor
  49505. * @param impostor to create the softbody for
  49506. */
  49507. private _createCloth;
  49508. /**
  49509. * Create rope for an impostor
  49510. * @param impostor to create the softbody for
  49511. */
  49512. private _createRope;
  49513. private _addHullVerts;
  49514. private _createShape;
  49515. /**
  49516. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49517. * @param impostor imposter containing the physics body and babylon object
  49518. */
  49519. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49520. /**
  49521. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49522. * @param impostor imposter containing the physics body and babylon object
  49523. * @param newPosition new position
  49524. * @param newRotation new rotation
  49525. */
  49526. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49527. /**
  49528. * If this plugin is supported
  49529. * @returns true if its supported
  49530. */
  49531. isSupported(): boolean;
  49532. /**
  49533. * Sets the linear velocity of the physics body
  49534. * @param impostor imposter to set the velocity on
  49535. * @param velocity velocity to set
  49536. */
  49537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49538. /**
  49539. * Sets the angular velocity of the physics body
  49540. * @param impostor imposter to set the velocity on
  49541. * @param velocity velocity to set
  49542. */
  49543. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49544. /**
  49545. * gets the linear velocity
  49546. * @param impostor imposter to get linear velocity from
  49547. * @returns linear velocity
  49548. */
  49549. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49550. /**
  49551. * gets the angular velocity
  49552. * @param impostor imposter to get angular velocity from
  49553. * @returns angular velocity
  49554. */
  49555. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49556. /**
  49557. * Sets the mass of physics body
  49558. * @param impostor imposter to set the mass on
  49559. * @param mass mass to set
  49560. */
  49561. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49562. /**
  49563. * Gets the mass of the physics body
  49564. * @param impostor imposter to get the mass from
  49565. * @returns mass
  49566. */
  49567. getBodyMass(impostor: PhysicsImpostor): number;
  49568. /**
  49569. * Gets friction of the impostor
  49570. * @param impostor impostor to get friction from
  49571. * @returns friction value
  49572. */
  49573. getBodyFriction(impostor: PhysicsImpostor): number;
  49574. /**
  49575. * Sets friction of the impostor
  49576. * @param impostor impostor to set friction on
  49577. * @param friction friction value
  49578. */
  49579. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49580. /**
  49581. * Gets restitution of the impostor
  49582. * @param impostor impostor to get restitution from
  49583. * @returns restitution value
  49584. */
  49585. getBodyRestitution(impostor: PhysicsImpostor): number;
  49586. /**
  49587. * Sets resitution of the impostor
  49588. * @param impostor impostor to set resitution on
  49589. * @param restitution resitution value
  49590. */
  49591. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49592. /**
  49593. * Gets pressure inside the impostor
  49594. * @param impostor impostor to get pressure from
  49595. * @returns pressure value
  49596. */
  49597. getBodyPressure(impostor: PhysicsImpostor): number;
  49598. /**
  49599. * Sets pressure inside a soft body impostor
  49600. * Cloth and rope must remain 0 pressure
  49601. * @param impostor impostor to set pressure on
  49602. * @param pressure pressure value
  49603. */
  49604. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49605. /**
  49606. * Gets stiffness of the impostor
  49607. * @param impostor impostor to get stiffness from
  49608. * @returns pressure value
  49609. */
  49610. getBodyStiffness(impostor: PhysicsImpostor): number;
  49611. /**
  49612. * Sets stiffness of the impostor
  49613. * @param impostor impostor to set stiffness on
  49614. * @param stiffness stiffness value from 0 to 1
  49615. */
  49616. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49617. /**
  49618. * Gets velocityIterations of the impostor
  49619. * @param impostor impostor to get velocity iterations from
  49620. * @returns velocityIterations value
  49621. */
  49622. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49623. /**
  49624. * Sets velocityIterations of the impostor
  49625. * @param impostor impostor to set velocity iterations on
  49626. * @param velocityIterations velocityIterations value
  49627. */
  49628. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49629. /**
  49630. * Gets positionIterations of the impostor
  49631. * @param impostor impostor to get position iterations from
  49632. * @returns positionIterations value
  49633. */
  49634. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49635. /**
  49636. * Sets positionIterations of the impostor
  49637. * @param impostor impostor to set position on
  49638. * @param positionIterations positionIterations value
  49639. */
  49640. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49641. /**
  49642. * Append an anchor to a cloth object
  49643. * @param impostor is the cloth impostor to add anchor to
  49644. * @param otherImpostor is the rigid impostor to anchor to
  49645. * @param width ratio across width from 0 to 1
  49646. * @param height ratio up height from 0 to 1
  49647. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49648. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49649. */
  49650. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49651. /**
  49652. * Append an hook to a rope object
  49653. * @param impostor is the rope impostor to add hook to
  49654. * @param otherImpostor is the rigid impostor to hook to
  49655. * @param length ratio along the rope from 0 to 1
  49656. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49657. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49658. */
  49659. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49660. /**
  49661. * Sleeps the physics body and stops it from being active
  49662. * @param impostor impostor to sleep
  49663. */
  49664. sleepBody(impostor: PhysicsImpostor): void;
  49665. /**
  49666. * Activates the physics body
  49667. * @param impostor impostor to activate
  49668. */
  49669. wakeUpBody(impostor: PhysicsImpostor): void;
  49670. /**
  49671. * Updates the distance parameters of the joint
  49672. * @param joint joint to update
  49673. * @param maxDistance maximum distance of the joint
  49674. * @param minDistance minimum distance of the joint
  49675. */
  49676. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49677. /**
  49678. * Sets a motor on the joint
  49679. * @param joint joint to set motor on
  49680. * @param speed speed of the motor
  49681. * @param maxForce maximum force of the motor
  49682. * @param motorIndex index of the motor
  49683. */
  49684. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49685. /**
  49686. * Sets the motors limit
  49687. * @param joint joint to set limit on
  49688. * @param upperLimit upper limit
  49689. * @param lowerLimit lower limit
  49690. */
  49691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49692. /**
  49693. * Syncs the position and rotation of a mesh with the impostor
  49694. * @param mesh mesh to sync
  49695. * @param impostor impostor to update the mesh with
  49696. */
  49697. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49698. /**
  49699. * Gets the radius of the impostor
  49700. * @param impostor impostor to get radius from
  49701. * @returns the radius
  49702. */
  49703. getRadius(impostor: PhysicsImpostor): number;
  49704. /**
  49705. * Gets the box size of the impostor
  49706. * @param impostor impostor to get box size from
  49707. * @param result the resulting box size
  49708. */
  49709. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49710. /**
  49711. * Disposes of the impostor
  49712. */
  49713. dispose(): void;
  49714. /**
  49715. * Does a raycast in the physics world
  49716. * @param from when should the ray start?
  49717. * @param to when should the ray end?
  49718. * @returns PhysicsRaycastResult
  49719. */
  49720. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49721. }
  49722. }
  49723. declare module BABYLON {
  49724. interface AbstractScene {
  49725. /**
  49726. * The list of reflection probes added to the scene
  49727. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49728. */
  49729. reflectionProbes: Array<ReflectionProbe>;
  49730. /**
  49731. * Removes the given reflection probe from this scene.
  49732. * @param toRemove The reflection probe to remove
  49733. * @returns The index of the removed reflection probe
  49734. */
  49735. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49736. /**
  49737. * Adds the given reflection probe to this scene.
  49738. * @param newReflectionProbe The reflection probe to add
  49739. */
  49740. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49741. }
  49742. /**
  49743. * Class used to generate realtime reflection / refraction cube textures
  49744. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49745. */
  49746. export class ReflectionProbe {
  49747. /** defines the name of the probe */
  49748. name: string;
  49749. private _scene;
  49750. private _renderTargetTexture;
  49751. private _projectionMatrix;
  49752. private _viewMatrix;
  49753. private _target;
  49754. private _add;
  49755. private _attachedMesh;
  49756. private _invertYAxis;
  49757. /** Gets or sets probe position (center of the cube map) */
  49758. position: Vector3;
  49759. /**
  49760. * Creates a new reflection probe
  49761. * @param name defines the name of the probe
  49762. * @param size defines the texture resolution (for each face)
  49763. * @param scene defines the hosting scene
  49764. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49765. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49766. */
  49767. constructor(
  49768. /** defines the name of the probe */
  49769. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49770. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49771. samples: number;
  49772. /** Gets or sets the refresh rate to use (on every frame by default) */
  49773. refreshRate: number;
  49774. /**
  49775. * Gets the hosting scene
  49776. * @returns a Scene
  49777. */
  49778. getScene(): Scene;
  49779. /** Gets the internal CubeTexture used to render to */
  49780. readonly cubeTexture: RenderTargetTexture;
  49781. /** Gets the list of meshes to render */
  49782. readonly renderList: Nullable<AbstractMesh[]>;
  49783. /**
  49784. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49785. * @param mesh defines the mesh to attach to
  49786. */
  49787. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49788. /**
  49789. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49790. * @param renderingGroupId The rendering group id corresponding to its index
  49791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49792. */
  49793. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49794. /**
  49795. * Clean all associated resources
  49796. */
  49797. dispose(): void;
  49798. /**
  49799. * Converts the reflection probe information to a readable string for debug purpose.
  49800. * @param fullDetails Supports for multiple levels of logging within scene loading
  49801. * @returns the human readable reflection probe info
  49802. */
  49803. toString(fullDetails?: boolean): string;
  49804. /**
  49805. * Get the class name of the relfection probe.
  49806. * @returns "ReflectionProbe"
  49807. */
  49808. getClassName(): string;
  49809. /**
  49810. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49811. * @returns The JSON representation of the texture
  49812. */
  49813. serialize(): any;
  49814. /**
  49815. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49816. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49817. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49818. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49819. * @returns The parsed reflection probe if successful
  49820. */
  49821. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49822. }
  49823. }
  49824. declare module BABYLON {
  49825. /** @hidden */
  49826. export var _BabylonLoaderRegistered: boolean;
  49827. }
  49828. declare module BABYLON {
  49829. /**
  49830. * The Physically based simple base material of BJS.
  49831. *
  49832. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49833. * It is used as the base class for both the specGloss and metalRough conventions.
  49834. */
  49835. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49836. /**
  49837. * Number of Simultaneous lights allowed on the material.
  49838. */
  49839. maxSimultaneousLights: number;
  49840. /**
  49841. * If sets to true, disables all the lights affecting the material.
  49842. */
  49843. disableLighting: boolean;
  49844. /**
  49845. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49846. */
  49847. environmentTexture: BaseTexture;
  49848. /**
  49849. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49850. */
  49851. invertNormalMapX: boolean;
  49852. /**
  49853. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49854. */
  49855. invertNormalMapY: boolean;
  49856. /**
  49857. * Normal map used in the model.
  49858. */
  49859. normalTexture: BaseTexture;
  49860. /**
  49861. * Emissivie color used to self-illuminate the model.
  49862. */
  49863. emissiveColor: Color3;
  49864. /**
  49865. * Emissivie texture used to self-illuminate the model.
  49866. */
  49867. emissiveTexture: BaseTexture;
  49868. /**
  49869. * Occlusion Channel Strenght.
  49870. */
  49871. occlusionStrength: number;
  49872. /**
  49873. * Occlusion Texture of the material (adding extra occlusion effects).
  49874. */
  49875. occlusionTexture: BaseTexture;
  49876. /**
  49877. * Defines the alpha limits in alpha test mode.
  49878. */
  49879. alphaCutOff: number;
  49880. /**
  49881. * Gets the current double sided mode.
  49882. */
  49883. /**
  49884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49885. */
  49886. doubleSided: boolean;
  49887. /**
  49888. * Stores the pre-calculated light information of a mesh in a texture.
  49889. */
  49890. lightmapTexture: BaseTexture;
  49891. /**
  49892. * If true, the light map contains occlusion information instead of lighting info.
  49893. */
  49894. useLightmapAsShadowmap: boolean;
  49895. /**
  49896. * Instantiates a new PBRMaterial instance.
  49897. *
  49898. * @param name The material name
  49899. * @param scene The scene the material will be use in.
  49900. */
  49901. constructor(name: string, scene: Scene);
  49902. getClassName(): string;
  49903. }
  49904. }
  49905. declare module BABYLON {
  49906. /**
  49907. * The PBR material of BJS following the metal roughness convention.
  49908. *
  49909. * This fits to the PBR convention in the GLTF definition:
  49910. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49911. */
  49912. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49913. /**
  49914. * The base color has two different interpretations depending on the value of metalness.
  49915. * When the material is a metal, the base color is the specific measured reflectance value
  49916. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49917. * of the material.
  49918. */
  49919. baseColor: Color3;
  49920. /**
  49921. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49922. * well as opacity information in the alpha channel.
  49923. */
  49924. baseTexture: BaseTexture;
  49925. /**
  49926. * Specifies the metallic scalar value of the material.
  49927. * Can also be used to scale the metalness values of the metallic texture.
  49928. */
  49929. metallic: number;
  49930. /**
  49931. * Specifies the roughness scalar value of the material.
  49932. * Can also be used to scale the roughness values of the metallic texture.
  49933. */
  49934. roughness: number;
  49935. /**
  49936. * Texture containing both the metallic value in the B channel and the
  49937. * roughness value in the G channel to keep better precision.
  49938. */
  49939. metallicRoughnessTexture: BaseTexture;
  49940. /**
  49941. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49942. *
  49943. * @param name The material name
  49944. * @param scene The scene the material will be use in.
  49945. */
  49946. constructor(name: string, scene: Scene);
  49947. /**
  49948. * Return the currrent class name of the material.
  49949. */
  49950. getClassName(): string;
  49951. /**
  49952. * Makes a duplicate of the current material.
  49953. * @param name - name to use for the new material.
  49954. */
  49955. clone(name: string): PBRMetallicRoughnessMaterial;
  49956. /**
  49957. * Serialize the material to a parsable JSON object.
  49958. */
  49959. serialize(): any;
  49960. /**
  49961. * Parses a JSON object correponding to the serialize function.
  49962. */
  49963. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49964. }
  49965. }
  49966. declare module BABYLON {
  49967. /**
  49968. * The PBR material of BJS following the specular glossiness convention.
  49969. *
  49970. * This fits to the PBR convention in the GLTF definition:
  49971. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49972. */
  49973. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49974. /**
  49975. * Specifies the diffuse color of the material.
  49976. */
  49977. diffuseColor: Color3;
  49978. /**
  49979. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49980. * channel.
  49981. */
  49982. diffuseTexture: BaseTexture;
  49983. /**
  49984. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49985. */
  49986. specularColor: Color3;
  49987. /**
  49988. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49989. */
  49990. glossiness: number;
  49991. /**
  49992. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49993. */
  49994. specularGlossinessTexture: BaseTexture;
  49995. /**
  49996. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49997. *
  49998. * @param name The material name
  49999. * @param scene The scene the material will be use in.
  50000. */
  50001. constructor(name: string, scene: Scene);
  50002. /**
  50003. * Return the currrent class name of the material.
  50004. */
  50005. getClassName(): string;
  50006. /**
  50007. * Makes a duplicate of the current material.
  50008. * @param name - name to use for the new material.
  50009. */
  50010. clone(name: string): PBRSpecularGlossinessMaterial;
  50011. /**
  50012. * Serialize the material to a parsable JSON object.
  50013. */
  50014. serialize(): any;
  50015. /**
  50016. * Parses a JSON object correponding to the serialize function.
  50017. */
  50018. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50019. }
  50020. }
  50021. declare module BABYLON {
  50022. /**
  50023. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50024. * It can help converting any input color in a desired output one. This can then be used to create effects
  50025. * from sepia, black and white to sixties or futuristic rendering...
  50026. *
  50027. * The only supported format is currently 3dl.
  50028. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50029. */
  50030. export class ColorGradingTexture extends BaseTexture {
  50031. /**
  50032. * The current texture matrix. (will always be identity in color grading texture)
  50033. */
  50034. private _textureMatrix;
  50035. /**
  50036. * The texture URL.
  50037. */
  50038. url: string;
  50039. /**
  50040. * Empty line regex stored for GC.
  50041. */
  50042. private static _noneEmptyLineRegex;
  50043. private _engine;
  50044. /**
  50045. * Instantiates a ColorGradingTexture from the following parameters.
  50046. *
  50047. * @param url The location of the color gradind data (currently only supporting 3dl)
  50048. * @param scene The scene the texture will be used in
  50049. */
  50050. constructor(url: string, scene: Scene);
  50051. /**
  50052. * Returns the texture matrix used in most of the material.
  50053. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50054. */
  50055. getTextureMatrix(): Matrix;
  50056. /**
  50057. * Occurs when the file being loaded is a .3dl LUT file.
  50058. */
  50059. private load3dlTexture;
  50060. /**
  50061. * Starts the loading process of the texture.
  50062. */
  50063. private loadTexture;
  50064. /**
  50065. * Clones the color gradind texture.
  50066. */
  50067. clone(): ColorGradingTexture;
  50068. /**
  50069. * Called during delayed load for textures.
  50070. */
  50071. delayLoad(): void;
  50072. /**
  50073. * Parses a color grading texture serialized by Babylon.
  50074. * @param parsedTexture The texture information being parsedTexture
  50075. * @param scene The scene to load the texture in
  50076. * @param rootUrl The root url of the data assets to load
  50077. * @return A color gradind texture
  50078. */
  50079. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50080. /**
  50081. * Serializes the LUT texture to json format.
  50082. */
  50083. serialize(): any;
  50084. }
  50085. }
  50086. declare module BABYLON {
  50087. /**
  50088. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50089. */
  50090. export class EquiRectangularCubeTexture extends BaseTexture {
  50091. /** The six faces of the cube. */
  50092. private static _FacesMapping;
  50093. private _noMipmap;
  50094. private _onLoad;
  50095. private _onError;
  50096. /** The size of the cubemap. */
  50097. private _size;
  50098. /** The buffer of the image. */
  50099. private _buffer;
  50100. /** The width of the input image. */
  50101. private _width;
  50102. /** The height of the input image. */
  50103. private _height;
  50104. /** The URL to the image. */
  50105. url: string;
  50106. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50107. coordinatesMode: number;
  50108. /**
  50109. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50110. * @param url The location of the image
  50111. * @param scene The scene the texture will be used in
  50112. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50113. * @param noMipmap Forces to not generate the mipmap if true
  50114. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50115. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50116. * @param onLoad — defines a callback called when texture is loaded
  50117. * @param onError — defines a callback called if there is an error
  50118. */
  50119. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50120. /**
  50121. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50122. */
  50123. private loadImage;
  50124. /**
  50125. * Convert the image buffer into a cubemap and create a CubeTexture.
  50126. */
  50127. private loadTexture;
  50128. /**
  50129. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50130. * @param buffer The ArrayBuffer that should be converted.
  50131. * @returns The buffer as Float32Array.
  50132. */
  50133. private getFloat32ArrayFromArrayBuffer;
  50134. /**
  50135. * Get the current class name of the texture useful for serialization or dynamic coding.
  50136. * @returns "EquiRectangularCubeTexture"
  50137. */
  50138. getClassName(): string;
  50139. /**
  50140. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50141. * @returns A clone of the current EquiRectangularCubeTexture.
  50142. */
  50143. clone(): EquiRectangularCubeTexture;
  50144. }
  50145. }
  50146. declare module BABYLON {
  50147. /**
  50148. * Based on jsTGALoader - Javascript loader for TGA file
  50149. * By Vincent Thibault
  50150. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50151. */
  50152. export class TGATools {
  50153. private static _TYPE_INDEXED;
  50154. private static _TYPE_RGB;
  50155. private static _TYPE_GREY;
  50156. private static _TYPE_RLE_INDEXED;
  50157. private static _TYPE_RLE_RGB;
  50158. private static _TYPE_RLE_GREY;
  50159. private static _ORIGIN_MASK;
  50160. private static _ORIGIN_SHIFT;
  50161. private static _ORIGIN_BL;
  50162. private static _ORIGIN_BR;
  50163. private static _ORIGIN_UL;
  50164. private static _ORIGIN_UR;
  50165. /**
  50166. * Gets the header of a TGA file
  50167. * @param data defines the TGA data
  50168. * @returns the header
  50169. */
  50170. static GetTGAHeader(data: Uint8Array): any;
  50171. /**
  50172. * Uploads TGA content to a Babylon Texture
  50173. * @hidden
  50174. */
  50175. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50176. /** @hidden */
  50177. 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;
  50178. /** @hidden */
  50179. 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;
  50180. /** @hidden */
  50181. 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;
  50182. /** @hidden */
  50183. 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;
  50184. /** @hidden */
  50185. 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;
  50186. /** @hidden */
  50187. 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;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Implementation of the TGA Texture Loader.
  50193. * @hidden
  50194. */
  50195. export class _TGATextureLoader implements IInternalTextureLoader {
  50196. /**
  50197. * Defines wether the loader supports cascade loading the different faces.
  50198. */
  50199. readonly supportCascades: boolean;
  50200. /**
  50201. * This returns if the loader support the current file information.
  50202. * @param extension defines the file extension of the file being loaded
  50203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50204. * @param fallback defines the fallback internal texture if any
  50205. * @param isBase64 defines whether the texture is encoded as a base64
  50206. * @param isBuffer defines whether the texture data are stored as a buffer
  50207. * @returns true if the loader can load the specified file
  50208. */
  50209. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50210. /**
  50211. * Transform the url before loading if required.
  50212. * @param rootUrl the url of the texture
  50213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50214. * @returns the transformed texture
  50215. */
  50216. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50217. /**
  50218. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50219. * @param rootUrl the url of the texture
  50220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50221. * @returns the fallback texture
  50222. */
  50223. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50224. /**
  50225. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50226. * @param data contains the texture data
  50227. * @param texture defines the BabylonJS internal texture
  50228. * @param createPolynomials will be true if polynomials have been requested
  50229. * @param onLoad defines the callback to trigger once the texture is ready
  50230. * @param onError defines the callback to trigger in case of error
  50231. */
  50232. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50233. /**
  50234. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50235. * @param data contains the texture data
  50236. * @param texture defines the BabylonJS internal texture
  50237. * @param callback defines the method to call once ready to upload
  50238. */
  50239. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * Info about the .basis files
  50245. */
  50246. class BasisFileInfo {
  50247. /**
  50248. * If the file has alpha
  50249. */
  50250. hasAlpha: boolean;
  50251. /**
  50252. * Info about each image of the basis file
  50253. */
  50254. images: Array<{
  50255. levels: Array<{
  50256. width: number;
  50257. height: number;
  50258. transcodedPixels: ArrayBufferView;
  50259. }>;
  50260. }>;
  50261. }
  50262. /**
  50263. * Result of transcoding a basis file
  50264. */
  50265. class TranscodeResult {
  50266. /**
  50267. * Info about the .basis file
  50268. */
  50269. fileInfo: BasisFileInfo;
  50270. /**
  50271. * Format to use when loading the file
  50272. */
  50273. format: number;
  50274. }
  50275. /**
  50276. * Configuration options for the Basis transcoder
  50277. */
  50278. export class BasisTranscodeConfiguration {
  50279. /**
  50280. * Supported compression formats used to determine the supported output format of the transcoder
  50281. */
  50282. supportedCompressionFormats?: {
  50283. /**
  50284. * etc1 compression format
  50285. */
  50286. etc1?: boolean;
  50287. /**
  50288. * s3tc compression format
  50289. */
  50290. s3tc?: boolean;
  50291. /**
  50292. * pvrtc compression format
  50293. */
  50294. pvrtc?: boolean;
  50295. /**
  50296. * etc2 compression format
  50297. */
  50298. etc2?: boolean;
  50299. };
  50300. /**
  50301. * If mipmap levels should be loaded for transcoded images (Default: true)
  50302. */
  50303. loadMipmapLevels?: boolean;
  50304. /**
  50305. * Index of a single image to load (Default: all images)
  50306. */
  50307. loadSingleImage?: number;
  50308. }
  50309. /**
  50310. * Used to load .Basis files
  50311. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50312. */
  50313. export class BasisTools {
  50314. private static _IgnoreSupportedFormats;
  50315. /**
  50316. * URL to use when loading the basis transcoder
  50317. */
  50318. static JSModuleURL: string;
  50319. /**
  50320. * URL to use when loading the wasm module for the transcoder
  50321. */
  50322. static WasmModuleURL: string;
  50323. /**
  50324. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50325. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50326. * @returns internal format corresponding to the Basis format
  50327. */
  50328. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50329. private static _WorkerPromise;
  50330. private static _Worker;
  50331. private static _actionId;
  50332. private static _CreateWorkerAsync;
  50333. /**
  50334. * Transcodes a loaded image file to compressed pixel data
  50335. * @param imageData image data to transcode
  50336. * @param config configuration options for the transcoding
  50337. * @returns a promise resulting in the transcoded image
  50338. */
  50339. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50340. /**
  50341. * Loads a texture from the transcode result
  50342. * @param texture texture load to
  50343. * @param transcodeResult the result of transcoding the basis file to load from
  50344. */
  50345. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50346. }
  50347. }
  50348. declare module BABYLON {
  50349. /**
  50350. * Loader for .basis file format
  50351. */
  50352. export class _BasisTextureLoader implements IInternalTextureLoader {
  50353. /**
  50354. * Defines whether the loader supports cascade loading the different faces.
  50355. */
  50356. readonly supportCascades: boolean;
  50357. /**
  50358. * This returns if the loader support the current file information.
  50359. * @param extension defines the file extension of the file being loaded
  50360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50361. * @param fallback defines the fallback internal texture if any
  50362. * @param isBase64 defines whether the texture is encoded as a base64
  50363. * @param isBuffer defines whether the texture data are stored as a buffer
  50364. * @returns true if the loader can load the specified file
  50365. */
  50366. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50367. /**
  50368. * Transform the url before loading if required.
  50369. * @param rootUrl the url of the texture
  50370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50371. * @returns the transformed texture
  50372. */
  50373. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50374. /**
  50375. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50376. * @param rootUrl the url of the texture
  50377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50378. * @returns the fallback texture
  50379. */
  50380. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50381. /**
  50382. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50383. * @param data contains the texture data
  50384. * @param texture defines the BabylonJS internal texture
  50385. * @param createPolynomials will be true if polynomials have been requested
  50386. * @param onLoad defines the callback to trigger once the texture is ready
  50387. * @param onError defines the callback to trigger in case of error
  50388. */
  50389. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50390. /**
  50391. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50392. * @param data contains the texture data
  50393. * @param texture defines the BabylonJS internal texture
  50394. * @param callback defines the method to call once ready to upload
  50395. */
  50396. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50397. }
  50398. }
  50399. declare module BABYLON {
  50400. /**
  50401. * 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.
  50402. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50403. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50404. */
  50405. export class CustomProceduralTexture extends ProceduralTexture {
  50406. private _animate;
  50407. private _time;
  50408. private _config;
  50409. private _texturePath;
  50410. /**
  50411. * Instantiates a new Custom Procedural Texture.
  50412. * 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.
  50413. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50414. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50415. * @param name Define the name of the texture
  50416. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50417. * @param size Define the size of the texture to create
  50418. * @param scene Define the scene the texture belongs to
  50419. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50420. * @param generateMipMaps Define if the texture should creates mip maps or not
  50421. */
  50422. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50423. private _loadJson;
  50424. /**
  50425. * Is the texture ready to be used ? (rendered at least once)
  50426. * @returns true if ready, otherwise, false.
  50427. */
  50428. isReady(): boolean;
  50429. /**
  50430. * Render the texture to its associated render target.
  50431. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50432. */
  50433. render(useCameraPostProcess?: boolean): void;
  50434. /**
  50435. * Update the list of dependant textures samplers in the shader.
  50436. */
  50437. updateTextures(): void;
  50438. /**
  50439. * Update the uniform values of the procedural texture in the shader.
  50440. */
  50441. updateShaderUniforms(): void;
  50442. /**
  50443. * Define if the texture animates or not.
  50444. */
  50445. animate: boolean;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /** @hidden */
  50450. export var noisePixelShader: {
  50451. name: string;
  50452. shader: string;
  50453. };
  50454. }
  50455. declare module BABYLON {
  50456. /**
  50457. * Class used to generate noise procedural textures
  50458. */
  50459. export class NoiseProceduralTexture extends ProceduralTexture {
  50460. private _time;
  50461. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50462. brightness: number;
  50463. /** Defines the number of octaves to process */
  50464. octaves: number;
  50465. /** Defines the level of persistence (0.8 by default) */
  50466. persistence: number;
  50467. /** Gets or sets animation speed factor (default is 1) */
  50468. animationSpeedFactor: number;
  50469. /**
  50470. * Creates a new NoiseProceduralTexture
  50471. * @param name defines the name fo the texture
  50472. * @param size defines the size of the texture (default is 256)
  50473. * @param scene defines the hosting scene
  50474. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50475. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50476. */
  50477. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50478. private _updateShaderUniforms;
  50479. protected _getDefines(): string;
  50480. /** Generate the current state of the procedural texture */
  50481. render(useCameraPostProcess?: boolean): void;
  50482. /**
  50483. * Serializes this noise procedural texture
  50484. * @returns a serialized noise procedural texture object
  50485. */
  50486. serialize(): any;
  50487. /**
  50488. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50489. * @param parsedTexture defines parsed texture data
  50490. * @param scene defines the current scene
  50491. * @param rootUrl defines the root URL containing noise procedural texture information
  50492. * @returns a parsed NoiseProceduralTexture
  50493. */
  50494. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50495. }
  50496. }
  50497. declare module BABYLON {
  50498. /**
  50499. * Raw cube texture where the raw buffers are passed in
  50500. */
  50501. export class RawCubeTexture extends CubeTexture {
  50502. /**
  50503. * Creates a cube texture where the raw buffers are passed in.
  50504. * @param scene defines the scene the texture is attached to
  50505. * @param data defines the array of data to use to create each face
  50506. * @param size defines the size of the textures
  50507. * @param format defines the format of the data
  50508. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50509. * @param generateMipMaps defines if the engine should generate the mip levels
  50510. * @param invertY defines if data must be stored with Y axis inverted
  50511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50512. * @param compression defines the compression used (null by default)
  50513. */
  50514. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50515. /**
  50516. * Updates the raw cube texture.
  50517. * @param data defines the data to store
  50518. * @param format defines the data format
  50519. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50520. * @param invertY defines if data must be stored with Y axis inverted
  50521. * @param compression defines the compression used (null by default)
  50522. * @param level defines which level of the texture to update
  50523. */
  50524. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50525. /**
  50526. * Updates a raw cube texture with RGBD encoded data.
  50527. * @param data defines the array of data [mipmap][face] to use to create each face
  50528. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50529. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50530. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50531. * @returns a promsie that resolves when the operation is complete
  50532. */
  50533. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50534. /**
  50535. * Clones the raw cube texture.
  50536. * @return a new cube texture
  50537. */
  50538. clone(): CubeTexture;
  50539. /** @hidden */
  50540. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50541. }
  50542. }
  50543. declare module BABYLON {
  50544. /**
  50545. * Class used to store 3D textures containing user data
  50546. */
  50547. export class RawTexture3D extends Texture {
  50548. /** Gets or sets the texture format to use */
  50549. format: number;
  50550. private _engine;
  50551. /**
  50552. * Create a new RawTexture3D
  50553. * @param data defines the data of the texture
  50554. * @param width defines the width of the texture
  50555. * @param height defines the height of the texture
  50556. * @param depth defines the depth of the texture
  50557. * @param format defines the texture format to use
  50558. * @param scene defines the hosting scene
  50559. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50560. * @param invertY defines if texture must be stored with Y axis inverted
  50561. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50562. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50563. */
  50564. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50565. /** Gets or sets the texture format to use */
  50566. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50567. /**
  50568. * Update the texture with new data
  50569. * @param data defines the data to store in the texture
  50570. */
  50571. update(data: ArrayBufferView): void;
  50572. }
  50573. }
  50574. declare module BABYLON {
  50575. /**
  50576. * Creates a refraction texture used by refraction channel of the standard material.
  50577. * It is like a mirror but to see through a material.
  50578. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50579. */
  50580. export class RefractionTexture extends RenderTargetTexture {
  50581. /**
  50582. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50583. * 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.
  50584. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50585. */
  50586. refractionPlane: Plane;
  50587. /**
  50588. * Define how deep under the surface we should see.
  50589. */
  50590. depth: number;
  50591. /**
  50592. * Creates a refraction texture used by refraction channel of the standard material.
  50593. * It is like a mirror but to see through a material.
  50594. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50595. * @param name Define the texture name
  50596. * @param size Define the size of the underlying texture
  50597. * @param scene Define the scene the refraction belongs to
  50598. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50599. */
  50600. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50601. /**
  50602. * Clone the refraction texture.
  50603. * @returns the cloned texture
  50604. */
  50605. clone(): RefractionTexture;
  50606. /**
  50607. * Serialize the texture to a JSON representation you could use in Parse later on
  50608. * @returns the serialized JSON representation
  50609. */
  50610. serialize(): any;
  50611. }
  50612. }
  50613. declare module BABYLON {
  50614. /**
  50615. * Defines the options related to the creation of an HtmlElementTexture
  50616. */
  50617. export interface IHtmlElementTextureOptions {
  50618. /**
  50619. * Defines wether mip maps should be created or not.
  50620. */
  50621. generateMipMaps?: boolean;
  50622. /**
  50623. * Defines the sampling mode of the texture.
  50624. */
  50625. samplingMode?: number;
  50626. /**
  50627. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50628. */
  50629. engine: Nullable<Engine>;
  50630. /**
  50631. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50632. */
  50633. scene: Nullable<Scene>;
  50634. }
  50635. /**
  50636. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50637. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50638. * is automatically managed.
  50639. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50640. * in your application.
  50641. *
  50642. * As the update is not automatic, you need to call them manually.
  50643. */
  50644. export class HtmlElementTexture extends BaseTexture {
  50645. /**
  50646. * The texture URL.
  50647. */
  50648. element: HTMLVideoElement | HTMLCanvasElement;
  50649. private static readonly DefaultOptions;
  50650. private _textureMatrix;
  50651. private _engine;
  50652. private _isVideo;
  50653. private _generateMipMaps;
  50654. private _samplingMode;
  50655. /**
  50656. * Instantiates a HtmlElementTexture from the following parameters.
  50657. *
  50658. * @param name Defines the name of the texture
  50659. * @param element Defines the video or canvas the texture is filled with
  50660. * @param options Defines the other none mandatory texture creation options
  50661. */
  50662. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50663. private _createInternalTexture;
  50664. /**
  50665. * Returns the texture matrix used in most of the material.
  50666. */
  50667. getTextureMatrix(): Matrix;
  50668. /**
  50669. * Updates the content of the texture.
  50670. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50671. */
  50672. update(invertY?: Nullable<boolean>): void;
  50673. }
  50674. }
  50675. declare module BABYLON {
  50676. /**
  50677. * Enum used to define the target of a block
  50678. */
  50679. export enum NodeMaterialBlockTargets {
  50680. /** Vertex shader */
  50681. Vertex = 1,
  50682. /** Fragment shader */
  50683. Fragment = 2,
  50684. /** Vertex and Fragment */
  50685. VertexAndFragment = 3
  50686. }
  50687. }
  50688. declare module BABYLON {
  50689. /**
  50690. * Defines the kind of connection point for node based material
  50691. */
  50692. export enum NodeMaterialBlockConnectionPointTypes {
  50693. /** Float */
  50694. Float = 1,
  50695. /** Int */
  50696. Int = 2,
  50697. /** Vector2 */
  50698. Vector2 = 4,
  50699. /** Vector3 */
  50700. Vector3 = 8,
  50701. /** Vector4 */
  50702. Vector4 = 16,
  50703. /** Color3 */
  50704. Color3 = 32,
  50705. /** Color4 */
  50706. Color4 = 64,
  50707. /** Matrix */
  50708. Matrix = 128,
  50709. /** Texture */
  50710. Texture = 256,
  50711. /** Texture3D */
  50712. Texture3D = 512,
  50713. /** Vector3 or Color3 */
  50714. Vector3OrColor3 = 40,
  50715. /** Vector3 or Vector4 */
  50716. Vector3OrVector4 = 24,
  50717. /** Vector4 or Color4 */
  50718. Vector4OrColor4 = 80,
  50719. /** Color3 or Color4 */
  50720. Color3OrColor4 = 96,
  50721. /** Vector3 or Color3 */
  50722. Vector3OrColor3OrVector4OrColor4 = 120,
  50723. /** Detect type based on connection */
  50724. AutoDetect = 1024,
  50725. /** Output type that will be defined by input type */
  50726. BasedOnInput = 2048,
  50727. /** Light */
  50728. Light = 4096
  50729. }
  50730. }
  50731. declare module BABYLON {
  50732. /**
  50733. * Enum used to define well known values e.g. values automatically provided by the system
  50734. */
  50735. export enum NodeMaterialWellKnownValues {
  50736. /** World */
  50737. World = 1,
  50738. /** View */
  50739. View = 2,
  50740. /** Projection */
  50741. Projection = 3,
  50742. /** ViewProjection */
  50743. ViewProjection = 4,
  50744. /** WorldView */
  50745. WorldView = 5,
  50746. /** WorldViewProjection */
  50747. WorldViewProjection = 6,
  50748. /** CameraPosition */
  50749. CameraPosition = 7,
  50750. /** Will be filled by the block itself */
  50751. Automatic = 8
  50752. }
  50753. }
  50754. declare module BABYLON {
  50755. /**
  50756. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50757. */
  50758. export enum NodeMaterialBlockConnectionPointMode {
  50759. /** Value is an uniform */
  50760. Uniform = 0,
  50761. /** Value is a mesh attribute */
  50762. Attribute = 1,
  50763. /** Value is a varying between vertex and fragment shaders */
  50764. Varying = 2,
  50765. /** Mode is undefined */
  50766. Undefined = 3
  50767. }
  50768. }
  50769. declare module BABYLON {
  50770. /**
  50771. * Class used to store shared data between 2 NodeMaterialBuildState
  50772. */
  50773. export class NodeMaterialBuildStateSharedData {
  50774. /**
  50775. * Gets the list of emitted varyings
  50776. */
  50777. varyings: string[];
  50778. /**
  50779. * Gets the varying declaration string
  50780. */
  50781. varyingDeclaration: string;
  50782. /**
  50783. * Uniform connection points
  50784. */
  50785. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50786. /**
  50787. * Bindable blocks (Blocks that need to set data to the effect)
  50788. */
  50789. bindableBlocks: NodeMaterialBlock[];
  50790. /**
  50791. * List of blocks that can provide a compilation fallback
  50792. */
  50793. blocksWithFallbacks: NodeMaterialBlock[];
  50794. /**
  50795. * List of blocks that can provide a define update
  50796. */
  50797. blocksWithDefines: NodeMaterialBlock[];
  50798. /**
  50799. * List of blocks that can provide a repeatable content
  50800. */
  50801. repeatableContentBlocks: NodeMaterialBlock[];
  50802. /**
  50803. * List of blocks that can block the isReady function for the material
  50804. */
  50805. blockingBlocks: NodeMaterialBlock[];
  50806. /**
  50807. * Build Id used to avoid multiple recompilations
  50808. */
  50809. buildId: number;
  50810. /** List of emitted variables */
  50811. variableNames: {
  50812. [key: string]: number;
  50813. };
  50814. /** List of emitted defines */
  50815. defineNames: {
  50816. [key: string]: number;
  50817. };
  50818. /** Should emit comments? */
  50819. emitComments: boolean;
  50820. /** Emit build activity */
  50821. verbose: boolean;
  50822. /**
  50823. * Gets the compilation hints emitted at compilation time
  50824. */
  50825. hints: {
  50826. needWorldViewMatrix: boolean;
  50827. needWorldViewProjectionMatrix: boolean;
  50828. needAlphaBlending: boolean;
  50829. needAlphaTesting: boolean;
  50830. };
  50831. /**
  50832. * List of compilation checks
  50833. */
  50834. checks: {
  50835. emitVertex: boolean;
  50836. emitFragment: boolean;
  50837. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50838. };
  50839. /** Creates a new shared data */
  50840. constructor();
  50841. /**
  50842. * Emits console errors and exceptions if there is a failing check
  50843. */
  50844. emitErrors(): void;
  50845. }
  50846. }
  50847. declare module BABYLON {
  50848. /**
  50849. * Class used to store node based material build state
  50850. */
  50851. export class NodeMaterialBuildState {
  50852. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  50853. supportUniformBuffers: boolean;
  50854. /**
  50855. * Gets the list of emitted attributes
  50856. */
  50857. attributes: string[];
  50858. /**
  50859. * Gets the list of emitted uniforms
  50860. */
  50861. uniforms: string[];
  50862. /**
  50863. * Gets the list of emitted uniform buffers
  50864. */
  50865. uniformBuffers: string[];
  50866. /**
  50867. * Gets the list of emitted samplers
  50868. */
  50869. samplers: string[];
  50870. /**
  50871. * Gets the list of emitted functions
  50872. */
  50873. functions: {
  50874. [key: string]: string;
  50875. };
  50876. /**
  50877. * Gets the target of the compilation state
  50878. */
  50879. target: NodeMaterialBlockTargets;
  50880. /**
  50881. * Gets the list of emitted counters
  50882. */
  50883. counters: {
  50884. [key: string]: number;
  50885. };
  50886. /**
  50887. * Shared data between multiple NodeMaterialBuildState instances
  50888. */
  50889. sharedData: NodeMaterialBuildStateSharedData;
  50890. /** @hidden */
  50891. _vertexState: NodeMaterialBuildState;
  50892. private _attributeDeclaration;
  50893. private _uniformDeclaration;
  50894. private _samplerDeclaration;
  50895. private _varyingTransfer;
  50896. private _repeatableContentAnchorIndex;
  50897. /** @hidden */
  50898. _builtCompilationString: string;
  50899. /**
  50900. * Gets the emitted compilation strings
  50901. */
  50902. compilationString: string;
  50903. /**
  50904. * Finalize the compilation strings
  50905. * @param state defines the current compilation state
  50906. */
  50907. finalize(state: NodeMaterialBuildState): void;
  50908. /** @hidden */
  50909. readonly _repeatableContentAnchor: string;
  50910. /** @hidden */
  50911. _getFreeVariableName(prefix: string): string;
  50912. /** @hidden */
  50913. _getFreeDefineName(prefix: string): string;
  50914. /** @hidden */
  50915. _excludeVariableName(name: string): void;
  50916. /** @hidden */
  50917. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50918. /** @hidden */
  50919. _emitFunction(name: string, code: string, comments: string): void;
  50920. /** @hidden */
  50921. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50922. replaceStrings?: {
  50923. search: RegExp;
  50924. replace: string;
  50925. }[];
  50926. }): string;
  50927. /** @hidden */
  50928. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50929. repeatKey?: string;
  50930. removeAttributes?: boolean;
  50931. removeUniforms?: boolean;
  50932. removeVaryings?: boolean;
  50933. removeIfDef?: boolean;
  50934. replaceStrings?: {
  50935. search: RegExp;
  50936. replace: string;
  50937. }[];
  50938. }, storeKey?: string): void;
  50939. /** @hidden */
  50940. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  50941. private _emitDefine;
  50942. /** @hidden */
  50943. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50944. }
  50945. }
  50946. declare module BABYLON {
  50947. /**
  50948. * Root class for all node material optimizers
  50949. */
  50950. export class NodeMaterialOptimizer {
  50951. /**
  50952. * Function used to optimize a NodeMaterial graph
  50953. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50954. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50955. */
  50956. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50957. }
  50958. }
  50959. declare module BABYLON {
  50960. /**
  50961. * Block used to transform a vector4 with a matrix
  50962. */
  50963. export class Vector4TransformBlock extends NodeMaterialBlock {
  50964. /**
  50965. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50966. */
  50967. complementW: number;
  50968. /**
  50969. * Creates a new Vector4TransformBlock
  50970. * @param name defines the block name
  50971. */
  50972. constructor(name: string);
  50973. /**
  50974. * Gets the current class name
  50975. * @returns the class name
  50976. */
  50977. getClassName(): string;
  50978. /**
  50979. * Gets the vector input
  50980. */
  50981. readonly vector: NodeMaterialConnectionPoint;
  50982. /**
  50983. * Gets the output component
  50984. */
  50985. readonly output: NodeMaterialConnectionPoint;
  50986. /**
  50987. * Gets the matrix transform input
  50988. */
  50989. readonly transform: NodeMaterialConnectionPoint;
  50990. protected _buildBlock(state: NodeMaterialBuildState): this;
  50991. }
  50992. }
  50993. declare module BABYLON {
  50994. /**
  50995. * Block used to output the vertex position
  50996. */
  50997. export class VertexOutputBlock extends NodeMaterialBlock {
  50998. /**
  50999. * Creates a new VertexOutputBlock
  51000. * @param name defines the block name
  51001. */
  51002. constructor(name: string);
  51003. /**
  51004. * Gets the current class name
  51005. * @returns the class name
  51006. */
  51007. getClassName(): string;
  51008. /**
  51009. * Gets the vector input component
  51010. */
  51011. readonly vector: NodeMaterialConnectionPoint;
  51012. protected _buildBlock(state: NodeMaterialBuildState): this;
  51013. }
  51014. }
  51015. declare module BABYLON {
  51016. /**
  51017. * Block used to output the final color
  51018. */
  51019. export class FragmentOutputBlock extends NodeMaterialBlock {
  51020. /**
  51021. * Gets or sets a boolean indicating if this block will output an alpha value
  51022. */
  51023. alphaBlendingEnabled: boolean;
  51024. /**
  51025. * Create a new FragmentOutputBlock
  51026. * @param name defines the block name
  51027. */
  51028. constructor(name: string);
  51029. /**
  51030. * Gets the current class name
  51031. * @returns the class name
  51032. */
  51033. getClassName(): string;
  51034. /**
  51035. * Gets the color input component
  51036. */
  51037. readonly color: NodeMaterialConnectionPoint;
  51038. protected _buildBlock(state: NodeMaterialBuildState): this;
  51039. }
  51040. }
  51041. declare module BABYLON {
  51042. /**
  51043. * Interface used to configure the node material editor
  51044. */
  51045. export interface INodeMaterialEditorOptions {
  51046. /** Define the URl to load node editor script */
  51047. editorURL?: string;
  51048. }
  51049. /** @hidden */
  51050. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51051. /** BONES */
  51052. NUM_BONE_INFLUENCERS: number;
  51053. BonesPerMesh: number;
  51054. BONETEXTURE: boolean;
  51055. /** MORPH TARGETS */
  51056. MORPHTARGETS: boolean;
  51057. MORPHTARGETS_NORMAL: boolean;
  51058. MORPHTARGETS_TANGENT: boolean;
  51059. MORPHTARGETS_UV: boolean;
  51060. NUM_MORPH_INFLUENCERS: number;
  51061. /** IMAGE PROCESSING */
  51062. IMAGEPROCESSING: boolean;
  51063. VIGNETTE: boolean;
  51064. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51065. VIGNETTEBLENDMODEOPAQUE: boolean;
  51066. TONEMAPPING: boolean;
  51067. TONEMAPPING_ACES: boolean;
  51068. CONTRAST: boolean;
  51069. EXPOSURE: boolean;
  51070. COLORCURVES: boolean;
  51071. COLORGRADING: boolean;
  51072. COLORGRADING3D: boolean;
  51073. SAMPLER3DGREENDEPTH: boolean;
  51074. SAMPLER3DBGRMAP: boolean;
  51075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51076. constructor();
  51077. setValue(name: string, value: boolean): void;
  51078. }
  51079. /**
  51080. * Class used to configure NodeMaterial
  51081. */
  51082. export interface INodeMaterialOptions {
  51083. /**
  51084. * Defines if blocks should emit comments
  51085. */
  51086. emitComments: boolean;
  51087. }
  51088. /**
  51089. * Class used to create a node based material built by assembling shader blocks
  51090. */
  51091. export class NodeMaterial extends PushMaterial {
  51092. private _options;
  51093. private _vertexCompilationState;
  51094. private _fragmentCompilationState;
  51095. private _sharedData;
  51096. private _buildId;
  51097. private _buildWasSuccessful;
  51098. private _cachedWorldViewMatrix;
  51099. private _cachedWorldViewProjectionMatrix;
  51100. private _textureConnectionPoints;
  51101. private _optimizers;
  51102. /** Define the URl to load node editor script */
  51103. static EditorURL: string;
  51104. private BJSNODEMATERIALEDITOR;
  51105. /** Get the inspector from bundle or global */
  51106. private _getGlobalNodeMaterialEditor;
  51107. /**
  51108. * Defines the maximum number of lights that can be used in the material
  51109. */
  51110. maxSimultaneousLights: number;
  51111. /**
  51112. * Observable raised when the material is built
  51113. */
  51114. onBuildObservable: Observable<NodeMaterial>;
  51115. /**
  51116. * Gets or sets the root nodes of the material vertex shader
  51117. */
  51118. _vertexOutputNodes: NodeMaterialBlock[];
  51119. /**
  51120. * Gets or sets the root nodes of the material fragment (pixel) shader
  51121. */
  51122. _fragmentOutputNodes: NodeMaterialBlock[];
  51123. /** Gets or sets options to control the node material overall behavior */
  51124. options: INodeMaterialOptions;
  51125. /**
  51126. * Default configuration related to image processing available in the standard Material.
  51127. */
  51128. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51129. /**
  51130. * Gets the image processing configuration used either in this material.
  51131. */
  51132. /**
  51133. * Sets the Default image processing configuration used either in the this material.
  51134. *
  51135. * If sets to null, the scene one is in use.
  51136. */
  51137. imageProcessingConfiguration: ImageProcessingConfiguration;
  51138. /**
  51139. * Create a new node based material
  51140. * @param name defines the material name
  51141. * @param scene defines the hosting scene
  51142. * @param options defines creation option
  51143. */
  51144. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51145. /**
  51146. * Gets the current class name of the material e.g. "NodeMaterial"
  51147. * @returns the class name
  51148. */
  51149. getClassName(): string;
  51150. /**
  51151. * Keep track of the image processing observer to allow dispose and replace.
  51152. */
  51153. private _imageProcessingObserver;
  51154. /**
  51155. * Attaches a new image processing configuration to the Standard Material.
  51156. * @param configuration
  51157. */
  51158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51159. /**
  51160. * Adds a new optimizer to the list of optimizers
  51161. * @param optimizer defines the optimizers to add
  51162. * @returns the current material
  51163. */
  51164. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51165. /**
  51166. * Remove an optimizer from the list of optimizers
  51167. * @param optimizer defines the optimizers to remove
  51168. * @returns the current material
  51169. */
  51170. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51171. /**
  51172. * Add a new block to the list of output nodes
  51173. * @param node defines the node to add
  51174. * @returns the current material
  51175. */
  51176. addOutputNode(node: NodeMaterialBlock): this;
  51177. /**
  51178. * Remove a block from the list of root nodes
  51179. * @param node defines the node to remove
  51180. * @returns the current material
  51181. */
  51182. removeOutputNode(node: NodeMaterialBlock): this;
  51183. private _addVertexOutputNode;
  51184. private _removeVertexOutputNode;
  51185. private _addFragmentOutputNode;
  51186. private _removeFragmentOutputNode;
  51187. /**
  51188. * Specifies if the material will require alpha blending
  51189. * @returns a boolean specifying if alpha blending is needed
  51190. */
  51191. needAlphaBlending(): boolean;
  51192. /**
  51193. * Specifies if this material should be rendered in alpha test mode
  51194. * @returns a boolean specifying if an alpha test is needed.
  51195. */
  51196. needAlphaTesting(): boolean;
  51197. private _initializeBlock;
  51198. private _resetDualBlocks;
  51199. /**
  51200. * Build the material and generates the inner effect
  51201. * @param verbose defines if the build should log activity
  51202. */
  51203. build(verbose?: boolean): void;
  51204. /**
  51205. * Runs an otpimization phase to try to improve the shader code
  51206. */
  51207. optimize(): void;
  51208. private _prepareDefinesForAttributes;
  51209. /**
  51210. * Get if the submesh is ready to be used and all its information available.
  51211. * Child classes can use it to update shaders
  51212. * @param mesh defines the mesh to check
  51213. * @param subMesh defines which submesh to check
  51214. * @param useInstances specifies that instances should be used
  51215. * @returns a boolean indicating that the submesh is ready or not
  51216. */
  51217. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51218. /**
  51219. * Binds the world matrix to the material
  51220. * @param world defines the world transformation matrix
  51221. */
  51222. bindOnlyWorldMatrix(world: Matrix): void;
  51223. /**
  51224. * Binds the submesh to this material by preparing the effect and shader to draw
  51225. * @param world defines the world transformation matrix
  51226. * @param mesh defines the mesh containing the submesh
  51227. * @param subMesh defines the submesh to bind the material to
  51228. */
  51229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51230. /**
  51231. * Gets the active textures from the material
  51232. * @returns an array of textures
  51233. */
  51234. getActiveTextures(): BaseTexture[];
  51235. /**
  51236. * Specifies if the material uses a texture
  51237. * @param texture defines the texture to check against the material
  51238. * @returns a boolean specifying if the material uses the texture
  51239. */
  51240. hasTexture(texture: BaseTexture): boolean;
  51241. /**
  51242. * Disposes the material
  51243. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51244. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51245. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51246. */
  51247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51248. /** Creates the node editor window. */
  51249. private _createNodeEditor;
  51250. /**
  51251. * Launch the node material editor
  51252. * @param config Define the configuration of the editor
  51253. * @return a promise fulfilled when the node editor is visible
  51254. */
  51255. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51256. /**
  51257. * Clear the current material
  51258. */
  51259. clear(): void;
  51260. /**
  51261. * Clear the current material and set it to a default state
  51262. */
  51263. setToDefault(): void;
  51264. }
  51265. }
  51266. declare module BABYLON {
  51267. /**
  51268. * Defines a block that can be used inside a node based material
  51269. */
  51270. export class NodeMaterialBlock {
  51271. private _buildId;
  51272. private _target;
  51273. private _isFinalMerger;
  51274. /** @hidden */
  51275. _inputs: NodeMaterialConnectionPoint[];
  51276. /** @hidden */
  51277. _outputs: NodeMaterialConnectionPoint[];
  51278. /**
  51279. * Gets or sets the name of the block
  51280. */
  51281. name: string;
  51282. /**
  51283. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51284. */
  51285. readonly isFinalMerger: boolean;
  51286. /**
  51287. * Gets or sets the build Id
  51288. */
  51289. buildId: number;
  51290. /**
  51291. * Gets or sets the target of the block
  51292. */
  51293. target: NodeMaterialBlockTargets;
  51294. /**
  51295. * Gets the list of input points
  51296. */
  51297. readonly inputs: NodeMaterialConnectionPoint[];
  51298. /** Gets the list of output points */
  51299. readonly outputs: NodeMaterialConnectionPoint[];
  51300. /**
  51301. * Find an input by its name
  51302. * @param name defines the name of the input to look for
  51303. * @returns the input or null if not found
  51304. */
  51305. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51306. /**
  51307. * Find an output by its name
  51308. * @param name defines the name of the outputto look for
  51309. * @returns the output or null if not found
  51310. */
  51311. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51312. /**
  51313. * Creates a new NodeMaterialBlock
  51314. * @param name defines the block name
  51315. * @param target defines the target of that block (Vertex by default)
  51316. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51317. */
  51318. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  51319. /**
  51320. * Initialize the block and prepare the context for build
  51321. * @param state defines the state that will be used for the build
  51322. */
  51323. initialize(state: NodeMaterialBuildState): void;
  51324. /**
  51325. * Bind data to effect. Will only be called for blocks with isBindable === true
  51326. * @param effect defines the effect to bind data to
  51327. * @param nodeMaterial defines the hosting NodeMaterial
  51328. * @param mesh defines the mesh that will be rendered
  51329. */
  51330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51331. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51332. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51333. protected _writeFloat(value: number): string;
  51334. /**
  51335. * Gets the current class name e.g. "NodeMaterialBlock"
  51336. * @returns the class name
  51337. */
  51338. getClassName(): string;
  51339. /**
  51340. * Register a new input. Must be called inside a block constructor
  51341. * @param name defines the connection point name
  51342. * @param type defines the connection point type
  51343. * @param isOptional defines a boolean indicating that this input can be omitted
  51344. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51345. * @returns the current block
  51346. */
  51347. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51348. /**
  51349. * Register a new output. Must be called inside a block constructor
  51350. * @param name defines the connection point name
  51351. * @param type defines the connection point type
  51352. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51353. * @returns the current block
  51354. */
  51355. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51356. /**
  51357. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51358. * @param forOutput defines an optional connection point to check compatibility with
  51359. * @returns the first available input or null
  51360. */
  51361. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51362. /**
  51363. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51364. * @param forBlock defines an optional block to check compatibility with
  51365. * @returns the first available input or null
  51366. */
  51367. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51368. /**
  51369. * Connect current block with another block
  51370. * @param other defines the block to connect with
  51371. * @param options define the various options to help pick the right connections
  51372. * @returns the current block
  51373. */
  51374. connectTo(other: NodeMaterialBlock, options?: {
  51375. input?: string;
  51376. output?: string;
  51377. outputSwizzle?: string;
  51378. }): this | undefined;
  51379. protected _buildBlock(state: NodeMaterialBuildState): void;
  51380. /**
  51381. * Add potential fallbacks if shader compilation fails
  51382. * @param mesh defines the mesh to be rendered
  51383. * @param fallbacks defines the current prioritized list of fallbacks
  51384. */
  51385. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51386. /**
  51387. * Update defines for shader compilation
  51388. * @param mesh defines the mesh to be rendered
  51389. * @param nodeMaterial defines the node material requesting the update
  51390. * @param defines defines the material defines to update
  51391. * @param useInstances specifies that instances should be used
  51392. */
  51393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51394. /**
  51395. * Lets the block try to connect some inputs automatically
  51396. */
  51397. autoConfigure(): void;
  51398. /**
  51399. * Function called when a block is declared as repeatable content generator
  51400. * @param vertexShaderState defines the current compilation state for the vertex shader
  51401. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51402. * @param mesh defines the mesh to be rendered
  51403. * @param defines defines the material defines to update
  51404. */
  51405. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51406. /**
  51407. * Checks if the block is ready
  51408. * @param mesh defines the mesh to be rendered
  51409. * @param nodeMaterial defines the node material requesting the update
  51410. * @param defines defines the material defines to update
  51411. * @param useInstances specifies that instances should be used
  51412. * @returns true if the block is ready
  51413. */
  51414. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51415. /**
  51416. * Compile the current node and generate the shader code
  51417. * @param state defines the current compilation state (uniforms, samplers, current string)
  51418. * @returns the current block
  51419. */
  51420. build(state: NodeMaterialBuildState): this | undefined;
  51421. }
  51422. }
  51423. declare module BABYLON {
  51424. /**
  51425. * Defines a connection point for a block
  51426. */
  51427. export class NodeMaterialConnectionPoint {
  51428. /** @hidden */
  51429. _ownerBlock: NodeMaterialBlock;
  51430. /** @hidden */
  51431. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51432. private _associatedVariableName;
  51433. private _endpoints;
  51434. private _storedValue;
  51435. private _valueCallback;
  51436. private _mode;
  51437. /** @hidden */
  51438. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51439. /** @hidden */
  51440. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51441. /** @hidden */
  51442. _needToEmitVarying: boolean;
  51443. /** @hidden */
  51444. _forceUniformInVertexShaderOnly: boolean;
  51445. private _type;
  51446. /**
  51447. * Gets or sets the connection point type (default is float)
  51448. */
  51449. type: NodeMaterialBlockConnectionPointTypes;
  51450. /**
  51451. * Gets or sets the connection point name
  51452. */
  51453. name: string;
  51454. /**
  51455. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51456. */
  51457. swizzle: string;
  51458. /**
  51459. * Gets or sets a boolean indicating that this connection point can be omitted
  51460. */
  51461. isOptional: boolean;
  51462. /**
  51463. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51464. */
  51465. define: string;
  51466. /** Gets or sets the target of that connection point */
  51467. target: NodeMaterialBlockTargets;
  51468. /**
  51469. * Gets or sets the value of that point.
  51470. * Please note that this value will be ignored if valueCallback is defined
  51471. */
  51472. value: any;
  51473. /**
  51474. * Gets or sets a callback used to get the value of that point.
  51475. * Please note that setting this value will force the connection point to ignore the value property
  51476. */
  51477. valueCallback: () => any;
  51478. /**
  51479. * Gets or sets the associated variable name in the shader
  51480. */
  51481. associatedVariableName: string;
  51482. /**
  51483. * Gets a boolean indicating that this connection point not defined yet
  51484. */
  51485. readonly isUndefined: boolean;
  51486. /**
  51487. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51488. * In this case the connection point name must be the name of the uniform to use.
  51489. * Can only be set on inputs
  51490. */
  51491. isUniform: boolean;
  51492. /**
  51493. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51494. * In this case the connection point name must be the name of the attribute to use
  51495. * Can only be set on inputs
  51496. */
  51497. isAttribute: boolean;
  51498. /**
  51499. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51500. * Can only be set on exit points
  51501. */
  51502. isVarying: boolean;
  51503. /** Get the other side of the connection (if any) */
  51504. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51505. /** Get the block that owns this connection point */
  51506. readonly ownerBlock: NodeMaterialBlock;
  51507. /** Get the block connected on the other side of this connection (if any) */
  51508. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51509. /** Get the block connected on the endpoints of this connection (if any) */
  51510. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51511. /**
  51512. * Creates a new connection point
  51513. * @param name defines the connection point name
  51514. * @param ownerBlock defines the block hosting this connection point
  51515. */
  51516. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51517. /**
  51518. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51519. * @returns the class name
  51520. */
  51521. getClassName(): string;
  51522. /**
  51523. * Set the source of this connection point to a vertex attribute
  51524. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51525. * @returns the current connection point
  51526. */
  51527. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  51528. /**
  51529. * Set the source of this connection point to a well known value
  51530. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51531. * @returns the current connection point
  51532. */
  51533. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  51534. /**
  51535. * Gets a boolean indicating that the current connection point is a well known value
  51536. */
  51537. readonly isWellKnownValue: boolean;
  51538. /**
  51539. * Gets or sets the current well known value or null if not defined as well know value
  51540. */
  51541. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51542. private _getTypeLength;
  51543. /**
  51544. * Connect this point to another connection point
  51545. * @param connectionPoint defines the other connection point
  51546. * @returns the current connection point
  51547. */
  51548. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51549. /**
  51550. * Disconnect this point from one of his endpoint
  51551. * @param endpoint defines the other connection point
  51552. * @returns the current connection point
  51553. */
  51554. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51555. /**
  51556. * When connection point is an uniform, this function will send its value to the effect
  51557. * @param effect defines the effect to transmit value to
  51558. * @param world defines the world matrix
  51559. * @param worldView defines the worldxview matrix
  51560. * @param worldViewProjection defines the worldxviewxprojection matrix
  51561. */
  51562. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51563. /**
  51564. * When connection point is an uniform, this function will send its value to the effect
  51565. * @param effect defines the effect to transmit value to
  51566. * @param scene defines the hosting scene
  51567. */
  51568. transmit(effect: Effect, scene: Scene): void;
  51569. }
  51570. }
  51571. declare module BABYLON {
  51572. /**
  51573. * Block used to add support for vertex skinning (bones)
  51574. */
  51575. export class BonesBlock extends NodeMaterialBlock {
  51576. /**
  51577. * Creates a new BonesBlock
  51578. * @param name defines the block name
  51579. */
  51580. constructor(name: string);
  51581. /**
  51582. * Initialize the block and prepare the context for build
  51583. * @param state defines the state that will be used for the build
  51584. */
  51585. initialize(state: NodeMaterialBuildState): void;
  51586. /**
  51587. * Gets the current class name
  51588. * @returns the class name
  51589. */
  51590. getClassName(): string;
  51591. /**
  51592. * Gets the matrix indices input component
  51593. */
  51594. readonly matricesIndices: NodeMaterialConnectionPoint;
  51595. /**
  51596. * Gets the matrix weights input component
  51597. */
  51598. readonly matricesWeights: NodeMaterialConnectionPoint;
  51599. /**
  51600. * Gets the extra matrix indices input component
  51601. */
  51602. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51603. /**
  51604. * Gets the extra matrix weights input component
  51605. */
  51606. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51607. /**
  51608. * Gets the world input component
  51609. */
  51610. readonly world: NodeMaterialConnectionPoint;
  51611. /**
  51612. * Gets the output component
  51613. */
  51614. readonly output: NodeMaterialConnectionPoint;
  51615. autoConfigure(): void;
  51616. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51619. protected _buildBlock(state: NodeMaterialBuildState): this;
  51620. }
  51621. }
  51622. declare module BABYLON {
  51623. /**
  51624. * Block used to add support for instances
  51625. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51626. */
  51627. export class InstancesBlock extends NodeMaterialBlock {
  51628. /**
  51629. * Creates a new InstancesBlock
  51630. * @param name defines the block name
  51631. */
  51632. constructor(name: string);
  51633. /**
  51634. * Gets the current class name
  51635. * @returns the class name
  51636. */
  51637. getClassName(): string;
  51638. /**
  51639. * Gets the first world row input component
  51640. */
  51641. readonly world0: NodeMaterialConnectionPoint;
  51642. /**
  51643. * Gets the second world row input component
  51644. */
  51645. readonly world1: NodeMaterialConnectionPoint;
  51646. /**
  51647. * Gets the third world row input component
  51648. */
  51649. readonly world2: NodeMaterialConnectionPoint;
  51650. /**
  51651. * Gets the forth world row input component
  51652. */
  51653. readonly world3: NodeMaterialConnectionPoint;
  51654. /**
  51655. * Gets the world input component
  51656. */
  51657. readonly world: NodeMaterialConnectionPoint;
  51658. /**
  51659. * Gets the output component
  51660. */
  51661. readonly output: NodeMaterialConnectionPoint;
  51662. autoConfigure(): void;
  51663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51664. protected _buildBlock(state: NodeMaterialBuildState): this;
  51665. }
  51666. }
  51667. declare module BABYLON {
  51668. /**
  51669. * Block used to add morph targets support to vertex shader
  51670. */
  51671. export class MorphTargetsBlock extends NodeMaterialBlock {
  51672. private _repeatableContentAnchor;
  51673. private _repeatebleContentGenerated;
  51674. /**
  51675. * Create a new MorphTargetsBlock
  51676. * @param name defines the block name
  51677. */
  51678. constructor(name: string);
  51679. /**
  51680. * Gets the current class name
  51681. * @returns the class name
  51682. */
  51683. getClassName(): string;
  51684. /**
  51685. * Gets the position input component
  51686. */
  51687. readonly position: NodeMaterialConnectionPoint;
  51688. /**
  51689. * Gets the normal input component
  51690. */
  51691. readonly normal: NodeMaterialConnectionPoint;
  51692. /**
  51693. * Gets the tangent input component
  51694. */
  51695. readonly tangent: NodeMaterialConnectionPoint;
  51696. /**
  51697. * Gets the tangent input component
  51698. */
  51699. readonly uv: NodeMaterialConnectionPoint;
  51700. /**
  51701. * Gets the position output component
  51702. */
  51703. readonly positionOutput: NodeMaterialConnectionPoint;
  51704. /**
  51705. * Gets the normal output component
  51706. */
  51707. readonly normalOutput: NodeMaterialConnectionPoint;
  51708. /**
  51709. * Gets the tangent output component
  51710. */
  51711. readonly tangentOutput: NodeMaterialConnectionPoint;
  51712. /**
  51713. * Gets the tangent output component
  51714. */
  51715. readonly uvOutput: NodeMaterialConnectionPoint;
  51716. initialize(state: NodeMaterialBuildState): void;
  51717. autoConfigure(): void;
  51718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51720. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51721. protected _buildBlock(state: NodeMaterialBuildState): this;
  51722. }
  51723. }
  51724. declare module BABYLON {
  51725. /**
  51726. * Block used to add an alpha test in the fragment shader
  51727. */
  51728. export class AlphaTestBlock extends NodeMaterialBlock {
  51729. /**
  51730. * Gets or sets the alpha value where alpha testing happens
  51731. */
  51732. alphaCutOff: number;
  51733. /**
  51734. * Create a new AlphaTestBlock
  51735. * @param name defines the block name
  51736. */
  51737. constructor(name: string);
  51738. /**
  51739. * Gets the current class name
  51740. * @returns the class name
  51741. */
  51742. getClassName(): string;
  51743. /**
  51744. * Gets the color input component
  51745. */
  51746. readonly color: NodeMaterialConnectionPoint;
  51747. protected _buildBlock(state: NodeMaterialBuildState): this;
  51748. }
  51749. }
  51750. declare module BABYLON {
  51751. /**
  51752. * Block used to create a Color4 out of 4 inputs (one for each component)
  51753. */
  51754. export class RGBAMergerBlock extends NodeMaterialBlock {
  51755. /**
  51756. * Create a new RGBAMergerBlock
  51757. * @param name defines the block name
  51758. */
  51759. constructor(name: string);
  51760. /**
  51761. * Gets the current class name
  51762. * @returns the class name
  51763. */
  51764. getClassName(): string;
  51765. /**
  51766. * Gets the R input component
  51767. */
  51768. readonly r: NodeMaterialConnectionPoint;
  51769. /**
  51770. * Gets the G input component
  51771. */
  51772. readonly g: NodeMaterialConnectionPoint;
  51773. /**
  51774. * Gets the B input component
  51775. */
  51776. readonly b: NodeMaterialConnectionPoint;
  51777. /**
  51778. * Gets the RGB input component
  51779. */
  51780. readonly rgb: NodeMaterialConnectionPoint;
  51781. /**
  51782. * Gets the R input component
  51783. */
  51784. readonly a: NodeMaterialConnectionPoint;
  51785. /**
  51786. * Gets the output component
  51787. */
  51788. readonly output: NodeMaterialConnectionPoint;
  51789. protected _buildBlock(state: NodeMaterialBuildState): this;
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /**
  51794. * Block used to create a Color3 out of 3 inputs (one for each component)
  51795. */
  51796. export class RGBMergerBlock extends NodeMaterialBlock {
  51797. /**
  51798. * Create a new RGBMergerBlock
  51799. * @param name defines the block name
  51800. */
  51801. constructor(name: string);
  51802. /**
  51803. * Gets the current class name
  51804. * @returns the class name
  51805. */
  51806. getClassName(): string;
  51807. /**
  51808. * Gets the R component input
  51809. */
  51810. readonly r: NodeMaterialConnectionPoint;
  51811. /**
  51812. * Gets the G component input
  51813. */
  51814. readonly g: NodeMaterialConnectionPoint;
  51815. /**
  51816. * Gets the B component input
  51817. */
  51818. readonly b: NodeMaterialConnectionPoint;
  51819. /**
  51820. * Gets the output component
  51821. */
  51822. readonly output: NodeMaterialConnectionPoint;
  51823. protected _buildBlock(state: NodeMaterialBuildState): this;
  51824. }
  51825. }
  51826. declare module BABYLON {
  51827. /**
  51828. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51829. */
  51830. export class RGBASplitterBlock extends NodeMaterialBlock {
  51831. /**
  51832. * Create a new RGBASplitterBlock
  51833. * @param name defines the block name
  51834. */
  51835. constructor(name: string);
  51836. /**
  51837. * Gets the current class name
  51838. * @returns the class name
  51839. */
  51840. getClassName(): string;
  51841. /**
  51842. * Gets the input component
  51843. */
  51844. readonly input: NodeMaterialConnectionPoint;
  51845. protected _buildBlock(state: NodeMaterialBuildState): this;
  51846. }
  51847. }
  51848. declare module BABYLON {
  51849. /**
  51850. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51851. */
  51852. export class RGBSplitterBlock extends NodeMaterialBlock {
  51853. /**
  51854. * Create a new RGBSplitterBlock
  51855. * @param name defines the block name
  51856. */
  51857. constructor(name: string);
  51858. /**
  51859. * Gets the current class name
  51860. * @returns the class name
  51861. */
  51862. getClassName(): string;
  51863. /**
  51864. * Gets the input component
  51865. */
  51866. readonly input: NodeMaterialConnectionPoint;
  51867. protected _buildBlock(state: NodeMaterialBuildState): this;
  51868. }
  51869. }
  51870. declare module BABYLON {
  51871. /**
  51872. * Block used to read a texture from a sampler
  51873. */
  51874. export class TextureBlock extends NodeMaterialBlock {
  51875. private _defineName;
  51876. /**
  51877. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51878. */
  51879. autoConnectTextureMatrix: boolean;
  51880. /**
  51881. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51882. */
  51883. autoSelectUV: boolean;
  51884. /**
  51885. * Create a new TextureBlock
  51886. * @param name defines the block name
  51887. */
  51888. constructor(name: string);
  51889. /**
  51890. * Gets the current class name
  51891. * @returns the class name
  51892. */
  51893. getClassName(): string;
  51894. /**
  51895. * Gets the uv input component
  51896. */
  51897. readonly uv: NodeMaterialConnectionPoint;
  51898. /**
  51899. * Gets the texture information input component
  51900. */
  51901. readonly textureInfo: NodeMaterialConnectionPoint;
  51902. /**
  51903. * Gets the transformed uv input component
  51904. */
  51905. readonly transformedUV: NodeMaterialConnectionPoint;
  51906. /**
  51907. * Gets the texture input component
  51908. */
  51909. readonly texture: NodeMaterialConnectionPoint;
  51910. /**
  51911. * Gets the texture transform input component
  51912. */
  51913. readonly textureTransform: NodeMaterialConnectionPoint;
  51914. /**
  51915. * Gets the output component
  51916. */
  51917. readonly output: NodeMaterialConnectionPoint;
  51918. autoConfigure(): void;
  51919. initialize(state: NodeMaterialBuildState): void;
  51920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51921. isReady(): boolean;
  51922. private _injectVertexCode;
  51923. protected _buildBlock(state: NodeMaterialBuildState): this;
  51924. }
  51925. }
  51926. declare module BABYLON {
  51927. /**
  51928. * Block used to add image processing support to fragment shader
  51929. */
  51930. export class ImageProcessingBlock extends NodeMaterialBlock {
  51931. /**
  51932. * Create a new ImageProcessingBlock
  51933. * @param name defines the block name
  51934. */
  51935. constructor(name: string);
  51936. /**
  51937. * Gets the current class name
  51938. * @returns the class name
  51939. */
  51940. getClassName(): string;
  51941. /**
  51942. * Gets the color input component
  51943. */
  51944. readonly color: NodeMaterialConnectionPoint;
  51945. /**
  51946. * Gets the output component
  51947. */
  51948. readonly output: NodeMaterialConnectionPoint;
  51949. /**
  51950. * Initialize the block and prepare the context for build
  51951. * @param state defines the state that will be used for the build
  51952. */
  51953. initialize(state: NodeMaterialBuildState): void;
  51954. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51957. protected _buildBlock(state: NodeMaterialBuildState): this;
  51958. }
  51959. }
  51960. declare module BABYLON {
  51961. /**
  51962. * Block used to add support for scene fog
  51963. */
  51964. export class FogBlock extends NodeMaterialBlock {
  51965. /**
  51966. * Create a new FogBlock
  51967. * @param name defines the block name
  51968. */
  51969. constructor(name: string);
  51970. /**
  51971. * Gets the current class name
  51972. * @returns the class name
  51973. */
  51974. getClassName(): string;
  51975. /**
  51976. * Gets the world position input component
  51977. */
  51978. readonly worldPosition: NodeMaterialConnectionPoint;
  51979. /**
  51980. * Gets the view input component
  51981. */
  51982. readonly view: NodeMaterialConnectionPoint;
  51983. /**
  51984. * Gets the color input component
  51985. */
  51986. readonly color: NodeMaterialConnectionPoint;
  51987. /**
  51988. * Gets the fog color input component
  51989. */
  51990. readonly fogColor: NodeMaterialConnectionPoint;
  51991. /**
  51992. * Gets the for parameter input component
  51993. */
  51994. readonly fogParameters: NodeMaterialConnectionPoint;
  51995. /**
  51996. * Gets the output component
  51997. */
  51998. readonly output: NodeMaterialConnectionPoint;
  51999. autoConfigure(): void;
  52000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52002. protected _buildBlock(state: NodeMaterialBuildState): this;
  52003. }
  52004. }
  52005. declare module BABYLON {
  52006. /**
  52007. * Block used to add light in the fragment shader
  52008. */
  52009. export class LightBlock extends NodeMaterialBlock {
  52010. private _lightId;
  52011. /**
  52012. * Create a new LightBlock
  52013. * @param name defines the block name
  52014. */
  52015. constructor(name: string);
  52016. /**
  52017. * Gets the current class name
  52018. * @returns the class name
  52019. */
  52020. getClassName(): string;
  52021. /**
  52022. * Gets the world position input component
  52023. */
  52024. readonly worldPosition: NodeMaterialConnectionPoint;
  52025. /**
  52026. * Gets the world normal input component
  52027. */
  52028. readonly worldNormal: NodeMaterialConnectionPoint;
  52029. /**
  52030. * Gets the light input component
  52031. */
  52032. readonly light: NodeMaterialConnectionPoint;
  52033. /**
  52034. * Gets the camera (or eye) position component
  52035. */
  52036. readonly cameraPosition: NodeMaterialConnectionPoint;
  52037. /**
  52038. * Gets the diffuse output component
  52039. */
  52040. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52041. /**
  52042. * Gets the specular output component
  52043. */
  52044. readonly specularOutput: NodeMaterialConnectionPoint;
  52045. autoConfigure(): void;
  52046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52048. private _injectVertexCode;
  52049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52050. }
  52051. }
  52052. declare module BABYLON {
  52053. /**
  52054. * Block used to multiply 2 vector4
  52055. */
  52056. export class MultiplyBlock extends NodeMaterialBlock {
  52057. /**
  52058. * Creates a new MultiplyBlock
  52059. * @param name defines the block name
  52060. */
  52061. constructor(name: string);
  52062. /**
  52063. * Gets the current class name
  52064. * @returns the class name
  52065. */
  52066. getClassName(): string;
  52067. /**
  52068. * Gets the left operand input component
  52069. */
  52070. readonly left: NodeMaterialConnectionPoint;
  52071. /**
  52072. * Gets the right operand input component
  52073. */
  52074. readonly right: NodeMaterialConnectionPoint;
  52075. /**
  52076. * Gets the output component
  52077. */
  52078. readonly output: NodeMaterialConnectionPoint;
  52079. protected _buildBlock(state: NodeMaterialBuildState): this;
  52080. }
  52081. }
  52082. declare module BABYLON {
  52083. /**
  52084. * Block used to add 2 vector4
  52085. */
  52086. export class AddBlock extends NodeMaterialBlock {
  52087. /**
  52088. * Creates a new AddBlock
  52089. * @param name defines the block name
  52090. */
  52091. constructor(name: string);
  52092. /**
  52093. * Gets the current class name
  52094. * @returns the class name
  52095. */
  52096. getClassName(): string;
  52097. /**
  52098. * Gets the left operand input component
  52099. */
  52100. readonly left: NodeMaterialConnectionPoint;
  52101. /**
  52102. * Gets the right operand input component
  52103. */
  52104. readonly right: NodeMaterialConnectionPoint;
  52105. /**
  52106. * Gets the output component
  52107. */
  52108. readonly output: NodeMaterialConnectionPoint;
  52109. protected _buildBlock(state: NodeMaterialBuildState): this;
  52110. }
  52111. }
  52112. declare module BABYLON {
  52113. /**
  52114. * Block used to clamp a float
  52115. */
  52116. export class ClampBlock extends NodeMaterialBlock {
  52117. /** Gets or sets the minimum range */
  52118. minimum: number;
  52119. /** Gets or sets the maximum range */
  52120. maximum: number;
  52121. /**
  52122. * Creates a new ClampBlock
  52123. * @param name defines the block name
  52124. */
  52125. constructor(name: string);
  52126. /**
  52127. * Gets the current class name
  52128. * @returns the class name
  52129. */
  52130. getClassName(): string;
  52131. /**
  52132. * Gets the value input component
  52133. */
  52134. readonly value: NodeMaterialConnectionPoint;
  52135. /**
  52136. * Gets the output component
  52137. */
  52138. readonly output: NodeMaterialConnectionPoint;
  52139. protected _buildBlock(state: NodeMaterialBuildState): this;
  52140. }
  52141. }
  52142. declare module BABYLON {
  52143. /**
  52144. * Block used to scale a value
  52145. */
  52146. export class ScaleBlock extends NodeMaterialBlock {
  52147. /**
  52148. * Creates a new ScaleBlock
  52149. * @param name defines the block name
  52150. */
  52151. constructor(name: string);
  52152. /**
  52153. * Gets the current class name
  52154. * @returns the class name
  52155. */
  52156. getClassName(): string;
  52157. /**
  52158. * Gets the value operand input component
  52159. */
  52160. readonly value: NodeMaterialConnectionPoint;
  52161. /**
  52162. * Gets the scale operand input component
  52163. */
  52164. readonly scale: NodeMaterialConnectionPoint;
  52165. /**
  52166. * Gets the output component
  52167. */
  52168. readonly output: NodeMaterialConnectionPoint;
  52169. protected _buildBlock(state: NodeMaterialBuildState): this;
  52170. }
  52171. }
  52172. declare module BABYLON {
  52173. /**
  52174. * Block used to transform a vector2 with a matrix
  52175. */
  52176. export class Vector2TransformBlock extends NodeMaterialBlock {
  52177. /**
  52178. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52179. */
  52180. complementZ: number;
  52181. /**
  52182. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52183. */
  52184. complementW: number;
  52185. /**
  52186. * Creates a new Vector2TransformBlock
  52187. * @param name defines the block name
  52188. */
  52189. constructor(name: string);
  52190. /**
  52191. * Gets the vector input
  52192. */
  52193. readonly vector: NodeMaterialConnectionPoint;
  52194. /**
  52195. * Gets the matrix transform input
  52196. */
  52197. readonly transform: NodeMaterialConnectionPoint;
  52198. /**
  52199. * Gets the output component
  52200. */
  52201. readonly output: NodeMaterialConnectionPoint;
  52202. /**
  52203. * Gets the current class name
  52204. * @returns the class name
  52205. */
  52206. getClassName(): string;
  52207. protected _buildBlock(state: NodeMaterialBuildState): this;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /**
  52212. * Block used to transform a vector3 with a matrix
  52213. */
  52214. export class Vector3TransformBlock extends NodeMaterialBlock {
  52215. /**
  52216. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52217. */
  52218. complement: number;
  52219. /**
  52220. * Creates a new Vector3TransformBlock
  52221. * @param name defines the block name
  52222. */
  52223. constructor(name: string);
  52224. /**
  52225. * Gets the vector input
  52226. */
  52227. readonly vector: NodeMaterialConnectionPoint;
  52228. /**
  52229. * Gets the matrix transform input
  52230. */
  52231. readonly transform: NodeMaterialConnectionPoint;
  52232. /**
  52233. * Gets the output component
  52234. */
  52235. readonly output: NodeMaterialConnectionPoint;
  52236. /**
  52237. * Gets the current class name
  52238. * @returns the class name
  52239. */
  52240. getClassName(): string;
  52241. protected _buildBlock(state: NodeMaterialBuildState): this;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * Block used to multiply two matrices
  52247. */
  52248. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  52249. /**
  52250. * Creates a new MatrixMultiplicationBlock
  52251. * @param name defines the block name
  52252. */
  52253. constructor(name: string);
  52254. /**
  52255. * Gets the left operand
  52256. */
  52257. readonly left: NodeMaterialConnectionPoint;
  52258. /**
  52259. * Gets the right operand
  52260. */
  52261. readonly right: NodeMaterialConnectionPoint;
  52262. /**
  52263. * Gets the output component
  52264. */
  52265. readonly output: NodeMaterialConnectionPoint;
  52266. /**
  52267. * Gets the current class name
  52268. * @returns the class name
  52269. */
  52270. getClassName(): string;
  52271. protected _buildBlock(state: NodeMaterialBuildState): this;
  52272. }
  52273. }
  52274. declare module BABYLON {
  52275. /**
  52276. * Helper class to push actions to a pool of workers.
  52277. */
  52278. export class WorkerPool implements IDisposable {
  52279. private _workerInfos;
  52280. private _pendingActions;
  52281. /**
  52282. * Constructor
  52283. * @param workers Array of workers to use for actions
  52284. */
  52285. constructor(workers: Array<Worker>);
  52286. /**
  52287. * Terminates all workers and clears any pending actions.
  52288. */
  52289. dispose(): void;
  52290. /**
  52291. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52292. * pended until a worker has completed its action.
  52293. * @param action The action to perform. Call onComplete when the action is complete.
  52294. */
  52295. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52296. private _execute;
  52297. }
  52298. }
  52299. declare module BABYLON {
  52300. /**
  52301. * Configuration for Draco compression
  52302. */
  52303. export interface IDracoCompressionConfiguration {
  52304. /**
  52305. * Configuration for the decoder.
  52306. */
  52307. decoder: {
  52308. /**
  52309. * The url to the WebAssembly module.
  52310. */
  52311. wasmUrl?: string;
  52312. /**
  52313. * The url to the WebAssembly binary.
  52314. */
  52315. wasmBinaryUrl?: string;
  52316. /**
  52317. * The url to the fallback JavaScript module.
  52318. */
  52319. fallbackUrl?: string;
  52320. };
  52321. }
  52322. /**
  52323. * Draco compression (https://google.github.io/draco/)
  52324. *
  52325. * This class wraps the Draco module.
  52326. *
  52327. * **Encoder**
  52328. *
  52329. * The encoder is not currently implemented.
  52330. *
  52331. * **Decoder**
  52332. *
  52333. * 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.
  52334. *
  52335. * To update the configuration, use the following code:
  52336. * ```javascript
  52337. * DracoCompression.Configuration = {
  52338. * decoder: {
  52339. * wasmUrl: "<url to the WebAssembly library>",
  52340. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52341. * fallbackUrl: "<url to the fallback JavaScript library>",
  52342. * }
  52343. * };
  52344. * ```
  52345. *
  52346. * 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.
  52347. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52348. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52349. *
  52350. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52351. * ```javascript
  52352. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52353. * ```
  52354. *
  52355. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52356. */
  52357. export class DracoCompression implements IDisposable {
  52358. private _workerPoolPromise?;
  52359. private _decoderModulePromise?;
  52360. /**
  52361. * The configuration. Defaults to the following urls:
  52362. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52363. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52364. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52365. */
  52366. static Configuration: IDracoCompressionConfiguration;
  52367. /**
  52368. * Returns true if the decoder configuration is available.
  52369. */
  52370. static readonly DecoderAvailable: boolean;
  52371. /**
  52372. * Default number of workers to create when creating the draco compression object.
  52373. */
  52374. static DefaultNumWorkers: number;
  52375. private static GetDefaultNumWorkers;
  52376. private static _Default;
  52377. /**
  52378. * Default instance for the draco compression object.
  52379. */
  52380. static readonly Default: DracoCompression;
  52381. /**
  52382. * Constructor
  52383. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52384. */
  52385. constructor(numWorkers?: number);
  52386. /**
  52387. * Stop all async operations and release resources.
  52388. */
  52389. dispose(): void;
  52390. /**
  52391. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52392. * @returns a promise that resolves when ready
  52393. */
  52394. whenReadyAsync(): Promise<void>;
  52395. /**
  52396. * Decode Draco compressed mesh data to vertex data.
  52397. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52398. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52399. * @returns A promise that resolves with the decoded vertex data
  52400. */
  52401. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52402. [kind: string]: number;
  52403. }): Promise<VertexData>;
  52404. }
  52405. }
  52406. declare module BABYLON {
  52407. /**
  52408. * Class for building Constructive Solid Geometry
  52409. */
  52410. export class CSG {
  52411. private polygons;
  52412. /**
  52413. * The world matrix
  52414. */
  52415. matrix: Matrix;
  52416. /**
  52417. * Stores the position
  52418. */
  52419. position: Vector3;
  52420. /**
  52421. * Stores the rotation
  52422. */
  52423. rotation: Vector3;
  52424. /**
  52425. * Stores the rotation quaternion
  52426. */
  52427. rotationQuaternion: Nullable<Quaternion>;
  52428. /**
  52429. * Stores the scaling vector
  52430. */
  52431. scaling: Vector3;
  52432. /**
  52433. * Convert the Mesh to CSG
  52434. * @param mesh The Mesh to convert to CSG
  52435. * @returns A new CSG from the Mesh
  52436. */
  52437. static FromMesh(mesh: Mesh): CSG;
  52438. /**
  52439. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52440. * @param polygons Polygons used to construct a CSG solid
  52441. */
  52442. private static FromPolygons;
  52443. /**
  52444. * Clones, or makes a deep copy, of the CSG
  52445. * @returns A new CSG
  52446. */
  52447. clone(): CSG;
  52448. /**
  52449. * Unions this CSG with another CSG
  52450. * @param csg The CSG to union against this CSG
  52451. * @returns The unioned CSG
  52452. */
  52453. union(csg: CSG): CSG;
  52454. /**
  52455. * Unions this CSG with another CSG in place
  52456. * @param csg The CSG to union against this CSG
  52457. */
  52458. unionInPlace(csg: CSG): void;
  52459. /**
  52460. * Subtracts this CSG with another CSG
  52461. * @param csg The CSG to subtract against this CSG
  52462. * @returns A new CSG
  52463. */
  52464. subtract(csg: CSG): CSG;
  52465. /**
  52466. * Subtracts this CSG with another CSG in place
  52467. * @param csg The CSG to subtact against this CSG
  52468. */
  52469. subtractInPlace(csg: CSG): void;
  52470. /**
  52471. * Intersect this CSG with another CSG
  52472. * @param csg The CSG to intersect against this CSG
  52473. * @returns A new CSG
  52474. */
  52475. intersect(csg: CSG): CSG;
  52476. /**
  52477. * Intersects this CSG with another CSG in place
  52478. * @param csg The CSG to intersect against this CSG
  52479. */
  52480. intersectInPlace(csg: CSG): void;
  52481. /**
  52482. * Return a new CSG solid with solid and empty space switched. This solid is
  52483. * not modified.
  52484. * @returns A new CSG solid with solid and empty space switched
  52485. */
  52486. inverse(): CSG;
  52487. /**
  52488. * Inverses the CSG in place
  52489. */
  52490. inverseInPlace(): void;
  52491. /**
  52492. * This is used to keep meshes transformations so they can be restored
  52493. * when we build back a Babylon Mesh
  52494. * NB : All CSG operations are performed in world coordinates
  52495. * @param csg The CSG to copy the transform attributes from
  52496. * @returns This CSG
  52497. */
  52498. copyTransformAttributes(csg: CSG): CSG;
  52499. /**
  52500. * Build Raw mesh from CSG
  52501. * Coordinates here are in world space
  52502. * @param name The name of the mesh geometry
  52503. * @param scene The Scene
  52504. * @param keepSubMeshes Specifies if the submeshes should be kept
  52505. * @returns A new Mesh
  52506. */
  52507. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52508. /**
  52509. * Build Mesh from CSG taking material and transforms into account
  52510. * @param name The name of the Mesh
  52511. * @param material The material of the Mesh
  52512. * @param scene The Scene
  52513. * @param keepSubMeshes Specifies if submeshes should be kept
  52514. * @returns The new Mesh
  52515. */
  52516. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52517. }
  52518. }
  52519. declare module BABYLON {
  52520. /**
  52521. * Class used to create a trail following a mesh
  52522. */
  52523. export class TrailMesh extends Mesh {
  52524. private _generator;
  52525. private _autoStart;
  52526. private _running;
  52527. private _diameter;
  52528. private _length;
  52529. private _sectionPolygonPointsCount;
  52530. private _sectionVectors;
  52531. private _sectionNormalVectors;
  52532. private _beforeRenderObserver;
  52533. /**
  52534. * @constructor
  52535. * @param name The value used by scene.getMeshByName() to do a lookup.
  52536. * @param generator The mesh to generate a trail.
  52537. * @param scene The scene to add this mesh to.
  52538. * @param diameter Diameter of trailing mesh. Default is 1.
  52539. * @param length Length of trailing mesh. Default is 60.
  52540. * @param autoStart Automatically start trailing mesh. Default true.
  52541. */
  52542. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52543. /**
  52544. * "TrailMesh"
  52545. * @returns "TrailMesh"
  52546. */
  52547. getClassName(): string;
  52548. private _createMesh;
  52549. /**
  52550. * Start trailing mesh.
  52551. */
  52552. start(): void;
  52553. /**
  52554. * Stop trailing mesh.
  52555. */
  52556. stop(): void;
  52557. /**
  52558. * Update trailing mesh geometry.
  52559. */
  52560. update(): void;
  52561. /**
  52562. * Returns a new TrailMesh object.
  52563. * @param name is a string, the name given to the new mesh
  52564. * @param newGenerator use new generator object for cloned trail mesh
  52565. * @returns a new mesh
  52566. */
  52567. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52568. /**
  52569. * Serializes this trail mesh
  52570. * @param serializationObject object to write serialization to
  52571. */
  52572. serialize(serializationObject: any): void;
  52573. /**
  52574. * Parses a serialized trail mesh
  52575. * @param parsedMesh the serialized mesh
  52576. * @param scene the scene to create the trail mesh in
  52577. * @returns the created trail mesh
  52578. */
  52579. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52580. }
  52581. }
  52582. declare module BABYLON {
  52583. /**
  52584. * Class containing static functions to help procedurally build meshes
  52585. */
  52586. export class TiledBoxBuilder {
  52587. /**
  52588. * Creates a box mesh
  52589. * 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)
  52590. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52592. * * 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
  52593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52594. * @param name defines the name of the mesh
  52595. * @param options defines the options used to create the mesh
  52596. * @param scene defines the hosting scene
  52597. * @returns the box mesh
  52598. */
  52599. static CreateTiledBox(name: string, options: {
  52600. pattern?: number;
  52601. width?: number;
  52602. height?: number;
  52603. depth?: number;
  52604. tileSize?: number;
  52605. tileWidth?: number;
  52606. tileHeight?: number;
  52607. alignHorizontal?: number;
  52608. alignVertical?: number;
  52609. faceUV?: Vector4[];
  52610. faceColors?: Color4[];
  52611. sideOrientation?: number;
  52612. updatable?: boolean;
  52613. }, scene?: Nullable<Scene>): Mesh;
  52614. }
  52615. }
  52616. declare module BABYLON {
  52617. /**
  52618. * Class containing static functions to help procedurally build meshes
  52619. */
  52620. export class TorusKnotBuilder {
  52621. /**
  52622. * Creates a torus knot mesh
  52623. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52624. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52625. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52626. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52628. * * 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
  52629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52630. * @param name defines the name of the mesh
  52631. * @param options defines the options used to create the mesh
  52632. * @param scene defines the hosting scene
  52633. * @returns the torus knot mesh
  52634. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52635. */
  52636. static CreateTorusKnot(name: string, options: {
  52637. radius?: number;
  52638. tube?: number;
  52639. radialSegments?: number;
  52640. tubularSegments?: number;
  52641. p?: number;
  52642. q?: number;
  52643. updatable?: boolean;
  52644. sideOrientation?: number;
  52645. frontUVs?: Vector4;
  52646. backUVs?: Vector4;
  52647. }, scene: any): Mesh;
  52648. }
  52649. }
  52650. declare module BABYLON {
  52651. /**
  52652. * Polygon
  52653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52654. */
  52655. export class Polygon {
  52656. /**
  52657. * Creates a rectangle
  52658. * @param xmin bottom X coord
  52659. * @param ymin bottom Y coord
  52660. * @param xmax top X coord
  52661. * @param ymax top Y coord
  52662. * @returns points that make the resulting rectation
  52663. */
  52664. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52665. /**
  52666. * Creates a circle
  52667. * @param radius radius of circle
  52668. * @param cx scale in x
  52669. * @param cy scale in y
  52670. * @param numberOfSides number of sides that make up the circle
  52671. * @returns points that make the resulting circle
  52672. */
  52673. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52674. /**
  52675. * Creates a polygon from input string
  52676. * @param input Input polygon data
  52677. * @returns the parsed points
  52678. */
  52679. static Parse(input: string): Vector2[];
  52680. /**
  52681. * Starts building a polygon from x and y coordinates
  52682. * @param x x coordinate
  52683. * @param y y coordinate
  52684. * @returns the started path2
  52685. */
  52686. static StartingAt(x: number, y: number): Path2;
  52687. }
  52688. /**
  52689. * Builds a polygon
  52690. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52691. */
  52692. export class PolygonMeshBuilder {
  52693. private _points;
  52694. private _outlinepoints;
  52695. private _holes;
  52696. private _name;
  52697. private _scene;
  52698. private _epoints;
  52699. private _eholes;
  52700. private _addToepoint;
  52701. /**
  52702. * Babylon reference to the earcut plugin.
  52703. */
  52704. bjsEarcut: any;
  52705. /**
  52706. * Creates a PolygonMeshBuilder
  52707. * @param name name of the builder
  52708. * @param contours Path of the polygon
  52709. * @param scene scene to add to when creating the mesh
  52710. * @param earcutInjection can be used to inject your own earcut reference
  52711. */
  52712. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52713. /**
  52714. * Adds a whole within the polygon
  52715. * @param hole Array of points defining the hole
  52716. * @returns this
  52717. */
  52718. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52719. /**
  52720. * Creates the polygon
  52721. * @param updatable If the mesh should be updatable
  52722. * @param depth The depth of the mesh created
  52723. * @returns the created mesh
  52724. */
  52725. build(updatable?: boolean, depth?: number): Mesh;
  52726. /**
  52727. * Creates the polygon
  52728. * @param depth The depth of the mesh created
  52729. * @returns the created VertexData
  52730. */
  52731. buildVertexData(depth?: number): VertexData;
  52732. /**
  52733. * Adds a side to the polygon
  52734. * @param positions points that make the polygon
  52735. * @param normals normals of the polygon
  52736. * @param uvs uvs of the polygon
  52737. * @param indices indices of the polygon
  52738. * @param bounds bounds of the polygon
  52739. * @param points points of the polygon
  52740. * @param depth depth of the polygon
  52741. * @param flip flip of the polygon
  52742. */
  52743. private addSide;
  52744. }
  52745. }
  52746. declare module BABYLON {
  52747. /**
  52748. * Class containing static functions to help procedurally build meshes
  52749. */
  52750. export class PolygonBuilder {
  52751. /**
  52752. * Creates a polygon mesh
  52753. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52754. * * 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
  52755. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52757. * * 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)
  52758. * * Remember you can only change the shape positions, not their number when updating a polygon
  52759. * @param name defines the name of the mesh
  52760. * @param options defines the options used to create the mesh
  52761. * @param scene defines the hosting scene
  52762. * @param earcutInjection can be used to inject your own earcut reference
  52763. * @returns the polygon mesh
  52764. */
  52765. static CreatePolygon(name: string, options: {
  52766. shape: Vector3[];
  52767. holes?: Vector3[][];
  52768. depth?: number;
  52769. faceUV?: Vector4[];
  52770. faceColors?: Color4[];
  52771. updatable?: boolean;
  52772. sideOrientation?: number;
  52773. frontUVs?: Vector4;
  52774. backUVs?: Vector4;
  52775. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52776. /**
  52777. * Creates an extruded polygon mesh, with depth in the Y direction.
  52778. * * 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)
  52779. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52780. * @param name defines the name of the mesh
  52781. * @param options defines the options used to create the mesh
  52782. * @param scene defines the hosting scene
  52783. * @param earcutInjection can be used to inject your own earcut reference
  52784. * @returns the polygon mesh
  52785. */
  52786. static ExtrudePolygon(name: string, options: {
  52787. shape: Vector3[];
  52788. holes?: Vector3[][];
  52789. depth?: number;
  52790. faceUV?: Vector4[];
  52791. faceColors?: Color4[];
  52792. updatable?: boolean;
  52793. sideOrientation?: number;
  52794. frontUVs?: Vector4;
  52795. backUVs?: Vector4;
  52796. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52797. }
  52798. }
  52799. declare module BABYLON {
  52800. /**
  52801. * Class containing static functions to help procedurally build meshes
  52802. */
  52803. export class LatheBuilder {
  52804. /**
  52805. * Creates lathe mesh.
  52806. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52807. * * 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
  52808. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52809. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52810. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52811. * * 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
  52812. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52813. * * 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
  52814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52815. * * 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
  52816. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52818. * @param name defines the name of the mesh
  52819. * @param options defines the options used to create the mesh
  52820. * @param scene defines the hosting scene
  52821. * @returns the lathe mesh
  52822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52823. */
  52824. static CreateLathe(name: string, options: {
  52825. shape: Vector3[];
  52826. radius?: number;
  52827. tessellation?: number;
  52828. clip?: number;
  52829. arc?: number;
  52830. closed?: boolean;
  52831. updatable?: boolean;
  52832. sideOrientation?: number;
  52833. frontUVs?: Vector4;
  52834. backUVs?: Vector4;
  52835. cap?: number;
  52836. invertUV?: boolean;
  52837. }, scene?: Nullable<Scene>): Mesh;
  52838. }
  52839. }
  52840. declare module BABYLON {
  52841. /**
  52842. * Class containing static functions to help procedurally build meshes
  52843. */
  52844. export class TiledPlaneBuilder {
  52845. /**
  52846. * Creates a tiled plane mesh
  52847. * * The parameter `pattern` will, depending on value, do nothing or
  52848. * * * flip (reflect about central vertical) alternate tiles across and up
  52849. * * * flip every tile on alternate rows
  52850. * * * rotate (180 degs) alternate tiles across and up
  52851. * * * rotate every tile on alternate rows
  52852. * * * flip and rotate alternate tiles across and up
  52853. * * * flip and rotate every tile on alternate rows
  52854. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  52855. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  52856. * * 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
  52857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52858. * * 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)
  52859. * * 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)
  52860. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52861. * @param name defines the name of the mesh
  52862. * @param options defines the options used to create the mesh
  52863. * @param scene defines the hosting scene
  52864. * @returns the box mesh
  52865. */
  52866. static CreateTiledPlane(name: string, options: {
  52867. pattern?: number;
  52868. tileSize?: number;
  52869. tileWidth?: number;
  52870. tileHeight?: number;
  52871. size?: number;
  52872. width?: number;
  52873. height?: number;
  52874. alignHorizontal?: number;
  52875. alignVertical?: number;
  52876. sideOrientation?: number;
  52877. frontUVs?: Vector4;
  52878. backUVs?: Vector4;
  52879. updatable?: boolean;
  52880. }, scene?: Nullable<Scene>): Mesh;
  52881. }
  52882. }
  52883. declare module BABYLON {
  52884. /**
  52885. * Class containing static functions to help procedurally build meshes
  52886. */
  52887. export class TubeBuilder {
  52888. /**
  52889. * Creates a tube mesh.
  52890. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52891. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52892. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52893. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52894. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52895. * * 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)
  52896. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52897. * * 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
  52898. * * 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
  52899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52900. * * 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
  52901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52903. * @param name defines the name of the mesh
  52904. * @param options defines the options used to create the mesh
  52905. * @param scene defines the hosting scene
  52906. * @returns the tube mesh
  52907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52908. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52909. */
  52910. static CreateTube(name: string, options: {
  52911. path: Vector3[];
  52912. radius?: number;
  52913. tessellation?: number;
  52914. radiusFunction?: {
  52915. (i: number, distance: number): number;
  52916. };
  52917. cap?: number;
  52918. arc?: number;
  52919. updatable?: boolean;
  52920. sideOrientation?: number;
  52921. frontUVs?: Vector4;
  52922. backUVs?: Vector4;
  52923. instance?: Mesh;
  52924. invertUV?: boolean;
  52925. }, scene?: Nullable<Scene>): Mesh;
  52926. }
  52927. }
  52928. declare module BABYLON {
  52929. /**
  52930. * Class containing static functions to help procedurally build meshes
  52931. */
  52932. export class IcoSphereBuilder {
  52933. /**
  52934. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52935. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52936. * * 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`)
  52937. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52938. * * 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
  52939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52940. * * 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
  52941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52942. * @param name defines the name of the mesh
  52943. * @param options defines the options used to create the mesh
  52944. * @param scene defines the hosting scene
  52945. * @returns the icosahedron mesh
  52946. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52947. */
  52948. static CreateIcoSphere(name: string, options: {
  52949. radius?: number;
  52950. radiusX?: number;
  52951. radiusY?: number;
  52952. radiusZ?: number;
  52953. flat?: boolean;
  52954. subdivisions?: number;
  52955. sideOrientation?: number;
  52956. frontUVs?: Vector4;
  52957. backUVs?: Vector4;
  52958. updatable?: boolean;
  52959. }, scene?: Nullable<Scene>): Mesh;
  52960. }
  52961. }
  52962. declare module BABYLON {
  52963. /**
  52964. * Class containing static functions to help procedurally build meshes
  52965. */
  52966. export class DecalBuilder {
  52967. /**
  52968. * Creates a decal mesh.
  52969. * 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
  52970. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52971. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52972. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52973. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52974. * @param name defines the name of the mesh
  52975. * @param sourceMesh defines the mesh where the decal must be applied
  52976. * @param options defines the options used to create the mesh
  52977. * @param scene defines the hosting scene
  52978. * @returns the decal mesh
  52979. * @see https://doc.babylonjs.com/how_to/decals
  52980. */
  52981. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52982. position?: Vector3;
  52983. normal?: Vector3;
  52984. size?: Vector3;
  52985. angle?: number;
  52986. }): Mesh;
  52987. }
  52988. }
  52989. declare module BABYLON {
  52990. /**
  52991. * Class containing static functions to help procedurally build meshes
  52992. */
  52993. export class MeshBuilder {
  52994. /**
  52995. * Creates a box mesh
  52996. * * The parameter `size` sets the size (float) of each box side (default 1)
  52997. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52998. * * 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)
  52999. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53001. * * 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
  53002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53003. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53004. * @param name defines the name of the mesh
  53005. * @param options defines the options used to create the mesh
  53006. * @param scene defines the hosting scene
  53007. * @returns the box mesh
  53008. */
  53009. static CreateBox(name: string, options: {
  53010. size?: number;
  53011. width?: number;
  53012. height?: number;
  53013. depth?: number;
  53014. faceUV?: Vector4[];
  53015. faceColors?: Color4[];
  53016. sideOrientation?: number;
  53017. frontUVs?: Vector4;
  53018. backUVs?: Vector4;
  53019. updatable?: boolean;
  53020. }, scene?: Nullable<Scene>): Mesh;
  53021. /**
  53022. * Creates a tiled box mesh
  53023. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53025. * @param name defines the name of the mesh
  53026. * @param options defines the options used to create the mesh
  53027. * @param scene defines the hosting scene
  53028. * @returns the tiled box mesh
  53029. */
  53030. static CreateTiledBox(name: string, options: {
  53031. pattern?: number;
  53032. size?: number;
  53033. width?: number;
  53034. height?: number;
  53035. depth: number;
  53036. tileSize?: number;
  53037. tileWidth?: number;
  53038. tileHeight?: number;
  53039. faceUV?: Vector4[];
  53040. faceColors?: Color4[];
  53041. alignHorizontal?: number;
  53042. alignVertical?: number;
  53043. sideOrientation?: number;
  53044. updatable?: boolean;
  53045. }, scene?: Nullable<Scene>): Mesh;
  53046. /**
  53047. * Creates a sphere mesh
  53048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53049. * * 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`)
  53050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53051. * * 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
  53052. * * 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)
  53053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53054. * * 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
  53055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53056. * @param name defines the name of the mesh
  53057. * @param options defines the options used to create the mesh
  53058. * @param scene defines the hosting scene
  53059. * @returns the sphere mesh
  53060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53061. */
  53062. static CreateSphere(name: string, options: {
  53063. segments?: number;
  53064. diameter?: number;
  53065. diameterX?: number;
  53066. diameterY?: number;
  53067. diameterZ?: number;
  53068. arc?: number;
  53069. slice?: number;
  53070. sideOrientation?: number;
  53071. frontUVs?: Vector4;
  53072. backUVs?: Vector4;
  53073. updatable?: boolean;
  53074. }, scene?: Nullable<Scene>): Mesh;
  53075. /**
  53076. * Creates a plane polygonal mesh. By default, this is a disc
  53077. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53078. * * 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
  53079. * * 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
  53080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53081. * * 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
  53082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53083. * @param name defines the name of the mesh
  53084. * @param options defines the options used to create the mesh
  53085. * @param scene defines the hosting scene
  53086. * @returns the plane polygonal mesh
  53087. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53088. */
  53089. static CreateDisc(name: string, options: {
  53090. radius?: number;
  53091. tessellation?: number;
  53092. arc?: number;
  53093. updatable?: boolean;
  53094. sideOrientation?: number;
  53095. frontUVs?: Vector4;
  53096. backUVs?: Vector4;
  53097. }, scene?: Nullable<Scene>): Mesh;
  53098. /**
  53099. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53100. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53101. * * 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`)
  53102. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53103. * * 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
  53104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53105. * * 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
  53106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53107. * @param name defines the name of the mesh
  53108. * @param options defines the options used to create the mesh
  53109. * @param scene defines the hosting scene
  53110. * @returns the icosahedron mesh
  53111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53112. */
  53113. static CreateIcoSphere(name: string, options: {
  53114. radius?: number;
  53115. radiusX?: number;
  53116. radiusY?: number;
  53117. radiusZ?: number;
  53118. flat?: boolean;
  53119. subdivisions?: number;
  53120. sideOrientation?: number;
  53121. frontUVs?: Vector4;
  53122. backUVs?: Vector4;
  53123. updatable?: boolean;
  53124. }, scene?: Nullable<Scene>): Mesh;
  53125. /**
  53126. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53127. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53128. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53129. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53130. * * 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
  53131. * * 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
  53132. * * 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
  53133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53134. * * 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
  53135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53136. * * 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
  53137. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53138. * * 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
  53139. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53141. * @param name defines the name of the mesh
  53142. * @param options defines the options used to create the mesh
  53143. * @param scene defines the hosting scene
  53144. * @returns the ribbon mesh
  53145. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53147. */
  53148. static CreateRibbon(name: string, options: {
  53149. pathArray: Vector3[][];
  53150. closeArray?: boolean;
  53151. closePath?: boolean;
  53152. offset?: number;
  53153. updatable?: boolean;
  53154. sideOrientation?: number;
  53155. frontUVs?: Vector4;
  53156. backUVs?: Vector4;
  53157. instance?: Mesh;
  53158. invertUV?: boolean;
  53159. uvs?: Vector2[];
  53160. colors?: Color4[];
  53161. }, scene?: Nullable<Scene>): Mesh;
  53162. /**
  53163. * Creates a cylinder or a cone mesh
  53164. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53165. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53166. * * 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.
  53167. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53168. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53169. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53170. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53171. * * 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).
  53172. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53173. * * 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).
  53174. * * 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
  53175. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53176. * * 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
  53177. * * 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.
  53178. * * If `enclose` is false, a ring surface is one element.
  53179. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53180. * * 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
  53181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53182. * * 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
  53183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53184. * @param name defines the name of the mesh
  53185. * @param options defines the options used to create the mesh
  53186. * @param scene defines the hosting scene
  53187. * @returns the cylinder mesh
  53188. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53189. */
  53190. static CreateCylinder(name: string, options: {
  53191. height?: number;
  53192. diameterTop?: number;
  53193. diameterBottom?: number;
  53194. diameter?: number;
  53195. tessellation?: number;
  53196. subdivisions?: number;
  53197. arc?: number;
  53198. faceColors?: Color4[];
  53199. faceUV?: Vector4[];
  53200. updatable?: boolean;
  53201. hasRings?: boolean;
  53202. enclose?: boolean;
  53203. cap?: number;
  53204. sideOrientation?: number;
  53205. frontUVs?: Vector4;
  53206. backUVs?: Vector4;
  53207. }, scene?: Nullable<Scene>): Mesh;
  53208. /**
  53209. * Creates a torus mesh
  53210. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53211. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53212. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53214. * * 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
  53215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53216. * @param name defines the name of the mesh
  53217. * @param options defines the options used to create the mesh
  53218. * @param scene defines the hosting scene
  53219. * @returns the torus mesh
  53220. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53221. */
  53222. static CreateTorus(name: string, options: {
  53223. diameter?: number;
  53224. thickness?: number;
  53225. tessellation?: number;
  53226. updatable?: boolean;
  53227. sideOrientation?: number;
  53228. frontUVs?: Vector4;
  53229. backUVs?: Vector4;
  53230. }, scene?: Nullable<Scene>): Mesh;
  53231. /**
  53232. * Creates a torus knot mesh
  53233. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53234. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53235. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53236. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53238. * * 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
  53239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53240. * @param name defines the name of the mesh
  53241. * @param options defines the options used to create the mesh
  53242. * @param scene defines the hosting scene
  53243. * @returns the torus knot mesh
  53244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53245. */
  53246. static CreateTorusKnot(name: string, options: {
  53247. radius?: number;
  53248. tube?: number;
  53249. radialSegments?: number;
  53250. tubularSegments?: number;
  53251. p?: number;
  53252. q?: number;
  53253. updatable?: boolean;
  53254. sideOrientation?: number;
  53255. frontUVs?: Vector4;
  53256. backUVs?: Vector4;
  53257. }, scene?: Nullable<Scene>): Mesh;
  53258. /**
  53259. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53260. * * 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
  53261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53262. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53263. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53264. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53265. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53266. * * 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
  53267. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53270. * @param name defines the name of the new line system
  53271. * @param options defines the options used to create the line system
  53272. * @param scene defines the hosting scene
  53273. * @returns a new line system mesh
  53274. */
  53275. static CreateLineSystem(name: string, options: {
  53276. lines: Vector3[][];
  53277. updatable?: boolean;
  53278. instance?: Nullable<LinesMesh>;
  53279. colors?: Nullable<Color4[][]>;
  53280. useVertexAlpha?: boolean;
  53281. }, scene: Nullable<Scene>): LinesMesh;
  53282. /**
  53283. * Creates a line mesh
  53284. * 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
  53285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53286. * * The parameter `points` is an array successive Vector3
  53287. * * 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
  53288. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53290. * * When updating an instance, remember that only point positions can change, not the number of points
  53291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53293. * @param name defines the name of the new line system
  53294. * @param options defines the options used to create the line system
  53295. * @param scene defines the hosting scene
  53296. * @returns a new line mesh
  53297. */
  53298. static CreateLines(name: string, options: {
  53299. points: Vector3[];
  53300. updatable?: boolean;
  53301. instance?: Nullable<LinesMesh>;
  53302. colors?: Color4[];
  53303. useVertexAlpha?: boolean;
  53304. }, scene?: Nullable<Scene>): LinesMesh;
  53305. /**
  53306. * Creates a dashed line mesh
  53307. * * 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
  53308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53309. * * The parameter `points` is an array successive Vector3
  53310. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53311. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53312. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53313. * * 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
  53314. * * When updating an instance, remember that only point positions can change, not the number of points
  53315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53316. * @param name defines the name of the mesh
  53317. * @param options defines the options used to create the mesh
  53318. * @param scene defines the hosting scene
  53319. * @returns the dashed line mesh
  53320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53321. */
  53322. static CreateDashedLines(name: string, options: {
  53323. points: Vector3[];
  53324. dashSize?: number;
  53325. gapSize?: number;
  53326. dashNb?: number;
  53327. updatable?: boolean;
  53328. instance?: LinesMesh;
  53329. }, scene?: Nullable<Scene>): LinesMesh;
  53330. /**
  53331. * 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.
  53332. * * 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.
  53333. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53334. * * 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.
  53335. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53336. * * 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
  53337. * * 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
  53338. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53340. * * 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
  53341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53343. * @param name defines the name of the mesh
  53344. * @param options defines the options used to create the mesh
  53345. * @param scene defines the hosting scene
  53346. * @returns the extruded shape mesh
  53347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53349. */
  53350. static ExtrudeShape(name: string, options: {
  53351. shape: Vector3[];
  53352. path: Vector3[];
  53353. scale?: number;
  53354. rotation?: number;
  53355. cap?: number;
  53356. updatable?: boolean;
  53357. sideOrientation?: number;
  53358. frontUVs?: Vector4;
  53359. backUVs?: Vector4;
  53360. instance?: Mesh;
  53361. invertUV?: boolean;
  53362. }, scene?: Nullable<Scene>): Mesh;
  53363. /**
  53364. * Creates an custom extruded shape mesh.
  53365. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53366. * * 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.
  53367. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53368. * * 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
  53369. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53370. * * 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
  53371. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53372. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53373. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53374. * * 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
  53375. * * 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
  53376. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53378. * * 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
  53379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53381. * @param name defines the name of the mesh
  53382. * @param options defines the options used to create the mesh
  53383. * @param scene defines the hosting scene
  53384. * @returns the custom extruded shape mesh
  53385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53386. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53388. */
  53389. static ExtrudeShapeCustom(name: string, options: {
  53390. shape: Vector3[];
  53391. path: Vector3[];
  53392. scaleFunction?: any;
  53393. rotationFunction?: any;
  53394. ribbonCloseArray?: boolean;
  53395. ribbonClosePath?: boolean;
  53396. cap?: number;
  53397. updatable?: boolean;
  53398. sideOrientation?: number;
  53399. frontUVs?: Vector4;
  53400. backUVs?: Vector4;
  53401. instance?: Mesh;
  53402. invertUV?: boolean;
  53403. }, scene?: Nullable<Scene>): Mesh;
  53404. /**
  53405. * Creates lathe mesh.
  53406. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53407. * * 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
  53408. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53409. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53410. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53411. * * 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
  53412. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53413. * * 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
  53414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53415. * * 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
  53416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53418. * @param name defines the name of the mesh
  53419. * @param options defines the options used to create the mesh
  53420. * @param scene defines the hosting scene
  53421. * @returns the lathe mesh
  53422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53423. */
  53424. static CreateLathe(name: string, options: {
  53425. shape: Vector3[];
  53426. radius?: number;
  53427. tessellation?: number;
  53428. clip?: number;
  53429. arc?: number;
  53430. closed?: boolean;
  53431. updatable?: boolean;
  53432. sideOrientation?: number;
  53433. frontUVs?: Vector4;
  53434. backUVs?: Vector4;
  53435. cap?: number;
  53436. invertUV?: boolean;
  53437. }, scene?: Nullable<Scene>): Mesh;
  53438. /**
  53439. * Creates a tiled plane mesh
  53440. * * You can set a limited pattern arrangement with the tiles
  53441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53442. * * 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
  53443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53444. * @param name defines the name of the mesh
  53445. * @param options defines the options used to create the mesh
  53446. * @param scene defines the hosting scene
  53447. * @returns the plane mesh
  53448. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53449. */
  53450. static CreateTiledPlane(name: string, options: {
  53451. pattern?: number;
  53452. tileSize?: number;
  53453. tileWidth?: number;
  53454. tileHeight?: number;
  53455. size?: number;
  53456. width?: number;
  53457. height?: number;
  53458. alignHorizontal?: number;
  53459. alignVertical?: number;
  53460. sideOrientation?: number;
  53461. frontUVs?: Vector4;
  53462. backUVs?: Vector4;
  53463. updatable?: boolean;
  53464. }, scene?: Nullable<Scene>): Mesh;
  53465. /**
  53466. * Creates a plane mesh
  53467. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53468. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53469. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53473. * @param name defines the name of the mesh
  53474. * @param options defines the options used to create the mesh
  53475. * @param scene defines the hosting scene
  53476. * @returns the plane mesh
  53477. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53478. */
  53479. static CreatePlane(name: string, options: {
  53480. size?: number;
  53481. width?: number;
  53482. height?: number;
  53483. sideOrientation?: number;
  53484. frontUVs?: Vector4;
  53485. backUVs?: Vector4;
  53486. updatable?: boolean;
  53487. sourcePlane?: Plane;
  53488. }, scene?: Nullable<Scene>): Mesh;
  53489. /**
  53490. * Creates a ground mesh
  53491. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53492. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53494. * @param name defines the name of the mesh
  53495. * @param options defines the options used to create the mesh
  53496. * @param scene defines the hosting scene
  53497. * @returns the ground mesh
  53498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53499. */
  53500. static CreateGround(name: string, options: {
  53501. width?: number;
  53502. height?: number;
  53503. subdivisions?: number;
  53504. subdivisionsX?: number;
  53505. subdivisionsY?: number;
  53506. updatable?: boolean;
  53507. }, scene?: Nullable<Scene>): Mesh;
  53508. /**
  53509. * Creates a tiled ground mesh
  53510. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53511. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53512. * * 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
  53513. * * 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
  53514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53515. * @param name defines the name of the mesh
  53516. * @param options defines the options used to create the mesh
  53517. * @param scene defines the hosting scene
  53518. * @returns the tiled ground mesh
  53519. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53520. */
  53521. static CreateTiledGround(name: string, options: {
  53522. xmin: number;
  53523. zmin: number;
  53524. xmax: number;
  53525. zmax: number;
  53526. subdivisions?: {
  53527. w: number;
  53528. h: number;
  53529. };
  53530. precision?: {
  53531. w: number;
  53532. h: number;
  53533. };
  53534. updatable?: boolean;
  53535. }, scene?: Nullable<Scene>): Mesh;
  53536. /**
  53537. * Creates a ground mesh from a height map
  53538. * * The parameter `url` sets the URL of the height map image resource.
  53539. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53540. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53541. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53542. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53543. * * 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.
  53544. * * 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).
  53545. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53547. * @param name defines the name of the mesh
  53548. * @param url defines the url to the height map
  53549. * @param options defines the options used to create the mesh
  53550. * @param scene defines the hosting scene
  53551. * @returns the ground mesh
  53552. * @see https://doc.babylonjs.com/babylon101/height_map
  53553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53554. */
  53555. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53556. width?: number;
  53557. height?: number;
  53558. subdivisions?: number;
  53559. minHeight?: number;
  53560. maxHeight?: number;
  53561. colorFilter?: Color3;
  53562. alphaFilter?: number;
  53563. updatable?: boolean;
  53564. onReady?: (mesh: GroundMesh) => void;
  53565. }, scene?: Nullable<Scene>): GroundMesh;
  53566. /**
  53567. * Creates a polygon mesh
  53568. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53569. * * 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
  53570. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53572. * * 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)
  53573. * * Remember you can only change the shape positions, not their number when updating a polygon
  53574. * @param name defines the name of the mesh
  53575. * @param options defines the options used to create the mesh
  53576. * @param scene defines the hosting scene
  53577. * @param earcutInjection can be used to inject your own earcut reference
  53578. * @returns the polygon mesh
  53579. */
  53580. static CreatePolygon(name: string, options: {
  53581. shape: Vector3[];
  53582. holes?: Vector3[][];
  53583. depth?: number;
  53584. faceUV?: Vector4[];
  53585. faceColors?: Color4[];
  53586. updatable?: boolean;
  53587. sideOrientation?: number;
  53588. frontUVs?: Vector4;
  53589. backUVs?: Vector4;
  53590. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53591. /**
  53592. * Creates an extruded polygon mesh, with depth in the Y direction.
  53593. * * 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)
  53594. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53595. * @param name defines the name of the mesh
  53596. * @param options defines the options used to create the mesh
  53597. * @param scene defines the hosting scene
  53598. * @param earcutInjection can be used to inject your own earcut reference
  53599. * @returns the polygon mesh
  53600. */
  53601. static ExtrudePolygon(name: string, options: {
  53602. shape: Vector3[];
  53603. holes?: Vector3[][];
  53604. depth?: number;
  53605. faceUV?: Vector4[];
  53606. faceColors?: Color4[];
  53607. updatable?: boolean;
  53608. sideOrientation?: number;
  53609. frontUVs?: Vector4;
  53610. backUVs?: Vector4;
  53611. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53612. /**
  53613. * Creates a tube mesh.
  53614. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53615. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53616. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53617. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53618. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53619. * * 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)
  53620. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53621. * * 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
  53622. * * 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
  53623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53624. * * 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
  53625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53627. * @param name defines the name of the mesh
  53628. * @param options defines the options used to create the mesh
  53629. * @param scene defines the hosting scene
  53630. * @returns the tube mesh
  53631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53632. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53633. */
  53634. static CreateTube(name: string, options: {
  53635. path: Vector3[];
  53636. radius?: number;
  53637. tessellation?: number;
  53638. radiusFunction?: {
  53639. (i: number, distance: number): number;
  53640. };
  53641. cap?: number;
  53642. arc?: number;
  53643. updatable?: boolean;
  53644. sideOrientation?: number;
  53645. frontUVs?: Vector4;
  53646. backUVs?: Vector4;
  53647. instance?: Mesh;
  53648. invertUV?: boolean;
  53649. }, scene?: Nullable<Scene>): Mesh;
  53650. /**
  53651. * Creates a polyhedron mesh
  53652. * * 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
  53653. * * The parameter `size` (positive float, default 1) sets the polygon size
  53654. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53655. * * 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`
  53656. * * 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
  53657. * * 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)`)
  53658. * * 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
  53659. * * 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
  53660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53661. * * 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
  53662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53663. * @param name defines the name of the mesh
  53664. * @param options defines the options used to create the mesh
  53665. * @param scene defines the hosting scene
  53666. * @returns the polyhedron mesh
  53667. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53668. */
  53669. static CreatePolyhedron(name: string, options: {
  53670. type?: number;
  53671. size?: number;
  53672. sizeX?: number;
  53673. sizeY?: number;
  53674. sizeZ?: number;
  53675. custom?: any;
  53676. faceUV?: Vector4[];
  53677. faceColors?: Color4[];
  53678. flat?: boolean;
  53679. updatable?: boolean;
  53680. sideOrientation?: number;
  53681. frontUVs?: Vector4;
  53682. backUVs?: Vector4;
  53683. }, scene?: Nullable<Scene>): Mesh;
  53684. /**
  53685. * Creates a decal mesh.
  53686. * 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
  53687. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53688. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53689. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53690. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53691. * @param name defines the name of the mesh
  53692. * @param sourceMesh defines the mesh where the decal must be applied
  53693. * @param options defines the options used to create the mesh
  53694. * @param scene defines the hosting scene
  53695. * @returns the decal mesh
  53696. * @see https://doc.babylonjs.com/how_to/decals
  53697. */
  53698. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53699. position?: Vector3;
  53700. normal?: Vector3;
  53701. size?: Vector3;
  53702. angle?: number;
  53703. }): Mesh;
  53704. }
  53705. }
  53706. declare module BABYLON {
  53707. /**
  53708. * A simplifier interface for future simplification implementations
  53709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53710. */
  53711. export interface ISimplifier {
  53712. /**
  53713. * Simplification of a given mesh according to the given settings.
  53714. * Since this requires computation, it is assumed that the function runs async.
  53715. * @param settings The settings of the simplification, including quality and distance
  53716. * @param successCallback A callback that will be called after the mesh was simplified.
  53717. * @param errorCallback in case of an error, this callback will be called. optional.
  53718. */
  53719. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53720. }
  53721. /**
  53722. * Expected simplification settings.
  53723. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53724. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53725. */
  53726. export interface ISimplificationSettings {
  53727. /**
  53728. * Gets or sets the expected quality
  53729. */
  53730. quality: number;
  53731. /**
  53732. * Gets or sets the distance when this optimized version should be used
  53733. */
  53734. distance: number;
  53735. /**
  53736. * Gets an already optimized mesh
  53737. */
  53738. optimizeMesh?: boolean;
  53739. }
  53740. /**
  53741. * Class used to specify simplification options
  53742. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53743. */
  53744. export class SimplificationSettings implements ISimplificationSettings {
  53745. /** expected quality */
  53746. quality: number;
  53747. /** distance when this optimized version should be used */
  53748. distance: number;
  53749. /** already optimized mesh */
  53750. optimizeMesh?: boolean | undefined;
  53751. /**
  53752. * Creates a SimplificationSettings
  53753. * @param quality expected quality
  53754. * @param distance distance when this optimized version should be used
  53755. * @param optimizeMesh already optimized mesh
  53756. */
  53757. constructor(
  53758. /** expected quality */
  53759. quality: number,
  53760. /** distance when this optimized version should be used */
  53761. distance: number,
  53762. /** already optimized mesh */
  53763. optimizeMesh?: boolean | undefined);
  53764. }
  53765. /**
  53766. * Interface used to define a simplification task
  53767. */
  53768. export interface ISimplificationTask {
  53769. /**
  53770. * Array of settings
  53771. */
  53772. settings: Array<ISimplificationSettings>;
  53773. /**
  53774. * Simplification type
  53775. */
  53776. simplificationType: SimplificationType;
  53777. /**
  53778. * Mesh to simplify
  53779. */
  53780. mesh: Mesh;
  53781. /**
  53782. * Callback called on success
  53783. */
  53784. successCallback?: () => void;
  53785. /**
  53786. * Defines if parallel processing can be used
  53787. */
  53788. parallelProcessing: boolean;
  53789. }
  53790. /**
  53791. * Queue used to order the simplification tasks
  53792. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53793. */
  53794. export class SimplificationQueue {
  53795. private _simplificationArray;
  53796. /**
  53797. * Gets a boolean indicating that the process is still running
  53798. */
  53799. running: boolean;
  53800. /**
  53801. * Creates a new queue
  53802. */
  53803. constructor();
  53804. /**
  53805. * Adds a new simplification task
  53806. * @param task defines a task to add
  53807. */
  53808. addTask(task: ISimplificationTask): void;
  53809. /**
  53810. * Execute next task
  53811. */
  53812. executeNext(): void;
  53813. /**
  53814. * Execute a simplification task
  53815. * @param task defines the task to run
  53816. */
  53817. runSimplification(task: ISimplificationTask): void;
  53818. private getSimplifier;
  53819. }
  53820. /**
  53821. * The implemented types of simplification
  53822. * At the moment only Quadratic Error Decimation is implemented
  53823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53824. */
  53825. export enum SimplificationType {
  53826. /** Quadratic error decimation */
  53827. QUADRATIC = 0
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. interface Scene {
  53832. /** @hidden (Backing field) */
  53833. _simplificationQueue: SimplificationQueue;
  53834. /**
  53835. * Gets or sets the simplification queue attached to the scene
  53836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53837. */
  53838. simplificationQueue: SimplificationQueue;
  53839. }
  53840. interface Mesh {
  53841. /**
  53842. * Simplify the mesh according to the given array of settings.
  53843. * Function will return immediately and will simplify async
  53844. * @param settings a collection of simplification settings
  53845. * @param parallelProcessing should all levels calculate parallel or one after the other
  53846. * @param simplificationType the type of simplification to run
  53847. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53848. * @returns the current mesh
  53849. */
  53850. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53851. }
  53852. /**
  53853. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53854. * created in a scene
  53855. */
  53856. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53857. /**
  53858. * The component name helpfull to identify the component in the list of scene components.
  53859. */
  53860. readonly name: string;
  53861. /**
  53862. * The scene the component belongs to.
  53863. */
  53864. scene: Scene;
  53865. /**
  53866. * Creates a new instance of the component for the given scene
  53867. * @param scene Defines the scene to register the component in
  53868. */
  53869. constructor(scene: Scene);
  53870. /**
  53871. * Registers the component in a given scene
  53872. */
  53873. register(): void;
  53874. /**
  53875. * Rebuilds the elements related to this component in case of
  53876. * context lost for instance.
  53877. */
  53878. rebuild(): void;
  53879. /**
  53880. * Disposes the component and the associated ressources
  53881. */
  53882. dispose(): void;
  53883. private _beforeCameraUpdate;
  53884. }
  53885. }
  53886. declare module BABYLON {
  53887. /**
  53888. * Class used to enable access to IndexedDB
  53889. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53890. */
  53891. export class Database implements IOfflineProvider {
  53892. private _callbackManifestChecked;
  53893. private _currentSceneUrl;
  53894. private _db;
  53895. private _enableSceneOffline;
  53896. private _enableTexturesOffline;
  53897. private _manifestVersionFound;
  53898. private _mustUpdateRessources;
  53899. private _hasReachedQuota;
  53900. private _isSupported;
  53901. private _idbFactory;
  53902. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53903. private static IsUASupportingBlobStorage;
  53904. /**
  53905. * Gets a boolean indicating if Database storate is enabled (off by default)
  53906. */
  53907. static IDBStorageEnabled: boolean;
  53908. /**
  53909. * Gets a boolean indicating if scene must be saved in the database
  53910. */
  53911. readonly enableSceneOffline: boolean;
  53912. /**
  53913. * Gets a boolean indicating if textures must be saved in the database
  53914. */
  53915. readonly enableTexturesOffline: boolean;
  53916. /**
  53917. * Creates a new Database
  53918. * @param urlToScene defines the url to load the scene
  53919. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53920. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53921. */
  53922. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53923. private static _ParseURL;
  53924. private static _ReturnFullUrlLocation;
  53925. private _checkManifestFile;
  53926. /**
  53927. * Open the database and make it available
  53928. * @param successCallback defines the callback to call on success
  53929. * @param errorCallback defines the callback to call on error
  53930. */
  53931. open(successCallback: () => void, errorCallback: () => void): void;
  53932. /**
  53933. * Loads an image from the database
  53934. * @param url defines the url to load from
  53935. * @param image defines the target DOM image
  53936. */
  53937. loadImage(url: string, image: HTMLImageElement): void;
  53938. private _loadImageFromDBAsync;
  53939. private _saveImageIntoDBAsync;
  53940. private _checkVersionFromDB;
  53941. private _loadVersionFromDBAsync;
  53942. private _saveVersionIntoDBAsync;
  53943. /**
  53944. * Loads a file from database
  53945. * @param url defines the URL to load from
  53946. * @param sceneLoaded defines a callback to call on success
  53947. * @param progressCallBack defines a callback to call when progress changed
  53948. * @param errorCallback defines a callback to call on error
  53949. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53950. */
  53951. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53952. private _loadFileAsync;
  53953. private _saveFileAsync;
  53954. /**
  53955. * Validates if xhr data is correct
  53956. * @param xhr defines the request to validate
  53957. * @param dataType defines the expected data type
  53958. * @returns true if data is correct
  53959. */
  53960. private static _ValidateXHRData;
  53961. }
  53962. }
  53963. declare module BABYLON {
  53964. /** @hidden */
  53965. export var gpuUpdateParticlesPixelShader: {
  53966. name: string;
  53967. shader: string;
  53968. };
  53969. }
  53970. declare module BABYLON {
  53971. /** @hidden */
  53972. export var gpuUpdateParticlesVertexShader: {
  53973. name: string;
  53974. shader: string;
  53975. };
  53976. }
  53977. declare module BABYLON {
  53978. /** @hidden */
  53979. export var clipPlaneFragmentDeclaration2: {
  53980. name: string;
  53981. shader: string;
  53982. };
  53983. }
  53984. declare module BABYLON {
  53985. /** @hidden */
  53986. export var gpuRenderParticlesPixelShader: {
  53987. name: string;
  53988. shader: string;
  53989. };
  53990. }
  53991. declare module BABYLON {
  53992. /** @hidden */
  53993. export var clipPlaneVertexDeclaration2: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module BABYLON {
  53999. /** @hidden */
  54000. export var gpuRenderParticlesVertexShader: {
  54001. name: string;
  54002. shader: string;
  54003. };
  54004. }
  54005. declare module BABYLON {
  54006. /**
  54007. * This represents a GPU particle system in Babylon
  54008. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54009. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54010. */
  54011. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54012. /**
  54013. * The layer mask we are rendering the particles through.
  54014. */
  54015. layerMask: number;
  54016. private _capacity;
  54017. private _activeCount;
  54018. private _currentActiveCount;
  54019. private _accumulatedCount;
  54020. private _renderEffect;
  54021. private _updateEffect;
  54022. private _buffer0;
  54023. private _buffer1;
  54024. private _spriteBuffer;
  54025. private _updateVAO;
  54026. private _renderVAO;
  54027. private _targetIndex;
  54028. private _sourceBuffer;
  54029. private _targetBuffer;
  54030. private _engine;
  54031. private _currentRenderId;
  54032. private _started;
  54033. private _stopped;
  54034. private _timeDelta;
  54035. private _randomTexture;
  54036. private _randomTexture2;
  54037. private _attributesStrideSize;
  54038. private _updateEffectOptions;
  54039. private _randomTextureSize;
  54040. private _actualFrame;
  54041. private readonly _rawTextureWidth;
  54042. /**
  54043. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54044. */
  54045. static readonly IsSupported: boolean;
  54046. /**
  54047. * An event triggered when the system is disposed.
  54048. */
  54049. onDisposeObservable: Observable<GPUParticleSystem>;
  54050. /**
  54051. * Gets the maximum number of particles active at the same time.
  54052. * @returns The max number of active particles.
  54053. */
  54054. getCapacity(): number;
  54055. /**
  54056. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54057. * to override the particles.
  54058. */
  54059. forceDepthWrite: boolean;
  54060. /**
  54061. * Gets or set the number of active particles
  54062. */
  54063. activeParticleCount: number;
  54064. private _preWarmDone;
  54065. /**
  54066. * Is this system ready to be used/rendered
  54067. * @return true if the system is ready
  54068. */
  54069. isReady(): boolean;
  54070. /**
  54071. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54072. * @returns True if it has been started, otherwise false.
  54073. */
  54074. isStarted(): boolean;
  54075. /**
  54076. * Starts the particle system and begins to emit
  54077. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54078. */
  54079. start(delay?: number): void;
  54080. /**
  54081. * Stops the particle system.
  54082. */
  54083. stop(): void;
  54084. /**
  54085. * Remove all active particles
  54086. */
  54087. reset(): void;
  54088. /**
  54089. * Returns the string "GPUParticleSystem"
  54090. * @returns a string containing the class name
  54091. */
  54092. getClassName(): string;
  54093. private _colorGradientsTexture;
  54094. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54095. /**
  54096. * Adds a new color gradient
  54097. * @param gradient defines the gradient to use (between 0 and 1)
  54098. * @param color1 defines the color to affect to the specified gradient
  54099. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54100. * @returns the current particle system
  54101. */
  54102. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54103. /**
  54104. * Remove a specific color gradient
  54105. * @param gradient defines the gradient to remove
  54106. * @returns the current particle system
  54107. */
  54108. removeColorGradient(gradient: number): GPUParticleSystem;
  54109. private _angularSpeedGradientsTexture;
  54110. private _sizeGradientsTexture;
  54111. private _velocityGradientsTexture;
  54112. private _limitVelocityGradientsTexture;
  54113. private _dragGradientsTexture;
  54114. private _addFactorGradient;
  54115. /**
  54116. * Adds a new size gradient
  54117. * @param gradient defines the gradient to use (between 0 and 1)
  54118. * @param factor defines the size factor to affect to the specified gradient
  54119. * @returns the current particle system
  54120. */
  54121. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54122. /**
  54123. * Remove a specific size gradient
  54124. * @param gradient defines the gradient to remove
  54125. * @returns the current particle system
  54126. */
  54127. removeSizeGradient(gradient: number): GPUParticleSystem;
  54128. /**
  54129. * Adds a new angular speed gradient
  54130. * @param gradient defines the gradient to use (between 0 and 1)
  54131. * @param factor defines the angular speed to affect to the specified gradient
  54132. * @returns the current particle system
  54133. */
  54134. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54135. /**
  54136. * Remove a specific angular speed gradient
  54137. * @param gradient defines the gradient to remove
  54138. * @returns the current particle system
  54139. */
  54140. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54141. /**
  54142. * Adds a new velocity gradient
  54143. * @param gradient defines the gradient to use (between 0 and 1)
  54144. * @param factor defines the velocity to affect to the specified gradient
  54145. * @returns the current particle system
  54146. */
  54147. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54148. /**
  54149. * Remove a specific velocity gradient
  54150. * @param gradient defines the gradient to remove
  54151. * @returns the current particle system
  54152. */
  54153. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54154. /**
  54155. * Adds a new limit velocity gradient
  54156. * @param gradient defines the gradient to use (between 0 and 1)
  54157. * @param factor defines the limit velocity value to affect to the specified gradient
  54158. * @returns the current particle system
  54159. */
  54160. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54161. /**
  54162. * Remove a specific limit velocity gradient
  54163. * @param gradient defines the gradient to remove
  54164. * @returns the current particle system
  54165. */
  54166. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54167. /**
  54168. * Adds a new drag gradient
  54169. * @param gradient defines the gradient to use (between 0 and 1)
  54170. * @param factor defines the drag value to affect to the specified gradient
  54171. * @returns the current particle system
  54172. */
  54173. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54174. /**
  54175. * Remove a specific drag gradient
  54176. * @param gradient defines the gradient to remove
  54177. * @returns the current particle system
  54178. */
  54179. removeDragGradient(gradient: number): GPUParticleSystem;
  54180. /**
  54181. * Not supported by GPUParticleSystem
  54182. * @param gradient defines the gradient to use (between 0 and 1)
  54183. * @param factor defines the emit rate value to affect to the specified gradient
  54184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54185. * @returns the current particle system
  54186. */
  54187. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54188. /**
  54189. * Not supported by GPUParticleSystem
  54190. * @param gradient defines the gradient to remove
  54191. * @returns the current particle system
  54192. */
  54193. removeEmitRateGradient(gradient: number): IParticleSystem;
  54194. /**
  54195. * Not supported by GPUParticleSystem
  54196. * @param gradient defines the gradient to use (between 0 and 1)
  54197. * @param factor defines the start size value to affect to the specified gradient
  54198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54199. * @returns the current particle system
  54200. */
  54201. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54202. /**
  54203. * Not supported by GPUParticleSystem
  54204. * @param gradient defines the gradient to remove
  54205. * @returns the current particle system
  54206. */
  54207. removeStartSizeGradient(gradient: number): IParticleSystem;
  54208. /**
  54209. * Not supported by GPUParticleSystem
  54210. * @param gradient defines the gradient to use (between 0 and 1)
  54211. * @param min defines the color remap minimal range
  54212. * @param max defines the color remap maximal range
  54213. * @returns the current particle system
  54214. */
  54215. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54216. /**
  54217. * Not supported by GPUParticleSystem
  54218. * @param gradient defines the gradient to remove
  54219. * @returns the current particle system
  54220. */
  54221. removeColorRemapGradient(): IParticleSystem;
  54222. /**
  54223. * Not supported by GPUParticleSystem
  54224. * @param gradient defines the gradient to use (between 0 and 1)
  54225. * @param min defines the alpha remap minimal range
  54226. * @param max defines the alpha remap maximal range
  54227. * @returns the current particle system
  54228. */
  54229. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54230. /**
  54231. * Not supported by GPUParticleSystem
  54232. * @param gradient defines the gradient to remove
  54233. * @returns the current particle system
  54234. */
  54235. removeAlphaRemapGradient(): IParticleSystem;
  54236. /**
  54237. * Not supported by GPUParticleSystem
  54238. * @param gradient defines the gradient to use (between 0 and 1)
  54239. * @param color defines the color to affect to the specified gradient
  54240. * @returns the current particle system
  54241. */
  54242. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54243. /**
  54244. * Not supported by GPUParticleSystem
  54245. * @param gradient defines the gradient to remove
  54246. * @returns the current particle system
  54247. */
  54248. removeRampGradient(): IParticleSystem;
  54249. /**
  54250. * Not supported by GPUParticleSystem
  54251. * @returns the list of ramp gradients
  54252. */
  54253. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54254. /**
  54255. * Not supported by GPUParticleSystem
  54256. * Gets or sets a boolean indicating that ramp gradients must be used
  54257. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54258. */
  54259. useRampGradients: boolean;
  54260. /**
  54261. * Not supported by GPUParticleSystem
  54262. * @param gradient defines the gradient to use (between 0 and 1)
  54263. * @param factor defines the life time factor to affect to the specified gradient
  54264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54265. * @returns the current particle system
  54266. */
  54267. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54268. /**
  54269. * Not supported by GPUParticleSystem
  54270. * @param gradient defines the gradient to remove
  54271. * @returns the current particle system
  54272. */
  54273. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54274. /**
  54275. * Instantiates a GPU particle system.
  54276. * 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.
  54277. * @param name The name of the particle system
  54278. * @param options The options used to create the system
  54279. * @param scene The scene the particle system belongs to
  54280. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54281. */
  54282. constructor(name: string, options: Partial<{
  54283. capacity: number;
  54284. randomTextureSize: number;
  54285. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54286. protected _reset(): void;
  54287. private _createUpdateVAO;
  54288. private _createRenderVAO;
  54289. private _initialize;
  54290. /** @hidden */
  54291. _recreateUpdateEffect(): void;
  54292. /** @hidden */
  54293. _recreateRenderEffect(): void;
  54294. /**
  54295. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54296. * @param preWarm defines if we are in the pre-warmimg phase
  54297. */
  54298. animate(preWarm?: boolean): void;
  54299. private _createFactorGradientTexture;
  54300. private _createSizeGradientTexture;
  54301. private _createAngularSpeedGradientTexture;
  54302. private _createVelocityGradientTexture;
  54303. private _createLimitVelocityGradientTexture;
  54304. private _createDragGradientTexture;
  54305. private _createColorGradientTexture;
  54306. /**
  54307. * Renders the particle system in its current state
  54308. * @param preWarm defines if the system should only update the particles but not render them
  54309. * @returns the current number of particles
  54310. */
  54311. render(preWarm?: boolean): number;
  54312. /**
  54313. * Rebuilds the particle system
  54314. */
  54315. rebuild(): void;
  54316. private _releaseBuffers;
  54317. private _releaseVAOs;
  54318. /**
  54319. * Disposes the particle system and free the associated resources
  54320. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54321. */
  54322. dispose(disposeTexture?: boolean): void;
  54323. /**
  54324. * Clones the particle system.
  54325. * @param name The name of the cloned object
  54326. * @param newEmitter The new emitter to use
  54327. * @returns the cloned particle system
  54328. */
  54329. clone(name: string, newEmitter: any): GPUParticleSystem;
  54330. /**
  54331. * Serializes the particle system to a JSON object.
  54332. * @returns the JSON object
  54333. */
  54334. serialize(): any;
  54335. /**
  54336. * Parses a JSON object to create a GPU particle system.
  54337. * @param parsedParticleSystem The JSON object to parse
  54338. * @param scene The scene to create the particle system in
  54339. * @param rootUrl The root url to use to load external dependencies like texture
  54340. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54341. * @returns the parsed GPU particle system
  54342. */
  54343. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54344. }
  54345. }
  54346. declare module BABYLON {
  54347. /**
  54348. * Represents a set of particle systems working together to create a specific effect
  54349. */
  54350. export class ParticleSystemSet implements IDisposable {
  54351. private _emitterCreationOptions;
  54352. private _emitterNode;
  54353. /**
  54354. * Gets the particle system list
  54355. */
  54356. systems: IParticleSystem[];
  54357. /**
  54358. * Gets the emitter node used with this set
  54359. */
  54360. readonly emitterNode: Nullable<TransformNode>;
  54361. /**
  54362. * Creates a new emitter mesh as a sphere
  54363. * @param options defines the options used to create the sphere
  54364. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54365. * @param scene defines the hosting scene
  54366. */
  54367. setEmitterAsSphere(options: {
  54368. diameter: number;
  54369. segments: number;
  54370. color: Color3;
  54371. }, renderingGroupId: number, scene: Scene): void;
  54372. /**
  54373. * Starts all particle systems of the set
  54374. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54375. */
  54376. start(emitter?: AbstractMesh): void;
  54377. /**
  54378. * Release all associated resources
  54379. */
  54380. dispose(): void;
  54381. /**
  54382. * Serialize the set into a JSON compatible object
  54383. * @returns a JSON compatible representation of the set
  54384. */
  54385. serialize(): any;
  54386. /**
  54387. * Parse a new ParticleSystemSet from a serialized source
  54388. * @param data defines a JSON compatible representation of the set
  54389. * @param scene defines the hosting scene
  54390. * @param gpu defines if we want GPU particles or CPU particles
  54391. * @returns a new ParticleSystemSet
  54392. */
  54393. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54394. }
  54395. }
  54396. declare module BABYLON {
  54397. /**
  54398. * This class is made for on one-liner static method to help creating particle system set.
  54399. */
  54400. export class ParticleHelper {
  54401. /**
  54402. * Gets or sets base Assets URL
  54403. */
  54404. static BaseAssetsUrl: string;
  54405. /**
  54406. * Create a default particle system that you can tweak
  54407. * @param emitter defines the emitter to use
  54408. * @param capacity defines the system capacity (default is 500 particles)
  54409. * @param scene defines the hosting scene
  54410. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54411. * @returns the new Particle system
  54412. */
  54413. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54414. /**
  54415. * This is the main static method (one-liner) of this helper to create different particle systems
  54416. * @param type This string represents the type to the particle system to create
  54417. * @param scene The scene where the particle system should live
  54418. * @param gpu If the system will use gpu
  54419. * @returns the ParticleSystemSet created
  54420. */
  54421. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54422. /**
  54423. * Static function used to export a particle system to a ParticleSystemSet variable.
  54424. * Please note that the emitter shape is not exported
  54425. * @param systems defines the particle systems to export
  54426. * @returns the created particle system set
  54427. */
  54428. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54429. }
  54430. }
  54431. declare module BABYLON {
  54432. interface Engine {
  54433. /**
  54434. * Create an effect to use with particle systems.
  54435. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54436. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54437. * @param uniformsNames defines a list of attribute names
  54438. * @param samplers defines an array of string used to represent textures
  54439. * @param defines defines the string containing the defines to use to compile the shaders
  54440. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54441. * @param onCompiled defines a function to call when the effect creation is successful
  54442. * @param onError defines a function to call when the effect creation has failed
  54443. * @returns the new Effect
  54444. */
  54445. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54446. }
  54447. interface Mesh {
  54448. /**
  54449. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54450. * @returns an array of IParticleSystem
  54451. */
  54452. getEmittedParticleSystems(): IParticleSystem[];
  54453. /**
  54454. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54455. * @returns an array of IParticleSystem
  54456. */
  54457. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54458. }
  54459. /**
  54460. * @hidden
  54461. */
  54462. export var _IDoNeedToBeInTheBuild: number;
  54463. }
  54464. declare module BABYLON {
  54465. interface Scene {
  54466. /** @hidden (Backing field) */
  54467. _physicsEngine: Nullable<IPhysicsEngine>;
  54468. /**
  54469. * Gets the current physics engine
  54470. * @returns a IPhysicsEngine or null if none attached
  54471. */
  54472. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54473. /**
  54474. * Enables physics to the current scene
  54475. * @param gravity defines the scene's gravity for the physics engine
  54476. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54477. * @return a boolean indicating if the physics engine was initialized
  54478. */
  54479. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54480. /**
  54481. * Disables and disposes the physics engine associated with the scene
  54482. */
  54483. disablePhysicsEngine(): void;
  54484. /**
  54485. * Gets a boolean indicating if there is an active physics engine
  54486. * @returns a boolean indicating if there is an active physics engine
  54487. */
  54488. isPhysicsEnabled(): boolean;
  54489. /**
  54490. * Deletes a physics compound impostor
  54491. * @param compound defines the compound to delete
  54492. */
  54493. deleteCompoundImpostor(compound: any): void;
  54494. /**
  54495. * An event triggered when physic simulation is about to be run
  54496. */
  54497. onBeforePhysicsObservable: Observable<Scene>;
  54498. /**
  54499. * An event triggered when physic simulation has been done
  54500. */
  54501. onAfterPhysicsObservable: Observable<Scene>;
  54502. }
  54503. interface AbstractMesh {
  54504. /** @hidden */
  54505. _physicsImpostor: Nullable<PhysicsImpostor>;
  54506. /**
  54507. * Gets or sets impostor used for physic simulation
  54508. * @see http://doc.babylonjs.com/features/physics_engine
  54509. */
  54510. physicsImpostor: Nullable<PhysicsImpostor>;
  54511. /**
  54512. * Gets the current physics impostor
  54513. * @see http://doc.babylonjs.com/features/physics_engine
  54514. * @returns a physics impostor or null
  54515. */
  54516. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54517. /** Apply a physic impulse to the mesh
  54518. * @param force defines the force to apply
  54519. * @param contactPoint defines where to apply the force
  54520. * @returns the current mesh
  54521. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54522. */
  54523. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54524. /**
  54525. * Creates a physic joint between two meshes
  54526. * @param otherMesh defines the other mesh to use
  54527. * @param pivot1 defines the pivot to use on this mesh
  54528. * @param pivot2 defines the pivot to use on the other mesh
  54529. * @param options defines additional options (can be plugin dependent)
  54530. * @returns the current mesh
  54531. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54532. */
  54533. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54534. /** @hidden */
  54535. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54536. }
  54537. /**
  54538. * Defines the physics engine scene component responsible to manage a physics engine
  54539. */
  54540. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54541. /**
  54542. * The component name helpful to identify the component in the list of scene components.
  54543. */
  54544. readonly name: string;
  54545. /**
  54546. * The scene the component belongs to.
  54547. */
  54548. scene: Scene;
  54549. /**
  54550. * Creates a new instance of the component for the given scene
  54551. * @param scene Defines the scene to register the component in
  54552. */
  54553. constructor(scene: Scene);
  54554. /**
  54555. * Registers the component in a given scene
  54556. */
  54557. register(): void;
  54558. /**
  54559. * Rebuilds the elements related to this component in case of
  54560. * context lost for instance.
  54561. */
  54562. rebuild(): void;
  54563. /**
  54564. * Disposes the component and the associated ressources
  54565. */
  54566. dispose(): void;
  54567. }
  54568. }
  54569. declare module BABYLON {
  54570. /**
  54571. * A helper for physics simulations
  54572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54573. */
  54574. export class PhysicsHelper {
  54575. private _scene;
  54576. private _physicsEngine;
  54577. /**
  54578. * Initializes the Physics helper
  54579. * @param scene Babylon.js scene
  54580. */
  54581. constructor(scene: Scene);
  54582. /**
  54583. * Applies a radial explosion impulse
  54584. * @param origin the origin of the explosion
  54585. * @param radiusOrEventOptions the radius or the options of radial explosion
  54586. * @param strength the explosion strength
  54587. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54588. * @returns A physics radial explosion event, or null
  54589. */
  54590. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54591. /**
  54592. * Applies a radial explosion force
  54593. * @param origin the origin of the explosion
  54594. * @param radiusOrEventOptions the radius or the options of radial explosion
  54595. * @param strength the explosion strength
  54596. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54597. * @returns A physics radial explosion event, or null
  54598. */
  54599. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54600. /**
  54601. * Creates a gravitational field
  54602. * @param origin the origin of the explosion
  54603. * @param radiusOrEventOptions the radius or the options of radial explosion
  54604. * @param strength the explosion strength
  54605. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54606. * @returns A physics gravitational field event, or null
  54607. */
  54608. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54609. /**
  54610. * Creates a physics updraft event
  54611. * @param origin the origin of the updraft
  54612. * @param radiusOrEventOptions the radius or the options of the updraft
  54613. * @param strength the strength of the updraft
  54614. * @param height the height of the updraft
  54615. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54616. * @returns A physics updraft event, or null
  54617. */
  54618. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54619. /**
  54620. * Creates a physics vortex event
  54621. * @param origin the of the vortex
  54622. * @param radiusOrEventOptions the radius or the options of the vortex
  54623. * @param strength the strength of the vortex
  54624. * @param height the height of the vortex
  54625. * @returns a Physics vortex event, or null
  54626. * A physics vortex event or null
  54627. */
  54628. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54629. }
  54630. /**
  54631. * Represents a physics radial explosion event
  54632. */
  54633. class PhysicsRadialExplosionEvent {
  54634. private _scene;
  54635. private _options;
  54636. private _sphere;
  54637. private _dataFetched;
  54638. /**
  54639. * Initializes a radial explosioin event
  54640. * @param _scene BabylonJS scene
  54641. * @param _options The options for the vortex event
  54642. */
  54643. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54644. /**
  54645. * Returns the data related to the radial explosion event (sphere).
  54646. * @returns The radial explosion event data
  54647. */
  54648. getData(): PhysicsRadialExplosionEventData;
  54649. /**
  54650. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54651. * @param impostor A physics imposter
  54652. * @param origin the origin of the explosion
  54653. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54654. */
  54655. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54656. /**
  54657. * Triggers affecterd impostors callbacks
  54658. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54659. */
  54660. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54661. /**
  54662. * Disposes the sphere.
  54663. * @param force Specifies if the sphere should be disposed by force
  54664. */
  54665. dispose(force?: boolean): void;
  54666. /*** Helpers ***/
  54667. private _prepareSphere;
  54668. private _intersectsWithSphere;
  54669. }
  54670. /**
  54671. * Represents a gravitational field event
  54672. */
  54673. class PhysicsGravitationalFieldEvent {
  54674. private _physicsHelper;
  54675. private _scene;
  54676. private _origin;
  54677. private _options;
  54678. private _tickCallback;
  54679. private _sphere;
  54680. private _dataFetched;
  54681. /**
  54682. * Initializes the physics gravitational field event
  54683. * @param _physicsHelper A physics helper
  54684. * @param _scene BabylonJS scene
  54685. * @param _origin The origin position of the gravitational field event
  54686. * @param _options The options for the vortex event
  54687. */
  54688. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54689. /**
  54690. * Returns the data related to the gravitational field event (sphere).
  54691. * @returns A gravitational field event
  54692. */
  54693. getData(): PhysicsGravitationalFieldEventData;
  54694. /**
  54695. * Enables the gravitational field.
  54696. */
  54697. enable(): void;
  54698. /**
  54699. * Disables the gravitational field.
  54700. */
  54701. disable(): void;
  54702. /**
  54703. * Disposes the sphere.
  54704. * @param force The force to dispose from the gravitational field event
  54705. */
  54706. dispose(force?: boolean): void;
  54707. private _tick;
  54708. }
  54709. /**
  54710. * Represents a physics updraft event
  54711. */
  54712. class PhysicsUpdraftEvent {
  54713. private _scene;
  54714. private _origin;
  54715. private _options;
  54716. private _physicsEngine;
  54717. private _originTop;
  54718. private _originDirection;
  54719. private _tickCallback;
  54720. private _cylinder;
  54721. private _cylinderPosition;
  54722. private _dataFetched;
  54723. /**
  54724. * Initializes the physics updraft event
  54725. * @param _scene BabylonJS scene
  54726. * @param _origin The origin position of the updraft
  54727. * @param _options The options for the updraft event
  54728. */
  54729. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54730. /**
  54731. * Returns the data related to the updraft event (cylinder).
  54732. * @returns A physics updraft event
  54733. */
  54734. getData(): PhysicsUpdraftEventData;
  54735. /**
  54736. * Enables the updraft.
  54737. */
  54738. enable(): void;
  54739. /**
  54740. * Disables the updraft.
  54741. */
  54742. disable(): void;
  54743. /**
  54744. * Disposes the cylinder.
  54745. * @param force Specifies if the updraft should be disposed by force
  54746. */
  54747. dispose(force?: boolean): void;
  54748. private getImpostorHitData;
  54749. private _tick;
  54750. /*** Helpers ***/
  54751. private _prepareCylinder;
  54752. private _intersectsWithCylinder;
  54753. }
  54754. /**
  54755. * Represents a physics vortex event
  54756. */
  54757. class PhysicsVortexEvent {
  54758. private _scene;
  54759. private _origin;
  54760. private _options;
  54761. private _physicsEngine;
  54762. private _originTop;
  54763. private _tickCallback;
  54764. private _cylinder;
  54765. private _cylinderPosition;
  54766. private _dataFetched;
  54767. /**
  54768. * Initializes the physics vortex event
  54769. * @param _scene The BabylonJS scene
  54770. * @param _origin The origin position of the vortex
  54771. * @param _options The options for the vortex event
  54772. */
  54773. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54774. /**
  54775. * Returns the data related to the vortex event (cylinder).
  54776. * @returns The physics vortex event data
  54777. */
  54778. getData(): PhysicsVortexEventData;
  54779. /**
  54780. * Enables the vortex.
  54781. */
  54782. enable(): void;
  54783. /**
  54784. * Disables the cortex.
  54785. */
  54786. disable(): void;
  54787. /**
  54788. * Disposes the sphere.
  54789. * @param force
  54790. */
  54791. dispose(force?: boolean): void;
  54792. private getImpostorHitData;
  54793. private _tick;
  54794. /*** Helpers ***/
  54795. private _prepareCylinder;
  54796. private _intersectsWithCylinder;
  54797. }
  54798. /**
  54799. * Options fot the radial explosion event
  54800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54801. */
  54802. export class PhysicsRadialExplosionEventOptions {
  54803. /**
  54804. * The radius of the sphere for the radial explosion.
  54805. */
  54806. radius: number;
  54807. /**
  54808. * The strenth of the explosion.
  54809. */
  54810. strength: number;
  54811. /**
  54812. * The strenght of the force in correspondence to the distance of the affected object
  54813. */
  54814. falloff: PhysicsRadialImpulseFalloff;
  54815. /**
  54816. * Sphere options for the radial explosion.
  54817. */
  54818. sphere: {
  54819. segments: number;
  54820. diameter: number;
  54821. };
  54822. /**
  54823. * Sphere options for the radial explosion.
  54824. */
  54825. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54826. }
  54827. /**
  54828. * Options fot the updraft event
  54829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54830. */
  54831. export class PhysicsUpdraftEventOptions {
  54832. /**
  54833. * The radius of the cylinder for the vortex
  54834. */
  54835. radius: number;
  54836. /**
  54837. * The strenth of the updraft.
  54838. */
  54839. strength: number;
  54840. /**
  54841. * The height of the cylinder for the updraft.
  54842. */
  54843. height: number;
  54844. /**
  54845. * The mode for the the updraft.
  54846. */
  54847. updraftMode: PhysicsUpdraftMode;
  54848. }
  54849. /**
  54850. * Options fot the vortex event
  54851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54852. */
  54853. export class PhysicsVortexEventOptions {
  54854. /**
  54855. * The radius of the cylinder for the vortex
  54856. */
  54857. radius: number;
  54858. /**
  54859. * The strenth of the vortex.
  54860. */
  54861. strength: number;
  54862. /**
  54863. * The height of the cylinder for the vortex.
  54864. */
  54865. height: number;
  54866. /**
  54867. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54868. */
  54869. centripetalForceThreshold: number;
  54870. /**
  54871. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54872. */
  54873. centripetalForceMultiplier: number;
  54874. /**
  54875. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54876. */
  54877. centrifugalForceMultiplier: number;
  54878. /**
  54879. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54880. */
  54881. updraftForceMultiplier: number;
  54882. }
  54883. /**
  54884. * The strenght of the force in correspondence to the distance of the affected object
  54885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54886. */
  54887. export enum PhysicsRadialImpulseFalloff {
  54888. /** Defines that impulse is constant in strength across it's whole radius */
  54889. Constant = 0,
  54890. /** Defines that impulse gets weaker if it's further from the origin */
  54891. Linear = 1
  54892. }
  54893. /**
  54894. * The strength of the force in correspondence to the distance of the affected object
  54895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54896. */
  54897. export enum PhysicsUpdraftMode {
  54898. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54899. Center = 0,
  54900. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54901. Perpendicular = 1
  54902. }
  54903. /**
  54904. * Interface for a physics hit data
  54905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54906. */
  54907. export interface PhysicsHitData {
  54908. /**
  54909. * The force applied at the contact point
  54910. */
  54911. force: Vector3;
  54912. /**
  54913. * The contact point
  54914. */
  54915. contactPoint: Vector3;
  54916. /**
  54917. * The distance from the origin to the contact point
  54918. */
  54919. distanceFromOrigin: number;
  54920. }
  54921. /**
  54922. * Interface for radial explosion event data
  54923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54924. */
  54925. export interface PhysicsRadialExplosionEventData {
  54926. /**
  54927. * A sphere used for the radial explosion event
  54928. */
  54929. sphere: Mesh;
  54930. }
  54931. /**
  54932. * Interface for gravitational field event data
  54933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54934. */
  54935. export interface PhysicsGravitationalFieldEventData {
  54936. /**
  54937. * A sphere mesh used for the gravitational field event
  54938. */
  54939. sphere: Mesh;
  54940. }
  54941. /**
  54942. * Interface for updraft event data
  54943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54944. */
  54945. export interface PhysicsUpdraftEventData {
  54946. /**
  54947. * A cylinder used for the updraft event
  54948. */
  54949. cylinder: Mesh;
  54950. }
  54951. /**
  54952. * Interface for vortex event data
  54953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54954. */
  54955. export interface PhysicsVortexEventData {
  54956. /**
  54957. * A cylinder used for the vortex event
  54958. */
  54959. cylinder: Mesh;
  54960. }
  54961. /**
  54962. * Interface for an affected physics impostor
  54963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54964. */
  54965. export interface PhysicsAffectedImpostorWithData {
  54966. /**
  54967. * The impostor affected by the effect
  54968. */
  54969. impostor: PhysicsImpostor;
  54970. /**
  54971. * The data about the hit/horce from the explosion
  54972. */
  54973. hitData: PhysicsHitData;
  54974. }
  54975. }
  54976. declare module BABYLON {
  54977. /** @hidden */
  54978. export var blackAndWhitePixelShader: {
  54979. name: string;
  54980. shader: string;
  54981. };
  54982. }
  54983. declare module BABYLON {
  54984. /**
  54985. * Post process used to render in black and white
  54986. */
  54987. export class BlackAndWhitePostProcess extends PostProcess {
  54988. /**
  54989. * Linear about to convert he result to black and white (default: 1)
  54990. */
  54991. degree: number;
  54992. /**
  54993. * Creates a black and white post process
  54994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54995. * @param name The name of the effect.
  54996. * @param options The required width/height ratio to downsize to before computing the render pass.
  54997. * @param camera The camera to apply the render pass to.
  54998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54999. * @param engine The engine which the post process will be applied. (default: current engine)
  55000. * @param reusable If the post process can be reused on the same frame. (default: false)
  55001. */
  55002. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55003. }
  55004. }
  55005. declare module BABYLON {
  55006. /**
  55007. * This represents a set of one or more post processes in Babylon.
  55008. * A post process can be used to apply a shader to a texture after it is rendered.
  55009. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55010. */
  55011. export class PostProcessRenderEffect {
  55012. private _postProcesses;
  55013. private _getPostProcesses;
  55014. private _singleInstance;
  55015. private _cameras;
  55016. private _indicesForCamera;
  55017. /**
  55018. * Name of the effect
  55019. * @hidden
  55020. */
  55021. _name: string;
  55022. /**
  55023. * Instantiates a post process render effect.
  55024. * A post process can be used to apply a shader to a texture after it is rendered.
  55025. * @param engine The engine the effect is tied to
  55026. * @param name The name of the effect
  55027. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55028. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55029. */
  55030. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55031. /**
  55032. * Checks if all the post processes in the effect are supported.
  55033. */
  55034. readonly isSupported: boolean;
  55035. /**
  55036. * Updates the current state of the effect
  55037. * @hidden
  55038. */
  55039. _update(): void;
  55040. /**
  55041. * Attaches the effect on cameras
  55042. * @param cameras The camera to attach to.
  55043. * @hidden
  55044. */
  55045. _attachCameras(cameras: Camera): void;
  55046. /**
  55047. * Attaches the effect on cameras
  55048. * @param cameras The camera to attach to.
  55049. * @hidden
  55050. */
  55051. _attachCameras(cameras: Camera[]): void;
  55052. /**
  55053. * Detaches the effect on cameras
  55054. * @param cameras The camera to detatch from.
  55055. * @hidden
  55056. */
  55057. _detachCameras(cameras: Camera): void;
  55058. /**
  55059. * Detatches the effect on cameras
  55060. * @param cameras The camera to detatch from.
  55061. * @hidden
  55062. */
  55063. _detachCameras(cameras: Camera[]): void;
  55064. /**
  55065. * Enables the effect on given cameras
  55066. * @param cameras The camera to enable.
  55067. * @hidden
  55068. */
  55069. _enable(cameras: Camera): void;
  55070. /**
  55071. * Enables the effect on given cameras
  55072. * @param cameras The camera to enable.
  55073. * @hidden
  55074. */
  55075. _enable(cameras: Nullable<Camera[]>): void;
  55076. /**
  55077. * Disables the effect on the given cameras
  55078. * @param cameras The camera to disable.
  55079. * @hidden
  55080. */
  55081. _disable(cameras: Camera): void;
  55082. /**
  55083. * Disables the effect on the given cameras
  55084. * @param cameras The camera to disable.
  55085. * @hidden
  55086. */
  55087. _disable(cameras: Nullable<Camera[]>): void;
  55088. /**
  55089. * Gets a list of the post processes contained in the effect.
  55090. * @param camera The camera to get the post processes on.
  55091. * @returns The list of the post processes in the effect.
  55092. */
  55093. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55094. }
  55095. }
  55096. declare module BABYLON {
  55097. /** @hidden */
  55098. export var extractHighlightsPixelShader: {
  55099. name: string;
  55100. shader: string;
  55101. };
  55102. }
  55103. declare module BABYLON {
  55104. /**
  55105. * 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.
  55106. */
  55107. export class ExtractHighlightsPostProcess extends PostProcess {
  55108. /**
  55109. * The luminance threshold, pixels below this value will be set to black.
  55110. */
  55111. threshold: number;
  55112. /** @hidden */
  55113. _exposure: number;
  55114. /**
  55115. * Post process which has the input texture to be used when performing highlight extraction
  55116. * @hidden
  55117. */
  55118. _inputPostProcess: Nullable<PostProcess>;
  55119. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55120. }
  55121. }
  55122. declare module BABYLON {
  55123. /** @hidden */
  55124. export var bloomMergePixelShader: {
  55125. name: string;
  55126. shader: string;
  55127. };
  55128. }
  55129. declare module BABYLON {
  55130. /**
  55131. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55132. */
  55133. export class BloomMergePostProcess extends PostProcess {
  55134. /** Weight of the bloom to be added to the original input. */
  55135. weight: number;
  55136. /**
  55137. * Creates a new instance of @see BloomMergePostProcess
  55138. * @param name The name of the effect.
  55139. * @param originalFromInput Post process which's input will be used for the merge.
  55140. * @param blurred Blurred highlights post process which's output will be used.
  55141. * @param weight Weight of the bloom to be added to the original input.
  55142. * @param options The required width/height ratio to downsize to before computing the render pass.
  55143. * @param camera The camera to apply the render pass to.
  55144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55145. * @param engine The engine which the post process will be applied. (default: current engine)
  55146. * @param reusable If the post process can be reused on the same frame. (default: false)
  55147. * @param textureType Type of textures used when performing the post process. (default: 0)
  55148. * @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)
  55149. */
  55150. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55151. /** Weight of the bloom to be added to the original input. */
  55152. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55153. }
  55154. }
  55155. declare module BABYLON {
  55156. /**
  55157. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55158. */
  55159. export class BloomEffect extends PostProcessRenderEffect {
  55160. private bloomScale;
  55161. /**
  55162. * @hidden Internal
  55163. */
  55164. _effects: Array<PostProcess>;
  55165. /**
  55166. * @hidden Internal
  55167. */
  55168. _downscale: ExtractHighlightsPostProcess;
  55169. private _blurX;
  55170. private _blurY;
  55171. private _merge;
  55172. /**
  55173. * The luminance threshold to find bright areas of the image to bloom.
  55174. */
  55175. threshold: number;
  55176. /**
  55177. * The strength of the bloom.
  55178. */
  55179. weight: number;
  55180. /**
  55181. * Specifies the size of the bloom blur kernel, relative to the final output size
  55182. */
  55183. kernel: number;
  55184. /**
  55185. * Creates a new instance of @see BloomEffect
  55186. * @param scene The scene the effect belongs to.
  55187. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55188. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55189. * @param bloomWeight The the strength of bloom.
  55190. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55191. * @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)
  55192. */
  55193. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55194. /**
  55195. * Disposes each of the internal effects for a given camera.
  55196. * @param camera The camera to dispose the effect on.
  55197. */
  55198. disposeEffects(camera: Camera): void;
  55199. /**
  55200. * @hidden Internal
  55201. */
  55202. _updateEffects(): void;
  55203. /**
  55204. * Internal
  55205. * @returns if all the contained post processes are ready.
  55206. * @hidden
  55207. */
  55208. _isReady(): boolean;
  55209. }
  55210. }
  55211. declare module BABYLON {
  55212. /** @hidden */
  55213. export var chromaticAberrationPixelShader: {
  55214. name: string;
  55215. shader: string;
  55216. };
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55221. */
  55222. export class ChromaticAberrationPostProcess extends PostProcess {
  55223. /**
  55224. * The amount of seperation of rgb channels (default: 30)
  55225. */
  55226. aberrationAmount: number;
  55227. /**
  55228. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55229. */
  55230. radialIntensity: number;
  55231. /**
  55232. * 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))
  55233. */
  55234. direction: Vector2;
  55235. /**
  55236. * 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))
  55237. */
  55238. centerPosition: Vector2;
  55239. /**
  55240. * Creates a new instance ChromaticAberrationPostProcess
  55241. * @param name The name of the effect.
  55242. * @param screenWidth The width of the screen to apply the effect on.
  55243. * @param screenHeight The height of the screen to apply the effect on.
  55244. * @param options The required width/height ratio to downsize to before computing the render pass.
  55245. * @param camera The camera to apply the render pass to.
  55246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55247. * @param engine The engine which the post process will be applied. (default: current engine)
  55248. * @param reusable If the post process can be reused on the same frame. (default: false)
  55249. * @param textureType Type of textures used when performing the post process. (default: 0)
  55250. * @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)
  55251. */
  55252. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55253. }
  55254. }
  55255. declare module BABYLON {
  55256. /** @hidden */
  55257. export var circleOfConfusionPixelShader: {
  55258. name: string;
  55259. shader: string;
  55260. };
  55261. }
  55262. declare module BABYLON {
  55263. /**
  55264. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55265. */
  55266. export class CircleOfConfusionPostProcess extends PostProcess {
  55267. /**
  55268. * 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.
  55269. */
  55270. lensSize: number;
  55271. /**
  55272. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55273. */
  55274. fStop: number;
  55275. /**
  55276. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55277. */
  55278. focusDistance: number;
  55279. /**
  55280. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55281. */
  55282. focalLength: number;
  55283. private _depthTexture;
  55284. /**
  55285. * Creates a new instance CircleOfConfusionPostProcess
  55286. * @param name The name of the effect.
  55287. * @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.
  55288. * @param options The required width/height ratio to downsize to before computing the render pass.
  55289. * @param camera The camera to apply the render pass to.
  55290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55291. * @param engine The engine which the post process will be applied. (default: current engine)
  55292. * @param reusable If the post process can be reused on the same frame. (default: false)
  55293. * @param textureType Type of textures used when performing the post process. (default: 0)
  55294. * @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)
  55295. */
  55296. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55297. /**
  55298. * 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.
  55299. */
  55300. depthTexture: RenderTargetTexture;
  55301. }
  55302. }
  55303. declare module BABYLON {
  55304. /** @hidden */
  55305. export var colorCorrectionPixelShader: {
  55306. name: string;
  55307. shader: string;
  55308. };
  55309. }
  55310. declare module BABYLON {
  55311. /**
  55312. *
  55313. * This post-process allows the modification of rendered colors by using
  55314. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55315. *
  55316. * The object needs to be provided an url to a texture containing the color
  55317. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55318. * Use an image editing software to tweak the LUT to match your needs.
  55319. *
  55320. * For an example of a color LUT, see here:
  55321. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55322. * For explanations on color grading, see here:
  55323. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55324. *
  55325. */
  55326. export class ColorCorrectionPostProcess extends PostProcess {
  55327. private _colorTableTexture;
  55328. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55329. }
  55330. }
  55331. declare module BABYLON {
  55332. /** @hidden */
  55333. export var convolutionPixelShader: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module BABYLON {
  55339. /**
  55340. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55341. * input texture to perform effects such as edge detection or sharpening
  55342. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55343. */
  55344. export class ConvolutionPostProcess extends PostProcess {
  55345. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55346. kernel: number[];
  55347. /**
  55348. * Creates a new instance ConvolutionPostProcess
  55349. * @param name The name of the effect.
  55350. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55351. * @param options The required width/height ratio to downsize to before computing the render pass.
  55352. * @param camera The camera to apply the render pass to.
  55353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55354. * @param engine The engine which the post process will be applied. (default: current engine)
  55355. * @param reusable If the post process can be reused on the same frame. (default: false)
  55356. * @param textureType Type of textures used when performing the post process. (default: 0)
  55357. */
  55358. constructor(name: string,
  55359. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55360. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55361. /**
  55362. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55363. */
  55364. static EdgeDetect0Kernel: number[];
  55365. /**
  55366. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55367. */
  55368. static EdgeDetect1Kernel: number[];
  55369. /**
  55370. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55371. */
  55372. static EdgeDetect2Kernel: number[];
  55373. /**
  55374. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55375. */
  55376. static SharpenKernel: number[];
  55377. /**
  55378. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55379. */
  55380. static EmbossKernel: number[];
  55381. /**
  55382. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55383. */
  55384. static GaussianKernel: number[];
  55385. }
  55386. }
  55387. declare module BABYLON {
  55388. /**
  55389. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55390. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55391. * based on samples that have a large difference in distance than the center pixel.
  55392. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55393. */
  55394. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55395. direction: Vector2;
  55396. /**
  55397. * Creates a new instance CircleOfConfusionPostProcess
  55398. * @param name The name of the effect.
  55399. * @param scene The scene the effect belongs to.
  55400. * @param direction The direction the blur should be applied.
  55401. * @param kernel The size of the kernel used to blur.
  55402. * @param options The required width/height ratio to downsize to before computing the render pass.
  55403. * @param camera The camera to apply the render pass to.
  55404. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55405. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55407. * @param engine The engine which the post process will be applied. (default: current engine)
  55408. * @param reusable If the post process can be reused on the same frame. (default: false)
  55409. * @param textureType Type of textures used when performing the post process. (default: 0)
  55410. * @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)
  55411. */
  55412. 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);
  55413. }
  55414. }
  55415. declare module BABYLON {
  55416. /** @hidden */
  55417. export var depthOfFieldMergePixelShader: {
  55418. name: string;
  55419. shader: string;
  55420. };
  55421. }
  55422. declare module BABYLON {
  55423. /**
  55424. * Options to be set when merging outputs from the default pipeline.
  55425. */
  55426. export class DepthOfFieldMergePostProcessOptions {
  55427. /**
  55428. * The original image to merge on top of
  55429. */
  55430. originalFromInput: PostProcess;
  55431. /**
  55432. * Parameters to perform the merge of the depth of field effect
  55433. */
  55434. depthOfField?: {
  55435. circleOfConfusion: PostProcess;
  55436. blurSteps: Array<PostProcess>;
  55437. };
  55438. /**
  55439. * Parameters to perform the merge of bloom effect
  55440. */
  55441. bloom?: {
  55442. blurred: PostProcess;
  55443. weight: number;
  55444. };
  55445. }
  55446. /**
  55447. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55448. */
  55449. export class DepthOfFieldMergePostProcess extends PostProcess {
  55450. private blurSteps;
  55451. /**
  55452. * Creates a new instance of DepthOfFieldMergePostProcess
  55453. * @param name The name of the effect.
  55454. * @param originalFromInput Post process which's input will be used for the merge.
  55455. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55456. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55457. * @param options The required width/height ratio to downsize to before computing the render pass.
  55458. * @param camera The camera to apply the render pass to.
  55459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55460. * @param engine The engine which the post process will be applied. (default: current engine)
  55461. * @param reusable If the post process can be reused on the same frame. (default: false)
  55462. * @param textureType Type of textures used when performing the post process. (default: 0)
  55463. * @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)
  55464. */
  55465. 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);
  55466. /**
  55467. * Updates the effect with the current post process compile time values and recompiles the shader.
  55468. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55469. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55470. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55471. * @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
  55472. * @param onCompiled Called when the shader has been compiled.
  55473. * @param onError Called if there is an error when compiling a shader.
  55474. */
  55475. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55476. }
  55477. }
  55478. declare module BABYLON {
  55479. /**
  55480. * Specifies the level of max blur that should be applied when using the depth of field effect
  55481. */
  55482. export enum DepthOfFieldEffectBlurLevel {
  55483. /**
  55484. * Subtle blur
  55485. */
  55486. Low = 0,
  55487. /**
  55488. * Medium blur
  55489. */
  55490. Medium = 1,
  55491. /**
  55492. * Large blur
  55493. */
  55494. High = 2
  55495. }
  55496. /**
  55497. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55498. */
  55499. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55500. private _circleOfConfusion;
  55501. /**
  55502. * @hidden Internal, blurs from high to low
  55503. */
  55504. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55505. private _depthOfFieldBlurY;
  55506. private _dofMerge;
  55507. /**
  55508. * @hidden Internal post processes in depth of field effect
  55509. */
  55510. _effects: Array<PostProcess>;
  55511. /**
  55512. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55513. */
  55514. focalLength: number;
  55515. /**
  55516. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55517. */
  55518. fStop: number;
  55519. /**
  55520. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55521. */
  55522. focusDistance: number;
  55523. /**
  55524. * 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.
  55525. */
  55526. lensSize: number;
  55527. /**
  55528. * Creates a new instance DepthOfFieldEffect
  55529. * @param scene The scene the effect belongs to.
  55530. * @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.
  55531. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55532. * @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)
  55533. */
  55534. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55535. /**
  55536. * Get the current class name of the current effet
  55537. * @returns "DepthOfFieldEffect"
  55538. */
  55539. getClassName(): string;
  55540. /**
  55541. * 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.
  55542. */
  55543. depthTexture: RenderTargetTexture;
  55544. /**
  55545. * Disposes each of the internal effects for a given camera.
  55546. * @param camera The camera to dispose the effect on.
  55547. */
  55548. disposeEffects(camera: Camera): void;
  55549. /**
  55550. * @hidden Internal
  55551. */
  55552. _updateEffects(): void;
  55553. /**
  55554. * Internal
  55555. * @returns if all the contained post processes are ready.
  55556. * @hidden
  55557. */
  55558. _isReady(): boolean;
  55559. }
  55560. }
  55561. declare module BABYLON {
  55562. /** @hidden */
  55563. export var displayPassPixelShader: {
  55564. name: string;
  55565. shader: string;
  55566. };
  55567. }
  55568. declare module BABYLON {
  55569. /**
  55570. * DisplayPassPostProcess which produces an output the same as it's input
  55571. */
  55572. export class DisplayPassPostProcess extends PostProcess {
  55573. /**
  55574. * Creates the DisplayPassPostProcess
  55575. * @param name The name of the effect.
  55576. * @param options The required width/height ratio to downsize to before computing the render pass.
  55577. * @param camera The camera to apply the render pass to.
  55578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55579. * @param engine The engine which the post process will be applied. (default: current engine)
  55580. * @param reusable If the post process can be reused on the same frame. (default: false)
  55581. */
  55582. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55583. }
  55584. }
  55585. declare module BABYLON {
  55586. /** @hidden */
  55587. export var filterPixelShader: {
  55588. name: string;
  55589. shader: string;
  55590. };
  55591. }
  55592. declare module BABYLON {
  55593. /**
  55594. * Applies a kernel filter to the image
  55595. */
  55596. export class FilterPostProcess extends PostProcess {
  55597. /** The matrix to be applied to the image */
  55598. kernelMatrix: Matrix;
  55599. /**
  55600. *
  55601. * @param name The name of the effect.
  55602. * @param kernelMatrix The matrix to be applied to the image
  55603. * @param options The required width/height ratio to downsize to before computing the render pass.
  55604. * @param camera The camera to apply the render pass to.
  55605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55606. * @param engine The engine which the post process will be applied. (default: current engine)
  55607. * @param reusable If the post process can be reused on the same frame. (default: false)
  55608. */
  55609. constructor(name: string,
  55610. /** The matrix to be applied to the image */
  55611. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55612. }
  55613. }
  55614. declare module BABYLON {
  55615. /** @hidden */
  55616. export var fxaaPixelShader: {
  55617. name: string;
  55618. shader: string;
  55619. };
  55620. }
  55621. declare module BABYLON {
  55622. /** @hidden */
  55623. export var fxaaVertexShader: {
  55624. name: string;
  55625. shader: string;
  55626. };
  55627. }
  55628. declare module BABYLON {
  55629. /**
  55630. * Fxaa post process
  55631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55632. */
  55633. export class FxaaPostProcess extends PostProcess {
  55634. /** @hidden */
  55635. texelWidth: number;
  55636. /** @hidden */
  55637. texelHeight: number;
  55638. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55639. private _getDefines;
  55640. }
  55641. }
  55642. declare module BABYLON {
  55643. /** @hidden */
  55644. export var grainPixelShader: {
  55645. name: string;
  55646. shader: string;
  55647. };
  55648. }
  55649. declare module BABYLON {
  55650. /**
  55651. * The GrainPostProcess adds noise to the image at mid luminance levels
  55652. */
  55653. export class GrainPostProcess extends PostProcess {
  55654. /**
  55655. * The intensity of the grain added (default: 30)
  55656. */
  55657. intensity: number;
  55658. /**
  55659. * If the grain should be randomized on every frame
  55660. */
  55661. animated: boolean;
  55662. /**
  55663. * Creates a new instance of @see GrainPostProcess
  55664. * @param name The name of the effect.
  55665. * @param options The required width/height ratio to downsize to before computing the render pass.
  55666. * @param camera The camera to apply the render pass to.
  55667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55668. * @param engine The engine which the post process will be applied. (default: current engine)
  55669. * @param reusable If the post process can be reused on the same frame. (default: false)
  55670. * @param textureType Type of textures used when performing the post process. (default: 0)
  55671. * @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)
  55672. */
  55673. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55674. }
  55675. }
  55676. declare module BABYLON {
  55677. /** @hidden */
  55678. export var highlightsPixelShader: {
  55679. name: string;
  55680. shader: string;
  55681. };
  55682. }
  55683. declare module BABYLON {
  55684. /**
  55685. * Extracts highlights from the image
  55686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55687. */
  55688. export class HighlightsPostProcess extends PostProcess {
  55689. /**
  55690. * Extracts highlights from the image
  55691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55692. * @param name The name of the effect.
  55693. * @param options The required width/height ratio to downsize to before computing the render pass.
  55694. * @param camera The camera to apply the render pass to.
  55695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55696. * @param engine The engine which the post process will be applied. (default: current engine)
  55697. * @param reusable If the post process can be reused on the same frame. (default: false)
  55698. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55699. */
  55700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55701. }
  55702. }
  55703. declare module BABYLON {
  55704. /** @hidden */
  55705. export var mrtFragmentDeclaration: {
  55706. name: string;
  55707. shader: string;
  55708. };
  55709. }
  55710. declare module BABYLON {
  55711. /** @hidden */
  55712. export var geometryPixelShader: {
  55713. name: string;
  55714. shader: string;
  55715. };
  55716. }
  55717. declare module BABYLON {
  55718. /** @hidden */
  55719. export var geometryVertexShader: {
  55720. name: string;
  55721. shader: string;
  55722. };
  55723. }
  55724. declare module BABYLON {
  55725. /** @hidden */
  55726. interface ISavedTransformationMatrix {
  55727. world: Matrix;
  55728. viewProjection: Matrix;
  55729. }
  55730. /**
  55731. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55732. */
  55733. export class GeometryBufferRenderer {
  55734. /**
  55735. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55736. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55737. */
  55738. static readonly POSITION_TEXTURE_TYPE: number;
  55739. /**
  55740. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55741. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55742. */
  55743. static readonly VELOCITY_TEXTURE_TYPE: number;
  55744. /**
  55745. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55746. * in order to compute objects velocities when enableVelocity is set to "true"
  55747. * @hidden
  55748. */
  55749. _previousTransformationMatrices: {
  55750. [index: number]: ISavedTransformationMatrix;
  55751. };
  55752. /**
  55753. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55754. * in order to compute objects velocities when enableVelocity is set to "true"
  55755. * @hidden
  55756. */
  55757. _previousBonesTransformationMatrices: {
  55758. [index: number]: Float32Array;
  55759. };
  55760. /**
  55761. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55762. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55763. */
  55764. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55765. private _scene;
  55766. private _multiRenderTarget;
  55767. private _ratio;
  55768. private _enablePosition;
  55769. private _enableVelocity;
  55770. private _positionIndex;
  55771. private _velocityIndex;
  55772. protected _effect: Effect;
  55773. protected _cachedDefines: string;
  55774. /**
  55775. * Set the render list (meshes to be rendered) used in the G buffer.
  55776. */
  55777. renderList: Mesh[];
  55778. /**
  55779. * Gets wether or not G buffer are supported by the running hardware.
  55780. * This requires draw buffer supports
  55781. */
  55782. readonly isSupported: boolean;
  55783. /**
  55784. * Returns the index of the given texture type in the G-Buffer textures array
  55785. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55786. * @returns the index of the given texture type in the G-Buffer textures array
  55787. */
  55788. getTextureIndex(textureType: number): number;
  55789. /**
  55790. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55791. */
  55792. /**
  55793. * Sets whether or not objects positions are enabled for the G buffer.
  55794. */
  55795. enablePosition: boolean;
  55796. /**
  55797. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55798. */
  55799. /**
  55800. * Sets wether or not objects velocities are enabled for the G buffer.
  55801. */
  55802. enableVelocity: boolean;
  55803. /**
  55804. * Gets the scene associated with the buffer.
  55805. */
  55806. readonly scene: Scene;
  55807. /**
  55808. * Gets the ratio used by the buffer during its creation.
  55809. * How big is the buffer related to the main canvas.
  55810. */
  55811. readonly ratio: number;
  55812. /** @hidden */
  55813. static _SceneComponentInitialization: (scene: Scene) => void;
  55814. /**
  55815. * Creates a new G Buffer for the scene
  55816. * @param scene The scene the buffer belongs to
  55817. * @param ratio How big is the buffer related to the main canvas.
  55818. */
  55819. constructor(scene: Scene, ratio?: number);
  55820. /**
  55821. * Checks wether everything is ready to render a submesh to the G buffer.
  55822. * @param subMesh the submesh to check readiness for
  55823. * @param useInstances is the mesh drawn using instance or not
  55824. * @returns true if ready otherwise false
  55825. */
  55826. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55827. /**
  55828. * Gets the current underlying G Buffer.
  55829. * @returns the buffer
  55830. */
  55831. getGBuffer(): MultiRenderTarget;
  55832. /**
  55833. * Gets the number of samples used to render the buffer (anti aliasing).
  55834. */
  55835. /**
  55836. * Sets the number of samples used to render the buffer (anti aliasing).
  55837. */
  55838. samples: number;
  55839. /**
  55840. * Disposes the renderer and frees up associated resources.
  55841. */
  55842. dispose(): void;
  55843. protected _createRenderTargets(): void;
  55844. private _copyBonesTransformationMatrices;
  55845. }
  55846. }
  55847. declare module BABYLON {
  55848. interface Scene {
  55849. /** @hidden (Backing field) */
  55850. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55851. /**
  55852. * Gets or Sets the current geometry buffer associated to the scene.
  55853. */
  55854. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55855. /**
  55856. * Enables a GeometryBufferRender and associates it with the scene
  55857. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55858. * @returns the GeometryBufferRenderer
  55859. */
  55860. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55861. /**
  55862. * Disables the GeometryBufferRender associated with the scene
  55863. */
  55864. disableGeometryBufferRenderer(): void;
  55865. }
  55866. /**
  55867. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55868. * in several rendering techniques.
  55869. */
  55870. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55871. /**
  55872. * The component name helpful to identify the component in the list of scene components.
  55873. */
  55874. readonly name: string;
  55875. /**
  55876. * The scene the component belongs to.
  55877. */
  55878. scene: Scene;
  55879. /**
  55880. * Creates a new instance of the component for the given scene
  55881. * @param scene Defines the scene to register the component in
  55882. */
  55883. constructor(scene: Scene);
  55884. /**
  55885. * Registers the component in a given scene
  55886. */
  55887. register(): void;
  55888. /**
  55889. * Rebuilds the elements related to this component in case of
  55890. * context lost for instance.
  55891. */
  55892. rebuild(): void;
  55893. /**
  55894. * Disposes the component and the associated ressources
  55895. */
  55896. dispose(): void;
  55897. private _gatherRenderTargets;
  55898. }
  55899. }
  55900. declare module BABYLON {
  55901. /** @hidden */
  55902. export var motionBlurPixelShader: {
  55903. name: string;
  55904. shader: string;
  55905. };
  55906. }
  55907. declare module BABYLON {
  55908. /**
  55909. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55910. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55911. * As an example, all you have to do is to create the post-process:
  55912. * var mb = new BABYLON.MotionBlurPostProcess(
  55913. * 'mb', // The name of the effect.
  55914. * scene, // The scene containing the objects to blur according to their velocity.
  55915. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55916. * camera // The camera to apply the render pass to.
  55917. * );
  55918. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55919. */
  55920. export class MotionBlurPostProcess extends PostProcess {
  55921. /**
  55922. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55923. */
  55924. motionStrength: number;
  55925. /**
  55926. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55927. */
  55928. /**
  55929. * Sets the number of iterations to be used for motion blur quality
  55930. */
  55931. motionBlurSamples: number;
  55932. private _motionBlurSamples;
  55933. private _geometryBufferRenderer;
  55934. /**
  55935. * Creates a new instance MotionBlurPostProcess
  55936. * @param name The name of the effect.
  55937. * @param scene The scene containing the objects to blur according to their velocity.
  55938. * @param options The required width/height ratio to downsize to before computing the render pass.
  55939. * @param camera The camera to apply the render pass to.
  55940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55941. * @param engine The engine which the post process will be applied. (default: current engine)
  55942. * @param reusable If the post process can be reused on the same frame. (default: false)
  55943. * @param textureType Type of textures used when performing the post process. (default: 0)
  55944. * @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)
  55945. */
  55946. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55947. /**
  55948. * Excludes the given skinned mesh from computing bones velocities.
  55949. * 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.
  55950. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55951. */
  55952. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55953. /**
  55954. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55955. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55956. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55957. */
  55958. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55959. /**
  55960. * Disposes the post process.
  55961. * @param camera The camera to dispose the post process on.
  55962. */
  55963. dispose(camera?: Camera): void;
  55964. }
  55965. }
  55966. declare module BABYLON {
  55967. /** @hidden */
  55968. export var refractionPixelShader: {
  55969. name: string;
  55970. shader: string;
  55971. };
  55972. }
  55973. declare module BABYLON {
  55974. /**
  55975. * Post process which applies a refractin texture
  55976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55977. */
  55978. export class RefractionPostProcess extends PostProcess {
  55979. /** the base color of the refraction (used to taint the rendering) */
  55980. color: Color3;
  55981. /** simulated refraction depth */
  55982. depth: number;
  55983. /** the coefficient of the base color (0 to remove base color tainting) */
  55984. colorLevel: number;
  55985. private _refTexture;
  55986. private _ownRefractionTexture;
  55987. /**
  55988. * Gets or sets the refraction texture
  55989. * Please note that you are responsible for disposing the texture if you set it manually
  55990. */
  55991. refractionTexture: Texture;
  55992. /**
  55993. * Initializes the RefractionPostProcess
  55994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55995. * @param name The name of the effect.
  55996. * @param refractionTextureUrl Url of the refraction texture to use
  55997. * @param color the base color of the refraction (used to taint the rendering)
  55998. * @param depth simulated refraction depth
  55999. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56000. * @param camera The camera to apply the render pass to.
  56001. * @param options The required width/height ratio to downsize to before computing the render pass.
  56002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56003. * @param engine The engine which the post process will be applied. (default: current engine)
  56004. * @param reusable If the post process can be reused on the same frame. (default: false)
  56005. */
  56006. constructor(name: string, refractionTextureUrl: string,
  56007. /** the base color of the refraction (used to taint the rendering) */
  56008. color: Color3,
  56009. /** simulated refraction depth */
  56010. depth: number,
  56011. /** the coefficient of the base color (0 to remove base color tainting) */
  56012. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56013. /**
  56014. * Disposes of the post process
  56015. * @param camera Camera to dispose post process on
  56016. */
  56017. dispose(camera: Camera): void;
  56018. }
  56019. }
  56020. declare module BABYLON {
  56021. /** @hidden */
  56022. export var sharpenPixelShader: {
  56023. name: string;
  56024. shader: string;
  56025. };
  56026. }
  56027. declare module BABYLON {
  56028. /**
  56029. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56030. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56031. */
  56032. export class SharpenPostProcess extends PostProcess {
  56033. /**
  56034. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56035. */
  56036. colorAmount: number;
  56037. /**
  56038. * How much sharpness should be applied (default: 0.3)
  56039. */
  56040. edgeAmount: number;
  56041. /**
  56042. * Creates a new instance ConvolutionPostProcess
  56043. * @param name The name of the effect.
  56044. * @param options The required width/height ratio to downsize to before computing the render pass.
  56045. * @param camera The camera to apply the render pass to.
  56046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56047. * @param engine The engine which the post process will be applied. (default: current engine)
  56048. * @param reusable If the post process can be reused on the same frame. (default: false)
  56049. * @param textureType Type of textures used when performing the post process. (default: 0)
  56050. * @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)
  56051. */
  56052. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * PostProcessRenderPipeline
  56058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56059. */
  56060. export class PostProcessRenderPipeline {
  56061. private engine;
  56062. private _renderEffects;
  56063. private _renderEffectsForIsolatedPass;
  56064. /**
  56065. * List of inspectable custom properties (used by the Inspector)
  56066. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56067. */
  56068. inspectableCustomProperties: IInspectable[];
  56069. /**
  56070. * @hidden
  56071. */
  56072. protected _cameras: Camera[];
  56073. /** @hidden */
  56074. _name: string;
  56075. /**
  56076. * Gets pipeline name
  56077. */
  56078. readonly name: string;
  56079. /**
  56080. * Initializes a PostProcessRenderPipeline
  56081. * @param engine engine to add the pipeline to
  56082. * @param name name of the pipeline
  56083. */
  56084. constructor(engine: Engine, name: string);
  56085. /**
  56086. * Gets the class name
  56087. * @returns "PostProcessRenderPipeline"
  56088. */
  56089. getClassName(): string;
  56090. /**
  56091. * If all the render effects in the pipeline are supported
  56092. */
  56093. readonly isSupported: boolean;
  56094. /**
  56095. * Adds an effect to the pipeline
  56096. * @param renderEffect the effect to add
  56097. */
  56098. addEffect(renderEffect: PostProcessRenderEffect): void;
  56099. /** @hidden */
  56100. _rebuild(): void;
  56101. /** @hidden */
  56102. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56103. /** @hidden */
  56104. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56105. /** @hidden */
  56106. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56107. /** @hidden */
  56108. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56109. /** @hidden */
  56110. _attachCameras(cameras: Camera, unique: boolean): void;
  56111. /** @hidden */
  56112. _attachCameras(cameras: Camera[], unique: boolean): void;
  56113. /** @hidden */
  56114. _detachCameras(cameras: Camera): void;
  56115. /** @hidden */
  56116. _detachCameras(cameras: Nullable<Camera[]>): void;
  56117. /** @hidden */
  56118. _update(): void;
  56119. /** @hidden */
  56120. _reset(): void;
  56121. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56122. /**
  56123. * Disposes of the pipeline
  56124. */
  56125. dispose(): void;
  56126. }
  56127. }
  56128. declare module BABYLON {
  56129. /**
  56130. * PostProcessRenderPipelineManager class
  56131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56132. */
  56133. export class PostProcessRenderPipelineManager {
  56134. private _renderPipelines;
  56135. /**
  56136. * Initializes a PostProcessRenderPipelineManager
  56137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56138. */
  56139. constructor();
  56140. /**
  56141. * Gets the list of supported render pipelines
  56142. */
  56143. readonly supportedPipelines: PostProcessRenderPipeline[];
  56144. /**
  56145. * Adds a pipeline to the manager
  56146. * @param renderPipeline The pipeline to add
  56147. */
  56148. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56149. /**
  56150. * Attaches a camera to the pipeline
  56151. * @param renderPipelineName The name of the pipeline to attach to
  56152. * @param cameras the camera to attach
  56153. * @param unique if the camera can be attached multiple times to the pipeline
  56154. */
  56155. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56156. /**
  56157. * Detaches a camera from the pipeline
  56158. * @param renderPipelineName The name of the pipeline to detach from
  56159. * @param cameras the camera to detach
  56160. */
  56161. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56162. /**
  56163. * Enables an effect by name on a pipeline
  56164. * @param renderPipelineName the name of the pipeline to enable the effect in
  56165. * @param renderEffectName the name of the effect to enable
  56166. * @param cameras the cameras that the effect should be enabled on
  56167. */
  56168. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56169. /**
  56170. * Disables an effect by name on a pipeline
  56171. * @param renderPipelineName the name of the pipeline to disable the effect in
  56172. * @param renderEffectName the name of the effect to disable
  56173. * @param cameras the cameras that the effect should be disabled on
  56174. */
  56175. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56176. /**
  56177. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56178. */
  56179. update(): void;
  56180. /** @hidden */
  56181. _rebuild(): void;
  56182. /**
  56183. * Disposes of the manager and pipelines
  56184. */
  56185. dispose(): void;
  56186. }
  56187. }
  56188. declare module BABYLON {
  56189. interface Scene {
  56190. /** @hidden (Backing field) */
  56191. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56192. /**
  56193. * Gets the postprocess render pipeline manager
  56194. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56195. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56196. */
  56197. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56198. }
  56199. /**
  56200. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56201. */
  56202. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56203. /**
  56204. * The component name helpfull to identify the component in the list of scene components.
  56205. */
  56206. readonly name: string;
  56207. /**
  56208. * The scene the component belongs to.
  56209. */
  56210. scene: Scene;
  56211. /**
  56212. * Creates a new instance of the component for the given scene
  56213. * @param scene Defines the scene to register the component in
  56214. */
  56215. constructor(scene: Scene);
  56216. /**
  56217. * Registers the component in a given scene
  56218. */
  56219. register(): void;
  56220. /**
  56221. * Rebuilds the elements related to this component in case of
  56222. * context lost for instance.
  56223. */
  56224. rebuild(): void;
  56225. /**
  56226. * Disposes the component and the associated ressources
  56227. */
  56228. dispose(): void;
  56229. private _gatherRenderTargets;
  56230. }
  56231. }
  56232. declare module BABYLON {
  56233. /**
  56234. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56235. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56236. */
  56237. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56238. private _scene;
  56239. private _camerasToBeAttached;
  56240. /**
  56241. * ID of the sharpen post process,
  56242. */
  56243. private readonly SharpenPostProcessId;
  56244. /**
  56245. * @ignore
  56246. * ID of the image processing post process;
  56247. */
  56248. readonly ImageProcessingPostProcessId: string;
  56249. /**
  56250. * @ignore
  56251. * ID of the Fast Approximate Anti-Aliasing post process;
  56252. */
  56253. readonly FxaaPostProcessId: string;
  56254. /**
  56255. * ID of the chromatic aberration post process,
  56256. */
  56257. private readonly ChromaticAberrationPostProcessId;
  56258. /**
  56259. * ID of the grain post process
  56260. */
  56261. private readonly GrainPostProcessId;
  56262. /**
  56263. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56264. */
  56265. sharpen: SharpenPostProcess;
  56266. private _sharpenEffect;
  56267. private bloom;
  56268. /**
  56269. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56270. */
  56271. depthOfField: DepthOfFieldEffect;
  56272. /**
  56273. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56274. */
  56275. fxaa: FxaaPostProcess;
  56276. /**
  56277. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56278. */
  56279. imageProcessing: ImageProcessingPostProcess;
  56280. /**
  56281. * Chromatic aberration post process which will shift rgb colors in the image
  56282. */
  56283. chromaticAberration: ChromaticAberrationPostProcess;
  56284. private _chromaticAberrationEffect;
  56285. /**
  56286. * Grain post process which add noise to the image
  56287. */
  56288. grain: GrainPostProcess;
  56289. private _grainEffect;
  56290. /**
  56291. * Glow post process which adds a glow to emissive areas of the image
  56292. */
  56293. private _glowLayer;
  56294. /**
  56295. * Animations which can be used to tweak settings over a period of time
  56296. */
  56297. animations: Animation[];
  56298. private _imageProcessingConfigurationObserver;
  56299. private _sharpenEnabled;
  56300. private _bloomEnabled;
  56301. private _depthOfFieldEnabled;
  56302. private _depthOfFieldBlurLevel;
  56303. private _fxaaEnabled;
  56304. private _imageProcessingEnabled;
  56305. private _defaultPipelineTextureType;
  56306. private _bloomScale;
  56307. private _chromaticAberrationEnabled;
  56308. private _grainEnabled;
  56309. private _buildAllowed;
  56310. /**
  56311. * Gets active scene
  56312. */
  56313. readonly scene: Scene;
  56314. /**
  56315. * Enable or disable the sharpen process from the pipeline
  56316. */
  56317. sharpenEnabled: boolean;
  56318. private _resizeObserver;
  56319. private _hardwareScaleLevel;
  56320. private _bloomKernel;
  56321. /**
  56322. * Specifies the size of the bloom blur kernel, relative to the final output size
  56323. */
  56324. bloomKernel: number;
  56325. /**
  56326. * Specifies the weight of the bloom in the final rendering
  56327. */
  56328. private _bloomWeight;
  56329. /**
  56330. * Specifies the luma threshold for the area that will be blurred by the bloom
  56331. */
  56332. private _bloomThreshold;
  56333. private _hdr;
  56334. /**
  56335. * The strength of the bloom.
  56336. */
  56337. bloomWeight: number;
  56338. /**
  56339. * The strength of the bloom.
  56340. */
  56341. bloomThreshold: number;
  56342. /**
  56343. * The scale of the bloom, lower value will provide better performance.
  56344. */
  56345. bloomScale: number;
  56346. /**
  56347. * Enable or disable the bloom from the pipeline
  56348. */
  56349. bloomEnabled: boolean;
  56350. private _rebuildBloom;
  56351. /**
  56352. * If the depth of field is enabled.
  56353. */
  56354. depthOfFieldEnabled: boolean;
  56355. /**
  56356. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56357. */
  56358. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56359. /**
  56360. * If the anti aliasing is enabled.
  56361. */
  56362. fxaaEnabled: boolean;
  56363. private _samples;
  56364. /**
  56365. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56366. */
  56367. samples: number;
  56368. /**
  56369. * If image processing is enabled.
  56370. */
  56371. imageProcessingEnabled: boolean;
  56372. /**
  56373. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56374. */
  56375. glowLayerEnabled: boolean;
  56376. /**
  56377. * Gets the glow layer (or null if not defined)
  56378. */
  56379. readonly glowLayer: Nullable<GlowLayer>;
  56380. /**
  56381. * Enable or disable the chromaticAberration process from the pipeline
  56382. */
  56383. chromaticAberrationEnabled: boolean;
  56384. /**
  56385. * Enable or disable the grain process from the pipeline
  56386. */
  56387. grainEnabled: boolean;
  56388. /**
  56389. * @constructor
  56390. * @param name - The rendering pipeline name (default: "")
  56391. * @param hdr - If high dynamic range textures should be used (default: true)
  56392. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56393. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56394. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56395. */
  56396. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56397. /**
  56398. * Get the class name
  56399. * @returns "DefaultRenderingPipeline"
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Force the compilation of the entire pipeline.
  56404. */
  56405. prepare(): void;
  56406. private _hasCleared;
  56407. private _prevPostProcess;
  56408. private _prevPrevPostProcess;
  56409. private _setAutoClearAndTextureSharing;
  56410. private _depthOfFieldSceneObserver;
  56411. private _buildPipeline;
  56412. private _disposePostProcesses;
  56413. /**
  56414. * Adds a camera to the pipeline
  56415. * @param camera the camera to be added
  56416. */
  56417. addCamera(camera: Camera): void;
  56418. /**
  56419. * Removes a camera from the pipeline
  56420. * @param camera the camera to remove
  56421. */
  56422. removeCamera(camera: Camera): void;
  56423. /**
  56424. * Dispose of the pipeline and stop all post processes
  56425. */
  56426. dispose(): void;
  56427. /**
  56428. * Serialize the rendering pipeline (Used when exporting)
  56429. * @returns the serialized object
  56430. */
  56431. serialize(): any;
  56432. /**
  56433. * Parse the serialized pipeline
  56434. * @param source Source pipeline.
  56435. * @param scene The scene to load the pipeline to.
  56436. * @param rootUrl The URL of the serialized pipeline.
  56437. * @returns An instantiated pipeline from the serialized object.
  56438. */
  56439. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /** @hidden */
  56444. export var lensHighlightsPixelShader: {
  56445. name: string;
  56446. shader: string;
  56447. };
  56448. }
  56449. declare module BABYLON {
  56450. /** @hidden */
  56451. export var depthOfFieldPixelShader: {
  56452. name: string;
  56453. shader: string;
  56454. };
  56455. }
  56456. declare module BABYLON {
  56457. /**
  56458. * BABYLON.JS Chromatic Aberration GLSL Shader
  56459. * Author: Olivier Guyot
  56460. * Separates very slightly R, G and B colors on the edges of the screen
  56461. * Inspired by Francois Tarlier & Martins Upitis
  56462. */
  56463. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56464. /**
  56465. * @ignore
  56466. * The chromatic aberration PostProcess id in the pipeline
  56467. */
  56468. LensChromaticAberrationEffect: string;
  56469. /**
  56470. * @ignore
  56471. * The highlights enhancing PostProcess id in the pipeline
  56472. */
  56473. HighlightsEnhancingEffect: string;
  56474. /**
  56475. * @ignore
  56476. * The depth-of-field PostProcess id in the pipeline
  56477. */
  56478. LensDepthOfFieldEffect: string;
  56479. private _scene;
  56480. private _depthTexture;
  56481. private _grainTexture;
  56482. private _chromaticAberrationPostProcess;
  56483. private _highlightsPostProcess;
  56484. private _depthOfFieldPostProcess;
  56485. private _edgeBlur;
  56486. private _grainAmount;
  56487. private _chromaticAberration;
  56488. private _distortion;
  56489. private _highlightsGain;
  56490. private _highlightsThreshold;
  56491. private _dofDistance;
  56492. private _dofAperture;
  56493. private _dofDarken;
  56494. private _dofPentagon;
  56495. private _blurNoise;
  56496. /**
  56497. * @constructor
  56498. *
  56499. * Effect parameters are as follow:
  56500. * {
  56501. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56502. * edge_blur: number; // from 0 to x (1 for realism)
  56503. * distortion: number; // from 0 to x (1 for realism)
  56504. * grain_amount: number; // from 0 to 1
  56505. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56506. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56507. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56508. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56509. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56510. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56511. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56512. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56513. * }
  56514. * Note: if an effect parameter is unset, effect is disabled
  56515. *
  56516. * @param name The rendering pipeline name
  56517. * @param parameters - An object containing all parameters (see above)
  56518. * @param scene The scene linked to this pipeline
  56519. * @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)
  56520. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56521. */
  56522. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56523. /**
  56524. * Get the class name
  56525. * @returns "LensRenderingPipeline"
  56526. */
  56527. getClassName(): string;
  56528. /**
  56529. * Gets associated scene
  56530. */
  56531. readonly scene: Scene;
  56532. /**
  56533. * Gets or sets the edge blur
  56534. */
  56535. edgeBlur: number;
  56536. /**
  56537. * Gets or sets the grain amount
  56538. */
  56539. grainAmount: number;
  56540. /**
  56541. * Gets or sets the chromatic aberration amount
  56542. */
  56543. chromaticAberration: number;
  56544. /**
  56545. * Gets or sets the depth of field aperture
  56546. */
  56547. dofAperture: number;
  56548. /**
  56549. * Gets or sets the edge distortion
  56550. */
  56551. edgeDistortion: number;
  56552. /**
  56553. * Gets or sets the depth of field distortion
  56554. */
  56555. dofDistortion: number;
  56556. /**
  56557. * Gets or sets the darken out of focus amount
  56558. */
  56559. darkenOutOfFocus: number;
  56560. /**
  56561. * Gets or sets a boolean indicating if blur noise is enabled
  56562. */
  56563. blurNoise: boolean;
  56564. /**
  56565. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56566. */
  56567. pentagonBokeh: boolean;
  56568. /**
  56569. * Gets or sets the highlight grain amount
  56570. */
  56571. highlightsGain: number;
  56572. /**
  56573. * Gets or sets the highlight threshold
  56574. */
  56575. highlightsThreshold: number;
  56576. /**
  56577. * Sets the amount of blur at the edges
  56578. * @param amount blur amount
  56579. */
  56580. setEdgeBlur(amount: number): void;
  56581. /**
  56582. * Sets edge blur to 0
  56583. */
  56584. disableEdgeBlur(): void;
  56585. /**
  56586. * Sets the amout of grain
  56587. * @param amount Amount of grain
  56588. */
  56589. setGrainAmount(amount: number): void;
  56590. /**
  56591. * Set grain amount to 0
  56592. */
  56593. disableGrain(): void;
  56594. /**
  56595. * Sets the chromatic aberration amount
  56596. * @param amount amount of chromatic aberration
  56597. */
  56598. setChromaticAberration(amount: number): void;
  56599. /**
  56600. * Sets chromatic aberration amount to 0
  56601. */
  56602. disableChromaticAberration(): void;
  56603. /**
  56604. * Sets the EdgeDistortion amount
  56605. * @param amount amount of EdgeDistortion
  56606. */
  56607. setEdgeDistortion(amount: number): void;
  56608. /**
  56609. * Sets edge distortion to 0
  56610. */
  56611. disableEdgeDistortion(): void;
  56612. /**
  56613. * Sets the FocusDistance amount
  56614. * @param amount amount of FocusDistance
  56615. */
  56616. setFocusDistance(amount: number): void;
  56617. /**
  56618. * Disables depth of field
  56619. */
  56620. disableDepthOfField(): void;
  56621. /**
  56622. * Sets the Aperture amount
  56623. * @param amount amount of Aperture
  56624. */
  56625. setAperture(amount: number): void;
  56626. /**
  56627. * Sets the DarkenOutOfFocus amount
  56628. * @param amount amount of DarkenOutOfFocus
  56629. */
  56630. setDarkenOutOfFocus(amount: number): void;
  56631. private _pentagonBokehIsEnabled;
  56632. /**
  56633. * Creates a pentagon bokeh effect
  56634. */
  56635. enablePentagonBokeh(): void;
  56636. /**
  56637. * Disables the pentagon bokeh effect
  56638. */
  56639. disablePentagonBokeh(): void;
  56640. /**
  56641. * Enables noise blur
  56642. */
  56643. enableNoiseBlur(): void;
  56644. /**
  56645. * Disables noise blur
  56646. */
  56647. disableNoiseBlur(): void;
  56648. /**
  56649. * Sets the HighlightsGain amount
  56650. * @param amount amount of HighlightsGain
  56651. */
  56652. setHighlightsGain(amount: number): void;
  56653. /**
  56654. * Sets the HighlightsThreshold amount
  56655. * @param amount amount of HighlightsThreshold
  56656. */
  56657. setHighlightsThreshold(amount: number): void;
  56658. /**
  56659. * Disables highlights
  56660. */
  56661. disableHighlights(): void;
  56662. /**
  56663. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56664. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56665. */
  56666. dispose(disableDepthRender?: boolean): void;
  56667. private _createChromaticAberrationPostProcess;
  56668. private _createHighlightsPostProcess;
  56669. private _createDepthOfFieldPostProcess;
  56670. private _createGrainTexture;
  56671. }
  56672. }
  56673. declare module BABYLON {
  56674. /** @hidden */
  56675. export var ssao2PixelShader: {
  56676. name: string;
  56677. shader: string;
  56678. };
  56679. }
  56680. declare module BABYLON {
  56681. /** @hidden */
  56682. export var ssaoCombinePixelShader: {
  56683. name: string;
  56684. shader: string;
  56685. };
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * Render pipeline to produce ssao effect
  56690. */
  56691. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56692. /**
  56693. * @ignore
  56694. * The PassPostProcess id in the pipeline that contains the original scene color
  56695. */
  56696. SSAOOriginalSceneColorEffect: string;
  56697. /**
  56698. * @ignore
  56699. * The SSAO PostProcess id in the pipeline
  56700. */
  56701. SSAORenderEffect: string;
  56702. /**
  56703. * @ignore
  56704. * The horizontal blur PostProcess id in the pipeline
  56705. */
  56706. SSAOBlurHRenderEffect: string;
  56707. /**
  56708. * @ignore
  56709. * The vertical blur PostProcess id in the pipeline
  56710. */
  56711. SSAOBlurVRenderEffect: string;
  56712. /**
  56713. * @ignore
  56714. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56715. */
  56716. SSAOCombineRenderEffect: string;
  56717. /**
  56718. * The output strength of the SSAO post-process. Default value is 1.0.
  56719. */
  56720. totalStrength: number;
  56721. /**
  56722. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56723. */
  56724. maxZ: number;
  56725. /**
  56726. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56727. */
  56728. minZAspect: number;
  56729. private _samples;
  56730. /**
  56731. * Number of samples used for the SSAO calculations. Default value is 8
  56732. */
  56733. samples: number;
  56734. private _textureSamples;
  56735. /**
  56736. * Number of samples to use for antialiasing
  56737. */
  56738. textureSamples: number;
  56739. /**
  56740. * Ratio object used for SSAO ratio and blur ratio
  56741. */
  56742. private _ratio;
  56743. /**
  56744. * Dynamically generated sphere sampler.
  56745. */
  56746. private _sampleSphere;
  56747. /**
  56748. * Blur filter offsets
  56749. */
  56750. private _samplerOffsets;
  56751. private _expensiveBlur;
  56752. /**
  56753. * If bilateral blur should be used
  56754. */
  56755. expensiveBlur: boolean;
  56756. /**
  56757. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56758. */
  56759. radius: number;
  56760. /**
  56761. * The base color of the SSAO post-process
  56762. * The final result is "base + ssao" between [0, 1]
  56763. */
  56764. base: number;
  56765. /**
  56766. * Support test.
  56767. */
  56768. static readonly IsSupported: boolean;
  56769. private _scene;
  56770. private _depthTexture;
  56771. private _normalTexture;
  56772. private _randomTexture;
  56773. private _originalColorPostProcess;
  56774. private _ssaoPostProcess;
  56775. private _blurHPostProcess;
  56776. private _blurVPostProcess;
  56777. private _ssaoCombinePostProcess;
  56778. private _firstUpdate;
  56779. /**
  56780. * Gets active scene
  56781. */
  56782. readonly scene: Scene;
  56783. /**
  56784. * @constructor
  56785. * @param name The rendering pipeline name
  56786. * @param scene The scene linked to this pipeline
  56787. * @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 }
  56788. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56789. */
  56790. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56791. /**
  56792. * Get the class name
  56793. * @returns "SSAO2RenderingPipeline"
  56794. */
  56795. getClassName(): string;
  56796. /**
  56797. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56798. */
  56799. dispose(disableGeometryBufferRenderer?: boolean): void;
  56800. private _createBlurPostProcess;
  56801. /** @hidden */
  56802. _rebuild(): void;
  56803. private _bits;
  56804. private _radicalInverse_VdC;
  56805. private _hammersley;
  56806. private _hemisphereSample_uniform;
  56807. private _generateHemisphere;
  56808. private _createSSAOPostProcess;
  56809. private _createSSAOCombinePostProcess;
  56810. private _createRandomTexture;
  56811. /**
  56812. * Serialize the rendering pipeline (Used when exporting)
  56813. * @returns the serialized object
  56814. */
  56815. serialize(): any;
  56816. /**
  56817. * Parse the serialized pipeline
  56818. * @param source Source pipeline.
  56819. * @param scene The scene to load the pipeline to.
  56820. * @param rootUrl The URL of the serialized pipeline.
  56821. * @returns An instantiated pipeline from the serialized object.
  56822. */
  56823. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56824. }
  56825. }
  56826. declare module BABYLON {
  56827. /** @hidden */
  56828. export var ssaoPixelShader: {
  56829. name: string;
  56830. shader: string;
  56831. };
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Render pipeline to produce ssao effect
  56836. */
  56837. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56838. /**
  56839. * @ignore
  56840. * The PassPostProcess id in the pipeline that contains the original scene color
  56841. */
  56842. SSAOOriginalSceneColorEffect: string;
  56843. /**
  56844. * @ignore
  56845. * The SSAO PostProcess id in the pipeline
  56846. */
  56847. SSAORenderEffect: string;
  56848. /**
  56849. * @ignore
  56850. * The horizontal blur PostProcess id in the pipeline
  56851. */
  56852. SSAOBlurHRenderEffect: string;
  56853. /**
  56854. * @ignore
  56855. * The vertical blur PostProcess id in the pipeline
  56856. */
  56857. SSAOBlurVRenderEffect: string;
  56858. /**
  56859. * @ignore
  56860. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56861. */
  56862. SSAOCombineRenderEffect: string;
  56863. /**
  56864. * The output strength of the SSAO post-process. Default value is 1.0.
  56865. */
  56866. totalStrength: number;
  56867. /**
  56868. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56869. */
  56870. radius: number;
  56871. /**
  56872. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56873. * Must not be equal to fallOff and superior to fallOff.
  56874. * Default value is 0.0075
  56875. */
  56876. area: number;
  56877. /**
  56878. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56879. * Must not be equal to area and inferior to area.
  56880. * Default value is 0.000001
  56881. */
  56882. fallOff: number;
  56883. /**
  56884. * The base color of the SSAO post-process
  56885. * The final result is "base + ssao" between [0, 1]
  56886. */
  56887. base: number;
  56888. private _scene;
  56889. private _depthTexture;
  56890. private _randomTexture;
  56891. private _originalColorPostProcess;
  56892. private _ssaoPostProcess;
  56893. private _blurHPostProcess;
  56894. private _blurVPostProcess;
  56895. private _ssaoCombinePostProcess;
  56896. private _firstUpdate;
  56897. /**
  56898. * Gets active scene
  56899. */
  56900. readonly scene: Scene;
  56901. /**
  56902. * @constructor
  56903. * @param name - The rendering pipeline name
  56904. * @param scene - The scene linked to this pipeline
  56905. * @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 }
  56906. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56907. */
  56908. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56909. /**
  56910. * Get the class name
  56911. * @returns "SSAORenderingPipeline"
  56912. */
  56913. getClassName(): string;
  56914. /**
  56915. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56916. */
  56917. dispose(disableDepthRender?: boolean): void;
  56918. private _createBlurPostProcess;
  56919. /** @hidden */
  56920. _rebuild(): void;
  56921. private _createSSAOPostProcess;
  56922. private _createSSAOCombinePostProcess;
  56923. private _createRandomTexture;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /** @hidden */
  56928. export var standardPixelShader: {
  56929. name: string;
  56930. shader: string;
  56931. };
  56932. }
  56933. declare module BABYLON {
  56934. /**
  56935. * Standard rendering pipeline
  56936. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56937. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56938. */
  56939. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56940. /**
  56941. * Public members
  56942. */
  56943. /**
  56944. * Post-process which contains the original scene color before the pipeline applies all the effects
  56945. */
  56946. originalPostProcess: Nullable<PostProcess>;
  56947. /**
  56948. * Post-process used to down scale an image x4
  56949. */
  56950. downSampleX4PostProcess: Nullable<PostProcess>;
  56951. /**
  56952. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56953. */
  56954. brightPassPostProcess: Nullable<PostProcess>;
  56955. /**
  56956. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56957. */
  56958. blurHPostProcesses: PostProcess[];
  56959. /**
  56960. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56961. */
  56962. blurVPostProcesses: PostProcess[];
  56963. /**
  56964. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56965. */
  56966. textureAdderPostProcess: Nullable<PostProcess>;
  56967. /**
  56968. * Post-process used to create volumetric lighting effect
  56969. */
  56970. volumetricLightPostProcess: Nullable<PostProcess>;
  56971. /**
  56972. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56973. */
  56974. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56975. /**
  56976. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56977. */
  56978. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56979. /**
  56980. * Post-process used to merge the volumetric light effect and the real scene color
  56981. */
  56982. volumetricLightMergePostProces: Nullable<PostProcess>;
  56983. /**
  56984. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56985. */
  56986. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56987. /**
  56988. * Base post-process used to calculate the average luminance of the final image for HDR
  56989. */
  56990. luminancePostProcess: Nullable<PostProcess>;
  56991. /**
  56992. * Post-processes used to create down sample post-processes in order to get
  56993. * the average luminance of the final image for HDR
  56994. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56995. */
  56996. luminanceDownSamplePostProcesses: PostProcess[];
  56997. /**
  56998. * Post-process used to create a HDR effect (light adaptation)
  56999. */
  57000. hdrPostProcess: Nullable<PostProcess>;
  57001. /**
  57002. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57003. */
  57004. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57005. /**
  57006. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57007. */
  57008. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57009. /**
  57010. * Post-process used to merge the final HDR post-process and the real scene color
  57011. */
  57012. hdrFinalPostProcess: Nullable<PostProcess>;
  57013. /**
  57014. * Post-process used to create a lens flare effect
  57015. */
  57016. lensFlarePostProcess: Nullable<PostProcess>;
  57017. /**
  57018. * Post-process that merges the result of the lens flare post-process and the real scene color
  57019. */
  57020. lensFlareComposePostProcess: Nullable<PostProcess>;
  57021. /**
  57022. * Post-process used to create a motion blur effect
  57023. */
  57024. motionBlurPostProcess: Nullable<PostProcess>;
  57025. /**
  57026. * Post-process used to create a depth of field effect
  57027. */
  57028. depthOfFieldPostProcess: Nullable<PostProcess>;
  57029. /**
  57030. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57031. */
  57032. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57033. /**
  57034. * Represents the brightness threshold in order to configure the illuminated surfaces
  57035. */
  57036. brightThreshold: number;
  57037. /**
  57038. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57039. */
  57040. blurWidth: number;
  57041. /**
  57042. * Sets if the blur for highlighted surfaces must be only horizontal
  57043. */
  57044. horizontalBlur: boolean;
  57045. /**
  57046. * Gets the overall exposure used by the pipeline
  57047. */
  57048. /**
  57049. * Sets the overall exposure used by the pipeline
  57050. */
  57051. exposure: number;
  57052. /**
  57053. * Texture used typically to simulate "dirty" on camera lens
  57054. */
  57055. lensTexture: Nullable<Texture>;
  57056. /**
  57057. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57058. */
  57059. volumetricLightCoefficient: number;
  57060. /**
  57061. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57062. */
  57063. volumetricLightPower: number;
  57064. /**
  57065. * Used the set the blur intensity to smooth the volumetric lights
  57066. */
  57067. volumetricLightBlurScale: number;
  57068. /**
  57069. * Light (spot or directional) used to generate the volumetric lights rays
  57070. * The source light must have a shadow generate so the pipeline can get its
  57071. * depth map
  57072. */
  57073. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57074. /**
  57075. * For eye adaptation, represents the minimum luminance the eye can see
  57076. */
  57077. hdrMinimumLuminance: number;
  57078. /**
  57079. * For eye adaptation, represents the decrease luminance speed
  57080. */
  57081. hdrDecreaseRate: number;
  57082. /**
  57083. * For eye adaptation, represents the increase luminance speed
  57084. */
  57085. hdrIncreaseRate: number;
  57086. /**
  57087. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57088. */
  57089. /**
  57090. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57091. */
  57092. hdrAutoExposure: boolean;
  57093. /**
  57094. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57095. */
  57096. lensColorTexture: Nullable<Texture>;
  57097. /**
  57098. * The overall strengh for the lens flare effect
  57099. */
  57100. lensFlareStrength: number;
  57101. /**
  57102. * Dispersion coefficient for lens flare ghosts
  57103. */
  57104. lensFlareGhostDispersal: number;
  57105. /**
  57106. * Main lens flare halo width
  57107. */
  57108. lensFlareHaloWidth: number;
  57109. /**
  57110. * Based on the lens distortion effect, defines how much the lens flare result
  57111. * is distorted
  57112. */
  57113. lensFlareDistortionStrength: number;
  57114. /**
  57115. * Lens star texture must be used to simulate rays on the flares and is available
  57116. * in the documentation
  57117. */
  57118. lensStarTexture: Nullable<Texture>;
  57119. /**
  57120. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57121. * flare effect by taking account of the dirt texture
  57122. */
  57123. lensFlareDirtTexture: Nullable<Texture>;
  57124. /**
  57125. * Represents the focal length for the depth of field effect
  57126. */
  57127. depthOfFieldDistance: number;
  57128. /**
  57129. * Represents the blur intensity for the blurred part of the depth of field effect
  57130. */
  57131. depthOfFieldBlurWidth: number;
  57132. /**
  57133. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57134. */
  57135. /**
  57136. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57137. */
  57138. motionStrength: number;
  57139. /**
  57140. * Gets wether or not the motion blur post-process is object based or screen based.
  57141. */
  57142. /**
  57143. * Sets wether or not the motion blur post-process should be object based or screen based
  57144. */
  57145. objectBasedMotionBlur: boolean;
  57146. /**
  57147. * List of animations for the pipeline (IAnimatable implementation)
  57148. */
  57149. animations: Animation[];
  57150. /**
  57151. * Private members
  57152. */
  57153. private _scene;
  57154. private _currentDepthOfFieldSource;
  57155. private _basePostProcess;
  57156. private _fixedExposure;
  57157. private _currentExposure;
  57158. private _hdrAutoExposure;
  57159. private _hdrCurrentLuminance;
  57160. private _motionStrength;
  57161. private _isObjectBasedMotionBlur;
  57162. private _floatTextureType;
  57163. private _ratio;
  57164. private _bloomEnabled;
  57165. private _depthOfFieldEnabled;
  57166. private _vlsEnabled;
  57167. private _lensFlareEnabled;
  57168. private _hdrEnabled;
  57169. private _motionBlurEnabled;
  57170. private _fxaaEnabled;
  57171. private _motionBlurSamples;
  57172. private _volumetricLightStepsCount;
  57173. private _samples;
  57174. /**
  57175. * @ignore
  57176. * Specifies if the bloom pipeline is enabled
  57177. */
  57178. BloomEnabled: boolean;
  57179. /**
  57180. * @ignore
  57181. * Specifies if the depth of field pipeline is enabed
  57182. */
  57183. DepthOfFieldEnabled: boolean;
  57184. /**
  57185. * @ignore
  57186. * Specifies if the lens flare pipeline is enabed
  57187. */
  57188. LensFlareEnabled: boolean;
  57189. /**
  57190. * @ignore
  57191. * Specifies if the HDR pipeline is enabled
  57192. */
  57193. HDREnabled: boolean;
  57194. /**
  57195. * @ignore
  57196. * Specifies if the volumetric lights scattering effect is enabled
  57197. */
  57198. VLSEnabled: boolean;
  57199. /**
  57200. * @ignore
  57201. * Specifies if the motion blur effect is enabled
  57202. */
  57203. MotionBlurEnabled: boolean;
  57204. /**
  57205. * Specifies if anti-aliasing is enabled
  57206. */
  57207. fxaaEnabled: boolean;
  57208. /**
  57209. * Specifies the number of steps used to calculate the volumetric lights
  57210. * Typically in interval [50, 200]
  57211. */
  57212. volumetricLightStepsCount: number;
  57213. /**
  57214. * Specifies the number of samples used for the motion blur effect
  57215. * Typically in interval [16, 64]
  57216. */
  57217. motionBlurSamples: number;
  57218. /**
  57219. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57220. */
  57221. samples: number;
  57222. /**
  57223. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57224. * @constructor
  57225. * @param name The rendering pipeline name
  57226. * @param scene The scene linked to this pipeline
  57227. * @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)
  57228. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57229. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57230. */
  57231. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57232. private _buildPipeline;
  57233. private _createDownSampleX4PostProcess;
  57234. private _createBrightPassPostProcess;
  57235. private _createBlurPostProcesses;
  57236. private _createTextureAdderPostProcess;
  57237. private _createVolumetricLightPostProcess;
  57238. private _createLuminancePostProcesses;
  57239. private _createHdrPostProcess;
  57240. private _createLensFlarePostProcess;
  57241. private _createDepthOfFieldPostProcess;
  57242. private _createMotionBlurPostProcess;
  57243. private _getDepthTexture;
  57244. private _disposePostProcesses;
  57245. /**
  57246. * Dispose of the pipeline and stop all post processes
  57247. */
  57248. dispose(): void;
  57249. /**
  57250. * Serialize the rendering pipeline (Used when exporting)
  57251. * @returns the serialized object
  57252. */
  57253. serialize(): any;
  57254. /**
  57255. * Parse the serialized pipeline
  57256. * @param source Source pipeline.
  57257. * @param scene The scene to load the pipeline to.
  57258. * @param rootUrl The URL of the serialized pipeline.
  57259. * @returns An instantiated pipeline from the serialized object.
  57260. */
  57261. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57262. /**
  57263. * Luminance steps
  57264. */
  57265. static LuminanceSteps: number;
  57266. }
  57267. }
  57268. declare module BABYLON {
  57269. /** @hidden */
  57270. export var tonemapPixelShader: {
  57271. name: string;
  57272. shader: string;
  57273. };
  57274. }
  57275. declare module BABYLON {
  57276. /** Defines operator used for tonemapping */
  57277. export enum TonemappingOperator {
  57278. /** Hable */
  57279. Hable = 0,
  57280. /** Reinhard */
  57281. Reinhard = 1,
  57282. /** HejiDawson */
  57283. HejiDawson = 2,
  57284. /** Photographic */
  57285. Photographic = 3
  57286. }
  57287. /**
  57288. * Defines a post process to apply tone mapping
  57289. */
  57290. export class TonemapPostProcess extends PostProcess {
  57291. private _operator;
  57292. /** Defines the required exposure adjustement */
  57293. exposureAdjustment: number;
  57294. /**
  57295. * Creates a new TonemapPostProcess
  57296. * @param name defines the name of the postprocess
  57297. * @param _operator defines the operator to use
  57298. * @param exposureAdjustment defines the required exposure adjustement
  57299. * @param camera defines the camera to use (can be null)
  57300. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57301. * @param engine defines the hosting engine (can be ignore if camera is set)
  57302. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57303. */
  57304. constructor(name: string, _operator: TonemappingOperator,
  57305. /** Defines the required exposure adjustement */
  57306. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57307. }
  57308. }
  57309. declare module BABYLON {
  57310. /** @hidden */
  57311. export var depthVertexShader: {
  57312. name: string;
  57313. shader: string;
  57314. };
  57315. }
  57316. declare module BABYLON {
  57317. /** @hidden */
  57318. export var volumetricLightScatteringPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module BABYLON {
  57324. /** @hidden */
  57325. export var volumetricLightScatteringPassPixelShader: {
  57326. name: string;
  57327. shader: string;
  57328. };
  57329. }
  57330. declare module BABYLON {
  57331. /**
  57332. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57333. */
  57334. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57335. private _volumetricLightScatteringPass;
  57336. private _volumetricLightScatteringRTT;
  57337. private _viewPort;
  57338. private _screenCoordinates;
  57339. private _cachedDefines;
  57340. /**
  57341. * If not undefined, the mesh position is computed from the attached node position
  57342. */
  57343. attachedNode: {
  57344. position: Vector3;
  57345. };
  57346. /**
  57347. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57348. */
  57349. customMeshPosition: Vector3;
  57350. /**
  57351. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57352. */
  57353. useCustomMeshPosition: boolean;
  57354. /**
  57355. * If the post-process should inverse the light scattering direction
  57356. */
  57357. invert: boolean;
  57358. /**
  57359. * The internal mesh used by the post-process
  57360. */
  57361. mesh: Mesh;
  57362. /**
  57363. * @hidden
  57364. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57365. */
  57366. useDiffuseColor: boolean;
  57367. /**
  57368. * Array containing the excluded meshes not rendered in the internal pass
  57369. */
  57370. excludedMeshes: AbstractMesh[];
  57371. /**
  57372. * Controls the overall intensity of the post-process
  57373. */
  57374. exposure: number;
  57375. /**
  57376. * Dissipates each sample's contribution in range [0, 1]
  57377. */
  57378. decay: number;
  57379. /**
  57380. * Controls the overall intensity of each sample
  57381. */
  57382. weight: number;
  57383. /**
  57384. * Controls the density of each sample
  57385. */
  57386. density: number;
  57387. /**
  57388. * @constructor
  57389. * @param name The post-process name
  57390. * @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)
  57391. * @param camera The camera that the post-process will be attached to
  57392. * @param mesh The mesh used to create the light scattering
  57393. * @param samples The post-process quality, default 100
  57394. * @param samplingModeThe post-process filtering mode
  57395. * @param engine The babylon engine
  57396. * @param reusable If the post-process is reusable
  57397. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57398. */
  57399. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57400. /**
  57401. * Returns the string "VolumetricLightScatteringPostProcess"
  57402. * @returns "VolumetricLightScatteringPostProcess"
  57403. */
  57404. getClassName(): string;
  57405. private _isReady;
  57406. /**
  57407. * Sets the new light position for light scattering effect
  57408. * @param position The new custom light position
  57409. */
  57410. setCustomMeshPosition(position: Vector3): void;
  57411. /**
  57412. * Returns the light position for light scattering effect
  57413. * @return Vector3 The custom light position
  57414. */
  57415. getCustomMeshPosition(): Vector3;
  57416. /**
  57417. * Disposes the internal assets and detaches the post-process from the camera
  57418. */
  57419. dispose(camera: Camera): void;
  57420. /**
  57421. * Returns the render target texture used by the post-process
  57422. * @return the render target texture used by the post-process
  57423. */
  57424. getPass(): RenderTargetTexture;
  57425. private _meshExcluded;
  57426. private _createPass;
  57427. private _updateMeshScreenCoordinates;
  57428. /**
  57429. * Creates a default mesh for the Volumeric Light Scattering post-process
  57430. * @param name The mesh name
  57431. * @param scene The scene where to create the mesh
  57432. * @return the default mesh
  57433. */
  57434. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57435. }
  57436. }
  57437. declare module BABYLON {
  57438. interface Scene {
  57439. /** @hidden (Backing field) */
  57440. _boundingBoxRenderer: BoundingBoxRenderer;
  57441. /** @hidden (Backing field) */
  57442. _forceShowBoundingBoxes: boolean;
  57443. /**
  57444. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57445. */
  57446. forceShowBoundingBoxes: boolean;
  57447. /**
  57448. * Gets the bounding box renderer associated with the scene
  57449. * @returns a BoundingBoxRenderer
  57450. */
  57451. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57452. }
  57453. interface AbstractMesh {
  57454. /** @hidden (Backing field) */
  57455. _showBoundingBox: boolean;
  57456. /**
  57457. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57458. */
  57459. showBoundingBox: boolean;
  57460. }
  57461. /**
  57462. * Component responsible of rendering the bounding box of the meshes in a scene.
  57463. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57464. */
  57465. export class BoundingBoxRenderer implements ISceneComponent {
  57466. /**
  57467. * The component name helpfull to identify the component in the list of scene components.
  57468. */
  57469. readonly name: string;
  57470. /**
  57471. * The scene the component belongs to.
  57472. */
  57473. scene: Scene;
  57474. /**
  57475. * Color of the bounding box lines placed in front of an object
  57476. */
  57477. frontColor: Color3;
  57478. /**
  57479. * Color of the bounding box lines placed behind an object
  57480. */
  57481. backColor: Color3;
  57482. /**
  57483. * Defines if the renderer should show the back lines or not
  57484. */
  57485. showBackLines: boolean;
  57486. /**
  57487. * @hidden
  57488. */
  57489. renderList: SmartArray<BoundingBox>;
  57490. private _colorShader;
  57491. private _vertexBuffers;
  57492. private _indexBuffer;
  57493. private _fillIndexBuffer;
  57494. private _fillIndexData;
  57495. /**
  57496. * Instantiates a new bounding box renderer in a scene.
  57497. * @param scene the scene the renderer renders in
  57498. */
  57499. constructor(scene: Scene);
  57500. /**
  57501. * Registers the component in a given scene
  57502. */
  57503. register(): void;
  57504. private _evaluateSubMesh;
  57505. private _activeMesh;
  57506. private _prepareRessources;
  57507. private _createIndexBuffer;
  57508. /**
  57509. * Rebuilds the elements related to this component in case of
  57510. * context lost for instance.
  57511. */
  57512. rebuild(): void;
  57513. /**
  57514. * @hidden
  57515. */
  57516. reset(): void;
  57517. /**
  57518. * Render the bounding boxes of a specific rendering group
  57519. * @param renderingGroupId defines the rendering group to render
  57520. */
  57521. render(renderingGroupId: number): void;
  57522. /**
  57523. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57524. * @param mesh Define the mesh to render the occlusion bounding box for
  57525. */
  57526. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57527. /**
  57528. * Dispose and release the resources attached to this renderer.
  57529. */
  57530. dispose(): void;
  57531. }
  57532. }
  57533. declare module BABYLON {
  57534. /** @hidden */
  57535. export var depthPixelShader: {
  57536. name: string;
  57537. shader: string;
  57538. };
  57539. }
  57540. declare module BABYLON {
  57541. /**
  57542. * This represents a depth renderer in Babylon.
  57543. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57544. */
  57545. export class DepthRenderer {
  57546. private _scene;
  57547. private _depthMap;
  57548. private _effect;
  57549. private _cachedDefines;
  57550. private _camera;
  57551. /**
  57552. * Specifiess that the depth renderer will only be used within
  57553. * the camera it is created for.
  57554. * This can help forcing its rendering during the camera processing.
  57555. */
  57556. useOnlyInActiveCamera: boolean;
  57557. /** @hidden */
  57558. static _SceneComponentInitialization: (scene: Scene) => void;
  57559. /**
  57560. * Instantiates a depth renderer
  57561. * @param scene The scene the renderer belongs to
  57562. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57563. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57564. */
  57565. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57566. /**
  57567. * Creates the depth rendering effect and checks if the effect is ready.
  57568. * @param subMesh The submesh to be used to render the depth map of
  57569. * @param useInstances If multiple world instances should be used
  57570. * @returns if the depth renderer is ready to render the depth map
  57571. */
  57572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57573. /**
  57574. * Gets the texture which the depth map will be written to.
  57575. * @returns The depth map texture
  57576. */
  57577. getDepthMap(): RenderTargetTexture;
  57578. /**
  57579. * Disposes of the depth renderer.
  57580. */
  57581. dispose(): void;
  57582. }
  57583. }
  57584. declare module BABYLON {
  57585. interface Scene {
  57586. /** @hidden (Backing field) */
  57587. _depthRenderer: {
  57588. [id: string]: DepthRenderer;
  57589. };
  57590. /**
  57591. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57592. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57593. * @returns the created depth renderer
  57594. */
  57595. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57596. /**
  57597. * Disables a depth renderer for a given camera
  57598. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57599. */
  57600. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57601. }
  57602. /**
  57603. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57604. * in several rendering techniques.
  57605. */
  57606. export class DepthRendererSceneComponent implements ISceneComponent {
  57607. /**
  57608. * The component name helpfull to identify the component in the list of scene components.
  57609. */
  57610. readonly name: string;
  57611. /**
  57612. * The scene the component belongs to.
  57613. */
  57614. scene: Scene;
  57615. /**
  57616. * Creates a new instance of the component for the given scene
  57617. * @param scene Defines the scene to register the component in
  57618. */
  57619. constructor(scene: Scene);
  57620. /**
  57621. * Registers the component in a given scene
  57622. */
  57623. register(): void;
  57624. /**
  57625. * Rebuilds the elements related to this component in case of
  57626. * context lost for instance.
  57627. */
  57628. rebuild(): void;
  57629. /**
  57630. * Disposes the component and the associated ressources
  57631. */
  57632. dispose(): void;
  57633. private _gatherRenderTargets;
  57634. private _gatherActiveCameraRenderTargets;
  57635. }
  57636. }
  57637. declare module BABYLON {
  57638. /** @hidden */
  57639. export var outlinePixelShader: {
  57640. name: string;
  57641. shader: string;
  57642. };
  57643. }
  57644. declare module BABYLON {
  57645. /** @hidden */
  57646. export var outlineVertexShader: {
  57647. name: string;
  57648. shader: string;
  57649. };
  57650. }
  57651. declare module BABYLON {
  57652. interface Scene {
  57653. /** @hidden */
  57654. _outlineRenderer: OutlineRenderer;
  57655. /**
  57656. * Gets the outline renderer associated with the scene
  57657. * @returns a OutlineRenderer
  57658. */
  57659. getOutlineRenderer(): OutlineRenderer;
  57660. }
  57661. interface AbstractMesh {
  57662. /** @hidden (Backing field) */
  57663. _renderOutline: boolean;
  57664. /**
  57665. * Gets or sets a boolean indicating if the outline must be rendered as well
  57666. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57667. */
  57668. renderOutline: boolean;
  57669. /** @hidden (Backing field) */
  57670. _renderOverlay: boolean;
  57671. /**
  57672. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57673. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57674. */
  57675. renderOverlay: boolean;
  57676. }
  57677. /**
  57678. * This class is responsible to draw bothe outline/overlay of meshes.
  57679. * It should not be used directly but through the available method on mesh.
  57680. */
  57681. export class OutlineRenderer implements ISceneComponent {
  57682. /**
  57683. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57684. */
  57685. private static _StencilReference;
  57686. /**
  57687. * The name of the component. Each component must have a unique name.
  57688. */
  57689. name: string;
  57690. /**
  57691. * The scene the component belongs to.
  57692. */
  57693. scene: Scene;
  57694. /**
  57695. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57696. */
  57697. zOffset: number;
  57698. private _engine;
  57699. private _effect;
  57700. private _cachedDefines;
  57701. private _savedDepthWrite;
  57702. /**
  57703. * Instantiates a new outline renderer. (There could be only one per scene).
  57704. * @param scene Defines the scene it belongs to
  57705. */
  57706. constructor(scene: Scene);
  57707. /**
  57708. * Register the component to one instance of a scene.
  57709. */
  57710. register(): void;
  57711. /**
  57712. * Rebuilds the elements related to this component in case of
  57713. * context lost for instance.
  57714. */
  57715. rebuild(): void;
  57716. /**
  57717. * Disposes the component and the associated ressources.
  57718. */
  57719. dispose(): void;
  57720. /**
  57721. * Renders the outline in the canvas.
  57722. * @param subMesh Defines the sumesh to render
  57723. * @param batch Defines the batch of meshes in case of instances
  57724. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57725. */
  57726. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57727. /**
  57728. * Returns whether or not the outline renderer is ready for a given submesh.
  57729. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57730. * @param subMesh Defines the submesh to check readyness for
  57731. * @param useInstances Defines wheter wee are trying to render instances or not
  57732. * @returns true if ready otherwise false
  57733. */
  57734. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57735. private _beforeRenderingMesh;
  57736. private _afterRenderingMesh;
  57737. }
  57738. }
  57739. declare module BABYLON {
  57740. /**
  57741. * Defines the list of states available for a task inside a AssetsManager
  57742. */
  57743. export enum AssetTaskState {
  57744. /**
  57745. * Initialization
  57746. */
  57747. INIT = 0,
  57748. /**
  57749. * Running
  57750. */
  57751. RUNNING = 1,
  57752. /**
  57753. * Done
  57754. */
  57755. DONE = 2,
  57756. /**
  57757. * Error
  57758. */
  57759. ERROR = 3
  57760. }
  57761. /**
  57762. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57763. */
  57764. export abstract class AbstractAssetTask {
  57765. /**
  57766. * Task name
  57767. */ name: string;
  57768. /**
  57769. * Callback called when the task is successful
  57770. */
  57771. onSuccess: (task: any) => void;
  57772. /**
  57773. * Callback called when the task is not successful
  57774. */
  57775. onError: (task: any, message?: string, exception?: any) => void;
  57776. /**
  57777. * Creates a new AssetsManager
  57778. * @param name defines the name of the task
  57779. */
  57780. constructor(
  57781. /**
  57782. * Task name
  57783. */ name: string);
  57784. private _isCompleted;
  57785. private _taskState;
  57786. private _errorObject;
  57787. /**
  57788. * Get if the task is completed
  57789. */
  57790. readonly isCompleted: boolean;
  57791. /**
  57792. * Gets the current state of the task
  57793. */
  57794. readonly taskState: AssetTaskState;
  57795. /**
  57796. * Gets the current error object (if task is in error)
  57797. */
  57798. readonly errorObject: {
  57799. message?: string;
  57800. exception?: any;
  57801. };
  57802. /**
  57803. * Internal only
  57804. * @hidden
  57805. */
  57806. _setErrorObject(message?: string, exception?: any): void;
  57807. /**
  57808. * Execute the current task
  57809. * @param scene defines the scene where you want your assets to be loaded
  57810. * @param onSuccess is a callback called when the task is successfully executed
  57811. * @param onError is a callback called if an error occurs
  57812. */
  57813. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57814. /**
  57815. * Execute the current task
  57816. * @param scene defines the scene where you want your assets to be loaded
  57817. * @param onSuccess is a callback called when the task is successfully executed
  57818. * @param onError is a callback called if an error occurs
  57819. */
  57820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57821. /**
  57822. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57823. * This can be used with failed tasks that have the reason for failure fixed.
  57824. */
  57825. reset(): void;
  57826. private onErrorCallback;
  57827. private onDoneCallback;
  57828. }
  57829. /**
  57830. * Define the interface used by progress events raised during assets loading
  57831. */
  57832. export interface IAssetsProgressEvent {
  57833. /**
  57834. * Defines the number of remaining tasks to process
  57835. */
  57836. remainingCount: number;
  57837. /**
  57838. * Defines the total number of tasks
  57839. */
  57840. totalCount: number;
  57841. /**
  57842. * Defines the task that was just processed
  57843. */
  57844. task: AbstractAssetTask;
  57845. }
  57846. /**
  57847. * Class used to share progress information about assets loading
  57848. */
  57849. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57850. /**
  57851. * Defines the number of remaining tasks to process
  57852. */
  57853. remainingCount: number;
  57854. /**
  57855. * Defines the total number of tasks
  57856. */
  57857. totalCount: number;
  57858. /**
  57859. * Defines the task that was just processed
  57860. */
  57861. task: AbstractAssetTask;
  57862. /**
  57863. * Creates a AssetsProgressEvent
  57864. * @param remainingCount defines the number of remaining tasks to process
  57865. * @param totalCount defines the total number of tasks
  57866. * @param task defines the task that was just processed
  57867. */
  57868. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57869. }
  57870. /**
  57871. * Define a task used by AssetsManager to load meshes
  57872. */
  57873. export class MeshAssetTask extends AbstractAssetTask {
  57874. /**
  57875. * Defines the name of the task
  57876. */
  57877. name: string;
  57878. /**
  57879. * Defines the list of mesh's names you want to load
  57880. */
  57881. meshesNames: any;
  57882. /**
  57883. * Defines the root url to use as a base to load your meshes and associated resources
  57884. */
  57885. rootUrl: string;
  57886. /**
  57887. * Defines the filename of the scene to load from
  57888. */
  57889. sceneFilename: string;
  57890. /**
  57891. * Gets the list of loaded meshes
  57892. */
  57893. loadedMeshes: Array<AbstractMesh>;
  57894. /**
  57895. * Gets the list of loaded particle systems
  57896. */
  57897. loadedParticleSystems: Array<IParticleSystem>;
  57898. /**
  57899. * Gets the list of loaded skeletons
  57900. */
  57901. loadedSkeletons: Array<Skeleton>;
  57902. /**
  57903. * Gets the list of loaded animation groups
  57904. */
  57905. loadedAnimationGroups: Array<AnimationGroup>;
  57906. /**
  57907. * Callback called when the task is successful
  57908. */
  57909. onSuccess: (task: MeshAssetTask) => void;
  57910. /**
  57911. * Callback called when the task is successful
  57912. */
  57913. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57914. /**
  57915. * Creates a new MeshAssetTask
  57916. * @param name defines the name of the task
  57917. * @param meshesNames defines the list of mesh's names you want to load
  57918. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57919. * @param sceneFilename defines the filename of the scene to load from
  57920. */
  57921. constructor(
  57922. /**
  57923. * Defines the name of the task
  57924. */
  57925. name: string,
  57926. /**
  57927. * Defines the list of mesh's names you want to load
  57928. */
  57929. meshesNames: any,
  57930. /**
  57931. * Defines the root url to use as a base to load your meshes and associated resources
  57932. */
  57933. rootUrl: string,
  57934. /**
  57935. * Defines the filename of the scene to load from
  57936. */
  57937. sceneFilename: string);
  57938. /**
  57939. * Execute the current task
  57940. * @param scene defines the scene where you want your assets to be loaded
  57941. * @param onSuccess is a callback called when the task is successfully executed
  57942. * @param onError is a callback called if an error occurs
  57943. */
  57944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57945. }
  57946. /**
  57947. * Define a task used by AssetsManager to load text content
  57948. */
  57949. export class TextFileAssetTask extends AbstractAssetTask {
  57950. /**
  57951. * Defines the name of the task
  57952. */
  57953. name: string;
  57954. /**
  57955. * Defines the location of the file to load
  57956. */
  57957. url: string;
  57958. /**
  57959. * Gets the loaded text string
  57960. */
  57961. text: string;
  57962. /**
  57963. * Callback called when the task is successful
  57964. */
  57965. onSuccess: (task: TextFileAssetTask) => void;
  57966. /**
  57967. * Callback called when the task is successful
  57968. */
  57969. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57970. /**
  57971. * Creates a new TextFileAssetTask object
  57972. * @param name defines the name of the task
  57973. * @param url defines the location of the file to load
  57974. */
  57975. constructor(
  57976. /**
  57977. * Defines the name of the task
  57978. */
  57979. name: string,
  57980. /**
  57981. * Defines the location of the file to load
  57982. */
  57983. url: string);
  57984. /**
  57985. * Execute the current task
  57986. * @param scene defines the scene where you want your assets to be loaded
  57987. * @param onSuccess is a callback called when the task is successfully executed
  57988. * @param onError is a callback called if an error occurs
  57989. */
  57990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57991. }
  57992. /**
  57993. * Define a task used by AssetsManager to load binary data
  57994. */
  57995. export class BinaryFileAssetTask extends AbstractAssetTask {
  57996. /**
  57997. * Defines the name of the task
  57998. */
  57999. name: string;
  58000. /**
  58001. * Defines the location of the file to load
  58002. */
  58003. url: string;
  58004. /**
  58005. * Gets the lodaded data (as an array buffer)
  58006. */
  58007. data: ArrayBuffer;
  58008. /**
  58009. * Callback called when the task is successful
  58010. */
  58011. onSuccess: (task: BinaryFileAssetTask) => void;
  58012. /**
  58013. * Callback called when the task is successful
  58014. */
  58015. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58016. /**
  58017. * Creates a new BinaryFileAssetTask object
  58018. * @param name defines the name of the new task
  58019. * @param url defines the location of the file to load
  58020. */
  58021. constructor(
  58022. /**
  58023. * Defines the name of the task
  58024. */
  58025. name: string,
  58026. /**
  58027. * Defines the location of the file to load
  58028. */
  58029. url: string);
  58030. /**
  58031. * Execute the current task
  58032. * @param scene defines the scene where you want your assets to be loaded
  58033. * @param onSuccess is a callback called when the task is successfully executed
  58034. * @param onError is a callback called if an error occurs
  58035. */
  58036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58037. }
  58038. /**
  58039. * Define a task used by AssetsManager to load images
  58040. */
  58041. export class ImageAssetTask extends AbstractAssetTask {
  58042. /**
  58043. * Defines the name of the task
  58044. */
  58045. name: string;
  58046. /**
  58047. * Defines the location of the image to load
  58048. */
  58049. url: string;
  58050. /**
  58051. * Gets the loaded images
  58052. */
  58053. image: HTMLImageElement;
  58054. /**
  58055. * Callback called when the task is successful
  58056. */
  58057. onSuccess: (task: ImageAssetTask) => void;
  58058. /**
  58059. * Callback called when the task is successful
  58060. */
  58061. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58062. /**
  58063. * Creates a new ImageAssetTask
  58064. * @param name defines the name of the task
  58065. * @param url defines the location of the image to load
  58066. */
  58067. constructor(
  58068. /**
  58069. * Defines the name of the task
  58070. */
  58071. name: string,
  58072. /**
  58073. * Defines the location of the image to load
  58074. */
  58075. url: string);
  58076. /**
  58077. * Execute the current task
  58078. * @param scene defines the scene where you want your assets to be loaded
  58079. * @param onSuccess is a callback called when the task is successfully executed
  58080. * @param onError is a callback called if an error occurs
  58081. */
  58082. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58083. }
  58084. /**
  58085. * Defines the interface used by texture loading tasks
  58086. */
  58087. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58088. /**
  58089. * Gets the loaded texture
  58090. */
  58091. texture: TEX;
  58092. }
  58093. /**
  58094. * Define a task used by AssetsManager to load 2D textures
  58095. */
  58096. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58097. /**
  58098. * Defines the name of the task
  58099. */
  58100. name: string;
  58101. /**
  58102. * Defines the location of the file to load
  58103. */
  58104. url: string;
  58105. /**
  58106. * Defines if mipmap should not be generated (default is false)
  58107. */
  58108. noMipmap?: boolean | undefined;
  58109. /**
  58110. * Defines if texture must be inverted on Y axis (default is false)
  58111. */
  58112. invertY?: boolean | undefined;
  58113. /**
  58114. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58115. */
  58116. samplingMode: number;
  58117. /**
  58118. * Gets the loaded texture
  58119. */
  58120. texture: Texture;
  58121. /**
  58122. * Callback called when the task is successful
  58123. */
  58124. onSuccess: (task: TextureAssetTask) => void;
  58125. /**
  58126. * Callback called when the task is successful
  58127. */
  58128. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58129. /**
  58130. * Creates a new TextureAssetTask object
  58131. * @param name defines the name of the task
  58132. * @param url defines the location of the file to load
  58133. * @param noMipmap defines if mipmap should not be generated (default is false)
  58134. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58135. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58136. */
  58137. constructor(
  58138. /**
  58139. * Defines the name of the task
  58140. */
  58141. name: string,
  58142. /**
  58143. * Defines the location of the file to load
  58144. */
  58145. url: string,
  58146. /**
  58147. * Defines if mipmap should not be generated (default is false)
  58148. */
  58149. noMipmap?: boolean | undefined,
  58150. /**
  58151. * Defines if texture must be inverted on Y axis (default is false)
  58152. */
  58153. invertY?: boolean | undefined,
  58154. /**
  58155. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58156. */
  58157. samplingMode?: number);
  58158. /**
  58159. * Execute the current task
  58160. * @param scene defines the scene where you want your assets to be loaded
  58161. * @param onSuccess is a callback called when the task is successfully executed
  58162. * @param onError is a callback called if an error occurs
  58163. */
  58164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58165. }
  58166. /**
  58167. * Define a task used by AssetsManager to load cube textures
  58168. */
  58169. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58170. /**
  58171. * Defines the name of the task
  58172. */
  58173. name: string;
  58174. /**
  58175. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58176. */
  58177. url: string;
  58178. /**
  58179. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58180. */
  58181. extensions?: string[] | undefined;
  58182. /**
  58183. * Defines if mipmaps should not be generated (default is false)
  58184. */
  58185. noMipmap?: boolean | undefined;
  58186. /**
  58187. * Defines the explicit list of files (undefined by default)
  58188. */
  58189. files?: string[] | undefined;
  58190. /**
  58191. * Gets the loaded texture
  58192. */
  58193. texture: CubeTexture;
  58194. /**
  58195. * Callback called when the task is successful
  58196. */
  58197. onSuccess: (task: CubeTextureAssetTask) => void;
  58198. /**
  58199. * Callback called when the task is successful
  58200. */
  58201. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58202. /**
  58203. * Creates a new CubeTextureAssetTask
  58204. * @param name defines the name of the task
  58205. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58206. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58207. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58208. * @param files defines the explicit list of files (undefined by default)
  58209. */
  58210. constructor(
  58211. /**
  58212. * Defines the name of the task
  58213. */
  58214. name: string,
  58215. /**
  58216. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58217. */
  58218. url: string,
  58219. /**
  58220. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58221. */
  58222. extensions?: string[] | undefined,
  58223. /**
  58224. * Defines if mipmaps should not be generated (default is false)
  58225. */
  58226. noMipmap?: boolean | undefined,
  58227. /**
  58228. * Defines the explicit list of files (undefined by default)
  58229. */
  58230. files?: string[] | undefined);
  58231. /**
  58232. * Execute the current task
  58233. * @param scene defines the scene where you want your assets to be loaded
  58234. * @param onSuccess is a callback called when the task is successfully executed
  58235. * @param onError is a callback called if an error occurs
  58236. */
  58237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58238. }
  58239. /**
  58240. * Define a task used by AssetsManager to load HDR cube textures
  58241. */
  58242. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58243. /**
  58244. * Defines the name of the task
  58245. */
  58246. name: string;
  58247. /**
  58248. * Defines the location of the file to load
  58249. */
  58250. url: string;
  58251. /**
  58252. * Defines the desired size (the more it increases the longer the generation will be)
  58253. */
  58254. size: number;
  58255. /**
  58256. * Defines if mipmaps should not be generated (default is false)
  58257. */
  58258. noMipmap: boolean;
  58259. /**
  58260. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58261. */
  58262. generateHarmonics: boolean;
  58263. /**
  58264. * 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)
  58265. */
  58266. gammaSpace: boolean;
  58267. /**
  58268. * Internal Use Only
  58269. */
  58270. reserved: boolean;
  58271. /**
  58272. * Gets the loaded texture
  58273. */
  58274. texture: HDRCubeTexture;
  58275. /**
  58276. * Callback called when the task is successful
  58277. */
  58278. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58279. /**
  58280. * Callback called when the task is successful
  58281. */
  58282. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58283. /**
  58284. * Creates a new HDRCubeTextureAssetTask object
  58285. * @param name defines the name of the task
  58286. * @param url defines the location of the file to load
  58287. * @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.
  58288. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58289. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58290. * @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)
  58291. * @param reserved Internal use only
  58292. */
  58293. constructor(
  58294. /**
  58295. * Defines the name of the task
  58296. */
  58297. name: string,
  58298. /**
  58299. * Defines the location of the file to load
  58300. */
  58301. url: string,
  58302. /**
  58303. * Defines the desired size (the more it increases the longer the generation will be)
  58304. */
  58305. size: number,
  58306. /**
  58307. * Defines if mipmaps should not be generated (default is false)
  58308. */
  58309. noMipmap?: boolean,
  58310. /**
  58311. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58312. */
  58313. generateHarmonics?: boolean,
  58314. /**
  58315. * 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)
  58316. */
  58317. gammaSpace?: boolean,
  58318. /**
  58319. * Internal Use Only
  58320. */
  58321. reserved?: boolean);
  58322. /**
  58323. * Execute the current task
  58324. * @param scene defines the scene where you want your assets to be loaded
  58325. * @param onSuccess is a callback called when the task is successfully executed
  58326. * @param onError is a callback called if an error occurs
  58327. */
  58328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58329. }
  58330. /**
  58331. * Define a task used by AssetsManager to load Equirectangular cube textures
  58332. */
  58333. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58334. /**
  58335. * Defines the name of the task
  58336. */
  58337. name: string;
  58338. /**
  58339. * Defines the location of the file to load
  58340. */
  58341. url: string;
  58342. /**
  58343. * Defines the desired size (the more it increases the longer the generation will be)
  58344. */
  58345. size: number;
  58346. /**
  58347. * Defines if mipmaps should not be generated (default is false)
  58348. */
  58349. noMipmap: boolean;
  58350. /**
  58351. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58352. * but the standard material would require them in Gamma space) (default is true)
  58353. */
  58354. gammaSpace: boolean;
  58355. /**
  58356. * Gets the loaded texture
  58357. */
  58358. texture: EquiRectangularCubeTexture;
  58359. /**
  58360. * Callback called when the task is successful
  58361. */
  58362. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58363. /**
  58364. * Callback called when the task is successful
  58365. */
  58366. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58367. /**
  58368. * Creates a new EquiRectangularCubeTextureAssetTask object
  58369. * @param name defines the name of the task
  58370. * @param url defines the location of the file to load
  58371. * @param size defines the desired size (the more it increases the longer the generation will be)
  58372. * If the size is omitted this implies you are using a preprocessed cubemap.
  58373. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58374. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58375. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58376. * (default is true)
  58377. */
  58378. constructor(
  58379. /**
  58380. * Defines the name of the task
  58381. */
  58382. name: string,
  58383. /**
  58384. * Defines the location of the file to load
  58385. */
  58386. url: string,
  58387. /**
  58388. * Defines the desired size (the more it increases the longer the generation will be)
  58389. */
  58390. size: number,
  58391. /**
  58392. * Defines if mipmaps should not be generated (default is false)
  58393. */
  58394. noMipmap?: boolean,
  58395. /**
  58396. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58397. * but the standard material would require them in Gamma space) (default is true)
  58398. */
  58399. gammaSpace?: boolean);
  58400. /**
  58401. * Execute the current task
  58402. * @param scene defines the scene where you want your assets to be loaded
  58403. * @param onSuccess is a callback called when the task is successfully executed
  58404. * @param onError is a callback called if an error occurs
  58405. */
  58406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58407. }
  58408. /**
  58409. * This class can be used to easily import assets into a scene
  58410. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58411. */
  58412. export class AssetsManager {
  58413. private _scene;
  58414. private _isLoading;
  58415. protected _tasks: AbstractAssetTask[];
  58416. protected _waitingTasksCount: number;
  58417. protected _totalTasksCount: number;
  58418. /**
  58419. * Callback called when all tasks are processed
  58420. */
  58421. onFinish: (tasks: AbstractAssetTask[]) => void;
  58422. /**
  58423. * Callback called when a task is successful
  58424. */
  58425. onTaskSuccess: (task: AbstractAssetTask) => void;
  58426. /**
  58427. * Callback called when a task had an error
  58428. */
  58429. onTaskError: (task: AbstractAssetTask) => void;
  58430. /**
  58431. * Callback called when a task is done (whatever the result is)
  58432. */
  58433. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58434. /**
  58435. * Observable called when all tasks are processed
  58436. */
  58437. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58438. /**
  58439. * Observable called when a task had an error
  58440. */
  58441. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58442. /**
  58443. * Observable called when all tasks were executed
  58444. */
  58445. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58446. /**
  58447. * Observable called when a task is done (whatever the result is)
  58448. */
  58449. onProgressObservable: Observable<IAssetsProgressEvent>;
  58450. /**
  58451. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58452. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58453. */
  58454. useDefaultLoadingScreen: boolean;
  58455. /**
  58456. * Creates a new AssetsManager
  58457. * @param scene defines the scene to work on
  58458. */
  58459. constructor(scene: Scene);
  58460. /**
  58461. * Add a MeshAssetTask to the list of active tasks
  58462. * @param taskName defines the name of the new task
  58463. * @param meshesNames defines the name of meshes to load
  58464. * @param rootUrl defines the root url to use to locate files
  58465. * @param sceneFilename defines the filename of the scene file
  58466. * @returns a new MeshAssetTask object
  58467. */
  58468. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58469. /**
  58470. * Add a TextFileAssetTask to the list of active tasks
  58471. * @param taskName defines the name of the new task
  58472. * @param url defines the url of the file to load
  58473. * @returns a new TextFileAssetTask object
  58474. */
  58475. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58476. /**
  58477. * Add a BinaryFileAssetTask to the list of active tasks
  58478. * @param taskName defines the name of the new task
  58479. * @param url defines the url of the file to load
  58480. * @returns a new BinaryFileAssetTask object
  58481. */
  58482. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58483. /**
  58484. * Add a ImageAssetTask to the list of active tasks
  58485. * @param taskName defines the name of the new task
  58486. * @param url defines the url of the file to load
  58487. * @returns a new ImageAssetTask object
  58488. */
  58489. addImageTask(taskName: string, url: string): ImageAssetTask;
  58490. /**
  58491. * Add a TextureAssetTask to the list of active tasks
  58492. * @param taskName defines the name of the new task
  58493. * @param url defines the url of the file to load
  58494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58495. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58496. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58497. * @returns a new TextureAssetTask object
  58498. */
  58499. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58500. /**
  58501. * Add a CubeTextureAssetTask to the list of active tasks
  58502. * @param taskName defines the name of the new task
  58503. * @param url defines the url of the file to load
  58504. * @param extensions defines the extension to use to load the cube map (can be null)
  58505. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58506. * @param files defines the list of files to load (can be null)
  58507. * @returns a new CubeTextureAssetTask object
  58508. */
  58509. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58510. /**
  58511. *
  58512. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58513. * @param taskName defines the name of the new task
  58514. * @param url defines the url of the file to load
  58515. * @param size defines the size you want for the cubemap (can be null)
  58516. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58517. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58518. * @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)
  58519. * @param reserved Internal use only
  58520. * @returns a new HDRCubeTextureAssetTask object
  58521. */
  58522. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58523. /**
  58524. *
  58525. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58526. * @param taskName defines the name of the new task
  58527. * @param url defines the url of the file to load
  58528. * @param size defines the size you want for the cubemap (can be null)
  58529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58530. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58531. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58532. * @returns a new EquiRectangularCubeTextureAssetTask object
  58533. */
  58534. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58535. /**
  58536. * Remove a task from the assets manager.
  58537. * @param task the task to remove
  58538. */
  58539. removeTask(task: AbstractAssetTask): void;
  58540. private _decreaseWaitingTasksCount;
  58541. private _runTask;
  58542. /**
  58543. * Reset the AssetsManager and remove all tasks
  58544. * @return the current instance of the AssetsManager
  58545. */
  58546. reset(): AssetsManager;
  58547. /**
  58548. * Start the loading process
  58549. * @return the current instance of the AssetsManager
  58550. */
  58551. load(): AssetsManager;
  58552. /**
  58553. * Start the loading process as an async operation
  58554. * @return a promise returning the list of failed tasks
  58555. */
  58556. loadAsync(): Promise<void>;
  58557. }
  58558. }
  58559. declare module BABYLON {
  58560. /**
  58561. * Wrapper class for promise with external resolve and reject.
  58562. */
  58563. export class Deferred<T> {
  58564. /**
  58565. * The promise associated with this deferred object.
  58566. */
  58567. readonly promise: Promise<T>;
  58568. private _resolve;
  58569. private _reject;
  58570. /**
  58571. * The resolve method of the promise associated with this deferred object.
  58572. */
  58573. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58574. /**
  58575. * The reject method of the promise associated with this deferred object.
  58576. */
  58577. readonly reject: (reason?: any) => void;
  58578. /**
  58579. * Constructor for this deferred object.
  58580. */
  58581. constructor();
  58582. }
  58583. }
  58584. declare module BABYLON {
  58585. /**
  58586. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58587. */
  58588. export class MeshExploder {
  58589. private _centerMesh;
  58590. private _meshes;
  58591. private _meshesOrigins;
  58592. private _toCenterVectors;
  58593. private _scaledDirection;
  58594. private _newPosition;
  58595. private _centerPosition;
  58596. /**
  58597. * Explodes meshes from a center mesh.
  58598. * @param meshes The meshes to explode.
  58599. * @param centerMesh The mesh to be center of explosion.
  58600. */
  58601. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58602. private _setCenterMesh;
  58603. /**
  58604. * Get class name
  58605. * @returns "MeshExploder"
  58606. */
  58607. getClassName(): string;
  58608. /**
  58609. * "Exploded meshes"
  58610. * @returns Array of meshes with the centerMesh at index 0.
  58611. */
  58612. getMeshes(): Array<Mesh>;
  58613. /**
  58614. * Explodes meshes giving a specific direction
  58615. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58616. */
  58617. explode(direction?: number): void;
  58618. }
  58619. }
  58620. declare module BABYLON {
  58621. /**
  58622. * Class used to help managing file picking and drag'n'drop
  58623. */
  58624. export class FilesInput {
  58625. /**
  58626. * List of files ready to be loaded
  58627. */
  58628. static readonly FilesToLoad: {
  58629. [key: string]: File;
  58630. };
  58631. /**
  58632. * Callback called when a file is processed
  58633. */
  58634. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58635. private _engine;
  58636. private _currentScene;
  58637. private _sceneLoadedCallback;
  58638. private _progressCallback;
  58639. private _additionalRenderLoopLogicCallback;
  58640. private _textureLoadingCallback;
  58641. private _startingProcessingFilesCallback;
  58642. private _onReloadCallback;
  58643. private _errorCallback;
  58644. private _elementToMonitor;
  58645. private _sceneFileToLoad;
  58646. private _filesToLoad;
  58647. /**
  58648. * Creates a new FilesInput
  58649. * @param engine defines the rendering engine
  58650. * @param scene defines the hosting scene
  58651. * @param sceneLoadedCallback callback called when scene is loaded
  58652. * @param progressCallback callback called to track progress
  58653. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58654. * @param textureLoadingCallback callback called when a texture is loading
  58655. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58656. * @param onReloadCallback callback called when a reload is requested
  58657. * @param errorCallback callback call if an error occurs
  58658. */
  58659. 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);
  58660. private _dragEnterHandler;
  58661. private _dragOverHandler;
  58662. private _dropHandler;
  58663. /**
  58664. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58665. * @param elementToMonitor defines the DOM element to track
  58666. */
  58667. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58668. /**
  58669. * Release all associated resources
  58670. */
  58671. dispose(): void;
  58672. private renderFunction;
  58673. private drag;
  58674. private drop;
  58675. private _traverseFolder;
  58676. private _processFiles;
  58677. /**
  58678. * Load files from a drop event
  58679. * @param event defines the drop event to use as source
  58680. */
  58681. loadFiles(event: any): void;
  58682. private _processReload;
  58683. /**
  58684. * Reload the current scene from the loaded files
  58685. */
  58686. reload(): void;
  58687. }
  58688. }
  58689. declare module BABYLON {
  58690. /**
  58691. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58693. */
  58694. export class SceneOptimization {
  58695. /**
  58696. * Defines the priority of this optimization (0 by default which means first in the list)
  58697. */
  58698. priority: number;
  58699. /**
  58700. * Gets a string describing the action executed by the current optimization
  58701. * @returns description string
  58702. */
  58703. getDescription(): string;
  58704. /**
  58705. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58706. * @param scene defines the current scene where to apply this optimization
  58707. * @param optimizer defines the current optimizer
  58708. * @returns true if everything that can be done was applied
  58709. */
  58710. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58711. /**
  58712. * Creates the SceneOptimization object
  58713. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58714. * @param desc defines the description associated with the optimization
  58715. */
  58716. constructor(
  58717. /**
  58718. * Defines the priority of this optimization (0 by default which means first in the list)
  58719. */
  58720. priority?: number);
  58721. }
  58722. /**
  58723. * Defines an optimization used to reduce the size of render target textures
  58724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58725. */
  58726. export class TextureOptimization extends SceneOptimization {
  58727. /**
  58728. * Defines the priority of this optimization (0 by default which means first in the list)
  58729. */
  58730. priority: number;
  58731. /**
  58732. * 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
  58733. */
  58734. maximumSize: number;
  58735. /**
  58736. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58737. */
  58738. step: number;
  58739. /**
  58740. * Gets a string describing the action executed by the current optimization
  58741. * @returns description string
  58742. */
  58743. getDescription(): string;
  58744. /**
  58745. * Creates the TextureOptimization object
  58746. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58747. * @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
  58748. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58749. */
  58750. constructor(
  58751. /**
  58752. * Defines the priority of this optimization (0 by default which means first in the list)
  58753. */
  58754. priority?: number,
  58755. /**
  58756. * 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
  58757. */
  58758. maximumSize?: number,
  58759. /**
  58760. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58761. */
  58762. step?: number);
  58763. /**
  58764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58765. * @param scene defines the current scene where to apply this optimization
  58766. * @param optimizer defines the current optimizer
  58767. * @returns true if everything that can be done was applied
  58768. */
  58769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58770. }
  58771. /**
  58772. * Defines an optimization used to increase or decrease the rendering resolution
  58773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58774. */
  58775. export class HardwareScalingOptimization extends SceneOptimization {
  58776. /**
  58777. * Defines the priority of this optimization (0 by default which means first in the list)
  58778. */
  58779. priority: number;
  58780. /**
  58781. * Defines the maximum scale to use (2 by default)
  58782. */
  58783. maximumScale: number;
  58784. /**
  58785. * Defines the step to use between two passes (0.5 by default)
  58786. */
  58787. step: number;
  58788. private _currentScale;
  58789. private _directionOffset;
  58790. /**
  58791. * Gets a string describing the action executed by the current optimization
  58792. * @return description string
  58793. */
  58794. getDescription(): string;
  58795. /**
  58796. * Creates the HardwareScalingOptimization object
  58797. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58798. * @param maximumScale defines the maximum scale to use (2 by default)
  58799. * @param step defines the step to use between two passes (0.5 by default)
  58800. */
  58801. constructor(
  58802. /**
  58803. * Defines the priority of this optimization (0 by default which means first in the list)
  58804. */
  58805. priority?: number,
  58806. /**
  58807. * Defines the maximum scale to use (2 by default)
  58808. */
  58809. maximumScale?: number,
  58810. /**
  58811. * Defines the step to use between two passes (0.5 by default)
  58812. */
  58813. step?: number);
  58814. /**
  58815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58816. * @param scene defines the current scene where to apply this optimization
  58817. * @param optimizer defines the current optimizer
  58818. * @returns true if everything that can be done was applied
  58819. */
  58820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58821. }
  58822. /**
  58823. * Defines an optimization used to remove shadows
  58824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58825. */
  58826. export class ShadowsOptimization extends SceneOptimization {
  58827. /**
  58828. * Gets a string describing the action executed by the current optimization
  58829. * @return description string
  58830. */
  58831. getDescription(): string;
  58832. /**
  58833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58834. * @param scene defines the current scene where to apply this optimization
  58835. * @param optimizer defines the current optimizer
  58836. * @returns true if everything that can be done was applied
  58837. */
  58838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58839. }
  58840. /**
  58841. * Defines an optimization used to turn post-processes off
  58842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58843. */
  58844. export class PostProcessesOptimization extends SceneOptimization {
  58845. /**
  58846. * Gets a string describing the action executed by the current optimization
  58847. * @return description string
  58848. */
  58849. getDescription(): string;
  58850. /**
  58851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58852. * @param scene defines the current scene where to apply this optimization
  58853. * @param optimizer defines the current optimizer
  58854. * @returns true if everything that can be done was applied
  58855. */
  58856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58857. }
  58858. /**
  58859. * Defines an optimization used to turn lens flares off
  58860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58861. */
  58862. export class LensFlaresOptimization extends SceneOptimization {
  58863. /**
  58864. * Gets a string describing the action executed by the current optimization
  58865. * @return description string
  58866. */
  58867. getDescription(): string;
  58868. /**
  58869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58870. * @param scene defines the current scene where to apply this optimization
  58871. * @param optimizer defines the current optimizer
  58872. * @returns true if everything that can be done was applied
  58873. */
  58874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58875. }
  58876. /**
  58877. * Defines an optimization based on user defined callback.
  58878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58879. */
  58880. export class CustomOptimization extends SceneOptimization {
  58881. /**
  58882. * Callback called to apply the custom optimization.
  58883. */
  58884. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58885. /**
  58886. * Callback called to get custom description
  58887. */
  58888. onGetDescription: () => string;
  58889. /**
  58890. * Gets a string describing the action executed by the current optimization
  58891. * @returns description string
  58892. */
  58893. getDescription(): string;
  58894. /**
  58895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58896. * @param scene defines the current scene where to apply this optimization
  58897. * @param optimizer defines the current optimizer
  58898. * @returns true if everything that can be done was applied
  58899. */
  58900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58901. }
  58902. /**
  58903. * Defines an optimization used to turn particles off
  58904. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58905. */
  58906. export class ParticlesOptimization extends SceneOptimization {
  58907. /**
  58908. * Gets a string describing the action executed by the current optimization
  58909. * @return description string
  58910. */
  58911. getDescription(): string;
  58912. /**
  58913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58914. * @param scene defines the current scene where to apply this optimization
  58915. * @param optimizer defines the current optimizer
  58916. * @returns true if everything that can be done was applied
  58917. */
  58918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58919. }
  58920. /**
  58921. * Defines an optimization used to turn render targets off
  58922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58923. */
  58924. export class RenderTargetsOptimization extends SceneOptimization {
  58925. /**
  58926. * Gets a string describing the action executed by the current optimization
  58927. * @return description string
  58928. */
  58929. getDescription(): string;
  58930. /**
  58931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58932. * @param scene defines the current scene where to apply this optimization
  58933. * @param optimizer defines the current optimizer
  58934. * @returns true if everything that can be done was applied
  58935. */
  58936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58937. }
  58938. /**
  58939. * Defines an optimization used to merge meshes with compatible materials
  58940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58941. */
  58942. export class MergeMeshesOptimization extends SceneOptimization {
  58943. private static _UpdateSelectionTree;
  58944. /**
  58945. * Gets or sets a boolean which defines if optimization octree has to be updated
  58946. */
  58947. /**
  58948. * Gets or sets a boolean which defines if optimization octree has to be updated
  58949. */
  58950. static UpdateSelectionTree: boolean;
  58951. /**
  58952. * Gets a string describing the action executed by the current optimization
  58953. * @return description string
  58954. */
  58955. getDescription(): string;
  58956. private _canBeMerged;
  58957. /**
  58958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58959. * @param scene defines the current scene where to apply this optimization
  58960. * @param optimizer defines the current optimizer
  58961. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58962. * @returns true if everything that can be done was applied
  58963. */
  58964. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58965. }
  58966. /**
  58967. * Defines a list of options used by SceneOptimizer
  58968. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58969. */
  58970. export class SceneOptimizerOptions {
  58971. /**
  58972. * Defines the target frame rate to reach (60 by default)
  58973. */
  58974. targetFrameRate: number;
  58975. /**
  58976. * Defines the interval between two checkes (2000ms by default)
  58977. */
  58978. trackerDuration: number;
  58979. /**
  58980. * Gets the list of optimizations to apply
  58981. */
  58982. optimizations: SceneOptimization[];
  58983. /**
  58984. * Creates a new list of options used by SceneOptimizer
  58985. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58986. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58987. */
  58988. constructor(
  58989. /**
  58990. * Defines the target frame rate to reach (60 by default)
  58991. */
  58992. targetFrameRate?: number,
  58993. /**
  58994. * Defines the interval between two checkes (2000ms by default)
  58995. */
  58996. trackerDuration?: number);
  58997. /**
  58998. * Add a new optimization
  58999. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59000. * @returns the current SceneOptimizerOptions
  59001. */
  59002. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59003. /**
  59004. * Add a new custom optimization
  59005. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59006. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59007. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59008. * @returns the current SceneOptimizerOptions
  59009. */
  59010. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59011. /**
  59012. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59013. * @param targetFrameRate defines the target frame rate (60 by default)
  59014. * @returns a SceneOptimizerOptions object
  59015. */
  59016. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59017. /**
  59018. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59019. * @param targetFrameRate defines the target frame rate (60 by default)
  59020. * @returns a SceneOptimizerOptions object
  59021. */
  59022. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59023. /**
  59024. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59025. * @param targetFrameRate defines the target frame rate (60 by default)
  59026. * @returns a SceneOptimizerOptions object
  59027. */
  59028. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59029. }
  59030. /**
  59031. * Class used to run optimizations in order to reach a target frame rate
  59032. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59033. */
  59034. export class SceneOptimizer implements IDisposable {
  59035. private _isRunning;
  59036. private _options;
  59037. private _scene;
  59038. private _currentPriorityLevel;
  59039. private _targetFrameRate;
  59040. private _trackerDuration;
  59041. private _currentFrameRate;
  59042. private _sceneDisposeObserver;
  59043. private _improvementMode;
  59044. /**
  59045. * Defines an observable called when the optimizer reaches the target frame rate
  59046. */
  59047. onSuccessObservable: Observable<SceneOptimizer>;
  59048. /**
  59049. * Defines an observable called when the optimizer enables an optimization
  59050. */
  59051. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59052. /**
  59053. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59054. */
  59055. onFailureObservable: Observable<SceneOptimizer>;
  59056. /**
  59057. * Gets a boolean indicating if the optimizer is in improvement mode
  59058. */
  59059. readonly isInImprovementMode: boolean;
  59060. /**
  59061. * Gets the current priority level (0 at start)
  59062. */
  59063. readonly currentPriorityLevel: number;
  59064. /**
  59065. * Gets the current frame rate checked by the SceneOptimizer
  59066. */
  59067. readonly currentFrameRate: number;
  59068. /**
  59069. * Gets or sets the current target frame rate (60 by default)
  59070. */
  59071. /**
  59072. * Gets or sets the current target frame rate (60 by default)
  59073. */
  59074. targetFrameRate: number;
  59075. /**
  59076. * Gets or sets the current interval between two checks (every 2000ms by default)
  59077. */
  59078. /**
  59079. * Gets or sets the current interval between two checks (every 2000ms by default)
  59080. */
  59081. trackerDuration: number;
  59082. /**
  59083. * Gets the list of active optimizations
  59084. */
  59085. readonly optimizations: SceneOptimization[];
  59086. /**
  59087. * Creates a new SceneOptimizer
  59088. * @param scene defines the scene to work on
  59089. * @param options defines the options to use with the SceneOptimizer
  59090. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59091. * @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)
  59092. */
  59093. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59094. /**
  59095. * Stops the current optimizer
  59096. */
  59097. stop(): void;
  59098. /**
  59099. * Reset the optimizer to initial step (current priority level = 0)
  59100. */
  59101. reset(): void;
  59102. /**
  59103. * Start the optimizer. By default it will try to reach a specific framerate
  59104. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59105. */
  59106. start(): void;
  59107. private _checkCurrentState;
  59108. /**
  59109. * Release all resources
  59110. */
  59111. dispose(): void;
  59112. /**
  59113. * Helper function to create a SceneOptimizer with one single line of code
  59114. * @param scene defines the scene to work on
  59115. * @param options defines the options to use with the SceneOptimizer
  59116. * @param onSuccess defines a callback to call on success
  59117. * @param onFailure defines a callback to call on failure
  59118. * @returns the new SceneOptimizer object
  59119. */
  59120. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59121. }
  59122. }
  59123. declare module BABYLON {
  59124. /**
  59125. * Class used to serialize a scene into a string
  59126. */
  59127. export class SceneSerializer {
  59128. /**
  59129. * Clear cache used by a previous serialization
  59130. */
  59131. static ClearCache(): void;
  59132. /**
  59133. * Serialize a scene into a JSON compatible object
  59134. * @param scene defines the scene to serialize
  59135. * @returns a JSON compatible object
  59136. */
  59137. static Serialize(scene: Scene): any;
  59138. /**
  59139. * Serialize a mesh into a JSON compatible object
  59140. * @param toSerialize defines the mesh to serialize
  59141. * @param withParents defines if parents must be serialized as well
  59142. * @param withChildren defines if children must be serialized as well
  59143. * @returns a JSON compatible object
  59144. */
  59145. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59146. }
  59147. }
  59148. declare module BABYLON {
  59149. /**
  59150. * Class used to host texture specific utilities
  59151. */
  59152. export class TextureTools {
  59153. /**
  59154. * Uses the GPU to create a copy texture rescaled at a given size
  59155. * @param texture Texture to copy from
  59156. * @param width defines the desired width
  59157. * @param height defines the desired height
  59158. * @param useBilinearMode defines if bilinear mode has to be used
  59159. * @return the generated texture
  59160. */
  59161. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59162. }
  59163. }
  59164. declare module BABYLON {
  59165. /**
  59166. * This represents the different options available for the video capture.
  59167. */
  59168. export interface VideoRecorderOptions {
  59169. /** Defines the mime type of the video. */
  59170. mimeType: string;
  59171. /** Defines the FPS the video should be recorded at. */
  59172. fps: number;
  59173. /** Defines the chunk size for the recording data. */
  59174. recordChunckSize: number;
  59175. /** The audio tracks to attach to the recording. */
  59176. audioTracks?: MediaStreamTrack[];
  59177. }
  59178. /**
  59179. * This can help with recording videos from BabylonJS.
  59180. * This is based on the available WebRTC functionalities of the browser.
  59181. *
  59182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59183. */
  59184. export class VideoRecorder {
  59185. private static readonly _defaultOptions;
  59186. /**
  59187. * Returns whether or not the VideoRecorder is available in your browser.
  59188. * @param engine Defines the Babylon Engine.
  59189. * @returns true if supported otherwise false.
  59190. */
  59191. static IsSupported(engine: Engine): boolean;
  59192. private readonly _options;
  59193. private _canvas;
  59194. private _mediaRecorder;
  59195. private _recordedChunks;
  59196. private _fileName;
  59197. private _resolve;
  59198. private _reject;
  59199. /**
  59200. * True when a recording is already in progress.
  59201. */
  59202. readonly isRecording: boolean;
  59203. /**
  59204. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59205. * @param engine Defines the BabylonJS Engine you wish to record.
  59206. * @param options Defines options that can be used to customize the capture.
  59207. */
  59208. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59209. /**
  59210. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59211. */
  59212. stopRecording(): void;
  59213. /**
  59214. * Starts recording the canvas for a max duration specified in parameters.
  59215. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59216. * If null no automatic download will start and you can rely on the promise to get the data back.
  59217. * @param maxDuration Defines the maximum recording time in seconds.
  59218. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59219. * @return A promise callback at the end of the recording with the video data in Blob.
  59220. */
  59221. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59222. /**
  59223. * Releases internal resources used during the recording.
  59224. */
  59225. dispose(): void;
  59226. private _handleDataAvailable;
  59227. private _handleError;
  59228. private _handleStop;
  59229. }
  59230. }
  59231. declare module BABYLON {
  59232. /**
  59233. * Class containing a set of static utilities functions for screenshots
  59234. */
  59235. export class ScreenshotTools {
  59236. /**
  59237. * Captures a screenshot of the current rendering
  59238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59239. * @param engine defines the rendering engine
  59240. * @param camera defines the source camera
  59241. * @param size This parameter can be set to a single number or to an object with the
  59242. * following (optional) properties: precision, width, height. If a single number is passed,
  59243. * it will be used for both width and height. If an object is passed, the screenshot size
  59244. * will be derived from the parameters. The precision property is a multiplier allowing
  59245. * rendering at a higher or lower resolution
  59246. * @param successCallback defines the callback receives a single parameter which contains the
  59247. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59248. * src parameter of an <img> to display it
  59249. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59250. * Check your browser for supported MIME types
  59251. */
  59252. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59253. /**
  59254. * Generates an image screenshot from the specified camera.
  59255. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59256. * @param engine The engine to use for rendering
  59257. * @param camera The camera to use for rendering
  59258. * @param size This parameter can be set to a single number or to an object with the
  59259. * following (optional) properties: precision, width, height. If a single number is passed,
  59260. * it will be used for both width and height. If an object is passed, the screenshot size
  59261. * will be derived from the parameters. The precision property is a multiplier allowing
  59262. * rendering at a higher or lower resolution
  59263. * @param successCallback The callback receives a single parameter which contains the
  59264. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59265. * src parameter of an <img> to display it
  59266. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59267. * Check your browser for supported MIME types
  59268. * @param samples Texture samples (default: 1)
  59269. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59270. * @param fileName A name for for the downloaded file.
  59271. */
  59272. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59273. }
  59274. }
  59275. declare module BABYLON {
  59276. /**
  59277. * A cursor which tracks a point on a path
  59278. */
  59279. export class PathCursor {
  59280. private path;
  59281. /**
  59282. * Stores path cursor callbacks for when an onchange event is triggered
  59283. */
  59284. private _onchange;
  59285. /**
  59286. * The value of the path cursor
  59287. */
  59288. value: number;
  59289. /**
  59290. * The animation array of the path cursor
  59291. */
  59292. animations: Animation[];
  59293. /**
  59294. * Initializes the path cursor
  59295. * @param path The path to track
  59296. */
  59297. constructor(path: Path2);
  59298. /**
  59299. * Gets the cursor point on the path
  59300. * @returns A point on the path cursor at the cursor location
  59301. */
  59302. getPoint(): Vector3;
  59303. /**
  59304. * Moves the cursor ahead by the step amount
  59305. * @param step The amount to move the cursor forward
  59306. * @returns This path cursor
  59307. */
  59308. moveAhead(step?: number): PathCursor;
  59309. /**
  59310. * Moves the cursor behind by the step amount
  59311. * @param step The amount to move the cursor back
  59312. * @returns This path cursor
  59313. */
  59314. moveBack(step?: number): PathCursor;
  59315. /**
  59316. * Moves the cursor by the step amount
  59317. * If the step amount is greater than one, an exception is thrown
  59318. * @param step The amount to move the cursor
  59319. * @returns This path cursor
  59320. */
  59321. move(step: number): PathCursor;
  59322. /**
  59323. * Ensures that the value is limited between zero and one
  59324. * @returns This path cursor
  59325. */
  59326. private ensureLimits;
  59327. /**
  59328. * Runs onchange callbacks on change (used by the animation engine)
  59329. * @returns This path cursor
  59330. */
  59331. private raiseOnChange;
  59332. /**
  59333. * Executes a function on change
  59334. * @param f A path cursor onchange callback
  59335. * @returns This path cursor
  59336. */
  59337. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59338. }
  59339. }
  59340. declare module BABYLON {
  59341. /** @hidden */
  59342. export var blurPixelShader: {
  59343. name: string;
  59344. shader: string;
  59345. };
  59346. }
  59347. declare module BABYLON {
  59348. /** @hidden */
  59349. export var pointCloudVertexDeclaration: {
  59350. name: string;
  59351. shader: string;
  59352. };
  59353. }
  59354. // Mixins
  59355. interface Window {
  59356. mozIndexedDB: IDBFactory;
  59357. webkitIndexedDB: IDBFactory;
  59358. msIndexedDB: IDBFactory;
  59359. webkitURL: typeof URL;
  59360. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59361. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59362. WebGLRenderingContext: WebGLRenderingContext;
  59363. MSGesture: MSGesture;
  59364. CANNON: any;
  59365. AudioContext: AudioContext;
  59366. webkitAudioContext: AudioContext;
  59367. PointerEvent: any;
  59368. Math: Math;
  59369. Uint8Array: Uint8ArrayConstructor;
  59370. Float32Array: Float32ArrayConstructor;
  59371. mozURL: typeof URL;
  59372. msURL: typeof URL;
  59373. VRFrameData: any; // WebVR, from specs 1.1
  59374. DracoDecoderModule: any;
  59375. setImmediate(handler: (...args: any[]) => void): number;
  59376. }
  59377. interface HTMLCanvasElement {
  59378. requestPointerLock(): void;
  59379. msRequestPointerLock?(): void;
  59380. mozRequestPointerLock?(): void;
  59381. webkitRequestPointerLock?(): void;
  59382. /** Track wether a record is in progress */
  59383. isRecording: boolean;
  59384. /** Capture Stream method defined by some browsers */
  59385. captureStream(fps?: number): MediaStream;
  59386. }
  59387. interface CanvasRenderingContext2D {
  59388. msImageSmoothingEnabled: boolean;
  59389. }
  59390. interface MouseEvent {
  59391. mozMovementX: number;
  59392. mozMovementY: number;
  59393. webkitMovementX: number;
  59394. webkitMovementY: number;
  59395. msMovementX: number;
  59396. msMovementY: number;
  59397. }
  59398. interface Navigator {
  59399. mozGetVRDevices: (any: any) => any;
  59400. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59401. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59402. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59403. webkitGetGamepads(): Gamepad[];
  59404. msGetGamepads(): Gamepad[];
  59405. webkitGamepads(): Gamepad[];
  59406. }
  59407. interface HTMLVideoElement {
  59408. mozSrcObject: any;
  59409. }
  59410. interface Math {
  59411. fround(x: number): number;
  59412. imul(a: number, b: number): number;
  59413. }
  59414. interface WebGLRenderingContext {
  59415. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59416. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59417. vertexAttribDivisor(index: number, divisor: number): void;
  59418. createVertexArray(): any;
  59419. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59420. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59421. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59422. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59423. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59424. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59425. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59426. // Queries
  59427. createQuery(): WebGLQuery;
  59428. deleteQuery(query: WebGLQuery): void;
  59429. beginQuery(target: number, query: WebGLQuery): void;
  59430. endQuery(target: number): void;
  59431. getQueryParameter(query: WebGLQuery, pname: number): any;
  59432. getQuery(target: number, pname: number): any;
  59433. MAX_SAMPLES: number;
  59434. RGBA8: number;
  59435. READ_FRAMEBUFFER: number;
  59436. DRAW_FRAMEBUFFER: number;
  59437. UNIFORM_BUFFER: number;
  59438. HALF_FLOAT_OES: number;
  59439. RGBA16F: number;
  59440. RGBA32F: number;
  59441. R32F: number;
  59442. RG32F: number;
  59443. RGB32F: number;
  59444. R16F: number;
  59445. RG16F: number;
  59446. RGB16F: number;
  59447. RED: number;
  59448. RG: number;
  59449. R8: number;
  59450. RG8: number;
  59451. UNSIGNED_INT_24_8: number;
  59452. DEPTH24_STENCIL8: number;
  59453. /* Multiple Render Targets */
  59454. drawBuffers(buffers: number[]): void;
  59455. readBuffer(src: number): void;
  59456. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59457. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59458. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59459. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59460. // Occlusion Query
  59461. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59462. ANY_SAMPLES_PASSED: number;
  59463. QUERY_RESULT_AVAILABLE: number;
  59464. QUERY_RESULT: number;
  59465. }
  59466. interface WebGLProgram {
  59467. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59468. }
  59469. interface EXT_disjoint_timer_query {
  59470. QUERY_COUNTER_BITS_EXT: number;
  59471. TIME_ELAPSED_EXT: number;
  59472. TIMESTAMP_EXT: number;
  59473. GPU_DISJOINT_EXT: number;
  59474. QUERY_RESULT_EXT: number;
  59475. QUERY_RESULT_AVAILABLE_EXT: number;
  59476. queryCounterEXT(query: WebGLQuery, target: number): void;
  59477. createQueryEXT(): WebGLQuery;
  59478. beginQueryEXT(target: number, query: WebGLQuery): void;
  59479. endQueryEXT(target: number): void;
  59480. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59481. deleteQueryEXT(query: WebGLQuery): void;
  59482. }
  59483. interface WebGLUniformLocation {
  59484. _currentState: any;
  59485. }
  59486. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59487. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59488. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59490. interface WebGLRenderingContext {
  59491. readonly RASTERIZER_DISCARD: number;
  59492. readonly DEPTH_COMPONENT24: number;
  59493. readonly TEXTURE_3D: number;
  59494. readonly TEXTURE_2D_ARRAY: number;
  59495. readonly TEXTURE_COMPARE_FUNC: number;
  59496. readonly TEXTURE_COMPARE_MODE: number;
  59497. readonly COMPARE_REF_TO_TEXTURE: number;
  59498. readonly TEXTURE_WRAP_R: number;
  59499. readonly HALF_FLOAT: number;
  59500. readonly RGB8: number;
  59501. readonly RED_INTEGER: number;
  59502. readonly RG_INTEGER: number;
  59503. readonly RGB_INTEGER: number;
  59504. readonly RGBA_INTEGER: number;
  59505. readonly R8_SNORM: number;
  59506. readonly RG8_SNORM: number;
  59507. readonly RGB8_SNORM: number;
  59508. readonly RGBA8_SNORM: number;
  59509. readonly R8I: number;
  59510. readonly RG8I: number;
  59511. readonly RGB8I: number;
  59512. readonly RGBA8I: number;
  59513. readonly R8UI: number;
  59514. readonly RG8UI: number;
  59515. readonly RGB8UI: number;
  59516. readonly RGBA8UI: number;
  59517. readonly R16I: number;
  59518. readonly RG16I: number;
  59519. readonly RGB16I: number;
  59520. readonly RGBA16I: number;
  59521. readonly R16UI: number;
  59522. readonly RG16UI: number;
  59523. readonly RGB16UI: number;
  59524. readonly RGBA16UI: number;
  59525. readonly R32I: number;
  59526. readonly RG32I: number;
  59527. readonly RGB32I: number;
  59528. readonly RGBA32I: number;
  59529. readonly R32UI: number;
  59530. readonly RG32UI: number;
  59531. readonly RGB32UI: number;
  59532. readonly RGBA32UI: number;
  59533. readonly RGB10_A2UI: number;
  59534. readonly R11F_G11F_B10F: number;
  59535. readonly RGB9_E5: number;
  59536. readonly RGB10_A2: number;
  59537. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59538. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59539. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59540. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59541. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59542. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59543. 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;
  59544. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59545. readonly TRANSFORM_FEEDBACK: number;
  59546. readonly INTERLEAVED_ATTRIBS: number;
  59547. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59548. createTransformFeedback(): WebGLTransformFeedback;
  59549. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59550. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59551. beginTransformFeedback(primitiveMode: number): void;
  59552. endTransformFeedback(): void;
  59553. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59554. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59555. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59556. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59557. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59558. }
  59559. interface ImageBitmap {
  59560. readonly width: number;
  59561. readonly height: number;
  59562. close(): void;
  59563. }
  59564. interface WebGLQuery extends WebGLObject {
  59565. }
  59566. declare var WebGLQuery: {
  59567. prototype: WebGLQuery;
  59568. new(): WebGLQuery;
  59569. };
  59570. interface WebGLSampler extends WebGLObject {
  59571. }
  59572. declare var WebGLSampler: {
  59573. prototype: WebGLSampler;
  59574. new(): WebGLSampler;
  59575. };
  59576. interface WebGLSync extends WebGLObject {
  59577. }
  59578. declare var WebGLSync: {
  59579. prototype: WebGLSync;
  59580. new(): WebGLSync;
  59581. };
  59582. interface WebGLTransformFeedback extends WebGLObject {
  59583. }
  59584. declare var WebGLTransformFeedback: {
  59585. prototype: WebGLTransformFeedback;
  59586. new(): WebGLTransformFeedback;
  59587. };
  59588. interface WebGLVertexArrayObject extends WebGLObject {
  59589. }
  59590. declare var WebGLVertexArrayObject: {
  59591. prototype: WebGLVertexArrayObject;
  59592. new(): WebGLVertexArrayObject;
  59593. };
  59594. // Type definitions for WebVR API
  59595. // Project: https://w3c.github.io/webvr/
  59596. // Definitions by: six a <https://github.com/lostfictions>
  59597. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59598. interface VRDisplay extends EventTarget {
  59599. /**
  59600. * Dictionary of capabilities describing the VRDisplay.
  59601. */
  59602. readonly capabilities: VRDisplayCapabilities;
  59603. /**
  59604. * z-depth defining the far plane of the eye view frustum
  59605. * enables mapping of values in the render target depth
  59606. * attachment to scene coordinates. Initially set to 10000.0.
  59607. */
  59608. depthFar: number;
  59609. /**
  59610. * z-depth defining the near plane of the eye view frustum
  59611. * enables mapping of values in the render target depth
  59612. * attachment to scene coordinates. Initially set to 0.01.
  59613. */
  59614. depthNear: number;
  59615. /**
  59616. * An identifier for this distinct VRDisplay. Used as an
  59617. * association point in the Gamepad API.
  59618. */
  59619. readonly displayId: number;
  59620. /**
  59621. * A display name, a user-readable name identifying it.
  59622. */
  59623. readonly displayName: string;
  59624. readonly isConnected: boolean;
  59625. readonly isPresenting: boolean;
  59626. /**
  59627. * If this VRDisplay supports room-scale experiences, the optional
  59628. * stage attribute contains details on the room-scale parameters.
  59629. */
  59630. readonly stageParameters: VRStageParameters | null;
  59631. /**
  59632. * Passing the value returned by `requestAnimationFrame` to
  59633. * `cancelAnimationFrame` will unregister the callback.
  59634. * @param handle Define the hanle of the request to cancel
  59635. */
  59636. cancelAnimationFrame(handle: number): void;
  59637. /**
  59638. * Stops presenting to the VRDisplay.
  59639. * @returns a promise to know when it stopped
  59640. */
  59641. exitPresent(): Promise<void>;
  59642. /**
  59643. * Return the current VREyeParameters for the given eye.
  59644. * @param whichEye Define the eye we want the parameter for
  59645. * @returns the eye parameters
  59646. */
  59647. getEyeParameters(whichEye: string): VREyeParameters;
  59648. /**
  59649. * Populates the passed VRFrameData with the information required to render
  59650. * the current frame.
  59651. * @param frameData Define the data structure to populate
  59652. * @returns true if ok otherwise false
  59653. */
  59654. getFrameData(frameData: VRFrameData): boolean;
  59655. /**
  59656. * Get the layers currently being presented.
  59657. * @returns the list of VR layers
  59658. */
  59659. getLayers(): VRLayer[];
  59660. /**
  59661. * Return a VRPose containing the future predicted pose of the VRDisplay
  59662. * when the current frame will be presented. The value returned will not
  59663. * change until JavaScript has returned control to the browser.
  59664. *
  59665. * The VRPose will contain the position, orientation, velocity,
  59666. * and acceleration of each of these properties.
  59667. * @returns the pose object
  59668. */
  59669. getPose(): VRPose;
  59670. /**
  59671. * Return the current instantaneous pose of the VRDisplay, with no
  59672. * prediction applied.
  59673. * @returns the current instantaneous pose
  59674. */
  59675. getImmediatePose(): VRPose;
  59676. /**
  59677. * The callback passed to `requestAnimationFrame` will be called
  59678. * any time a new frame should be rendered. When the VRDisplay is
  59679. * presenting the callback will be called at the native refresh
  59680. * rate of the HMD. When not presenting this function acts
  59681. * identically to how window.requestAnimationFrame acts. Content should
  59682. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59683. * asynchronously from other displays and at differing refresh rates.
  59684. * @param callback Define the eaction to run next frame
  59685. * @returns the request handle it
  59686. */
  59687. requestAnimationFrame(callback: FrameRequestCallback): number;
  59688. /**
  59689. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59690. * Repeat calls while already presenting will update the VRLayers being displayed.
  59691. * @param layers Define the list of layer to present
  59692. * @returns a promise to know when the request has been fulfilled
  59693. */
  59694. requestPresent(layers: VRLayer[]): Promise<void>;
  59695. /**
  59696. * Reset the pose for this display, treating its current position and
  59697. * orientation as the "origin/zero" values. VRPose.position,
  59698. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59699. * updated when calling resetPose(). This should be called in only
  59700. * sitting-space experiences.
  59701. */
  59702. resetPose(): void;
  59703. /**
  59704. * The VRLayer provided to the VRDisplay will be captured and presented
  59705. * in the HMD. Calling this function has the same effect on the source
  59706. * canvas as any other operation that uses its source image, and canvases
  59707. * created without preserveDrawingBuffer set to true will be cleared.
  59708. * @param pose Define the pose to submit
  59709. */
  59710. submitFrame(pose?: VRPose): void;
  59711. }
  59712. declare var VRDisplay: {
  59713. prototype: VRDisplay;
  59714. new(): VRDisplay;
  59715. };
  59716. interface VRLayer {
  59717. leftBounds?: number[] | Float32Array | null;
  59718. rightBounds?: number[] | Float32Array | null;
  59719. source?: HTMLCanvasElement | null;
  59720. }
  59721. interface VRDisplayCapabilities {
  59722. readonly canPresent: boolean;
  59723. readonly hasExternalDisplay: boolean;
  59724. readonly hasOrientation: boolean;
  59725. readonly hasPosition: boolean;
  59726. readonly maxLayers: number;
  59727. }
  59728. interface VREyeParameters {
  59729. /** @deprecated */
  59730. readonly fieldOfView: VRFieldOfView;
  59731. readonly offset: Float32Array;
  59732. readonly renderHeight: number;
  59733. readonly renderWidth: number;
  59734. }
  59735. interface VRFieldOfView {
  59736. readonly downDegrees: number;
  59737. readonly leftDegrees: number;
  59738. readonly rightDegrees: number;
  59739. readonly upDegrees: number;
  59740. }
  59741. interface VRFrameData {
  59742. readonly leftProjectionMatrix: Float32Array;
  59743. readonly leftViewMatrix: Float32Array;
  59744. readonly pose: VRPose;
  59745. readonly rightProjectionMatrix: Float32Array;
  59746. readonly rightViewMatrix: Float32Array;
  59747. readonly timestamp: number;
  59748. }
  59749. interface VRPose {
  59750. readonly angularAcceleration: Float32Array | null;
  59751. readonly angularVelocity: Float32Array | null;
  59752. readonly linearAcceleration: Float32Array | null;
  59753. readonly linearVelocity: Float32Array | null;
  59754. readonly orientation: Float32Array | null;
  59755. readonly position: Float32Array | null;
  59756. readonly timestamp: number;
  59757. }
  59758. interface VRStageParameters {
  59759. sittingToStandingTransform?: Float32Array;
  59760. sizeX?: number;
  59761. sizeY?: number;
  59762. }
  59763. interface Navigator {
  59764. getVRDisplays(): Promise<VRDisplay[]>;
  59765. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59766. }
  59767. interface Window {
  59768. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59769. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59770. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59771. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59772. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59773. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59774. }
  59775. interface Gamepad {
  59776. readonly displayId: number;
  59777. }
  59778. interface XRDevice {
  59779. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59780. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59781. }
  59782. interface XRSession {
  59783. getInputSources(): Array<any>;
  59784. baseLayer: XRWebGLLayer;
  59785. requestFrameOfReference(type: string): Promise<void>;
  59786. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59787. end(): Promise<void>;
  59788. requestAnimationFrame: Function;
  59789. addEventListener: Function;
  59790. }
  59791. interface XRSessionCreationOptions {
  59792. outputContext?: WebGLRenderingContext | null;
  59793. immersive?: boolean;
  59794. environmentIntegration?: boolean;
  59795. }
  59796. interface XRLayer {
  59797. getViewport: Function;
  59798. framebufferWidth: number;
  59799. framebufferHeight: number;
  59800. }
  59801. interface XRView {
  59802. projectionMatrix: Float32Array;
  59803. }
  59804. interface XRFrame {
  59805. getDevicePose: Function;
  59806. getInputPose: Function;
  59807. views: Array<XRView>;
  59808. baseLayer: XRLayer;
  59809. }
  59810. interface XRFrameOfReference {
  59811. }
  59812. interface XRWebGLLayer extends XRLayer {
  59813. framebuffer: WebGLFramebuffer;
  59814. }
  59815. declare var XRWebGLLayer: {
  59816. prototype: XRWebGLLayer;
  59817. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59818. };
  59819. declare module BABYLON.GUI {
  59820. /**
  59821. * Class used to specific a value and its associated unit
  59822. */
  59823. export class ValueAndUnit {
  59824. /** defines the unit to store */
  59825. unit: number;
  59826. /** defines a boolean indicating if the value can be negative */
  59827. negativeValueAllowed: boolean;
  59828. private _value;
  59829. private _originalUnit;
  59830. /**
  59831. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  59832. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59833. */
  59834. ignoreAdaptiveScaling: boolean;
  59835. /**
  59836. * Creates a new ValueAndUnit
  59837. * @param value defines the value to store
  59838. * @param unit defines the unit to store
  59839. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  59840. */
  59841. constructor(value: number,
  59842. /** defines the unit to store */
  59843. unit?: number,
  59844. /** defines a boolean indicating if the value can be negative */
  59845. negativeValueAllowed?: boolean);
  59846. /** Gets a boolean indicating if the value is a percentage */
  59847. readonly isPercentage: boolean;
  59848. /** Gets a boolean indicating if the value is store as pixel */
  59849. readonly isPixel: boolean;
  59850. /** Gets direct internal value */
  59851. readonly internalValue: number;
  59852. /**
  59853. * Gets value as pixel
  59854. * @param host defines the root host
  59855. * @param refValue defines the reference value for percentages
  59856. * @returns the value as pixel
  59857. */
  59858. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  59859. /**
  59860. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  59861. * @param value defines the value to store
  59862. * @param unit defines the unit to store
  59863. * @returns the current ValueAndUnit
  59864. */
  59865. updateInPlace(value: number, unit?: number): ValueAndUnit;
  59866. /**
  59867. * Gets the value accordingly to its unit
  59868. * @param host defines the root host
  59869. * @returns the value
  59870. */
  59871. getValue(host: AdvancedDynamicTexture): number;
  59872. /**
  59873. * Gets a string representation of the value
  59874. * @param host defines the root host
  59875. * @param decimals defines an optional number of decimals to display
  59876. * @returns a string
  59877. */
  59878. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59879. /**
  59880. * Store a value parsed from a string
  59881. * @param source defines the source string
  59882. * @returns true if the value was successfully parsed
  59883. */
  59884. fromString(source: string | number): boolean;
  59885. private static _Regex;
  59886. private static _UNITMODE_PERCENTAGE;
  59887. private static _UNITMODE_PIXEL;
  59888. /** UNITMODE_PERCENTAGE */
  59889. static readonly UNITMODE_PERCENTAGE: number;
  59890. /** UNITMODE_PIXEL */
  59891. static readonly UNITMODE_PIXEL: number;
  59892. }
  59893. }
  59894. declare module BABYLON.GUI {
  59895. /**
  59896. * Define a style used by control to automatically setup properties based on a template.
  59897. * Only support font related properties so far
  59898. */
  59899. export class Style implements BABYLON.IDisposable {
  59900. private _fontFamily;
  59901. private _fontStyle;
  59902. private _fontWeight;
  59903. /** @hidden */
  59904. _host: AdvancedDynamicTexture;
  59905. /** @hidden */
  59906. _fontSize: ValueAndUnit;
  59907. /**
  59908. * BABYLON.Observable raised when the style values are changed
  59909. */
  59910. onChangedObservable: BABYLON.Observable<Style>;
  59911. /**
  59912. * Creates a new style object
  59913. * @param host defines the AdvancedDynamicTexture which hosts this style
  59914. */
  59915. constructor(host: AdvancedDynamicTexture);
  59916. /**
  59917. * Gets or sets the font size
  59918. */
  59919. fontSize: string | number;
  59920. /**
  59921. * Gets or sets the font family
  59922. */
  59923. fontFamily: string;
  59924. /**
  59925. * Gets or sets the font style
  59926. */
  59927. fontStyle: string;
  59928. /** Gets or sets font weight */
  59929. fontWeight: string;
  59930. /** Dispose all associated resources */
  59931. dispose(): void;
  59932. }
  59933. }
  59934. declare module BABYLON.GUI {
  59935. /**
  59936. * Class used to transport BABYLON.Vector2 information for pointer events
  59937. */
  59938. export class Vector2WithInfo extends BABYLON.Vector2 {
  59939. /** defines the current mouse button index */
  59940. buttonIndex: number;
  59941. /**
  59942. * Creates a new Vector2WithInfo
  59943. * @param source defines the vector2 data to transport
  59944. * @param buttonIndex defines the current mouse button index
  59945. */
  59946. constructor(source: BABYLON.Vector2,
  59947. /** defines the current mouse button index */
  59948. buttonIndex?: number);
  59949. }
  59950. /** Class used to provide 2D matrix features */
  59951. export class Matrix2D {
  59952. /** Gets the internal array of 6 floats used to store matrix data */
  59953. m: Float32Array;
  59954. /**
  59955. * Creates a new matrix
  59956. * @param m00 defines value for (0, 0)
  59957. * @param m01 defines value for (0, 1)
  59958. * @param m10 defines value for (1, 0)
  59959. * @param m11 defines value for (1, 1)
  59960. * @param m20 defines value for (2, 0)
  59961. * @param m21 defines value for (2, 1)
  59962. */
  59963. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59964. /**
  59965. * Fills the matrix from direct values
  59966. * @param m00 defines value for (0, 0)
  59967. * @param m01 defines value for (0, 1)
  59968. * @param m10 defines value for (1, 0)
  59969. * @param m11 defines value for (1, 1)
  59970. * @param m20 defines value for (2, 0)
  59971. * @param m21 defines value for (2, 1)
  59972. * @returns the current modified matrix
  59973. */
  59974. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59975. /**
  59976. * Gets matrix determinant
  59977. * @returns the determinant
  59978. */
  59979. determinant(): number;
  59980. /**
  59981. * Inverses the matrix and stores it in a target matrix
  59982. * @param result defines the target matrix
  59983. * @returns the current matrix
  59984. */
  59985. invertToRef(result: Matrix2D): Matrix2D;
  59986. /**
  59987. * Multiplies the current matrix with another one
  59988. * @param other defines the second operand
  59989. * @param result defines the target matrix
  59990. * @returns the current matrix
  59991. */
  59992. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59993. /**
  59994. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59995. * @param x defines the x coordinate to transform
  59996. * @param y defines the x coordinate to transform
  59997. * @param result defines the target vector2
  59998. * @returns the current matrix
  59999. */
  60000. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60001. /**
  60002. * Creates an identity matrix
  60003. * @returns a new matrix
  60004. */
  60005. static Identity(): Matrix2D;
  60006. /**
  60007. * Creates a translation matrix and stores it in a target matrix
  60008. * @param x defines the x coordinate of the translation
  60009. * @param y defines the y coordinate of the translation
  60010. * @param result defines the target matrix
  60011. */
  60012. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60013. /**
  60014. * Creates a scaling matrix and stores it in a target matrix
  60015. * @param x defines the x coordinate of the scaling
  60016. * @param y defines the y coordinate of the scaling
  60017. * @param result defines the target matrix
  60018. */
  60019. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60020. /**
  60021. * Creates a rotation matrix and stores it in a target matrix
  60022. * @param angle defines the rotation angle
  60023. * @param result defines the target matrix
  60024. */
  60025. static RotationToRef(angle: number, result: Matrix2D): void;
  60026. private static _TempPreTranslationMatrix;
  60027. private static _TempPostTranslationMatrix;
  60028. private static _TempRotationMatrix;
  60029. private static _TempScalingMatrix;
  60030. private static _TempCompose0;
  60031. private static _TempCompose1;
  60032. private static _TempCompose2;
  60033. /**
  60034. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60035. * @param tx defines the x coordinate of the translation
  60036. * @param ty defines the y coordinate of the translation
  60037. * @param angle defines the rotation angle
  60038. * @param scaleX defines the x coordinate of the scaling
  60039. * @param scaleY defines the y coordinate of the scaling
  60040. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60041. * @param result defines the target matrix
  60042. */
  60043. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60044. }
  60045. }
  60046. declare module BABYLON.GUI {
  60047. /**
  60048. * Class used to store 2D control sizes
  60049. */
  60050. export class Measure {
  60051. /** defines left coordinate */
  60052. left: number;
  60053. /** defines top coordinate */
  60054. top: number;
  60055. /** defines width dimension */
  60056. width: number;
  60057. /** defines height dimension */
  60058. height: number;
  60059. /**
  60060. * Creates a new measure
  60061. * @param left defines left coordinate
  60062. * @param top defines top coordinate
  60063. * @param width defines width dimension
  60064. * @param height defines height dimension
  60065. */
  60066. constructor(
  60067. /** defines left coordinate */
  60068. left: number,
  60069. /** defines top coordinate */
  60070. top: number,
  60071. /** defines width dimension */
  60072. width: number,
  60073. /** defines height dimension */
  60074. height: number);
  60075. /**
  60076. * Copy from another measure
  60077. * @param other defines the other measure to copy from
  60078. */
  60079. copyFrom(other: Measure): void;
  60080. /**
  60081. * Copy from a group of 4 floats
  60082. * @param left defines left coordinate
  60083. * @param top defines top coordinate
  60084. * @param width defines width dimension
  60085. * @param height defines height dimension
  60086. */
  60087. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60088. /**
  60089. * Computes the axis aligned bounding box measure for two given measures
  60090. * @param a Input measure
  60091. * @param b Input measure
  60092. * @param result the resulting bounding measure
  60093. */
  60094. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60095. /**
  60096. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60097. * @param transform the matrix to transform the measure before computing the AABB
  60098. * @param result the resulting AABB
  60099. */
  60100. transformToRef(transform: Matrix2D, result: Measure): void;
  60101. /**
  60102. * Check equality between this measure and another one
  60103. * @param other defines the other measures
  60104. * @returns true if both measures are equals
  60105. */
  60106. isEqualsTo(other: Measure): boolean;
  60107. /**
  60108. * Creates an empty measure
  60109. * @returns a new measure
  60110. */
  60111. static Empty(): Measure;
  60112. }
  60113. }
  60114. declare module BABYLON.GUI {
  60115. /**
  60116. * Interface used to define a control that can receive focus
  60117. */
  60118. export interface IFocusableControl {
  60119. /**
  60120. * Function called when the control receives the focus
  60121. */
  60122. onFocus(): void;
  60123. /**
  60124. * Function called when the control loses the focus
  60125. */
  60126. onBlur(): void;
  60127. /**
  60128. * Function called to let the control handle keyboard events
  60129. * @param evt defines the current keyboard event
  60130. */
  60131. processKeyboard(evt: KeyboardEvent): void;
  60132. /**
  60133. * Function called to get the list of controls that should not steal the focus from this control
  60134. * @returns an array of controls
  60135. */
  60136. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60137. }
  60138. /**
  60139. * Class used to create texture to support 2D GUI elements
  60140. * @see http://doc.babylonjs.com/how_to/gui
  60141. */
  60142. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60143. private _isDirty;
  60144. private _renderObserver;
  60145. private _resizeObserver;
  60146. private _preKeyboardObserver;
  60147. private _pointerMoveObserver;
  60148. private _pointerObserver;
  60149. private _canvasPointerOutObserver;
  60150. private _background;
  60151. /** @hidden */
  60152. _rootContainer: Container;
  60153. /** @hidden */
  60154. _lastPickedControl: Control;
  60155. /** @hidden */
  60156. _lastControlOver: {
  60157. [pointerId: number]: Control;
  60158. };
  60159. /** @hidden */
  60160. _lastControlDown: {
  60161. [pointerId: number]: Control;
  60162. };
  60163. /** @hidden */
  60164. _capturingControl: {
  60165. [pointerId: number]: Control;
  60166. };
  60167. /** @hidden */
  60168. _shouldBlockPointer: boolean;
  60169. /** @hidden */
  60170. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60171. /** @hidden */
  60172. _linkedControls: Control[];
  60173. private _isFullscreen;
  60174. private _fullscreenViewport;
  60175. private _idealWidth;
  60176. private _idealHeight;
  60177. private _useSmallestIdeal;
  60178. private _renderAtIdealSize;
  60179. private _focusedControl;
  60180. private _blockNextFocusCheck;
  60181. private _renderScale;
  60182. private _rootCanvas;
  60183. private _cursorChanged;
  60184. /**
  60185. * Define type to string to ensure compatibility across browsers
  60186. * Safari doesn't support DataTransfer constructor
  60187. */
  60188. private _clipboardData;
  60189. /**
  60190. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60191. */
  60192. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60193. /**
  60194. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60195. */
  60196. onControlPickedObservable: BABYLON.Observable<Control>;
  60197. /**
  60198. * BABYLON.Observable event triggered before layout is evaluated
  60199. */
  60200. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60201. /**
  60202. * BABYLON.Observable event triggered after the layout was evaluated
  60203. */
  60204. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60205. /**
  60206. * BABYLON.Observable event triggered before the texture is rendered
  60207. */
  60208. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60209. /**
  60210. * BABYLON.Observable event triggered after the texture was rendered
  60211. */
  60212. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60213. /**
  60214. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60215. */
  60216. premulAlpha: boolean;
  60217. /**
  60218. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60219. * Useful when you want more antialiasing
  60220. */
  60221. renderScale: number;
  60222. /** Gets or sets the background color */
  60223. background: string;
  60224. /**
  60225. * Gets or sets the ideal width used to design controls.
  60226. * The GUI will then rescale everything accordingly
  60227. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60228. */
  60229. idealWidth: number;
  60230. /**
  60231. * Gets or sets the ideal height used to design controls.
  60232. * The GUI will then rescale everything accordingly
  60233. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60234. */
  60235. idealHeight: number;
  60236. /**
  60237. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60238. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60239. */
  60240. useSmallestIdeal: boolean;
  60241. /**
  60242. * Gets or sets a boolean indicating if adaptive scaling must be used
  60243. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60244. */
  60245. renderAtIdealSize: boolean;
  60246. /**
  60247. * Gets the underlying layer used to render the texture when in fullscreen mode
  60248. */
  60249. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60250. /**
  60251. * Gets the root container control
  60252. */
  60253. readonly rootContainer: Container;
  60254. /**
  60255. * Returns an array containing the root container.
  60256. * This is mostly used to let the Inspector introspects the ADT
  60257. * @returns an array containing the rootContainer
  60258. */
  60259. getChildren(): Array<Container>;
  60260. /**
  60261. * Will return all controls that are inside this texture
  60262. * @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
  60263. * @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
  60264. * @return all child controls
  60265. */
  60266. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60267. /**
  60268. * Gets or sets the current focused control
  60269. */
  60270. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60271. /**
  60272. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60273. */
  60274. isForeground: boolean;
  60275. /**
  60276. * Gets or set information about clipboardData
  60277. */
  60278. clipboardData: string;
  60279. /**
  60280. * Creates a new AdvancedDynamicTexture
  60281. * @param name defines the name of the texture
  60282. * @param width defines the width of the texture
  60283. * @param height defines the height of the texture
  60284. * @param scene defines the hosting scene
  60285. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60286. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60287. */
  60288. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60289. /**
  60290. * Get the current class name of the texture useful for serialization or dynamic coding.
  60291. * @returns "AdvancedDynamicTexture"
  60292. */
  60293. getClassName(): string;
  60294. /**
  60295. * Function used to execute a function on all controls
  60296. * @param func defines the function to execute
  60297. * @param container defines the container where controls belong. If null the root container will be used
  60298. */
  60299. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60300. private _useInvalidateRectOptimization;
  60301. /**
  60302. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60303. */
  60304. useInvalidateRectOptimization: boolean;
  60305. private _invalidatedRectangle;
  60306. /**
  60307. * Invalidates a rectangle area on the gui texture
  60308. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60309. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60310. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60311. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60312. */
  60313. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60314. /**
  60315. * Marks the texture as dirty forcing a complete update
  60316. */
  60317. markAsDirty(): void;
  60318. /**
  60319. * Helper function used to create a new style
  60320. * @returns a new style
  60321. * @see http://doc.babylonjs.com/how_to/gui#styles
  60322. */
  60323. createStyle(): Style;
  60324. /**
  60325. * Adds a new control to the root container
  60326. * @param control defines the control to add
  60327. * @returns the current texture
  60328. */
  60329. addControl(control: Control): AdvancedDynamicTexture;
  60330. /**
  60331. * Removes a control from the root container
  60332. * @param control defines the control to remove
  60333. * @returns the current texture
  60334. */
  60335. removeControl(control: Control): AdvancedDynamicTexture;
  60336. /**
  60337. * Release all resources
  60338. */
  60339. dispose(): void;
  60340. private _onResize;
  60341. /** @hidden */
  60342. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60343. /**
  60344. * Get screen coordinates for a vector3
  60345. * @param position defines the position to project
  60346. * @param worldMatrix defines the world matrix to use
  60347. * @returns the projected position
  60348. */
  60349. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60350. private _checkUpdate;
  60351. private _clearMeasure;
  60352. private _render;
  60353. /** @hidden */
  60354. _changeCursor(cursor: string): void;
  60355. /** @hidden */
  60356. _registerLastControlDown(control: Control, pointerId: number): void;
  60357. private _doPicking;
  60358. /** @hidden */
  60359. _cleanControlAfterRemovalFromList(list: {
  60360. [pointerId: number]: Control;
  60361. }, control: Control): void;
  60362. /** @hidden */
  60363. _cleanControlAfterRemoval(control: Control): void;
  60364. /** Attach to all scene events required to support pointer events */
  60365. attach(): void;
  60366. /** @hidden */
  60367. private onClipboardCopy;
  60368. /** @hidden */
  60369. private onClipboardCut;
  60370. /** @hidden */
  60371. private onClipboardPaste;
  60372. /**
  60373. * Register the clipboard Events onto the canvas
  60374. */
  60375. registerClipboardEvents(): void;
  60376. /**
  60377. * Unregister the clipboard Events from the canvas
  60378. */
  60379. unRegisterClipboardEvents(): void;
  60380. /**
  60381. * Connect the texture to a hosting mesh to enable interactions
  60382. * @param mesh defines the mesh to attach to
  60383. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60384. */
  60385. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60386. /**
  60387. * Move the focus to a specific control
  60388. * @param control defines the control which will receive the focus
  60389. */
  60390. moveFocusToControl(control: IFocusableControl): void;
  60391. private _manageFocus;
  60392. private _attachToOnPointerOut;
  60393. /**
  60394. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60395. * @param mesh defines the mesh which will receive the texture
  60396. * @param width defines the texture width (1024 by default)
  60397. * @param height defines the texture height (1024 by default)
  60398. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60399. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60400. * @returns a new AdvancedDynamicTexture
  60401. */
  60402. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60403. /**
  60404. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60405. * In this mode the texture will rely on a layer for its rendering.
  60406. * This allows it to be treated like any other layer.
  60407. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60408. * LayerMask is set through advancedTexture.layer.layerMask
  60409. * @param name defines name for the texture
  60410. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60411. * @param scene defines the hsoting scene
  60412. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60413. * @returns a new AdvancedDynamicTexture
  60414. */
  60415. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60416. }
  60417. }
  60418. declare module BABYLON.GUI {
  60419. /**
  60420. * Root class used for all 2D controls
  60421. * @see http://doc.babylonjs.com/how_to/gui#controls
  60422. */
  60423. export class Control {
  60424. /** defines the name of the control */
  60425. name?: string | undefined;
  60426. /**
  60427. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60428. */
  60429. static AllowAlphaInheritance: boolean;
  60430. private _alpha;
  60431. private _alphaSet;
  60432. private _zIndex;
  60433. /** @hidden */
  60434. _host: AdvancedDynamicTexture;
  60435. /** Gets or sets the control parent */
  60436. parent: BABYLON.Nullable<Container>;
  60437. /** @hidden */
  60438. _currentMeasure: Measure;
  60439. private _fontFamily;
  60440. private _fontStyle;
  60441. private _fontWeight;
  60442. private _fontSize;
  60443. private _font;
  60444. /** @hidden */
  60445. _width: ValueAndUnit;
  60446. /** @hidden */
  60447. _height: ValueAndUnit;
  60448. /** @hidden */
  60449. protected _fontOffset: {
  60450. ascent: number;
  60451. height: number;
  60452. descent: number;
  60453. };
  60454. private _color;
  60455. private _style;
  60456. private _styleObserver;
  60457. /** @hidden */
  60458. protected _horizontalAlignment: number;
  60459. /** @hidden */
  60460. protected _verticalAlignment: number;
  60461. /** @hidden */
  60462. protected _isDirty: boolean;
  60463. /** @hidden */
  60464. protected _wasDirty: boolean;
  60465. /** @hidden */
  60466. _tempParentMeasure: Measure;
  60467. /** @hidden */
  60468. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60469. /** @hidden */
  60470. protected _cachedParentMeasure: Measure;
  60471. private _paddingLeft;
  60472. private _paddingRight;
  60473. private _paddingTop;
  60474. private _paddingBottom;
  60475. /** @hidden */
  60476. _left: ValueAndUnit;
  60477. /** @hidden */
  60478. _top: ValueAndUnit;
  60479. private _scaleX;
  60480. private _scaleY;
  60481. private _rotation;
  60482. private _transformCenterX;
  60483. private _transformCenterY;
  60484. /** @hidden */
  60485. _transformMatrix: Matrix2D;
  60486. /** @hidden */
  60487. protected _invertTransformMatrix: Matrix2D;
  60488. /** @hidden */
  60489. protected _transformedPosition: BABYLON.Vector2;
  60490. private _isMatrixDirty;
  60491. private _cachedOffsetX;
  60492. private _cachedOffsetY;
  60493. private _isVisible;
  60494. private _isHighlighted;
  60495. /** @hidden */
  60496. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60497. private _fontSet;
  60498. private _dummyVector2;
  60499. private _downCount;
  60500. private _enterCount;
  60501. private _doNotRender;
  60502. private _downPointerIds;
  60503. protected _isEnabled: boolean;
  60504. protected _disabledColor: string;
  60505. /** @hidden */
  60506. protected _rebuildLayout: boolean;
  60507. /** @hidden */
  60508. _isClipped: boolean;
  60509. /** @hidden */
  60510. _tag: any;
  60511. /**
  60512. * 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
  60513. */
  60514. uniqueId: number;
  60515. /**
  60516. * Gets or sets an object used to store user defined information for the node
  60517. */
  60518. metadata: any;
  60519. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60520. isHitTestVisible: boolean;
  60521. /** Gets or sets a boolean indicating if the control can block pointer events */
  60522. isPointerBlocker: boolean;
  60523. /** Gets or sets a boolean indicating if the control can be focusable */
  60524. isFocusInvisible: boolean;
  60525. /**
  60526. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60527. * 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
  60528. */
  60529. clipChildren: boolean;
  60530. /**
  60531. * Gets or sets a boolean indicating that control content must be clipped
  60532. * 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
  60533. */
  60534. clipContent: boolean;
  60535. /**
  60536. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60537. */
  60538. useBitmapCache: boolean;
  60539. private _cacheData;
  60540. private _shadowOffsetX;
  60541. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60542. shadowOffsetX: number;
  60543. private _shadowOffsetY;
  60544. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60545. shadowOffsetY: number;
  60546. private _shadowBlur;
  60547. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60548. shadowBlur: number;
  60549. private _shadowColor;
  60550. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60551. shadowColor: string;
  60552. /** Gets or sets the cursor to use when the control is hovered */
  60553. hoverCursor: string;
  60554. /** @hidden */
  60555. protected _linkOffsetX: ValueAndUnit;
  60556. /** @hidden */
  60557. protected _linkOffsetY: ValueAndUnit;
  60558. /** Gets the control type name */
  60559. readonly typeName: string;
  60560. /**
  60561. * Get the current class name of the control.
  60562. * @returns current class name
  60563. */
  60564. getClassName(): string;
  60565. /**
  60566. * An event triggered when the pointer move over the control.
  60567. */
  60568. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60569. /**
  60570. * An event triggered when the pointer move out of the control.
  60571. */
  60572. onPointerOutObservable: BABYLON.Observable<Control>;
  60573. /**
  60574. * An event triggered when the pointer taps the control
  60575. */
  60576. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60577. /**
  60578. * An event triggered when pointer up
  60579. */
  60580. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60581. /**
  60582. * An event triggered when a control is clicked on
  60583. */
  60584. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60585. /**
  60586. * An event triggered when pointer enters the control
  60587. */
  60588. onPointerEnterObservable: BABYLON.Observable<Control>;
  60589. /**
  60590. * An event triggered when the control is marked as dirty
  60591. */
  60592. onDirtyObservable: BABYLON.Observable<Control>;
  60593. /**
  60594. * An event triggered before drawing the control
  60595. */
  60596. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60597. /**
  60598. * An event triggered after the control was drawn
  60599. */
  60600. onAfterDrawObservable: BABYLON.Observable<Control>;
  60601. /**
  60602. * Get the hosting AdvancedDynamicTexture
  60603. */
  60604. readonly host: AdvancedDynamicTexture;
  60605. /** Gets or set information about font offsets (used to render and align text) */
  60606. fontOffset: {
  60607. ascent: number;
  60608. height: number;
  60609. descent: number;
  60610. };
  60611. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60612. alpha: number;
  60613. /**
  60614. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60615. */
  60616. isHighlighted: boolean;
  60617. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60618. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60619. */
  60620. scaleX: number;
  60621. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60622. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60623. */
  60624. scaleY: number;
  60625. /** Gets or sets the rotation angle (0 by default)
  60626. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60627. */
  60628. rotation: number;
  60629. /** Gets or sets the transformation center on Y axis (0 by default)
  60630. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60631. */
  60632. transformCenterY: number;
  60633. /** Gets or sets the transformation center on X axis (0 by default)
  60634. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60635. */
  60636. transformCenterX: number;
  60637. /**
  60638. * Gets or sets the horizontal alignment
  60639. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60640. */
  60641. horizontalAlignment: number;
  60642. /**
  60643. * Gets or sets the vertical alignment
  60644. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60645. */
  60646. verticalAlignment: number;
  60647. /**
  60648. * Gets or sets control width
  60649. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60650. */
  60651. width: string | number;
  60652. /**
  60653. * Gets or sets the control width in pixel
  60654. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60655. */
  60656. widthInPixels: number;
  60657. /**
  60658. * Gets or sets control height
  60659. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60660. */
  60661. height: string | number;
  60662. /**
  60663. * Gets or sets control height in pixel
  60664. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60665. */
  60666. heightInPixels: number;
  60667. /** Gets or set font family */
  60668. fontFamily: string;
  60669. /** Gets or sets font style */
  60670. fontStyle: string;
  60671. /** Gets or sets font weight */
  60672. fontWeight: string;
  60673. /**
  60674. * Gets or sets style
  60675. * @see http://doc.babylonjs.com/how_to/gui#styles
  60676. */
  60677. style: BABYLON.Nullable<Style>;
  60678. /** @hidden */
  60679. readonly _isFontSizeInPercentage: boolean;
  60680. /** Gets or sets font size in pixels */
  60681. fontSizeInPixels: number;
  60682. /** Gets or sets font size */
  60683. fontSize: string | number;
  60684. /** Gets or sets foreground color */
  60685. color: string;
  60686. /** Gets or sets z index which is used to reorder controls on the z axis */
  60687. zIndex: number;
  60688. /** Gets or sets a boolean indicating if the control can be rendered */
  60689. notRenderable: boolean;
  60690. /** Gets or sets a boolean indicating if the control is visible */
  60691. isVisible: boolean;
  60692. /** Gets a boolean indicating that the control needs to update its rendering */
  60693. readonly isDirty: boolean;
  60694. /**
  60695. * Gets the current linked mesh (or null if none)
  60696. */
  60697. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60698. /**
  60699. * Gets or sets a value indicating the padding to use on the left of the control
  60700. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60701. */
  60702. paddingLeft: string | number;
  60703. /**
  60704. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60705. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60706. */
  60707. paddingLeftInPixels: number;
  60708. /**
  60709. * Gets or sets a value indicating the padding to use on the right of the control
  60710. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60711. */
  60712. paddingRight: string | number;
  60713. /**
  60714. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60715. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60716. */
  60717. paddingRightInPixels: number;
  60718. /**
  60719. * Gets or sets a value indicating the padding to use on the top of the control
  60720. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60721. */
  60722. paddingTop: string | number;
  60723. /**
  60724. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60725. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60726. */
  60727. paddingTopInPixels: number;
  60728. /**
  60729. * Gets or sets a value indicating the padding to use on the bottom of the control
  60730. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60731. */
  60732. paddingBottom: string | number;
  60733. /**
  60734. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60736. */
  60737. paddingBottomInPixels: number;
  60738. /**
  60739. * Gets or sets a value indicating the left coordinate of the control
  60740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60741. */
  60742. left: string | number;
  60743. /**
  60744. * Gets or sets a value indicating the left coordinate in pixels of the control
  60745. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60746. */
  60747. leftInPixels: number;
  60748. /**
  60749. * Gets or sets a value indicating the top coordinate of the control
  60750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60751. */
  60752. top: string | number;
  60753. /**
  60754. * Gets or sets a value indicating the top coordinate in pixels of the control
  60755. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60756. */
  60757. topInPixels: number;
  60758. /**
  60759. * Gets or sets a value indicating the offset on X axis to the linked mesh
  60760. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60761. */
  60762. linkOffsetX: string | number;
  60763. /**
  60764. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  60765. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60766. */
  60767. linkOffsetXInPixels: number;
  60768. /**
  60769. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  60770. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60771. */
  60772. linkOffsetY: string | number;
  60773. /**
  60774. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  60775. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60776. */
  60777. linkOffsetYInPixels: number;
  60778. /** Gets the center coordinate on X axis */
  60779. readonly centerX: number;
  60780. /** Gets the center coordinate on Y axis */
  60781. readonly centerY: number;
  60782. /** Gets or sets if control is Enabled*/
  60783. isEnabled: boolean;
  60784. /** Gets or sets background color of control if it's disabled*/
  60785. disabledColor: string;
  60786. /**
  60787. * Creates a new control
  60788. * @param name defines the name of the control
  60789. */
  60790. constructor(
  60791. /** defines the name of the control */
  60792. name?: string | undefined);
  60793. /** @hidden */
  60794. protected _getTypeName(): string;
  60795. /**
  60796. * Gets the first ascendant in the hierarchy of the given type
  60797. * @param className defines the required type
  60798. * @returns the ascendant or null if not found
  60799. */
  60800. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  60801. /** @hidden */
  60802. _resetFontCache(): void;
  60803. /**
  60804. * Determines if a container is an ascendant of the current control
  60805. * @param container defines the container to look for
  60806. * @returns true if the container is one of the ascendant of the control
  60807. */
  60808. isAscendant(container: Control): boolean;
  60809. /**
  60810. * Gets coordinates in local control space
  60811. * @param globalCoordinates defines the coordinates to transform
  60812. * @returns the new coordinates in local space
  60813. */
  60814. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60815. /**
  60816. * Gets coordinates in local control space
  60817. * @param globalCoordinates defines the coordinates to transform
  60818. * @param result defines the target vector2 where to store the result
  60819. * @returns the current control
  60820. */
  60821. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  60822. /**
  60823. * Gets coordinates in parent local control space
  60824. * @param globalCoordinates defines the coordinates to transform
  60825. * @returns the new coordinates in parent local space
  60826. */
  60827. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  60828. /**
  60829. * Move the current control to a vector3 position projected onto the screen.
  60830. * @param position defines the target position
  60831. * @param scene defines the hosting scene
  60832. */
  60833. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  60834. /** @hidden */
  60835. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60836. /**
  60837. * Will return all controls that have this control as ascendant
  60838. * @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
  60839. * @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
  60840. * @return all child controls
  60841. */
  60842. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60843. /**
  60844. * Link current control with a target mesh
  60845. * @param mesh defines the mesh to link with
  60846. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  60847. */
  60848. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  60849. /** @hidden */
  60850. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  60851. /** @hidden */
  60852. _offsetLeft(offset: number): void;
  60853. /** @hidden */
  60854. _offsetTop(offset: number): void;
  60855. /** @hidden */
  60856. _markMatrixAsDirty(): void;
  60857. /** @hidden */
  60858. _flagDescendantsAsMatrixDirty(): void;
  60859. /** @hidden */
  60860. _intersectsRect(rect: Measure): boolean;
  60861. /** @hidden */
  60862. protected invalidateRect(): void;
  60863. /** @hidden */
  60864. _markAsDirty(force?: boolean): void;
  60865. /** @hidden */
  60866. _markAllAsDirty(): void;
  60867. /** @hidden */
  60868. _link(host: AdvancedDynamicTexture): void;
  60869. /** @hidden */
  60870. protected _transform(context?: CanvasRenderingContext2D): void;
  60871. /** @hidden */
  60872. _renderHighlight(context: CanvasRenderingContext2D): void;
  60873. /** @hidden */
  60874. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60875. /** @hidden */
  60876. protected _applyStates(context: CanvasRenderingContext2D): void;
  60877. /** @hidden */
  60878. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60879. /** @hidden */
  60880. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60881. protected _evaluateClippingState(parentMeasure: Measure): void;
  60882. /** @hidden */
  60883. _measure(): void;
  60884. /** @hidden */
  60885. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60886. /** @hidden */
  60887. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60888. /** @hidden */
  60889. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60890. /** @hidden */
  60891. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60892. private static _ClipMeasure;
  60893. private _tmpMeasureA;
  60894. private _clip;
  60895. /** @hidden */
  60896. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60897. /** @hidden */
  60898. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60899. /**
  60900. * Tests if a given coordinates belong to the current control
  60901. * @param x defines x coordinate to test
  60902. * @param y defines y coordinate to test
  60903. * @returns true if the coordinates are inside the control
  60904. */
  60905. contains(x: number, y: number): boolean;
  60906. /** @hidden */
  60907. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60908. /** @hidden */
  60909. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60910. /** @hidden */
  60911. _onPointerEnter(target: Control): boolean;
  60912. /** @hidden */
  60913. _onPointerOut(target: Control, force?: boolean): void;
  60914. /** @hidden */
  60915. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60916. /** @hidden */
  60917. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60918. /** @hidden */
  60919. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60920. /** @hidden */
  60921. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60922. private _prepareFont;
  60923. /** Releases associated resources */
  60924. dispose(): void;
  60925. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60926. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60927. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60928. private static _VERTICAL_ALIGNMENT_TOP;
  60929. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60930. private static _VERTICAL_ALIGNMENT_CENTER;
  60931. /** HORIZONTAL_ALIGNMENT_LEFT */
  60932. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60933. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60934. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60935. /** HORIZONTAL_ALIGNMENT_CENTER */
  60936. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60937. /** VERTICAL_ALIGNMENT_TOP */
  60938. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60939. /** VERTICAL_ALIGNMENT_BOTTOM */
  60940. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60941. /** VERTICAL_ALIGNMENT_CENTER */
  60942. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60943. private static _FontHeightSizes;
  60944. /** @hidden */
  60945. static _GetFontOffset(font: string): {
  60946. ascent: number;
  60947. height: number;
  60948. descent: number;
  60949. };
  60950. /**
  60951. * Creates a stack panel that can be used to render headers
  60952. * @param control defines the control to associate with the header
  60953. * @param text defines the text of the header
  60954. * @param size defines the size of the header
  60955. * @param options defines options used to configure the header
  60956. * @returns a new StackPanel
  60957. * @ignore
  60958. * @hidden
  60959. */
  60960. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60961. isHorizontal: boolean;
  60962. controlFirst: boolean;
  60963. }) => any;
  60964. /** @hidden */
  60965. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60966. }
  60967. }
  60968. declare module BABYLON.GUI {
  60969. /**
  60970. * Root class for 2D containers
  60971. * @see http://doc.babylonjs.com/how_to/gui#containers
  60972. */
  60973. export class Container extends Control {
  60974. name?: string | undefined;
  60975. /** @hidden */
  60976. protected _children: Control[];
  60977. /** @hidden */
  60978. protected _measureForChildren: Measure;
  60979. /** @hidden */
  60980. protected _background: string;
  60981. /** @hidden */
  60982. protected _adaptWidthToChildren: boolean;
  60983. /** @hidden */
  60984. protected _adaptHeightToChildren: boolean;
  60985. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60986. adaptHeightToChildren: boolean;
  60987. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60988. adaptWidthToChildren: boolean;
  60989. /** Gets or sets background color */
  60990. background: string;
  60991. /** Gets the list of children */
  60992. readonly children: Control[];
  60993. /**
  60994. * Creates a new Container
  60995. * @param name defines the name of the container
  60996. */
  60997. constructor(name?: string | undefined);
  60998. protected _getTypeName(): string;
  60999. _flagDescendantsAsMatrixDirty(): void;
  61000. /**
  61001. * Gets a child using its name
  61002. * @param name defines the child name to look for
  61003. * @returns the child control if found
  61004. */
  61005. getChildByName(name: string): BABYLON.Nullable<Control>;
  61006. /**
  61007. * Gets a child using its type and its name
  61008. * @param name defines the child name to look for
  61009. * @param type defines the child type to look for
  61010. * @returns the child control if found
  61011. */
  61012. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61013. /**
  61014. * Search for a specific control in children
  61015. * @param control defines the control to look for
  61016. * @returns true if the control is in child list
  61017. */
  61018. containsControl(control: Control): boolean;
  61019. /**
  61020. * Adds a new control to the current container
  61021. * @param control defines the control to add
  61022. * @returns the current container
  61023. */
  61024. addControl(control: BABYLON.Nullable<Control>): Container;
  61025. /**
  61026. * Removes all controls from the current container
  61027. * @returns the current container
  61028. */
  61029. clearControls(): Container;
  61030. /**
  61031. * Removes a control from the current container
  61032. * @param control defines the control to remove
  61033. * @returns the current container
  61034. */
  61035. removeControl(control: Control): Container;
  61036. /** @hidden */
  61037. _reOrderControl(control: Control): void;
  61038. /** @hidden */
  61039. _offsetLeft(offset: number): void;
  61040. /** @hidden */
  61041. _offsetTop(offset: number): void;
  61042. /** @hidden */
  61043. _markAllAsDirty(): void;
  61044. /** @hidden */
  61045. protected _localDraw(context: CanvasRenderingContext2D): void;
  61046. /** @hidden */
  61047. _link(host: AdvancedDynamicTexture): void;
  61048. /** @hidden */
  61049. protected _beforeLayout(): void;
  61050. /** @hidden */
  61051. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61052. /** @hidden */
  61053. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61054. protected _postMeasure(): void;
  61055. /** @hidden */
  61056. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61057. /** @hidden */
  61058. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61059. /** @hidden */
  61060. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61061. /** @hidden */
  61062. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61063. /** Releases associated resources */
  61064. dispose(): void;
  61065. }
  61066. }
  61067. declare module BABYLON.GUI {
  61068. /** Class used to create rectangle container */
  61069. export class Rectangle extends Container {
  61070. name?: string | undefined;
  61071. private _thickness;
  61072. private _cornerRadius;
  61073. /** Gets or sets border thickness */
  61074. thickness: number;
  61075. /** Gets or sets the corner radius angle */
  61076. cornerRadius: number;
  61077. /**
  61078. * Creates a new Rectangle
  61079. * @param name defines the control name
  61080. */
  61081. constructor(name?: string | undefined);
  61082. protected _getTypeName(): string;
  61083. protected _localDraw(context: CanvasRenderingContext2D): void;
  61084. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61085. private _drawRoundedRect;
  61086. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61087. }
  61088. }
  61089. declare module BABYLON.GUI {
  61090. /**
  61091. * Enum that determines the text-wrapping mode to use.
  61092. */
  61093. export enum TextWrapping {
  61094. /**
  61095. * Clip the text when it's larger than Control.width; this is the default mode.
  61096. */
  61097. Clip = 0,
  61098. /**
  61099. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61100. */
  61101. WordWrap = 1,
  61102. /**
  61103. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61104. */
  61105. Ellipsis = 2
  61106. }
  61107. /**
  61108. * Class used to create text block control
  61109. */
  61110. export class TextBlock extends Control {
  61111. /**
  61112. * Defines the name of the control
  61113. */
  61114. name?: string | undefined;
  61115. private _text;
  61116. private _textWrapping;
  61117. private _textHorizontalAlignment;
  61118. private _textVerticalAlignment;
  61119. private _lines;
  61120. private _resizeToFit;
  61121. private _lineSpacing;
  61122. private _outlineWidth;
  61123. private _outlineColor;
  61124. /**
  61125. * An event triggered after the text is changed
  61126. */
  61127. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61128. /**
  61129. * An event triggered after the text was broken up into lines
  61130. */
  61131. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61132. /**
  61133. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61134. */
  61135. readonly lines: any[];
  61136. /**
  61137. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61138. */
  61139. /**
  61140. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61141. */
  61142. resizeToFit: boolean;
  61143. /**
  61144. * Gets or sets a boolean indicating if text must be wrapped
  61145. */
  61146. /**
  61147. * Gets or sets a boolean indicating if text must be wrapped
  61148. */
  61149. textWrapping: TextWrapping | boolean;
  61150. /**
  61151. * Gets or sets text to display
  61152. */
  61153. /**
  61154. * Gets or sets text to display
  61155. */
  61156. text: string;
  61157. /**
  61158. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61159. */
  61160. /**
  61161. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61162. */
  61163. textHorizontalAlignment: number;
  61164. /**
  61165. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61166. */
  61167. /**
  61168. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61169. */
  61170. textVerticalAlignment: number;
  61171. /**
  61172. * Gets or sets line spacing value
  61173. */
  61174. /**
  61175. * Gets or sets line spacing value
  61176. */
  61177. lineSpacing: string | number;
  61178. /**
  61179. * Gets or sets outlineWidth of the text to display
  61180. */
  61181. /**
  61182. * Gets or sets outlineWidth of the text to display
  61183. */
  61184. outlineWidth: number;
  61185. /**
  61186. * Gets or sets outlineColor of the text to display
  61187. */
  61188. /**
  61189. * Gets or sets outlineColor of the text to display
  61190. */
  61191. outlineColor: string;
  61192. /**
  61193. * Creates a new TextBlock object
  61194. * @param name defines the name of the control
  61195. * @param text defines the text to display (emptry string by default)
  61196. */
  61197. constructor(
  61198. /**
  61199. * Defines the name of the control
  61200. */
  61201. name?: string | undefined, text?: string);
  61202. protected _getTypeName(): string;
  61203. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61204. private _drawText;
  61205. /** @hidden */
  61206. _draw(context: CanvasRenderingContext2D): void;
  61207. protected _applyStates(context: CanvasRenderingContext2D): void;
  61208. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61209. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61210. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61211. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61212. protected _renderLines(context: CanvasRenderingContext2D): void;
  61213. /**
  61214. * Given a width constraint applied on the text block, find the expected height
  61215. * @returns expected height
  61216. */
  61217. computeExpectedHeight(): number;
  61218. dispose(): void;
  61219. }
  61220. }
  61221. declare module BABYLON.GUI {
  61222. /**
  61223. * Class used to create 2D images
  61224. */
  61225. export class Image extends Control {
  61226. name?: string | undefined;
  61227. private static _WorkingCanvas;
  61228. private _domImage;
  61229. private _imageWidth;
  61230. private _imageHeight;
  61231. private _loaded;
  61232. private _stretch;
  61233. private _source;
  61234. private _autoScale;
  61235. private _sourceLeft;
  61236. private _sourceTop;
  61237. private _sourceWidth;
  61238. private _sourceHeight;
  61239. private _cellWidth;
  61240. private _cellHeight;
  61241. private _cellId;
  61242. private _populateNinePatchSlicesFromImage;
  61243. private _sliceLeft;
  61244. private _sliceRight;
  61245. private _sliceTop;
  61246. private _sliceBottom;
  61247. private _detectPointerOnOpaqueOnly;
  61248. /**
  61249. * BABYLON.Observable notified when the content is loaded
  61250. */
  61251. onImageLoadedObservable: BABYLON.Observable<Image>;
  61252. /**
  61253. * Gets a boolean indicating that the content is loaded
  61254. */
  61255. readonly isLoaded: boolean;
  61256. /**
  61257. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61258. */
  61259. populateNinePatchSlicesFromImage: boolean;
  61260. /**
  61261. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61262. * Beware using this as this will comsume more memory as the image has to be stored twice
  61263. */
  61264. detectPointerOnOpaqueOnly: boolean;
  61265. /**
  61266. * Gets or sets the left value for slicing (9-patch)
  61267. */
  61268. sliceLeft: number;
  61269. /**
  61270. * Gets or sets the right value for slicing (9-patch)
  61271. */
  61272. sliceRight: number;
  61273. /**
  61274. * Gets or sets the top value for slicing (9-patch)
  61275. */
  61276. sliceTop: number;
  61277. /**
  61278. * Gets or sets the bottom value for slicing (9-patch)
  61279. */
  61280. sliceBottom: number;
  61281. /**
  61282. * Gets or sets the left coordinate in the source image
  61283. */
  61284. sourceLeft: number;
  61285. /**
  61286. * Gets or sets the top coordinate in the source image
  61287. */
  61288. sourceTop: number;
  61289. /**
  61290. * Gets or sets the width to capture in the source image
  61291. */
  61292. sourceWidth: number;
  61293. /**
  61294. * Gets or sets the height to capture in the source image
  61295. */
  61296. sourceHeight: number;
  61297. /**
  61298. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61299. * @see http://doc.babylonjs.com/how_to/gui#image
  61300. */
  61301. autoScale: boolean;
  61302. /** Gets or sets the streching mode used by the image */
  61303. stretch: number;
  61304. /**
  61305. * Gets or sets the internal DOM image used to render the control
  61306. */
  61307. domImage: HTMLImageElement;
  61308. private _onImageLoaded;
  61309. private _extractNinePatchSliceDataFromImage;
  61310. /**
  61311. * Gets or sets image source url
  61312. */
  61313. source: BABYLON.Nullable<string>;
  61314. /**
  61315. * Gets or sets the cell width to use when animation sheet is enabled
  61316. * @see http://doc.babylonjs.com/how_to/gui#image
  61317. */
  61318. cellWidth: number;
  61319. /**
  61320. * Gets or sets the cell height to use when animation sheet is enabled
  61321. * @see http://doc.babylonjs.com/how_to/gui#image
  61322. */
  61323. cellHeight: number;
  61324. /**
  61325. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61326. * @see http://doc.babylonjs.com/how_to/gui#image
  61327. */
  61328. cellId: number;
  61329. /**
  61330. * Creates a new Image
  61331. * @param name defines the control name
  61332. * @param url defines the image url
  61333. */
  61334. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61335. /**
  61336. * Tests if a given coordinates belong to the current control
  61337. * @param x defines x coordinate to test
  61338. * @param y defines y coordinate to test
  61339. * @returns true if the coordinates are inside the control
  61340. */
  61341. contains(x: number, y: number): boolean;
  61342. protected _getTypeName(): string;
  61343. /** Force the control to synchronize with its content */
  61344. synchronizeSizeWithContent(): void;
  61345. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61346. private _prepareWorkingCanvasForOpaqueDetection;
  61347. private _drawImage;
  61348. _draw(context: CanvasRenderingContext2D): void;
  61349. private _renderCornerPatch;
  61350. private _renderNinePatch;
  61351. dispose(): void;
  61352. /** STRETCH_NONE */
  61353. static readonly STRETCH_NONE: number;
  61354. /** STRETCH_FILL */
  61355. static readonly STRETCH_FILL: number;
  61356. /** STRETCH_UNIFORM */
  61357. static readonly STRETCH_UNIFORM: number;
  61358. /** STRETCH_EXTEND */
  61359. static readonly STRETCH_EXTEND: number;
  61360. /** NINE_PATCH */
  61361. static readonly STRETCH_NINE_PATCH: number;
  61362. }
  61363. }
  61364. declare module BABYLON.GUI {
  61365. /**
  61366. * Class used to create 2D buttons
  61367. */
  61368. export class Button extends Rectangle {
  61369. name?: string | undefined;
  61370. /**
  61371. * Function called to generate a pointer enter animation
  61372. */
  61373. pointerEnterAnimation: () => void;
  61374. /**
  61375. * Function called to generate a pointer out animation
  61376. */
  61377. pointerOutAnimation: () => void;
  61378. /**
  61379. * Function called to generate a pointer down animation
  61380. */
  61381. pointerDownAnimation: () => void;
  61382. /**
  61383. * Function called to generate a pointer up animation
  61384. */
  61385. pointerUpAnimation: () => void;
  61386. private _image;
  61387. /**
  61388. * Returns the image part of the button (if any)
  61389. */
  61390. readonly image: BABYLON.Nullable<Image>;
  61391. private _textBlock;
  61392. /**
  61393. * Returns the image part of the button (if any)
  61394. */
  61395. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61396. /**
  61397. * Creates a new Button
  61398. * @param name defines the name of the button
  61399. */
  61400. constructor(name?: string | undefined);
  61401. protected _getTypeName(): string;
  61402. /** @hidden */
  61403. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61404. /** @hidden */
  61405. _onPointerEnter(target: Control): boolean;
  61406. /** @hidden */
  61407. _onPointerOut(target: Control, force?: boolean): void;
  61408. /** @hidden */
  61409. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61410. /** @hidden */
  61411. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61412. /**
  61413. * Creates a new button made with an image and a text
  61414. * @param name defines the name of the button
  61415. * @param text defines the text of the button
  61416. * @param imageUrl defines the url of the image
  61417. * @returns a new Button
  61418. */
  61419. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61420. /**
  61421. * Creates a new button made with an image
  61422. * @param name defines the name of the button
  61423. * @param imageUrl defines the url of the image
  61424. * @returns a new Button
  61425. */
  61426. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61427. /**
  61428. * Creates a new button made with a text
  61429. * @param name defines the name of the button
  61430. * @param text defines the text of the button
  61431. * @returns a new Button
  61432. */
  61433. static CreateSimpleButton(name: string, text: string): Button;
  61434. /**
  61435. * Creates a new button made with an image and a centered text
  61436. * @param name defines the name of the button
  61437. * @param text defines the text of the button
  61438. * @param imageUrl defines the url of the image
  61439. * @returns a new Button
  61440. */
  61441. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61442. }
  61443. }
  61444. declare module BABYLON.GUI {
  61445. /**
  61446. * Class used to create a 2D stack panel container
  61447. */
  61448. export class StackPanel extends Container {
  61449. name?: string | undefined;
  61450. private _isVertical;
  61451. private _manualWidth;
  61452. private _manualHeight;
  61453. private _doNotTrackManualChanges;
  61454. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61455. isVertical: boolean;
  61456. /**
  61457. * Gets or sets panel width.
  61458. * This value should not be set when in horizontal mode as it will be computed automatically
  61459. */
  61460. width: string | number;
  61461. /**
  61462. * Gets or sets panel height.
  61463. * This value should not be set when in vertical mode as it will be computed automatically
  61464. */
  61465. height: string | number;
  61466. /**
  61467. * Creates a new StackPanel
  61468. * @param name defines control name
  61469. */
  61470. constructor(name?: string | undefined);
  61471. protected _getTypeName(): string;
  61472. /** @hidden */
  61473. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61474. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61475. protected _postMeasure(): void;
  61476. }
  61477. }
  61478. declare module BABYLON.GUI {
  61479. /**
  61480. * Class used to represent a 2D checkbox
  61481. */
  61482. export class Checkbox extends Control {
  61483. name?: string | undefined;
  61484. private _isChecked;
  61485. private _background;
  61486. private _checkSizeRatio;
  61487. private _thickness;
  61488. /** Gets or sets border thickness */
  61489. thickness: number;
  61490. /**
  61491. * BABYLON.Observable raised when isChecked property changes
  61492. */
  61493. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61494. /** Gets or sets a value indicating the ratio between overall size and check size */
  61495. checkSizeRatio: number;
  61496. /** Gets or sets background color */
  61497. background: string;
  61498. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61499. isChecked: boolean;
  61500. /**
  61501. * Creates a new CheckBox
  61502. * @param name defines the control name
  61503. */
  61504. constructor(name?: string | undefined);
  61505. protected _getTypeName(): string;
  61506. /** @hidden */
  61507. _draw(context: CanvasRenderingContext2D): void;
  61508. /** @hidden */
  61509. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61510. /**
  61511. * Utility function to easily create a checkbox with a header
  61512. * @param title defines the label to use for the header
  61513. * @param onValueChanged defines the callback to call when value changes
  61514. * @returns a StackPanel containing the checkbox and a textBlock
  61515. */
  61516. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61517. }
  61518. }
  61519. declare module BABYLON.GUI {
  61520. /**
  61521. * Class used to store key control properties
  61522. */
  61523. export class KeyPropertySet {
  61524. /** Width */
  61525. width?: string;
  61526. /** Height */
  61527. height?: string;
  61528. /** Left padding */
  61529. paddingLeft?: string;
  61530. /** Right padding */
  61531. paddingRight?: string;
  61532. /** Top padding */
  61533. paddingTop?: string;
  61534. /** Bottom padding */
  61535. paddingBottom?: string;
  61536. /** Foreground color */
  61537. color?: string;
  61538. /** Background color */
  61539. background?: string;
  61540. }
  61541. /**
  61542. * Class used to create virtual keyboard
  61543. */
  61544. export class VirtualKeyboard extends StackPanel {
  61545. /** BABYLON.Observable raised when a key is pressed */
  61546. onKeyPressObservable: BABYLON.Observable<string>;
  61547. /** Gets or sets default key button width */
  61548. defaultButtonWidth: string;
  61549. /** Gets or sets default key button height */
  61550. defaultButtonHeight: string;
  61551. /** Gets or sets default key button left padding */
  61552. defaultButtonPaddingLeft: string;
  61553. /** Gets or sets default key button right padding */
  61554. defaultButtonPaddingRight: string;
  61555. /** Gets or sets default key button top padding */
  61556. defaultButtonPaddingTop: string;
  61557. /** Gets or sets default key button bottom padding */
  61558. defaultButtonPaddingBottom: string;
  61559. /** Gets or sets default key button foreground color */
  61560. defaultButtonColor: string;
  61561. /** Gets or sets default key button background color */
  61562. defaultButtonBackground: string;
  61563. /** Gets or sets shift button foreground color */
  61564. shiftButtonColor: string;
  61565. /** Gets or sets shift button thickness*/
  61566. selectedShiftThickness: number;
  61567. /** Gets shift key state */
  61568. shiftState: number;
  61569. protected _getTypeName(): string;
  61570. private _createKey;
  61571. /**
  61572. * Adds a new row of keys
  61573. * @param keys defines the list of keys to add
  61574. * @param propertySets defines the associated property sets
  61575. */
  61576. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61577. /**
  61578. * Set the shift key to a specific state
  61579. * @param shiftState defines the new shift state
  61580. */
  61581. applyShiftState(shiftState: number): void;
  61582. private _currentlyConnectedInputText;
  61583. private _connectedInputTexts;
  61584. private _onKeyPressObserver;
  61585. /** Gets the input text control currently attached to the keyboard */
  61586. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61587. /**
  61588. * Connects the keyboard with an input text control
  61589. *
  61590. * @param input defines the target control
  61591. */
  61592. connect(input: InputText): void;
  61593. /**
  61594. * Disconnects the keyboard from connected InputText controls
  61595. *
  61596. * @param input optionally defines a target control, otherwise all are disconnected
  61597. */
  61598. disconnect(input?: InputText): void;
  61599. private _removeConnectedInputObservables;
  61600. /**
  61601. * Release all resources
  61602. */
  61603. dispose(): void;
  61604. /**
  61605. * Creates a new keyboard using a default layout
  61606. *
  61607. * @param name defines control name
  61608. * @returns a new VirtualKeyboard
  61609. */
  61610. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61611. }
  61612. }
  61613. declare module BABYLON.GUI {
  61614. /**
  61615. * Class used to create input text control
  61616. */
  61617. export class InputText extends Control implements IFocusableControl {
  61618. name?: string | undefined;
  61619. private _text;
  61620. private _placeholderText;
  61621. private _background;
  61622. private _focusedBackground;
  61623. private _focusedColor;
  61624. private _placeholderColor;
  61625. private _thickness;
  61626. private _margin;
  61627. private _autoStretchWidth;
  61628. private _maxWidth;
  61629. private _isFocused;
  61630. private _blinkTimeout;
  61631. private _blinkIsEven;
  61632. private _cursorOffset;
  61633. private _scrollLeft;
  61634. private _textWidth;
  61635. private _clickedCoordinate;
  61636. private _deadKey;
  61637. private _addKey;
  61638. private _currentKey;
  61639. private _isTextHighlightOn;
  61640. private _textHighlightColor;
  61641. private _highligherOpacity;
  61642. private _highlightedText;
  61643. private _startHighlightIndex;
  61644. private _endHighlightIndex;
  61645. private _cursorIndex;
  61646. private _onFocusSelectAll;
  61647. private _isPointerDown;
  61648. private _onClipboardObserver;
  61649. private _onPointerDblTapObserver;
  61650. /** @hidden */
  61651. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61652. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61653. promptMessage: string;
  61654. /** BABYLON.Observable raised when the text changes */
  61655. onTextChangedObservable: BABYLON.Observable<InputText>;
  61656. /** BABYLON.Observable raised just before an entered character is to be added */
  61657. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61658. /** BABYLON.Observable raised when the control gets the focus */
  61659. onFocusObservable: BABYLON.Observable<InputText>;
  61660. /** BABYLON.Observable raised when the control loses the focus */
  61661. onBlurObservable: BABYLON.Observable<InputText>;
  61662. /**Observable raised when the text is highlighted */
  61663. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61664. /**Observable raised when copy event is triggered */
  61665. onTextCopyObservable: BABYLON.Observable<InputText>;
  61666. /** BABYLON.Observable raised when cut event is triggered */
  61667. onTextCutObservable: BABYLON.Observable<InputText>;
  61668. /** BABYLON.Observable raised when paste event is triggered */
  61669. onTextPasteObservable: BABYLON.Observable<InputText>;
  61670. /** BABYLON.Observable raised when a key event was processed */
  61671. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61672. /** Gets or sets the maximum width allowed by the control */
  61673. maxWidth: string | number;
  61674. /** Gets the maximum width allowed by the control in pixels */
  61675. readonly maxWidthInPixels: number;
  61676. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61677. highligherOpacity: number;
  61678. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61679. onFocusSelectAll: boolean;
  61680. /** Gets or sets the text hightlight color */
  61681. textHighlightColor: string;
  61682. /** Gets or sets control margin */
  61683. margin: string;
  61684. /** Gets control margin in pixels */
  61685. readonly marginInPixels: number;
  61686. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61687. autoStretchWidth: boolean;
  61688. /** Gets or sets border thickness */
  61689. thickness: number;
  61690. /** Gets or sets the background color when focused */
  61691. focusedBackground: string;
  61692. /** Gets or sets the background color when focused */
  61693. focusedColor: string;
  61694. /** Gets or sets the background color */
  61695. background: string;
  61696. /** Gets or sets the placeholder color */
  61697. placeholderColor: string;
  61698. /** Gets or sets the text displayed when the control is empty */
  61699. placeholderText: string;
  61700. /** Gets or sets the dead key flag */
  61701. deadKey: boolean;
  61702. /** Gets or sets the highlight text */
  61703. highlightedText: string;
  61704. /** Gets or sets if the current key should be added */
  61705. addKey: boolean;
  61706. /** Gets or sets the value of the current key being entered */
  61707. currentKey: string;
  61708. /** Gets or sets the text displayed in the control */
  61709. text: string;
  61710. /** Gets or sets control width */
  61711. width: string | number;
  61712. /**
  61713. * Creates a new InputText
  61714. * @param name defines the control name
  61715. * @param text defines the text of the control
  61716. */
  61717. constructor(name?: string | undefined, text?: string);
  61718. /** @hidden */
  61719. onBlur(): void;
  61720. /** @hidden */
  61721. onFocus(): void;
  61722. protected _getTypeName(): string;
  61723. /**
  61724. * Function called to get the list of controls that should not steal the focus from this control
  61725. * @returns an array of controls
  61726. */
  61727. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61728. /** @hidden */
  61729. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61730. /** @hidden */
  61731. private _updateValueFromCursorIndex;
  61732. /** @hidden */
  61733. private _processDblClick;
  61734. /** @hidden */
  61735. private _selectAllText;
  61736. /**
  61737. * Handles the keyboard event
  61738. * @param evt Defines the KeyboardEvent
  61739. */
  61740. processKeyboard(evt: KeyboardEvent): void;
  61741. /** @hidden */
  61742. private _onCopyText;
  61743. /** @hidden */
  61744. private _onCutText;
  61745. /** @hidden */
  61746. private _onPasteText;
  61747. _draw(context: CanvasRenderingContext2D): void;
  61748. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61749. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61750. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61751. protected _beforeRenderText(text: string): string;
  61752. dispose(): void;
  61753. }
  61754. }
  61755. declare module BABYLON.GUI {
  61756. /**
  61757. * Class used to create a 2D grid container
  61758. */
  61759. export class Grid extends Container {
  61760. name?: string | undefined;
  61761. private _rowDefinitions;
  61762. private _columnDefinitions;
  61763. private _cells;
  61764. private _childControls;
  61765. /**
  61766. * Gets the number of columns
  61767. */
  61768. readonly columnCount: number;
  61769. /**
  61770. * Gets the number of rows
  61771. */
  61772. readonly rowCount: number;
  61773. /** Gets the list of children */
  61774. readonly children: Control[];
  61775. /** Gets the list of cells (e.g. the containers) */
  61776. readonly cells: {
  61777. [key: string]: Container;
  61778. };
  61779. /**
  61780. * Gets the definition of a specific row
  61781. * @param index defines the index of the row
  61782. * @returns the row definition
  61783. */
  61784. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61785. /**
  61786. * Gets the definition of a specific column
  61787. * @param index defines the index of the column
  61788. * @returns the column definition
  61789. */
  61790. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  61791. /**
  61792. * Adds a new row to the grid
  61793. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61794. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  61795. * @returns the current grid
  61796. */
  61797. addRowDefinition(height: number, isPixel?: boolean): Grid;
  61798. /**
  61799. * Adds a new column to the grid
  61800. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61801. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61802. * @returns the current grid
  61803. */
  61804. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  61805. /**
  61806. * Update a row definition
  61807. * @param index defines the index of the row to update
  61808. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  61809. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  61810. * @returns the current grid
  61811. */
  61812. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  61813. /**
  61814. * Update a column definition
  61815. * @param index defines the index of the column to update
  61816. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  61817. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  61818. * @returns the current grid
  61819. */
  61820. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  61821. /**
  61822. * Gets the list of children stored in a specific cell
  61823. * @param row defines the row to check
  61824. * @param column defines the column to check
  61825. * @returns the list of controls
  61826. */
  61827. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  61828. /**
  61829. * Gets a string representing the child cell info (row x column)
  61830. * @param child defines the control to get info from
  61831. * @returns a string containing the child cell info (row x column)
  61832. */
  61833. getChildCellInfo(child: Control): string;
  61834. private _removeCell;
  61835. private _offsetCell;
  61836. /**
  61837. * Remove a column definition at specified index
  61838. * @param index defines the index of the column to remove
  61839. * @returns the current grid
  61840. */
  61841. removeColumnDefinition(index: number): Grid;
  61842. /**
  61843. * Remove a row definition at specified index
  61844. * @param index defines the index of the row to remove
  61845. * @returns the current grid
  61846. */
  61847. removeRowDefinition(index: number): Grid;
  61848. /**
  61849. * Adds a new control to the current grid
  61850. * @param control defines the control to add
  61851. * @param row defines the row where to add the control (0 by default)
  61852. * @param column defines the column where to add the control (0 by default)
  61853. * @returns the current grid
  61854. */
  61855. addControl(control: Control, row?: number, column?: number): Grid;
  61856. /**
  61857. * Removes a control from the current container
  61858. * @param control defines the control to remove
  61859. * @returns the current container
  61860. */
  61861. removeControl(control: Control): Container;
  61862. /**
  61863. * Creates a new Grid
  61864. * @param name defines control name
  61865. */
  61866. constructor(name?: string | undefined);
  61867. protected _getTypeName(): string;
  61868. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  61869. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61870. _flagDescendantsAsMatrixDirty(): void;
  61871. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61872. /** Releases associated resources */
  61873. dispose(): void;
  61874. }
  61875. }
  61876. declare module BABYLON.GUI {
  61877. /** Class used to create color pickers */
  61878. export class ColorPicker extends Control {
  61879. name?: string | undefined;
  61880. private static _Epsilon;
  61881. private _colorWheelCanvas;
  61882. private _value;
  61883. private _tmpColor;
  61884. private _pointerStartedOnSquare;
  61885. private _pointerStartedOnWheel;
  61886. private _squareLeft;
  61887. private _squareTop;
  61888. private _squareSize;
  61889. private _h;
  61890. private _s;
  61891. private _v;
  61892. private _lastPointerDownID;
  61893. /**
  61894. * BABYLON.Observable raised when the value changes
  61895. */
  61896. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61897. /** Gets or sets the color of the color picker */
  61898. value: BABYLON.Color3;
  61899. /**
  61900. * Gets or sets control width
  61901. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61902. */
  61903. width: string | number;
  61904. /**
  61905. * Gets or sets control height
  61906. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61907. */
  61908. /** Gets or sets control height */
  61909. height: string | number;
  61910. /** Gets or sets control size */
  61911. size: string | number;
  61912. /**
  61913. * Creates a new ColorPicker
  61914. * @param name defines the control name
  61915. */
  61916. constructor(name?: string | undefined);
  61917. protected _getTypeName(): string;
  61918. /** @hidden */
  61919. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61920. private _updateSquareProps;
  61921. private _drawGradientSquare;
  61922. private _drawCircle;
  61923. private _createColorWheelCanvas;
  61924. /** @hidden */
  61925. _draw(context: CanvasRenderingContext2D): void;
  61926. private _pointerIsDown;
  61927. private _updateValueFromPointer;
  61928. private _isPointOnSquare;
  61929. private _isPointOnWheel;
  61930. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61931. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61932. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61933. /**
  61934. * This function expands the color picker by creating a color picker dialog with manual
  61935. * color value input and the ability to save colors into an array to be used later in
  61936. * subsequent launches of the dialogue.
  61937. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61938. * @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.
  61939. * @returns picked color as a hex string and the saved colors array as hex strings.
  61940. */
  61941. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61942. pickerWidth?: string;
  61943. pickerHeight?: string;
  61944. headerHeight?: string;
  61945. lastColor?: string;
  61946. swatchLimit?: number;
  61947. numSwatchesPerLine?: number;
  61948. savedColors?: Array<string>;
  61949. }): Promise<{
  61950. savedColors?: string[];
  61951. pickedColor: string;
  61952. }>;
  61953. }
  61954. }
  61955. declare module BABYLON.GUI {
  61956. /** Class used to create 2D ellipse containers */
  61957. export class Ellipse extends Container {
  61958. name?: string | undefined;
  61959. private _thickness;
  61960. /** Gets or sets border thickness */
  61961. thickness: number;
  61962. /**
  61963. * Creates a new Ellipse
  61964. * @param name defines the control name
  61965. */
  61966. constructor(name?: string | undefined);
  61967. protected _getTypeName(): string;
  61968. protected _localDraw(context: CanvasRenderingContext2D): void;
  61969. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61970. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61971. }
  61972. }
  61973. declare module BABYLON.GUI {
  61974. /**
  61975. * Class used to create a password control
  61976. */
  61977. export class InputPassword extends InputText {
  61978. protected _beforeRenderText(text: string): string;
  61979. }
  61980. }
  61981. declare module BABYLON.GUI {
  61982. /** Class used to render 2D lines */
  61983. export class Line extends Control {
  61984. name?: string | undefined;
  61985. private _lineWidth;
  61986. private _x1;
  61987. private _y1;
  61988. private _x2;
  61989. private _y2;
  61990. private _dash;
  61991. private _connectedControl;
  61992. private _connectedControlDirtyObserver;
  61993. /** Gets or sets the dash pattern */
  61994. dash: Array<number>;
  61995. /** Gets or sets the control connected with the line end */
  61996. connectedControl: Control;
  61997. /** Gets or sets start coordinates on X axis */
  61998. x1: string | number;
  61999. /** Gets or sets start coordinates on Y axis */
  62000. y1: string | number;
  62001. /** Gets or sets end coordinates on X axis */
  62002. x2: string | number;
  62003. /** Gets or sets end coordinates on Y axis */
  62004. y2: string | number;
  62005. /** Gets or sets line width */
  62006. lineWidth: number;
  62007. /** Gets or sets horizontal alignment */
  62008. horizontalAlignment: number;
  62009. /** Gets or sets vertical alignment */
  62010. verticalAlignment: number;
  62011. private readonly _effectiveX2;
  62012. private readonly _effectiveY2;
  62013. /**
  62014. * Creates a new Line
  62015. * @param name defines the control name
  62016. */
  62017. constructor(name?: string | undefined);
  62018. protected _getTypeName(): string;
  62019. _draw(context: CanvasRenderingContext2D): void;
  62020. _measure(): void;
  62021. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62022. /**
  62023. * Move one end of the line given 3D cartesian coordinates.
  62024. * @param position Targeted world position
  62025. * @param scene BABYLON.Scene
  62026. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62027. */
  62028. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62029. /**
  62030. * Move one end of the line to a position in screen absolute space.
  62031. * @param projectedPosition Position in screen absolute space (X, Y)
  62032. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62033. */
  62034. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62035. }
  62036. }
  62037. declare module BABYLON.GUI {
  62038. /**
  62039. * Class used to store a point for a MultiLine object.
  62040. * The point can be pure 2D coordinates, a mesh or a control
  62041. */
  62042. export class MultiLinePoint {
  62043. private _multiLine;
  62044. private _x;
  62045. private _y;
  62046. private _control;
  62047. private _mesh;
  62048. private _controlObserver;
  62049. private _meshObserver;
  62050. /** @hidden */
  62051. _point: BABYLON.Vector2;
  62052. /**
  62053. * Creates a new MultiLinePoint
  62054. * @param multiLine defines the source MultiLine object
  62055. */
  62056. constructor(multiLine: MultiLine);
  62057. /** Gets or sets x coordinate */
  62058. x: string | number;
  62059. /** Gets or sets y coordinate */
  62060. y: string | number;
  62061. /** Gets or sets the control associated with this point */
  62062. control: BABYLON.Nullable<Control>;
  62063. /** Gets or sets the mesh associated with this point */
  62064. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62065. /** Resets links */
  62066. resetLinks(): void;
  62067. /**
  62068. * Gets a translation vector
  62069. * @returns the translation vector
  62070. */
  62071. translate(): BABYLON.Vector2;
  62072. private _translatePoint;
  62073. /** Release associated resources */
  62074. dispose(): void;
  62075. }
  62076. }
  62077. declare module BABYLON.GUI {
  62078. /**
  62079. * Class used to create multi line control
  62080. */
  62081. export class MultiLine extends Control {
  62082. name?: string | undefined;
  62083. private _lineWidth;
  62084. private _dash;
  62085. private _points;
  62086. private _minX;
  62087. private _minY;
  62088. private _maxX;
  62089. private _maxY;
  62090. /**
  62091. * Creates a new MultiLine
  62092. * @param name defines the control name
  62093. */
  62094. constructor(name?: string | undefined);
  62095. /** Gets or sets dash pattern */
  62096. dash: Array<number>;
  62097. /**
  62098. * Gets point stored at specified index
  62099. * @param index defines the index to look for
  62100. * @returns the requested point if found
  62101. */
  62102. getAt(index: number): MultiLinePoint;
  62103. /** Function called when a point is updated */
  62104. onPointUpdate: () => void;
  62105. /**
  62106. * Adds new points to the point collection
  62107. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62108. * @returns the list of created MultiLinePoint
  62109. */
  62110. add(...items: (AbstractMesh | Control | {
  62111. x: string | number;
  62112. y: string | number;
  62113. })[]): MultiLinePoint[];
  62114. /**
  62115. * Adds a new point to the point collection
  62116. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62117. * @returns the created MultiLinePoint
  62118. */
  62119. push(item?: (AbstractMesh | Control | {
  62120. x: string | number;
  62121. y: string | number;
  62122. })): MultiLinePoint;
  62123. /**
  62124. * Remove a specific value or point from the active point collection
  62125. * @param value defines the value or point to remove
  62126. */
  62127. remove(value: number | MultiLinePoint): void;
  62128. /**
  62129. * Resets this object to initial state (no point)
  62130. */
  62131. reset(): void;
  62132. /**
  62133. * Resets all links
  62134. */
  62135. resetLinks(): void;
  62136. /** Gets or sets line width */
  62137. lineWidth: number;
  62138. horizontalAlignment: number;
  62139. verticalAlignment: number;
  62140. protected _getTypeName(): string;
  62141. _draw(context: CanvasRenderingContext2D): void;
  62142. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62143. _measure(): void;
  62144. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62145. dispose(): void;
  62146. }
  62147. }
  62148. declare module BABYLON.GUI {
  62149. /**
  62150. * Class used to create radio button controls
  62151. */
  62152. export class RadioButton extends Control {
  62153. name?: string | undefined;
  62154. private _isChecked;
  62155. private _background;
  62156. private _checkSizeRatio;
  62157. private _thickness;
  62158. /** Gets or sets border thickness */
  62159. thickness: number;
  62160. /** Gets or sets group name */
  62161. group: string;
  62162. /** BABYLON.Observable raised when isChecked is changed */
  62163. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62164. /** Gets or sets a value indicating the ratio between overall size and check size */
  62165. checkSizeRatio: number;
  62166. /** Gets or sets background color */
  62167. background: string;
  62168. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62169. isChecked: boolean;
  62170. /**
  62171. * Creates a new RadioButton
  62172. * @param name defines the control name
  62173. */
  62174. constructor(name?: string | undefined);
  62175. protected _getTypeName(): string;
  62176. _draw(context: CanvasRenderingContext2D): void;
  62177. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62178. /**
  62179. * Utility function to easily create a radio button with a header
  62180. * @param title defines the label to use for the header
  62181. * @param group defines the group to use for the radio button
  62182. * @param isChecked defines the initial state of the radio button
  62183. * @param onValueChanged defines the callback to call when value changes
  62184. * @returns a StackPanel containing the radio button and a textBlock
  62185. */
  62186. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62187. }
  62188. }
  62189. declare module BABYLON.GUI {
  62190. /**
  62191. * Class used to create slider controls
  62192. */
  62193. export class BaseSlider extends Control {
  62194. name?: string | undefined;
  62195. protected _thumbWidth: ValueAndUnit;
  62196. private _minimum;
  62197. private _maximum;
  62198. private _value;
  62199. private _isVertical;
  62200. protected _barOffset: ValueAndUnit;
  62201. private _isThumbClamped;
  62202. protected _displayThumb: boolean;
  62203. private _step;
  62204. private _lastPointerDownID;
  62205. protected _effectiveBarOffset: number;
  62206. protected _renderLeft: number;
  62207. protected _renderTop: number;
  62208. protected _renderWidth: number;
  62209. protected _renderHeight: number;
  62210. protected _backgroundBoxLength: number;
  62211. protected _backgroundBoxThickness: number;
  62212. protected _effectiveThumbThickness: number;
  62213. /** BABYLON.Observable raised when the sldier value changes */
  62214. onValueChangedObservable: BABYLON.Observable<number>;
  62215. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62216. displayThumb: boolean;
  62217. /** Gets or sets a step to apply to values (0 by default) */
  62218. step: number;
  62219. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62220. barOffset: string | number;
  62221. /** Gets main bar offset in pixels*/
  62222. readonly barOffsetInPixels: number;
  62223. /** Gets or sets thumb width */
  62224. thumbWidth: string | number;
  62225. /** Gets thumb width in pixels */
  62226. readonly thumbWidthInPixels: number;
  62227. /** Gets or sets minimum value */
  62228. minimum: number;
  62229. /** Gets or sets maximum value */
  62230. maximum: number;
  62231. /** Gets or sets current value */
  62232. value: number;
  62233. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62234. isVertical: boolean;
  62235. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62236. isThumbClamped: boolean;
  62237. /**
  62238. * Creates a new BaseSlider
  62239. * @param name defines the control name
  62240. */
  62241. constructor(name?: string | undefined);
  62242. protected _getTypeName(): string;
  62243. protected _getThumbPosition(): number;
  62244. protected _getThumbThickness(type: string): number;
  62245. protected _prepareRenderingData(type: string): void;
  62246. private _pointerIsDown;
  62247. /** @hidden */
  62248. protected _updateValueFromPointer(x: number, y: number): void;
  62249. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62250. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62251. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62252. }
  62253. }
  62254. declare module BABYLON.GUI {
  62255. /**
  62256. * Class used to create slider controls
  62257. */
  62258. export class Slider extends BaseSlider {
  62259. name?: string | undefined;
  62260. private _background;
  62261. private _borderColor;
  62262. private _isThumbCircle;
  62263. protected _displayValueBar: boolean;
  62264. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62265. displayValueBar: boolean;
  62266. /** Gets or sets border color */
  62267. borderColor: string;
  62268. /** Gets or sets background color */
  62269. background: string;
  62270. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62271. isThumbCircle: boolean;
  62272. /**
  62273. * Creates a new Slider
  62274. * @param name defines the control name
  62275. */
  62276. constructor(name?: string | undefined);
  62277. protected _getTypeName(): string;
  62278. _draw(context: CanvasRenderingContext2D): void;
  62279. }
  62280. }
  62281. declare module BABYLON.GUI {
  62282. /** Class used to create a RadioGroup
  62283. * which contains groups of radio buttons
  62284. */
  62285. export class SelectorGroup {
  62286. /** name of SelectorGroup */
  62287. name: string;
  62288. private _groupPanel;
  62289. private _selectors;
  62290. private _groupHeader;
  62291. /**
  62292. * Creates a new SelectorGroup
  62293. * @param name of group, used as a group heading
  62294. */
  62295. constructor(
  62296. /** name of SelectorGroup */
  62297. name: string);
  62298. /** Gets the groupPanel of the SelectorGroup */
  62299. readonly groupPanel: StackPanel;
  62300. /** Gets the selectors array */
  62301. readonly selectors: StackPanel[];
  62302. /** Gets and sets the group header */
  62303. header: string;
  62304. /** @hidden */
  62305. private _addGroupHeader;
  62306. /** @hidden*/
  62307. _getSelector(selectorNb: number): StackPanel | undefined;
  62308. /** Removes the selector at the given position
  62309. * @param selectorNb the position of the selector within the group
  62310. */
  62311. removeSelector(selectorNb: number): void;
  62312. }
  62313. /** Class used to create a CheckboxGroup
  62314. * which contains groups of checkbox buttons
  62315. */
  62316. export class CheckboxGroup extends SelectorGroup {
  62317. /** Adds a checkbox as a control
  62318. * @param text is the label for the selector
  62319. * @param func is the function called when the Selector is checked
  62320. * @param checked is true when Selector is checked
  62321. */
  62322. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62323. /** @hidden */
  62324. _setSelectorLabel(selectorNb: number, label: string): void;
  62325. /** @hidden */
  62326. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62327. /** @hidden */
  62328. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62329. /** @hidden */
  62330. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62331. }
  62332. /** Class used to create a RadioGroup
  62333. * which contains groups of radio buttons
  62334. */
  62335. export class RadioGroup extends SelectorGroup {
  62336. private _selectNb;
  62337. /** Adds a radio button as a control
  62338. * @param label is the label for the selector
  62339. * @param func is the function called when the Selector is checked
  62340. * @param checked is true when Selector is checked
  62341. */
  62342. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62343. /** @hidden */
  62344. _setSelectorLabel(selectorNb: number, label: string): void;
  62345. /** @hidden */
  62346. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62347. /** @hidden */
  62348. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62349. /** @hidden */
  62350. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62351. }
  62352. /** Class used to create a SliderGroup
  62353. * which contains groups of slider buttons
  62354. */
  62355. export class SliderGroup extends SelectorGroup {
  62356. /**
  62357. * Adds a slider to the SelectorGroup
  62358. * @param label is the label for the SliderBar
  62359. * @param func is the function called when the Slider moves
  62360. * @param unit is a string describing the units used, eg degrees or metres
  62361. * @param min is the minimum value for the Slider
  62362. * @param max is the maximum value for the Slider
  62363. * @param value is the start value for the Slider between min and max
  62364. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62365. */
  62366. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62367. /** @hidden */
  62368. _setSelectorLabel(selectorNb: number, label: string): void;
  62369. /** @hidden */
  62370. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62371. /** @hidden */
  62372. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62373. /** @hidden */
  62374. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62375. }
  62376. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62377. * @see http://doc.babylonjs.com/how_to/selector
  62378. */
  62379. export class SelectionPanel extends Rectangle {
  62380. /** name of SelectionPanel */
  62381. name: string;
  62382. /** an array of SelectionGroups */
  62383. groups: SelectorGroup[];
  62384. private _panel;
  62385. private _buttonColor;
  62386. private _buttonBackground;
  62387. private _headerColor;
  62388. private _barColor;
  62389. private _barHeight;
  62390. private _spacerHeight;
  62391. private _labelColor;
  62392. private _groups;
  62393. private _bars;
  62394. /**
  62395. * Creates a new SelectionPanel
  62396. * @param name of SelectionPanel
  62397. * @param groups is an array of SelectionGroups
  62398. */
  62399. constructor(
  62400. /** name of SelectionPanel */
  62401. name: string,
  62402. /** an array of SelectionGroups */
  62403. groups?: SelectorGroup[]);
  62404. protected _getTypeName(): string;
  62405. /** Gets or sets the headerColor */
  62406. headerColor: string;
  62407. private _setHeaderColor;
  62408. /** Gets or sets the button color */
  62409. buttonColor: string;
  62410. private _setbuttonColor;
  62411. /** Gets or sets the label color */
  62412. labelColor: string;
  62413. private _setLabelColor;
  62414. /** Gets or sets the button background */
  62415. buttonBackground: string;
  62416. private _setButtonBackground;
  62417. /** Gets or sets the color of separator bar */
  62418. barColor: string;
  62419. private _setBarColor;
  62420. /** Gets or sets the height of separator bar */
  62421. barHeight: string;
  62422. private _setBarHeight;
  62423. /** Gets or sets the height of spacers*/
  62424. spacerHeight: string;
  62425. private _setSpacerHeight;
  62426. /** Adds a bar between groups */
  62427. private _addSpacer;
  62428. /** Add a group to the selection panel
  62429. * @param group is the selector group to add
  62430. */
  62431. addGroup(group: SelectorGroup): void;
  62432. /** Remove the group from the given position
  62433. * @param groupNb is the position of the group in the list
  62434. */
  62435. removeGroup(groupNb: number): void;
  62436. /** Change a group header label
  62437. * @param label is the new group header label
  62438. * @param groupNb is the number of the group to relabel
  62439. * */
  62440. setHeaderName(label: string, groupNb: number): void;
  62441. /** Change selector label to the one given
  62442. * @param label is the new selector label
  62443. * @param groupNb is the number of the groupcontaining the selector
  62444. * @param selectorNb is the number of the selector within a group to relabel
  62445. * */
  62446. relabel(label: string, groupNb: number, selectorNb: number): void;
  62447. /** For a given group position remove the selector at the given position
  62448. * @param groupNb is the number of the group to remove the selector from
  62449. * @param selectorNb is the number of the selector within the group
  62450. */
  62451. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62452. /** For a given group position of correct type add a checkbox button
  62453. * @param groupNb is the number of the group to remove the selector from
  62454. * @param label is the label for the selector
  62455. * @param func is the function called when the Selector is checked
  62456. * @param checked is true when Selector is checked
  62457. */
  62458. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62459. /** For a given group position of correct type add a radio button
  62460. * @param groupNb is the number of the group to remove the selector from
  62461. * @param label is the label for the selector
  62462. * @param func is the function called when the Selector is checked
  62463. * @param checked is true when Selector is checked
  62464. */
  62465. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62466. /**
  62467. * For a given slider group add a slider
  62468. * @param groupNb is the number of the group to add the slider to
  62469. * @param label is the label for the Slider
  62470. * @param func is the function called when the Slider moves
  62471. * @param unit is a string describing the units used, eg degrees or metres
  62472. * @param min is the minimum value for the Slider
  62473. * @param max is the maximum value for the Slider
  62474. * @param value is the start value for the Slider between min and max
  62475. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62476. */
  62477. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62478. }
  62479. }
  62480. declare module BABYLON.GUI {
  62481. /**
  62482. * Class used to hold a the container for ScrollViewer
  62483. * @hidden
  62484. */
  62485. export class _ScrollViewerWindow extends Container {
  62486. parentClientWidth: number;
  62487. parentClientHeight: number;
  62488. /**
  62489. * Creates a new ScrollViewerWindow
  62490. * @param name of ScrollViewerWindow
  62491. */
  62492. constructor(name?: string);
  62493. protected _getTypeName(): string;
  62494. /** @hidden */
  62495. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62496. protected _postMeasure(): void;
  62497. }
  62498. }
  62499. declare module BABYLON.GUI {
  62500. /**
  62501. * Class used to create slider controls
  62502. */
  62503. export class ScrollBar extends BaseSlider {
  62504. name?: string | undefined;
  62505. private _background;
  62506. private _borderColor;
  62507. private _thumbMeasure;
  62508. /** Gets or sets border color */
  62509. borderColor: string;
  62510. /** Gets or sets background color */
  62511. background: string;
  62512. /**
  62513. * Creates a new Slider
  62514. * @param name defines the control name
  62515. */
  62516. constructor(name?: string | undefined);
  62517. protected _getTypeName(): string;
  62518. protected _getThumbThickness(): number;
  62519. _draw(context: CanvasRenderingContext2D): void;
  62520. private _first;
  62521. private _originX;
  62522. private _originY;
  62523. /** @hidden */
  62524. protected _updateValueFromPointer(x: number, y: number): void;
  62525. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62526. }
  62527. }
  62528. declare module BABYLON.GUI {
  62529. /**
  62530. * Class used to hold a viewer window and sliders in a grid
  62531. */
  62532. export class ScrollViewer extends Rectangle {
  62533. private _grid;
  62534. private _horizontalBarSpace;
  62535. private _verticalBarSpace;
  62536. private _dragSpace;
  62537. private _horizontalBar;
  62538. private _verticalBar;
  62539. private _barColor;
  62540. private _barBackground;
  62541. private _barSize;
  62542. private _endLeft;
  62543. private _endTop;
  62544. private _window;
  62545. private _pointerIsOver;
  62546. private _wheelPrecision;
  62547. private _onPointerObserver;
  62548. private _clientWidth;
  62549. private _clientHeight;
  62550. /**
  62551. * Gets the horizontal scrollbar
  62552. */
  62553. readonly horizontalBar: ScrollBar;
  62554. /**
  62555. * Gets the vertical scrollbar
  62556. */
  62557. readonly verticalBar: ScrollBar;
  62558. /**
  62559. * Adds a new control to the current container
  62560. * @param control defines the control to add
  62561. * @returns the current container
  62562. */
  62563. addControl(control: BABYLON.Nullable<Control>): Container;
  62564. /**
  62565. * Removes a control from the current container
  62566. * @param control defines the control to remove
  62567. * @returns the current container
  62568. */
  62569. removeControl(control: Control): Container;
  62570. /** Gets the list of children */
  62571. readonly children: Control[];
  62572. _flagDescendantsAsMatrixDirty(): void;
  62573. /**
  62574. * Creates a new ScrollViewer
  62575. * @param name of ScrollViewer
  62576. */
  62577. constructor(name?: string);
  62578. /** Reset the scroll viewer window to initial size */
  62579. resetWindow(): void;
  62580. protected _getTypeName(): string;
  62581. private _buildClientSizes;
  62582. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62583. protected _postMeasure(): void;
  62584. /**
  62585. * Gets or sets the mouse wheel precision
  62586. * from 0 to 1 with a default value of 0.05
  62587. * */
  62588. wheelPrecision: number;
  62589. /** Gets or sets the bar color */
  62590. barColor: string;
  62591. /** Gets or sets the size of the bar */
  62592. barSize: number;
  62593. /** Gets or sets the bar background */
  62594. barBackground: string;
  62595. /** @hidden */
  62596. private _updateScroller;
  62597. _link(host: AdvancedDynamicTexture): void;
  62598. /** @hidden */
  62599. private _attachWheel;
  62600. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62601. /** Releases associated resources */
  62602. dispose(): void;
  62603. }
  62604. }
  62605. declare module BABYLON.GUI {
  62606. /** Class used to render a grid */
  62607. export class DisplayGrid extends Control {
  62608. name?: string | undefined;
  62609. private _cellWidth;
  62610. private _cellHeight;
  62611. private _minorLineTickness;
  62612. private _minorLineColor;
  62613. private _majorLineTickness;
  62614. private _majorLineColor;
  62615. private _majorLineFrequency;
  62616. private _background;
  62617. private _displayMajorLines;
  62618. private _displayMinorLines;
  62619. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62620. displayMinorLines: boolean;
  62621. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62622. displayMajorLines: boolean;
  62623. /** Gets or sets background color (Black by default) */
  62624. background: string;
  62625. /** Gets or sets the width of each cell (20 by default) */
  62626. cellWidth: number;
  62627. /** Gets or sets the height of each cell (20 by default) */
  62628. cellHeight: number;
  62629. /** Gets or sets the tickness of minor lines (1 by default) */
  62630. minorLineTickness: number;
  62631. /** Gets or sets the color of minor lines (DarkGray by default) */
  62632. minorLineColor: string;
  62633. /** Gets or sets the tickness of major lines (2 by default) */
  62634. majorLineTickness: number;
  62635. /** Gets or sets the color of major lines (White by default) */
  62636. majorLineColor: string;
  62637. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62638. majorLineFrequency: number;
  62639. /**
  62640. * Creates a new GridDisplayRectangle
  62641. * @param name defines the control name
  62642. */
  62643. constructor(name?: string | undefined);
  62644. _draw(context: CanvasRenderingContext2D): void;
  62645. protected _getTypeName(): string;
  62646. }
  62647. }
  62648. declare module BABYLON.GUI {
  62649. /**
  62650. * Class used to create slider controls based on images
  62651. */
  62652. export class ImageBasedSlider extends BaseSlider {
  62653. name?: string | undefined;
  62654. private _backgroundImage;
  62655. private _thumbImage;
  62656. private _valueBarImage;
  62657. private _tempMeasure;
  62658. displayThumb: boolean;
  62659. /**
  62660. * Gets or sets the image used to render the background
  62661. */
  62662. backgroundImage: Image;
  62663. /**
  62664. * Gets or sets the image used to render the value bar
  62665. */
  62666. valueBarImage: Image;
  62667. /**
  62668. * Gets or sets the image used to render the thumb
  62669. */
  62670. thumbImage: Image;
  62671. /**
  62672. * Creates a new ImageBasedSlider
  62673. * @param name defines the control name
  62674. */
  62675. constructor(name?: string | undefined);
  62676. protected _getTypeName(): string;
  62677. _draw(context: CanvasRenderingContext2D): void;
  62678. }
  62679. }
  62680. declare module BABYLON.GUI {
  62681. /**
  62682. * Forcing an export so that this code will execute
  62683. * @hidden
  62684. */
  62685. const name = "Statics";
  62686. }
  62687. declare module BABYLON.GUI {
  62688. /**
  62689. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62690. */
  62691. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62692. /**
  62693. * Define the instrumented AdvancedDynamicTexture.
  62694. */
  62695. texture: AdvancedDynamicTexture;
  62696. private _captureRenderTime;
  62697. private _renderTime;
  62698. private _captureLayoutTime;
  62699. private _layoutTime;
  62700. private _onBeginRenderObserver;
  62701. private _onEndRenderObserver;
  62702. private _onBeginLayoutObserver;
  62703. private _onEndLayoutObserver;
  62704. /**
  62705. * Gets the perf counter used to capture render time
  62706. */
  62707. readonly renderTimeCounter: BABYLON.PerfCounter;
  62708. /**
  62709. * Gets the perf counter used to capture layout time
  62710. */
  62711. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62712. /**
  62713. * Enable or disable the render time capture
  62714. */
  62715. captureRenderTime: boolean;
  62716. /**
  62717. * Enable or disable the layout time capture
  62718. */
  62719. captureLayoutTime: boolean;
  62720. /**
  62721. * Instantiates a new advanced dynamic texture instrumentation.
  62722. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62723. * @param texture Defines the AdvancedDynamicTexture to instrument
  62724. */
  62725. constructor(
  62726. /**
  62727. * Define the instrumented AdvancedDynamicTexture.
  62728. */
  62729. texture: AdvancedDynamicTexture);
  62730. /**
  62731. * Dispose and release associated resources.
  62732. */
  62733. dispose(): void;
  62734. }
  62735. }
  62736. declare module BABYLON.GUI {
  62737. /**
  62738. * Class used to create containers for controls
  62739. */
  62740. export class Container3D extends Control3D {
  62741. private _blockLayout;
  62742. /**
  62743. * Gets the list of child controls
  62744. */
  62745. protected _children: Control3D[];
  62746. /**
  62747. * Gets the list of child controls
  62748. */
  62749. readonly children: Array<Control3D>;
  62750. /**
  62751. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62752. * This is helpful to optimize layout operation when adding multiple children in a row
  62753. */
  62754. blockLayout: boolean;
  62755. /**
  62756. * Creates a new container
  62757. * @param name defines the container name
  62758. */
  62759. constructor(name?: string);
  62760. /**
  62761. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  62762. * @returns the current container
  62763. */
  62764. updateLayout(): Container3D;
  62765. /**
  62766. * Gets a boolean indicating if the given control is in the children of this control
  62767. * @param control defines the control to check
  62768. * @returns true if the control is in the child list
  62769. */
  62770. containsControl(control: Control3D): boolean;
  62771. /**
  62772. * Adds a control to the children of this control
  62773. * @param control defines the control to add
  62774. * @returns the current container
  62775. */
  62776. addControl(control: Control3D): Container3D;
  62777. /**
  62778. * This function will be called everytime a new control is added
  62779. */
  62780. protected _arrangeChildren(): void;
  62781. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62782. /**
  62783. * Removes a control from the children of this control
  62784. * @param control defines the control to remove
  62785. * @returns the current container
  62786. */
  62787. removeControl(control: Control3D): Container3D;
  62788. protected _getTypeName(): string;
  62789. /**
  62790. * Releases all associated resources
  62791. */
  62792. dispose(): void;
  62793. /** Control rotation will remain unchanged */
  62794. static readonly UNSET_ORIENTATION: number;
  62795. /** Control will rotate to make it look at sphere central axis */
  62796. static readonly FACEORIGIN_ORIENTATION: number;
  62797. /** Control will rotate to make it look back at sphere central axis */
  62798. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  62799. /** Control will rotate to look at z axis (0, 0, 1) */
  62800. static readonly FACEFORWARD_ORIENTATION: number;
  62801. /** Control will rotate to look at negative z axis (0, 0, -1) */
  62802. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  62803. }
  62804. }
  62805. declare module BABYLON.GUI {
  62806. /**
  62807. * Class used to manage 3D user interface
  62808. * @see http://doc.babylonjs.com/how_to/gui3d
  62809. */
  62810. export class GUI3DManager implements BABYLON.IDisposable {
  62811. private _scene;
  62812. private _sceneDisposeObserver;
  62813. private _utilityLayer;
  62814. private _rootContainer;
  62815. private _pointerObserver;
  62816. private _pointerOutObserver;
  62817. /** @hidden */
  62818. _lastPickedControl: Control3D;
  62819. /** @hidden */
  62820. _lastControlOver: {
  62821. [pointerId: number]: Control3D;
  62822. };
  62823. /** @hidden */
  62824. _lastControlDown: {
  62825. [pointerId: number]: Control3D;
  62826. };
  62827. /**
  62828. * BABYLON.Observable raised when the point picked by the pointer events changed
  62829. */
  62830. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  62831. /** @hidden */
  62832. _sharedMaterials: {
  62833. [key: string]: BABYLON.Material;
  62834. };
  62835. /** Gets the hosting scene */
  62836. readonly scene: BABYLON.Scene;
  62837. /** Gets associated utility layer */
  62838. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  62839. /**
  62840. * Creates a new GUI3DManager
  62841. * @param scene
  62842. */
  62843. constructor(scene?: BABYLON.Scene);
  62844. private _handlePointerOut;
  62845. private _doPicking;
  62846. /**
  62847. * Gets the root container
  62848. */
  62849. readonly rootContainer: Container3D;
  62850. /**
  62851. * Gets a boolean indicating if the given control is in the root child list
  62852. * @param control defines the control to check
  62853. * @returns true if the control is in the root child list
  62854. */
  62855. containsControl(control: Control3D): boolean;
  62856. /**
  62857. * Adds a control to the root child list
  62858. * @param control defines the control to add
  62859. * @returns the current manager
  62860. */
  62861. addControl(control: Control3D): GUI3DManager;
  62862. /**
  62863. * Removes a control from the root child list
  62864. * @param control defines the control to remove
  62865. * @returns the current container
  62866. */
  62867. removeControl(control: Control3D): GUI3DManager;
  62868. /**
  62869. * Releases all associated resources
  62870. */
  62871. dispose(): void;
  62872. }
  62873. }
  62874. declare module BABYLON.GUI {
  62875. /**
  62876. * Class used to transport BABYLON.Vector3 information for pointer events
  62877. */
  62878. export class Vector3WithInfo extends BABYLON.Vector3 {
  62879. /** defines the current mouse button index */
  62880. buttonIndex: number;
  62881. /**
  62882. * Creates a new Vector3WithInfo
  62883. * @param source defines the vector3 data to transport
  62884. * @param buttonIndex defines the current mouse button index
  62885. */
  62886. constructor(source: BABYLON.Vector3,
  62887. /** defines the current mouse button index */
  62888. buttonIndex?: number);
  62889. }
  62890. }
  62891. declare module BABYLON.GUI {
  62892. /**
  62893. * Class used as base class for controls
  62894. */
  62895. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62896. /** Defines the control name */
  62897. name?: string | undefined;
  62898. /** @hidden */
  62899. _host: GUI3DManager;
  62900. private _node;
  62901. private _downCount;
  62902. private _enterCount;
  62903. private _downPointerIds;
  62904. private _isVisible;
  62905. /** Gets or sets the control position in world space */
  62906. position: BABYLON.Vector3;
  62907. /** Gets or sets the control scaling in world space */
  62908. scaling: BABYLON.Vector3;
  62909. /** Callback used to start pointer enter animation */
  62910. pointerEnterAnimation: () => void;
  62911. /** Callback used to start pointer out animation */
  62912. pointerOutAnimation: () => void;
  62913. /** Callback used to start pointer down animation */
  62914. pointerDownAnimation: () => void;
  62915. /** Callback used to start pointer up animation */
  62916. pointerUpAnimation: () => void;
  62917. /**
  62918. * An event triggered when the pointer move over the control
  62919. */
  62920. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62921. /**
  62922. * An event triggered when the pointer move out of the control
  62923. */
  62924. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62925. /**
  62926. * An event triggered when the pointer taps the control
  62927. */
  62928. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62929. /**
  62930. * An event triggered when pointer is up
  62931. */
  62932. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62933. /**
  62934. * An event triggered when a control is clicked on (with a mouse)
  62935. */
  62936. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62937. /**
  62938. * An event triggered when pointer enters the control
  62939. */
  62940. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62941. /**
  62942. * Gets or sets the parent container
  62943. */
  62944. parent: BABYLON.Nullable<Container3D>;
  62945. private _behaviors;
  62946. /**
  62947. * Gets the list of attached behaviors
  62948. * @see http://doc.babylonjs.com/features/behaviour
  62949. */
  62950. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62951. /**
  62952. * Attach a behavior to the control
  62953. * @see http://doc.babylonjs.com/features/behaviour
  62954. * @param behavior defines the behavior to attach
  62955. * @returns the current control
  62956. */
  62957. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62958. /**
  62959. * Remove an attached behavior
  62960. * @see http://doc.babylonjs.com/features/behaviour
  62961. * @param behavior defines the behavior to attach
  62962. * @returns the current control
  62963. */
  62964. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62965. /**
  62966. * Gets an attached behavior by name
  62967. * @param name defines the name of the behavior to look for
  62968. * @see http://doc.babylonjs.com/features/behaviour
  62969. * @returns null if behavior was not found else the requested behavior
  62970. */
  62971. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62972. /** Gets or sets a boolean indicating if the control is visible */
  62973. isVisible: boolean;
  62974. /**
  62975. * Creates a new control
  62976. * @param name defines the control name
  62977. */
  62978. constructor(
  62979. /** Defines the control name */
  62980. name?: string | undefined);
  62981. /**
  62982. * Gets a string representing the class name
  62983. */
  62984. readonly typeName: string;
  62985. /**
  62986. * Get the current class name of the control.
  62987. * @returns current class name
  62988. */
  62989. getClassName(): string;
  62990. protected _getTypeName(): string;
  62991. /**
  62992. * Gets the transform node used by this control
  62993. */
  62994. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62995. /**
  62996. * Gets the mesh used to render this control
  62997. */
  62998. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62999. /**
  63000. * Link the control as child of the given node
  63001. * @param node defines the node to link to. Use null to unlink the control
  63002. * @returns the current control
  63003. */
  63004. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63005. /** @hidden **/
  63006. _prepareNode(scene: BABYLON.Scene): void;
  63007. /**
  63008. * Node creation.
  63009. * Can be overriden by children
  63010. * @param scene defines the scene where the node must be attached
  63011. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63012. */
  63013. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63014. /**
  63015. * Affect a material to the given mesh
  63016. * @param mesh defines the mesh which will represent the control
  63017. */
  63018. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63019. /** @hidden */
  63020. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63021. /** @hidden */
  63022. _onPointerEnter(target: Control3D): boolean;
  63023. /** @hidden */
  63024. _onPointerOut(target: Control3D): void;
  63025. /** @hidden */
  63026. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63027. /** @hidden */
  63028. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63029. /** @hidden */
  63030. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63031. /** @hidden */
  63032. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63033. /** @hidden */
  63034. _disposeNode(): void;
  63035. /**
  63036. * Releases all associated resources
  63037. */
  63038. dispose(): void;
  63039. }
  63040. }
  63041. declare module BABYLON.GUI {
  63042. /**
  63043. * Class used as a root to all buttons
  63044. */
  63045. export class AbstractButton3D extends Control3D {
  63046. /**
  63047. * Creates a new button
  63048. * @param name defines the control name
  63049. */
  63050. constructor(name?: string);
  63051. protected _getTypeName(): string;
  63052. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63053. }
  63054. }
  63055. declare module BABYLON.GUI {
  63056. /**
  63057. * Class used to create a button in 3D
  63058. */
  63059. export class Button3D extends AbstractButton3D {
  63060. /** @hidden */
  63061. protected _currentMaterial: BABYLON.Material;
  63062. private _facadeTexture;
  63063. private _content;
  63064. private _contentResolution;
  63065. private _contentScaleRatio;
  63066. /**
  63067. * Gets or sets the texture resolution used to render content (512 by default)
  63068. */
  63069. contentResolution: BABYLON.int;
  63070. /**
  63071. * Gets or sets the texture scale ratio used to render content (2 by default)
  63072. */
  63073. contentScaleRatio: number;
  63074. protected _disposeFacadeTexture(): void;
  63075. protected _resetContent(): void;
  63076. /**
  63077. * Creates a new button
  63078. * @param name defines the control name
  63079. */
  63080. constructor(name?: string);
  63081. /**
  63082. * Gets or sets the GUI 2D content used to display the button's facade
  63083. */
  63084. content: Control;
  63085. /**
  63086. * Apply the facade texture (created from the content property).
  63087. * This function can be overloaded by child classes
  63088. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63089. */
  63090. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63091. protected _getTypeName(): string;
  63092. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63093. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63094. /**
  63095. * Releases all associated resources
  63096. */
  63097. dispose(): void;
  63098. }
  63099. }
  63100. declare module BABYLON.GUI {
  63101. /**
  63102. * Abstract class used to create a container panel deployed on the surface of a volume
  63103. */
  63104. export abstract class VolumeBasedPanel extends Container3D {
  63105. private _columns;
  63106. private _rows;
  63107. private _rowThenColum;
  63108. private _orientation;
  63109. protected _cellWidth: number;
  63110. protected _cellHeight: number;
  63111. /**
  63112. * Gets or sets the distance between elements
  63113. */
  63114. margin: number;
  63115. /**
  63116. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63117. * | Value | Type | Description |
  63118. * | ----- | ----------------------------------- | ----------- |
  63119. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63120. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63121. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63122. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63123. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63124. */
  63125. orientation: number;
  63126. /**
  63127. * Gets or sets the number of columns requested (10 by default).
  63128. * The panel will automatically compute the number of rows based on number of child controls.
  63129. */
  63130. columns: BABYLON.int;
  63131. /**
  63132. * Gets or sets a the number of rows requested.
  63133. * The panel will automatically compute the number of columns based on number of child controls.
  63134. */
  63135. rows: BABYLON.int;
  63136. /**
  63137. * Creates new VolumeBasedPanel
  63138. */
  63139. constructor();
  63140. protected _arrangeChildren(): void;
  63141. /** Child classes must implement this function to provide correct control positioning */
  63142. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63143. /** Child classes can implement this function to provide additional processing */
  63144. protected _finalProcessing(): void;
  63145. }
  63146. }
  63147. declare module BABYLON.GUI {
  63148. /**
  63149. * Class used to create a container panel deployed on the surface of a cylinder
  63150. */
  63151. export class CylinderPanel extends VolumeBasedPanel {
  63152. private _radius;
  63153. /**
  63154. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63155. */
  63156. radius: BABYLON.float;
  63157. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63158. private _cylindricalMapping;
  63159. }
  63160. }
  63161. declare module BABYLON.GUI {
  63162. /** @hidden */
  63163. export var fluentVertexShader: {
  63164. name: string;
  63165. shader: string;
  63166. };
  63167. }
  63168. declare module BABYLON.GUI {
  63169. /** @hidden */
  63170. export var fluentPixelShader: {
  63171. name: string;
  63172. shader: string;
  63173. };
  63174. }
  63175. declare module BABYLON.GUI {
  63176. /** @hidden */
  63177. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63178. INNERGLOW: boolean;
  63179. BORDER: boolean;
  63180. HOVERLIGHT: boolean;
  63181. TEXTURE: boolean;
  63182. constructor();
  63183. }
  63184. /**
  63185. * Class used to render controls with fluent desgin
  63186. */
  63187. export class FluentMaterial extends BABYLON.PushMaterial {
  63188. /**
  63189. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63190. */
  63191. innerGlowColorIntensity: number;
  63192. /**
  63193. * Gets or sets the inner glow color (white by default)
  63194. */
  63195. innerGlowColor: BABYLON.Color3;
  63196. /**
  63197. * Gets or sets alpha value (default is 1.0)
  63198. */
  63199. alpha: number;
  63200. /**
  63201. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63202. */
  63203. albedoColor: BABYLON.Color3;
  63204. /**
  63205. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63206. */
  63207. renderBorders: boolean;
  63208. /**
  63209. * Gets or sets border width (default is 0.5)
  63210. */
  63211. borderWidth: number;
  63212. /**
  63213. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63214. */
  63215. edgeSmoothingValue: number;
  63216. /**
  63217. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63218. */
  63219. borderMinValue: number;
  63220. /**
  63221. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63222. */
  63223. renderHoverLight: boolean;
  63224. /**
  63225. * Gets or sets the radius used to render the hover light (default is 1.0)
  63226. */
  63227. hoverRadius: number;
  63228. /**
  63229. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63230. */
  63231. hoverColor: BABYLON.Color4;
  63232. /**
  63233. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63234. */
  63235. hoverPosition: BABYLON.Vector3;
  63236. private _albedoTexture;
  63237. /** Gets or sets the texture to use for albedo color */
  63238. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63239. /**
  63240. * Creates a new Fluent material
  63241. * @param name defines the name of the material
  63242. * @param scene defines the hosting scene
  63243. */
  63244. constructor(name: string, scene: BABYLON.Scene);
  63245. needAlphaBlending(): boolean;
  63246. needAlphaTesting(): boolean;
  63247. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63248. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63249. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63250. getActiveTextures(): BABYLON.BaseTexture[];
  63251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63252. dispose(forceDisposeEffect?: boolean): void;
  63253. clone(name: string): FluentMaterial;
  63254. serialize(): any;
  63255. getClassName(): string;
  63256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63257. }
  63258. }
  63259. declare module BABYLON.GUI {
  63260. /**
  63261. * Class used to create a holographic button in 3D
  63262. */
  63263. export class HolographicButton extends Button3D {
  63264. private _backPlate;
  63265. private _textPlate;
  63266. private _frontPlate;
  63267. private _text;
  63268. private _imageUrl;
  63269. private _shareMaterials;
  63270. private _frontMaterial;
  63271. private _backMaterial;
  63272. private _plateMaterial;
  63273. private _pickedPointObserver;
  63274. private _tooltipFade;
  63275. private _tooltipTextBlock;
  63276. private _tooltipTexture;
  63277. private _tooltipMesh;
  63278. private _tooltipHoverObserver;
  63279. private _tooltipOutObserver;
  63280. private _disposeTooltip;
  63281. /**
  63282. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63283. */
  63284. tooltipText: BABYLON.Nullable<string>;
  63285. /**
  63286. * Gets or sets text for the button
  63287. */
  63288. text: string;
  63289. /**
  63290. * Gets or sets the image url for the button
  63291. */
  63292. imageUrl: string;
  63293. /**
  63294. * Gets the back material used by this button
  63295. */
  63296. readonly backMaterial: FluentMaterial;
  63297. /**
  63298. * Gets the front material used by this button
  63299. */
  63300. readonly frontMaterial: FluentMaterial;
  63301. /**
  63302. * Gets the plate material used by this button
  63303. */
  63304. readonly plateMaterial: BABYLON.StandardMaterial;
  63305. /**
  63306. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63307. */
  63308. readonly shareMaterials: boolean;
  63309. /**
  63310. * Creates a new button
  63311. * @param name defines the control name
  63312. */
  63313. constructor(name?: string, shareMaterials?: boolean);
  63314. protected _getTypeName(): string;
  63315. private _rebuildContent;
  63316. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63317. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63318. private _createBackMaterial;
  63319. private _createFrontMaterial;
  63320. private _createPlateMaterial;
  63321. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63322. /**
  63323. * Releases all associated resources
  63324. */
  63325. dispose(): void;
  63326. }
  63327. }
  63328. declare module BABYLON.GUI {
  63329. /**
  63330. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63331. */
  63332. export class MeshButton3D extends Button3D {
  63333. /** @hidden */
  63334. protected _currentMesh: BABYLON.Mesh;
  63335. /**
  63336. * Creates a new 3D button based on a mesh
  63337. * @param mesh mesh to become a 3D button
  63338. * @param name defines the control name
  63339. */
  63340. constructor(mesh: BABYLON.Mesh, name?: string);
  63341. protected _getTypeName(): string;
  63342. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63343. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63344. }
  63345. }
  63346. declare module BABYLON.GUI {
  63347. /**
  63348. * Class used to create a container panel deployed on the surface of a plane
  63349. */
  63350. export class PlanePanel extends VolumeBasedPanel {
  63351. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63352. }
  63353. }
  63354. declare module BABYLON.GUI {
  63355. /**
  63356. * Class used to create a container panel where items get randomized planar mapping
  63357. */
  63358. export class ScatterPanel extends VolumeBasedPanel {
  63359. private _iteration;
  63360. /**
  63361. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63362. */
  63363. iteration: BABYLON.float;
  63364. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63365. private _scatterMapping;
  63366. protected _finalProcessing(): void;
  63367. }
  63368. }
  63369. declare module BABYLON.GUI {
  63370. /**
  63371. * Class used to create a container panel deployed on the surface of a sphere
  63372. */
  63373. export class SpherePanel extends VolumeBasedPanel {
  63374. private _radius;
  63375. /**
  63376. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63377. */
  63378. radius: BABYLON.float;
  63379. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63380. private _sphericalMapping;
  63381. }
  63382. }
  63383. declare module BABYLON.GUI {
  63384. /**
  63385. * Class used to create a stack panel in 3D on XY plane
  63386. */
  63387. export class StackPanel3D extends Container3D {
  63388. private _isVertical;
  63389. /**
  63390. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63391. */
  63392. isVertical: boolean;
  63393. /**
  63394. * Gets or sets the distance between elements
  63395. */
  63396. margin: number;
  63397. /**
  63398. * Creates new StackPanel
  63399. * @param isVertical
  63400. */
  63401. constructor(isVertical?: boolean);
  63402. protected _arrangeChildren(): void;
  63403. }
  63404. }
  63405. declare module BABYLON {
  63406. /**
  63407. * Mode that determines the coordinate system to use.
  63408. */
  63409. export enum GLTFLoaderCoordinateSystemMode {
  63410. /**
  63411. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63412. */
  63413. AUTO = 0,
  63414. /**
  63415. * Sets the useRightHandedSystem flag on the scene.
  63416. */
  63417. FORCE_RIGHT_HANDED = 1
  63418. }
  63419. /**
  63420. * Mode that determines what animations will start.
  63421. */
  63422. export enum GLTFLoaderAnimationStartMode {
  63423. /**
  63424. * No animation will start.
  63425. */
  63426. NONE = 0,
  63427. /**
  63428. * The first animation will start.
  63429. */
  63430. FIRST = 1,
  63431. /**
  63432. * All animations will start.
  63433. */
  63434. ALL = 2
  63435. }
  63436. /**
  63437. * Interface that contains the data for the glTF asset.
  63438. */
  63439. export interface IGLTFLoaderData {
  63440. /**
  63441. * Object that represents the glTF JSON.
  63442. */
  63443. json: Object;
  63444. /**
  63445. * The BIN chunk of a binary glTF.
  63446. */
  63447. bin: Nullable<ArrayBufferView>;
  63448. }
  63449. /**
  63450. * Interface for extending the loader.
  63451. */
  63452. export interface IGLTFLoaderExtension {
  63453. /**
  63454. * The name of this extension.
  63455. */
  63456. readonly name: string;
  63457. /**
  63458. * Defines whether this extension is enabled.
  63459. */
  63460. enabled: boolean;
  63461. }
  63462. /**
  63463. * Loader state.
  63464. */
  63465. export enum GLTFLoaderState {
  63466. /**
  63467. * The asset is loading.
  63468. */
  63469. LOADING = 0,
  63470. /**
  63471. * The asset is ready for rendering.
  63472. */
  63473. READY = 1,
  63474. /**
  63475. * The asset is completely loaded.
  63476. */
  63477. COMPLETE = 2
  63478. }
  63479. /** @hidden */
  63480. export interface IGLTFLoader extends IDisposable {
  63481. readonly state: Nullable<GLTFLoaderState>;
  63482. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63483. meshes: AbstractMesh[];
  63484. particleSystems: IParticleSystem[];
  63485. skeletons: Skeleton[];
  63486. animationGroups: AnimationGroup[];
  63487. }>;
  63488. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63489. }
  63490. /**
  63491. * File loader for loading glTF files into a scene.
  63492. */
  63493. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63494. /** @hidden */
  63495. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63496. /** @hidden */
  63497. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63498. /**
  63499. * Raised when the asset has been parsed
  63500. */
  63501. onParsedObservable: Observable<IGLTFLoaderData>;
  63502. private _onParsedObserver;
  63503. /**
  63504. * Raised when the asset has been parsed
  63505. */
  63506. onParsed: (loaderData: IGLTFLoaderData) => void;
  63507. /**
  63508. * 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.
  63509. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63510. * Defaults to true.
  63511. * @hidden
  63512. */
  63513. static IncrementalLoading: boolean;
  63514. /**
  63515. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63516. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63517. * @hidden
  63518. */
  63519. static HomogeneousCoordinates: boolean;
  63520. /**
  63521. * The coordinate system mode. Defaults to AUTO.
  63522. */
  63523. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63524. /**
  63525. * The animation start mode. Defaults to FIRST.
  63526. */
  63527. animationStartMode: GLTFLoaderAnimationStartMode;
  63528. /**
  63529. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63530. */
  63531. compileMaterials: boolean;
  63532. /**
  63533. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63534. */
  63535. useClipPlane: boolean;
  63536. /**
  63537. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63538. */
  63539. compileShadowGenerators: boolean;
  63540. /**
  63541. * Defines if the Alpha blended materials are only applied as coverage.
  63542. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63543. * If true, no extra effects are applied to transparent pixels.
  63544. */
  63545. transparencyAsCoverage: boolean;
  63546. /**
  63547. * Function called before loading a url referenced by the asset.
  63548. */
  63549. preprocessUrlAsync: (url: string) => Promise<string>;
  63550. /**
  63551. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63552. */
  63553. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63554. private _onMeshLoadedObserver;
  63555. /**
  63556. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63557. */
  63558. onMeshLoaded: (mesh: AbstractMesh) => void;
  63559. /**
  63560. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63561. */
  63562. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63563. private _onTextureLoadedObserver;
  63564. /**
  63565. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63566. */
  63567. onTextureLoaded: (texture: BaseTexture) => void;
  63568. /**
  63569. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63570. */
  63571. readonly onMaterialLoadedObservable: Observable<Material>;
  63572. private _onMaterialLoadedObserver;
  63573. /**
  63574. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63575. */
  63576. onMaterialLoaded: (material: Material) => void;
  63577. /**
  63578. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63579. */
  63580. readonly onCameraLoadedObservable: Observable<Camera>;
  63581. private _onCameraLoadedObserver;
  63582. /**
  63583. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63584. */
  63585. onCameraLoaded: (camera: Camera) => void;
  63586. /**
  63587. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63588. * For assets with LODs, raised when all of the LODs are complete.
  63589. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63590. */
  63591. readonly onCompleteObservable: Observable<void>;
  63592. private _onCompleteObserver;
  63593. /**
  63594. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63595. * For assets with LODs, raised when all of the LODs are complete.
  63596. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63597. */
  63598. onComplete: () => void;
  63599. /**
  63600. * Observable raised when an error occurs.
  63601. */
  63602. readonly onErrorObservable: Observable<any>;
  63603. private _onErrorObserver;
  63604. /**
  63605. * Callback raised when an error occurs.
  63606. */
  63607. onError: (reason: any) => void;
  63608. /**
  63609. * Observable raised after the loader is disposed.
  63610. */
  63611. readonly onDisposeObservable: Observable<void>;
  63612. private _onDisposeObserver;
  63613. /**
  63614. * Callback raised after the loader is disposed.
  63615. */
  63616. onDispose: () => void;
  63617. /**
  63618. * Observable raised after a loader extension is created.
  63619. * Set additional options for a loader extension in this event.
  63620. */
  63621. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63622. private _onExtensionLoadedObserver;
  63623. /**
  63624. * Callback raised after a loader extension is created.
  63625. */
  63626. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63627. /**
  63628. * Defines if the loader logging is enabled.
  63629. */
  63630. loggingEnabled: boolean;
  63631. /**
  63632. * Defines if the loader should capture performance counters.
  63633. */
  63634. capturePerformanceCounters: boolean;
  63635. /**
  63636. * Defines if the loader should validate the asset.
  63637. */
  63638. validate: boolean;
  63639. /**
  63640. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63641. */
  63642. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63643. private _onValidatedObserver;
  63644. /**
  63645. * Callback raised after a loader extension is created.
  63646. */
  63647. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63648. private _loader;
  63649. /**
  63650. * Name of the loader ("gltf")
  63651. */
  63652. name: string;
  63653. /**
  63654. * Supported file extensions of the loader (.gltf, .glb)
  63655. */
  63656. extensions: ISceneLoaderPluginExtensions;
  63657. /**
  63658. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63659. */
  63660. dispose(): void;
  63661. /** @hidden */
  63662. _clear(): void;
  63663. /**
  63664. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63665. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63666. * @param scene the scene the meshes should be added to
  63667. * @param data the glTF data to load
  63668. * @param rootUrl root url to load from
  63669. * @param onProgress event that fires when loading progress has occured
  63670. * @param fileName Defines the name of the file to load
  63671. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63672. */
  63673. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63674. meshes: AbstractMesh[];
  63675. particleSystems: IParticleSystem[];
  63676. skeletons: Skeleton[];
  63677. animationGroups: AnimationGroup[];
  63678. }>;
  63679. /**
  63680. * Imports all objects from the loaded glTF data and adds them to the scene
  63681. * @param scene the scene the objects should be added to
  63682. * @param data the glTF data to load
  63683. * @param rootUrl root url to load from
  63684. * @param onProgress event that fires when loading progress has occured
  63685. * @param fileName Defines the name of the file to load
  63686. * @returns a promise which completes when objects have been loaded to the scene
  63687. */
  63688. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63689. /**
  63690. * Load into an asset container.
  63691. * @param scene The scene to load into
  63692. * @param data The data to import
  63693. * @param rootUrl The root url for scene and resources
  63694. * @param onProgress The callback when the load progresses
  63695. * @param fileName Defines the name of the file to load
  63696. * @returns The loaded asset container
  63697. */
  63698. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63699. /**
  63700. * If the data string can be loaded directly.
  63701. * @param data string contianing the file data
  63702. * @returns if the data can be loaded directly
  63703. */
  63704. canDirectLoad(data: string): boolean;
  63705. /**
  63706. * Rewrites a url by combining a root url and response url.
  63707. */
  63708. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63709. /**
  63710. * Instantiates a glTF file loader plugin.
  63711. * @returns the created plugin
  63712. */
  63713. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63714. /**
  63715. * The loader state or null if the loader is not active.
  63716. */
  63717. readonly loaderState: Nullable<GLTFLoaderState>;
  63718. /**
  63719. * Returns a promise that resolves when the asset is completely loaded.
  63720. * @returns a promise that resolves when the asset is completely loaded.
  63721. */
  63722. whenCompleteAsync(): Promise<void>;
  63723. private _parseAsync;
  63724. private _validateAsync;
  63725. private _getLoader;
  63726. private _unpackBinary;
  63727. private _unpackBinaryV1;
  63728. private _unpackBinaryV2;
  63729. private static _parseVersion;
  63730. private static _compareVersion;
  63731. private static _decodeBufferToText;
  63732. private static readonly _logSpaces;
  63733. private _logIndentLevel;
  63734. private _loggingEnabled;
  63735. /** @hidden */
  63736. _log: (message: string) => void;
  63737. /** @hidden */
  63738. _logOpen(message: string): void;
  63739. /** @hidden */
  63740. _logClose(): void;
  63741. private _logEnabled;
  63742. private _logDisabled;
  63743. private _capturePerformanceCounters;
  63744. /** @hidden */
  63745. _startPerformanceCounter: (counterName: string) => void;
  63746. /** @hidden */
  63747. _endPerformanceCounter: (counterName: string) => void;
  63748. private _startPerformanceCounterEnabled;
  63749. private _startPerformanceCounterDisabled;
  63750. private _endPerformanceCounterEnabled;
  63751. private _endPerformanceCounterDisabled;
  63752. }
  63753. }
  63754. declare module BABYLON.GLTF1 {
  63755. /**
  63756. * Enums
  63757. * @hidden
  63758. */
  63759. export enum EComponentType {
  63760. BYTE = 5120,
  63761. UNSIGNED_BYTE = 5121,
  63762. SHORT = 5122,
  63763. UNSIGNED_SHORT = 5123,
  63764. FLOAT = 5126
  63765. }
  63766. /** @hidden */
  63767. export enum EShaderType {
  63768. FRAGMENT = 35632,
  63769. VERTEX = 35633
  63770. }
  63771. /** @hidden */
  63772. export enum EParameterType {
  63773. BYTE = 5120,
  63774. UNSIGNED_BYTE = 5121,
  63775. SHORT = 5122,
  63776. UNSIGNED_SHORT = 5123,
  63777. INT = 5124,
  63778. UNSIGNED_INT = 5125,
  63779. FLOAT = 5126,
  63780. FLOAT_VEC2 = 35664,
  63781. FLOAT_VEC3 = 35665,
  63782. FLOAT_VEC4 = 35666,
  63783. INT_VEC2 = 35667,
  63784. INT_VEC3 = 35668,
  63785. INT_VEC4 = 35669,
  63786. BOOL = 35670,
  63787. BOOL_VEC2 = 35671,
  63788. BOOL_VEC3 = 35672,
  63789. BOOL_VEC4 = 35673,
  63790. FLOAT_MAT2 = 35674,
  63791. FLOAT_MAT3 = 35675,
  63792. FLOAT_MAT4 = 35676,
  63793. SAMPLER_2D = 35678
  63794. }
  63795. /** @hidden */
  63796. export enum ETextureWrapMode {
  63797. CLAMP_TO_EDGE = 33071,
  63798. MIRRORED_REPEAT = 33648,
  63799. REPEAT = 10497
  63800. }
  63801. /** @hidden */
  63802. export enum ETextureFilterType {
  63803. NEAREST = 9728,
  63804. LINEAR = 9728,
  63805. NEAREST_MIPMAP_NEAREST = 9984,
  63806. LINEAR_MIPMAP_NEAREST = 9985,
  63807. NEAREST_MIPMAP_LINEAR = 9986,
  63808. LINEAR_MIPMAP_LINEAR = 9987
  63809. }
  63810. /** @hidden */
  63811. export enum ETextureFormat {
  63812. ALPHA = 6406,
  63813. RGB = 6407,
  63814. RGBA = 6408,
  63815. LUMINANCE = 6409,
  63816. LUMINANCE_ALPHA = 6410
  63817. }
  63818. /** @hidden */
  63819. export enum ECullingType {
  63820. FRONT = 1028,
  63821. BACK = 1029,
  63822. FRONT_AND_BACK = 1032
  63823. }
  63824. /** @hidden */
  63825. export enum EBlendingFunction {
  63826. ZERO = 0,
  63827. ONE = 1,
  63828. SRC_COLOR = 768,
  63829. ONE_MINUS_SRC_COLOR = 769,
  63830. DST_COLOR = 774,
  63831. ONE_MINUS_DST_COLOR = 775,
  63832. SRC_ALPHA = 770,
  63833. ONE_MINUS_SRC_ALPHA = 771,
  63834. DST_ALPHA = 772,
  63835. ONE_MINUS_DST_ALPHA = 773,
  63836. CONSTANT_COLOR = 32769,
  63837. ONE_MINUS_CONSTANT_COLOR = 32770,
  63838. CONSTANT_ALPHA = 32771,
  63839. ONE_MINUS_CONSTANT_ALPHA = 32772,
  63840. SRC_ALPHA_SATURATE = 776
  63841. }
  63842. /** @hidden */
  63843. export interface IGLTFProperty {
  63844. extensions?: {
  63845. [key: string]: any;
  63846. };
  63847. extras?: Object;
  63848. }
  63849. /** @hidden */
  63850. export interface IGLTFChildRootProperty extends IGLTFProperty {
  63851. name?: string;
  63852. }
  63853. /** @hidden */
  63854. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  63855. bufferView: string;
  63856. byteOffset: number;
  63857. byteStride: number;
  63858. count: number;
  63859. type: string;
  63860. componentType: EComponentType;
  63861. max?: number[];
  63862. min?: number[];
  63863. name?: string;
  63864. }
  63865. /** @hidden */
  63866. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  63867. buffer: string;
  63868. byteOffset: number;
  63869. byteLength: number;
  63870. byteStride: number;
  63871. target?: number;
  63872. }
  63873. /** @hidden */
  63874. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63875. uri: string;
  63876. byteLength?: number;
  63877. type?: string;
  63878. }
  63879. /** @hidden */
  63880. export interface IGLTFShader extends IGLTFChildRootProperty {
  63881. uri: string;
  63882. type: EShaderType;
  63883. }
  63884. /** @hidden */
  63885. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63886. attributes: string[];
  63887. fragmentShader: string;
  63888. vertexShader: string;
  63889. }
  63890. /** @hidden */
  63891. export interface IGLTFTechniqueParameter {
  63892. type: number;
  63893. count?: number;
  63894. semantic?: string;
  63895. node?: string;
  63896. value?: number | boolean | string | Array<any>;
  63897. source?: string;
  63898. babylonValue?: any;
  63899. }
  63900. /** @hidden */
  63901. export interface IGLTFTechniqueCommonProfile {
  63902. lightingModel: string;
  63903. texcoordBindings: Object;
  63904. parameters?: Array<any>;
  63905. }
  63906. /** @hidden */
  63907. export interface IGLTFTechniqueStatesFunctions {
  63908. blendColor?: number[];
  63909. blendEquationSeparate?: number[];
  63910. blendFuncSeparate?: number[];
  63911. colorMask: boolean[];
  63912. cullFace: number[];
  63913. }
  63914. /** @hidden */
  63915. export interface IGLTFTechniqueStates {
  63916. enable: number[];
  63917. functions: IGLTFTechniqueStatesFunctions;
  63918. }
  63919. /** @hidden */
  63920. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63921. parameters: {
  63922. [key: string]: IGLTFTechniqueParameter;
  63923. };
  63924. program: string;
  63925. attributes: {
  63926. [key: string]: string;
  63927. };
  63928. uniforms: {
  63929. [key: string]: string;
  63930. };
  63931. states: IGLTFTechniqueStates;
  63932. }
  63933. /** @hidden */
  63934. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63935. technique?: string;
  63936. values: string[];
  63937. }
  63938. /** @hidden */
  63939. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63940. attributes: {
  63941. [key: string]: string;
  63942. };
  63943. indices: string;
  63944. material: string;
  63945. mode?: number;
  63946. }
  63947. /** @hidden */
  63948. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63949. primitives: IGLTFMeshPrimitive[];
  63950. }
  63951. /** @hidden */
  63952. export interface IGLTFImage extends IGLTFChildRootProperty {
  63953. uri: string;
  63954. }
  63955. /** @hidden */
  63956. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63957. magFilter?: number;
  63958. minFilter?: number;
  63959. wrapS?: number;
  63960. wrapT?: number;
  63961. }
  63962. /** @hidden */
  63963. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63964. sampler: string;
  63965. source: string;
  63966. format?: ETextureFormat;
  63967. internalFormat?: ETextureFormat;
  63968. target?: number;
  63969. type?: number;
  63970. babylonTexture?: Texture;
  63971. }
  63972. /** @hidden */
  63973. export interface IGLTFAmbienLight {
  63974. color?: number[];
  63975. }
  63976. /** @hidden */
  63977. export interface IGLTFDirectionalLight {
  63978. color?: number[];
  63979. }
  63980. /** @hidden */
  63981. export interface IGLTFPointLight {
  63982. color?: number[];
  63983. constantAttenuation?: number;
  63984. linearAttenuation?: number;
  63985. quadraticAttenuation?: number;
  63986. }
  63987. /** @hidden */
  63988. export interface IGLTFSpotLight {
  63989. color?: number[];
  63990. constantAttenuation?: number;
  63991. fallOfAngle?: number;
  63992. fallOffExponent?: number;
  63993. linearAttenuation?: number;
  63994. quadraticAttenuation?: number;
  63995. }
  63996. /** @hidden */
  63997. export interface IGLTFLight extends IGLTFChildRootProperty {
  63998. type: string;
  63999. }
  64000. /** @hidden */
  64001. export interface IGLTFCameraOrthographic {
  64002. xmag: number;
  64003. ymag: number;
  64004. zfar: number;
  64005. znear: number;
  64006. }
  64007. /** @hidden */
  64008. export interface IGLTFCameraPerspective {
  64009. aspectRatio: number;
  64010. yfov: number;
  64011. zfar: number;
  64012. znear: number;
  64013. }
  64014. /** @hidden */
  64015. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64016. type: string;
  64017. }
  64018. /** @hidden */
  64019. export interface IGLTFAnimationChannelTarget {
  64020. id: string;
  64021. path: string;
  64022. }
  64023. /** @hidden */
  64024. export interface IGLTFAnimationChannel {
  64025. sampler: string;
  64026. target: IGLTFAnimationChannelTarget;
  64027. }
  64028. /** @hidden */
  64029. export interface IGLTFAnimationSampler {
  64030. input: string;
  64031. output: string;
  64032. interpolation?: string;
  64033. }
  64034. /** @hidden */
  64035. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64036. channels?: IGLTFAnimationChannel[];
  64037. parameters?: {
  64038. [key: string]: string;
  64039. };
  64040. samplers?: {
  64041. [key: string]: IGLTFAnimationSampler;
  64042. };
  64043. }
  64044. /** @hidden */
  64045. export interface IGLTFNodeInstanceSkin {
  64046. skeletons: string[];
  64047. skin: string;
  64048. meshes: string[];
  64049. }
  64050. /** @hidden */
  64051. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64052. bindShapeMatrix: number[];
  64053. inverseBindMatrices: string;
  64054. jointNames: string[];
  64055. babylonSkeleton?: Skeleton;
  64056. }
  64057. /** @hidden */
  64058. export interface IGLTFNode extends IGLTFChildRootProperty {
  64059. camera?: string;
  64060. children: string[];
  64061. skin?: string;
  64062. jointName?: string;
  64063. light?: string;
  64064. matrix: number[];
  64065. mesh?: string;
  64066. meshes?: string[];
  64067. rotation?: number[];
  64068. scale?: number[];
  64069. translation?: number[];
  64070. babylonNode?: Node;
  64071. }
  64072. /** @hidden */
  64073. export interface IGLTFScene extends IGLTFChildRootProperty {
  64074. nodes: string[];
  64075. }
  64076. /** @hidden */
  64077. export interface IGLTFRuntime {
  64078. extensions: {
  64079. [key: string]: any;
  64080. };
  64081. accessors: {
  64082. [key: string]: IGLTFAccessor;
  64083. };
  64084. buffers: {
  64085. [key: string]: IGLTFBuffer;
  64086. };
  64087. bufferViews: {
  64088. [key: string]: IGLTFBufferView;
  64089. };
  64090. meshes: {
  64091. [key: string]: IGLTFMesh;
  64092. };
  64093. lights: {
  64094. [key: string]: IGLTFLight;
  64095. };
  64096. cameras: {
  64097. [key: string]: IGLTFCamera;
  64098. };
  64099. nodes: {
  64100. [key: string]: IGLTFNode;
  64101. };
  64102. images: {
  64103. [key: string]: IGLTFImage;
  64104. };
  64105. textures: {
  64106. [key: string]: IGLTFTexture;
  64107. };
  64108. shaders: {
  64109. [key: string]: IGLTFShader;
  64110. };
  64111. programs: {
  64112. [key: string]: IGLTFProgram;
  64113. };
  64114. samplers: {
  64115. [key: string]: IGLTFSampler;
  64116. };
  64117. techniques: {
  64118. [key: string]: IGLTFTechnique;
  64119. };
  64120. materials: {
  64121. [key: string]: IGLTFMaterial;
  64122. };
  64123. animations: {
  64124. [key: string]: IGLTFAnimation;
  64125. };
  64126. skins: {
  64127. [key: string]: IGLTFSkins;
  64128. };
  64129. currentScene?: Object;
  64130. scenes: {
  64131. [key: string]: IGLTFScene;
  64132. };
  64133. extensionsUsed: string[];
  64134. extensionsRequired?: string[];
  64135. buffersCount: number;
  64136. shaderscount: number;
  64137. scene: Scene;
  64138. rootUrl: string;
  64139. loadedBufferCount: number;
  64140. loadedBufferViews: {
  64141. [name: string]: ArrayBufferView;
  64142. };
  64143. loadedShaderCount: number;
  64144. importOnlyMeshes: boolean;
  64145. importMeshesNames?: string[];
  64146. dummyNodes: Node[];
  64147. }
  64148. /** @hidden */
  64149. export interface INodeToRoot {
  64150. bone: Bone;
  64151. node: IGLTFNode;
  64152. id: string;
  64153. }
  64154. /** @hidden */
  64155. export interface IJointNode {
  64156. node: IGLTFNode;
  64157. id: string;
  64158. }
  64159. }
  64160. declare module BABYLON.GLTF1 {
  64161. /**
  64162. * Utils functions for GLTF
  64163. * @hidden
  64164. */
  64165. export class GLTFUtils {
  64166. /**
  64167. * Sets the given "parameter" matrix
  64168. * @param scene: the Scene object
  64169. * @param source: the source node where to pick the matrix
  64170. * @param parameter: the GLTF technique parameter
  64171. * @param uniformName: the name of the shader's uniform
  64172. * @param shaderMaterial: the shader material
  64173. */
  64174. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64175. /**
  64176. * Sets the given "parameter" matrix
  64177. * @param shaderMaterial: the shader material
  64178. * @param uniform: the name of the shader's uniform
  64179. * @param value: the value of the uniform
  64180. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64181. */
  64182. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64183. /**
  64184. * Returns the wrap mode of the texture
  64185. * @param mode: the mode value
  64186. */
  64187. static GetWrapMode(mode: number): number;
  64188. /**
  64189. * Returns the byte stride giving an accessor
  64190. * @param accessor: the GLTF accessor objet
  64191. */
  64192. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64193. /**
  64194. * Returns the texture filter mode giving a mode value
  64195. * @param mode: the filter mode value
  64196. */
  64197. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64198. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64199. /**
  64200. * Returns a buffer from its accessor
  64201. * @param gltfRuntime: the GLTF runtime
  64202. * @param accessor: the GLTF accessor
  64203. */
  64204. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64205. /**
  64206. * Decodes a buffer view into a string
  64207. * @param view: the buffer view
  64208. */
  64209. static DecodeBufferToText(view: ArrayBufferView): string;
  64210. /**
  64211. * Returns the default material of gltf. Related to
  64212. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64213. * @param scene: the Babylon.js scene
  64214. */
  64215. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64216. private static _DefaultMaterial;
  64217. }
  64218. }
  64219. declare module BABYLON.GLTF1 {
  64220. /**
  64221. * Implementation of the base glTF spec
  64222. * @hidden
  64223. */
  64224. export class GLTFLoaderBase {
  64225. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64226. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64227. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64228. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64229. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64230. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64231. }
  64232. /**
  64233. * glTF V1 Loader
  64234. * @hidden
  64235. */
  64236. export class GLTFLoader implements IGLTFLoader {
  64237. static Extensions: {
  64238. [name: string]: GLTFLoaderExtension;
  64239. };
  64240. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64241. state: Nullable<GLTFLoaderState>;
  64242. dispose(): void;
  64243. private _importMeshAsync;
  64244. /**
  64245. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64246. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64247. * @param scene the scene the meshes should be added to
  64248. * @param data gltf data containing information of the meshes in a loaded file
  64249. * @param rootUrl root url to load from
  64250. * @param onProgress event that fires when loading progress has occured
  64251. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64252. */
  64253. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64254. meshes: AbstractMesh[];
  64255. particleSystems: IParticleSystem[];
  64256. skeletons: Skeleton[];
  64257. animationGroups: AnimationGroup[];
  64258. }>;
  64259. private _loadAsync;
  64260. /**
  64261. * Imports all objects from a loaded gltf file and adds them to the scene
  64262. * @param scene the scene the objects should be added to
  64263. * @param data gltf data containing information of the meshes in a loaded file
  64264. * @param rootUrl root url to load from
  64265. * @param onProgress event that fires when loading progress has occured
  64266. * @returns a promise which completes when objects have been loaded to the scene
  64267. */
  64268. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64269. private _loadShadersAsync;
  64270. private _loadBuffersAsync;
  64271. private _createNodes;
  64272. }
  64273. /** @hidden */
  64274. export abstract class GLTFLoaderExtension {
  64275. private _name;
  64276. constructor(name: string);
  64277. readonly name: string;
  64278. /**
  64279. * Defines an override for loading the runtime
  64280. * Return true to stop further extensions from loading the runtime
  64281. */
  64282. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64283. /**
  64284. * Defines an onverride for creating gltf runtime
  64285. * Return true to stop further extensions from creating the runtime
  64286. */
  64287. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64288. /**
  64289. * Defines an override for loading buffers
  64290. * Return true to stop further extensions from loading this buffer
  64291. */
  64292. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64293. /**
  64294. * Defines an override for loading texture buffers
  64295. * Return true to stop further extensions from loading this texture data
  64296. */
  64297. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64298. /**
  64299. * Defines an override for creating textures
  64300. * Return true to stop further extensions from loading this texture
  64301. */
  64302. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64303. /**
  64304. * Defines an override for loading shader strings
  64305. * Return true to stop further extensions from loading this shader data
  64306. */
  64307. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64308. /**
  64309. * Defines an override for loading materials
  64310. * Return true to stop further extensions from loading this material
  64311. */
  64312. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64313. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64314. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64315. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64316. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64317. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64318. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64319. private static LoadTextureBufferAsync;
  64320. private static CreateTextureAsync;
  64321. private static ApplyExtensions;
  64322. }
  64323. }
  64324. declare module BABYLON.GLTF1 {
  64325. /** @hidden */
  64326. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64327. private _bin;
  64328. constructor();
  64329. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64330. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64331. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64332. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64333. }
  64334. }
  64335. declare module BABYLON.GLTF1 {
  64336. /** @hidden */
  64337. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64338. constructor();
  64339. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64340. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64341. private _loadTexture;
  64342. }
  64343. }
  64344. declare module BABYLON.GLTF2.Loader {
  64345. /**
  64346. * Loader interface with an index field.
  64347. */
  64348. export interface IArrayItem {
  64349. /**
  64350. * The index of this item in the array.
  64351. */
  64352. index: number;
  64353. }
  64354. /**
  64355. * Loader interface with additional members.
  64356. */
  64357. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64358. /** @hidden */
  64359. _data?: Promise<ArrayBufferView>;
  64360. /** @hidden */
  64361. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64362. }
  64363. /**
  64364. * Loader interface with additional members.
  64365. */
  64366. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64367. }
  64368. /** @hidden */
  64369. export interface _IAnimationSamplerData {
  64370. input: Float32Array;
  64371. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64372. output: Float32Array;
  64373. }
  64374. /**
  64375. * Loader interface with additional members.
  64376. */
  64377. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64378. /** @hidden */
  64379. _data?: Promise<_IAnimationSamplerData>;
  64380. }
  64381. /**
  64382. * Loader interface with additional members.
  64383. */
  64384. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64385. channels: IAnimationChannel[];
  64386. samplers: IAnimationSampler[];
  64387. /** @hidden */
  64388. _babylonAnimationGroup?: AnimationGroup;
  64389. }
  64390. /**
  64391. * Loader interface with additional members.
  64392. */
  64393. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64394. /** @hidden */
  64395. _data?: Promise<ArrayBufferView>;
  64396. }
  64397. /**
  64398. * Loader interface with additional members.
  64399. */
  64400. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64401. /** @hidden */
  64402. _data?: Promise<ArrayBufferView>;
  64403. /** @hidden */
  64404. _babylonBuffer?: Promise<Buffer>;
  64405. }
  64406. /**
  64407. * Loader interface with additional members.
  64408. */
  64409. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64410. }
  64411. /**
  64412. * Loader interface with additional members.
  64413. */
  64414. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64415. /** @hidden */
  64416. _data?: Promise<ArrayBufferView>;
  64417. }
  64418. /**
  64419. * Loader interface with additional members.
  64420. */
  64421. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64422. }
  64423. /**
  64424. * Loader interface with additional members.
  64425. */
  64426. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64427. }
  64428. /**
  64429. * Loader interface with additional members.
  64430. */
  64431. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64432. baseColorTexture?: ITextureInfo;
  64433. metallicRoughnessTexture?: ITextureInfo;
  64434. }
  64435. /**
  64436. * Loader interface with additional members.
  64437. */
  64438. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64439. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64440. normalTexture?: IMaterialNormalTextureInfo;
  64441. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64442. emissiveTexture?: ITextureInfo;
  64443. /** @hidden */
  64444. _data?: {
  64445. [babylonDrawMode: number]: {
  64446. babylonMaterial: Material;
  64447. babylonMeshes: AbstractMesh[];
  64448. promise: Promise<void>;
  64449. };
  64450. };
  64451. }
  64452. /**
  64453. * Loader interface with additional members.
  64454. */
  64455. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64456. primitives: IMeshPrimitive[];
  64457. }
  64458. /**
  64459. * Loader interface with additional members.
  64460. */
  64461. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64462. /** @hidden */
  64463. _instanceData?: {
  64464. babylonSourceMesh: Mesh;
  64465. promise: Promise<any>;
  64466. };
  64467. }
  64468. /**
  64469. * Loader interface with additional members.
  64470. */
  64471. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64472. /**
  64473. * The parent glTF node.
  64474. */
  64475. parent?: INode;
  64476. /** @hidden */
  64477. _babylonTransformNode?: TransformNode;
  64478. /** @hidden */
  64479. _primitiveBabylonMeshes?: AbstractMesh[];
  64480. /** @hidden */
  64481. _babylonBones?: Bone[];
  64482. /** @hidden */
  64483. _numMorphTargets?: number;
  64484. }
  64485. /** @hidden */
  64486. export interface _ISamplerData {
  64487. noMipMaps: boolean;
  64488. samplingMode: number;
  64489. wrapU: number;
  64490. wrapV: number;
  64491. }
  64492. /**
  64493. * Loader interface with additional members.
  64494. */
  64495. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64496. /** @hidden */
  64497. _data?: _ISamplerData;
  64498. }
  64499. /**
  64500. * Loader interface with additional members.
  64501. */
  64502. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64503. }
  64504. /**
  64505. * Loader interface with additional members.
  64506. */
  64507. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64508. /** @hidden */
  64509. _data?: {
  64510. babylonSkeleton: Skeleton;
  64511. promise: Promise<void>;
  64512. };
  64513. }
  64514. /**
  64515. * Loader interface with additional members.
  64516. */
  64517. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64518. }
  64519. /**
  64520. * Loader interface with additional members.
  64521. */
  64522. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64523. }
  64524. /**
  64525. * Loader interface with additional members.
  64526. */
  64527. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64528. accessors?: IAccessor[];
  64529. animations?: IAnimation[];
  64530. buffers?: IBuffer[];
  64531. bufferViews?: IBufferView[];
  64532. cameras?: ICamera[];
  64533. images?: IImage[];
  64534. materials?: IMaterial[];
  64535. meshes?: IMesh[];
  64536. nodes?: INode[];
  64537. samplers?: ISampler[];
  64538. scenes?: IScene[];
  64539. skins?: ISkin[];
  64540. textures?: ITexture[];
  64541. }
  64542. }
  64543. declare module BABYLON.GLTF2 {
  64544. /**
  64545. * Interface for a glTF loader extension.
  64546. */
  64547. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64548. /**
  64549. * Called after the loader state changes to LOADING.
  64550. */
  64551. onLoading?(): void;
  64552. /**
  64553. * Called after the loader state changes to READY.
  64554. */
  64555. onReady?(): void;
  64556. /**
  64557. * Define this method to modify the default behavior when loading scenes.
  64558. * @param context The context when loading the asset
  64559. * @param scene The glTF scene property
  64560. * @returns A promise that resolves when the load is complete or null if not handled
  64561. */
  64562. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64563. /**
  64564. * Define this method to modify the default behavior when loading nodes.
  64565. * @param context The context when loading the asset
  64566. * @param node The glTF node property
  64567. * @param assign A function called synchronously after parsing the glTF properties
  64568. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64569. */
  64570. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64571. /**
  64572. * Define this method to modify the default behavior when loading cameras.
  64573. * @param context The context when loading the asset
  64574. * @param camera The glTF camera property
  64575. * @param assign A function called synchronously after parsing the glTF properties
  64576. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64577. */
  64578. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64579. /**
  64580. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64581. * @param context The context when loading the asset
  64582. * @param primitive The glTF mesh primitive property
  64583. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64584. */
  64585. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64586. /**
  64587. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64588. * @param context The context when loading the asset
  64589. * @param name The mesh name when loading the asset
  64590. * @param node The glTF node when loading the asset
  64591. * @param mesh The glTF mesh when loading the asset
  64592. * @param primitive The glTF mesh primitive property
  64593. * @param assign A function called synchronously after parsing the glTF properties
  64594. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64595. */
  64596. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64597. /**
  64598. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64599. * @param context The context when loading the asset
  64600. * @param material The glTF material property
  64601. * @param assign A function called synchronously after parsing the glTF properties
  64602. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64603. */
  64604. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64605. /**
  64606. * Define this method to modify the default behavior when creating materials.
  64607. * @param context The context when loading the asset
  64608. * @param material The glTF material property
  64609. * @param babylonDrawMode The draw mode for the Babylon material
  64610. * @returns The Babylon material or null if not handled
  64611. */
  64612. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64613. /**
  64614. * Define this method to modify the default behavior when loading material properties.
  64615. * @param context The context when loading the asset
  64616. * @param material The glTF material property
  64617. * @param babylonMaterial The Babylon material
  64618. * @returns A promise that resolves when the load is complete or null if not handled
  64619. */
  64620. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64621. /**
  64622. * Define this method to modify the default behavior when loading texture infos.
  64623. * @param context The context when loading the asset
  64624. * @param textureInfo The glTF texture info property
  64625. * @param assign A function called synchronously after parsing the glTF properties
  64626. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64627. */
  64628. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64629. /**
  64630. * Define this method to modify the default behavior when loading animations.
  64631. * @param context The context when loading the asset
  64632. * @param animation The glTF animation property
  64633. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64634. */
  64635. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64636. /**
  64637. * @hidden Define this method to modify the default behavior when loading skins.
  64638. * @param context The context when loading the asset
  64639. * @param node The glTF node property
  64640. * @param skin The glTF skin property
  64641. * @returns A promise that resolves when the load is complete or null if not handled
  64642. */
  64643. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64644. /**
  64645. * @hidden Define this method to modify the default behavior when loading uris.
  64646. * @param context The context when loading the asset
  64647. * @param property The glTF property associated with the uri
  64648. * @param uri The uri to load
  64649. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64650. */
  64651. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64652. }
  64653. }
  64654. declare module BABYLON.GLTF2 {
  64655. /**
  64656. * Helper class for working with arrays when loading the glTF asset
  64657. */
  64658. export class ArrayItem {
  64659. /**
  64660. * Gets an item from the given array.
  64661. * @param context The context when loading the asset
  64662. * @param array The array to get the item from
  64663. * @param index The index to the array
  64664. * @returns The array item
  64665. */
  64666. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64667. /**
  64668. * Assign an `index` field to each item of the given array.
  64669. * @param array The array of items
  64670. */
  64671. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64672. }
  64673. /**
  64674. * The glTF 2.0 loader
  64675. */
  64676. export class GLTFLoader implements IGLTFLoader {
  64677. /** @hidden */
  64678. _completePromises: Promise<any>[];
  64679. private _disposed;
  64680. private _parent;
  64681. private _state;
  64682. private _extensions;
  64683. private _rootUrl;
  64684. private _fileName;
  64685. private _uniqueRootUrl;
  64686. private _gltf;
  64687. private _babylonScene;
  64688. private _rootBabylonMesh;
  64689. private _defaultBabylonMaterialData;
  64690. private _progressCallback?;
  64691. private _requests;
  64692. private static readonly _DefaultSampler;
  64693. private static _ExtensionNames;
  64694. private static _ExtensionFactories;
  64695. /**
  64696. * Registers a loader extension.
  64697. * @param name The name of the loader extension.
  64698. * @param factory The factory function that creates the loader extension.
  64699. */
  64700. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64701. /**
  64702. * Unregisters a loader extension.
  64703. * @param name The name of the loader extenion.
  64704. * @returns A boolean indicating whether the extension has been unregistered
  64705. */
  64706. static UnregisterExtension(name: string): boolean;
  64707. /**
  64708. * Gets the loader state.
  64709. */
  64710. readonly state: Nullable<GLTFLoaderState>;
  64711. /**
  64712. * The glTF object parsed from the JSON.
  64713. */
  64714. readonly gltf: IGLTF;
  64715. /**
  64716. * The Babylon scene when loading the asset.
  64717. */
  64718. readonly babylonScene: Scene;
  64719. /**
  64720. * The root Babylon mesh when loading the asset.
  64721. */
  64722. readonly rootBabylonMesh: Mesh;
  64723. /** @hidden */
  64724. constructor(parent: GLTFFileLoader);
  64725. /** @hidden */
  64726. dispose(): void;
  64727. /** @hidden */
  64728. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64729. meshes: AbstractMesh[];
  64730. particleSystems: IParticleSystem[];
  64731. skeletons: Skeleton[];
  64732. animationGroups: AnimationGroup[];
  64733. }>;
  64734. /** @hidden */
  64735. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64736. private _loadAsync;
  64737. private _loadData;
  64738. private _setupData;
  64739. private _loadExtensions;
  64740. private _checkExtensions;
  64741. private _setState;
  64742. private _createRootNode;
  64743. /**
  64744. * Loads a glTF scene.
  64745. * @param context The context when loading the asset
  64746. * @param scene The glTF scene property
  64747. * @returns A promise that resolves when the load is complete
  64748. */
  64749. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64750. private _forEachPrimitive;
  64751. private _getMeshes;
  64752. private _getSkeletons;
  64753. private _getAnimationGroups;
  64754. private _startAnimations;
  64755. /**
  64756. * Loads a glTF node.
  64757. * @param context The context when loading the asset
  64758. * @param node The glTF node property
  64759. * @param assign A function called synchronously after parsing the glTF properties
  64760. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  64761. */
  64762. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  64763. private _loadMeshAsync;
  64764. /**
  64765. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64766. * @param context The context when loading the asset
  64767. * @param name The mesh name when loading the asset
  64768. * @param node The glTF node when loading the asset
  64769. * @param mesh The glTF mesh when loading the asset
  64770. * @param primitive The glTF mesh primitive property
  64771. * @param assign A function called synchronously after parsing the glTF properties
  64772. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64773. */
  64774. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64775. private _loadVertexDataAsync;
  64776. private _createMorphTargets;
  64777. private _loadMorphTargetsAsync;
  64778. private _loadMorphTargetVertexDataAsync;
  64779. private static _LoadTransform;
  64780. private _loadSkinAsync;
  64781. private _loadBones;
  64782. private _loadBone;
  64783. private _loadSkinInverseBindMatricesDataAsync;
  64784. private _updateBoneMatrices;
  64785. private _getNodeMatrix;
  64786. /**
  64787. * Loads a glTF camera.
  64788. * @param context The context when loading the asset
  64789. * @param camera The glTF camera property
  64790. * @param assign A function called synchronously after parsing the glTF properties
  64791. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  64792. */
  64793. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  64794. private _loadAnimationsAsync;
  64795. /**
  64796. * Loads a glTF animation.
  64797. * @param context The context when loading the asset
  64798. * @param animation The glTF animation property
  64799. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  64800. */
  64801. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  64802. /**
  64803. * @hidden Loads a glTF animation channel.
  64804. * @param context The context when loading the asset
  64805. * @param animationContext The context of the animation when loading the asset
  64806. * @param animation The glTF animation property
  64807. * @param channel The glTF animation channel property
  64808. * @param babylonAnimationGroup The babylon animation group property
  64809. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  64810. * @returns A void promise when the channel load is complete
  64811. */
  64812. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  64813. private _loadAnimationSamplerAsync;
  64814. private _loadBufferAsync;
  64815. /**
  64816. * Loads a glTF buffer view.
  64817. * @param context The context when loading the asset
  64818. * @param bufferView The glTF buffer view property
  64819. * @returns A promise that resolves with the loaded data when the load is complete
  64820. */
  64821. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  64822. private _loadIndicesAccessorAsync;
  64823. private _loadFloatAccessorAsync;
  64824. private _loadVertexBufferViewAsync;
  64825. private _loadVertexAccessorAsync;
  64826. private _loadMaterialMetallicRoughnessPropertiesAsync;
  64827. /** @hidden */
  64828. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  64829. private _createDefaultMaterial;
  64830. /**
  64831. * Creates a Babylon material from a glTF material.
  64832. * @param context The context when loading the asset
  64833. * @param material The glTF material property
  64834. * @param babylonDrawMode The draw mode for the Babylon material
  64835. * @returns The Babylon material
  64836. */
  64837. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  64838. /**
  64839. * Loads properties from a glTF material into a Babylon material.
  64840. * @param context The context when loading the asset
  64841. * @param material The glTF material property
  64842. * @param babylonMaterial The Babylon material
  64843. * @returns A promise that resolves when the load is complete
  64844. */
  64845. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64846. /**
  64847. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  64848. * @param context The context when loading the asset
  64849. * @param material The glTF material property
  64850. * @param babylonMaterial The Babylon material
  64851. * @returns A promise that resolves when the load is complete
  64852. */
  64853. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  64854. /**
  64855. * Loads the alpha properties from a glTF material into a Babylon material.
  64856. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  64857. * @param context The context when loading the asset
  64858. * @param material The glTF material property
  64859. * @param babylonMaterial The Babylon material
  64860. */
  64861. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  64862. /**
  64863. * Loads a glTF texture info.
  64864. * @param context The context when loading the asset
  64865. * @param textureInfo The glTF texture info property
  64866. * @param assign A function called synchronously after parsing the glTF properties
  64867. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  64868. */
  64869. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  64870. private _loadTextureAsync;
  64871. private _loadSampler;
  64872. /**
  64873. * Loads a glTF image.
  64874. * @param context The context when loading the asset
  64875. * @param image The glTF image property
  64876. * @returns A promise that resolves with the loaded data when the load is complete
  64877. */
  64878. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64879. /**
  64880. * Loads a glTF uri.
  64881. * @param context The context when loading the asset
  64882. * @param property The glTF property associated with the uri
  64883. * @param uri The base64 or relative uri
  64884. * @returns A promise that resolves with the loaded data when the load is complete
  64885. */
  64886. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64887. private _onProgress;
  64888. /**
  64889. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64890. * @param babylonObject the Babylon object with metadata
  64891. * @param pointer the JSON pointer
  64892. */
  64893. static AddPointerMetadata(babylonObject: {
  64894. metadata: any;
  64895. }, pointer: string): void;
  64896. private static _GetTextureWrapMode;
  64897. private static _GetTextureSamplingMode;
  64898. private static _GetTypedArray;
  64899. private static _GetNumComponents;
  64900. private static _ValidateUri;
  64901. private static _GetDrawMode;
  64902. private _compileMaterialsAsync;
  64903. private _compileShadowGeneratorsAsync;
  64904. private _forEachExtensions;
  64905. private _applyExtensions;
  64906. private _extensionsOnLoading;
  64907. private _extensionsOnReady;
  64908. private _extensionsLoadSceneAsync;
  64909. private _extensionsLoadNodeAsync;
  64910. private _extensionsLoadCameraAsync;
  64911. private _extensionsLoadVertexDataAsync;
  64912. private _extensionsLoadMeshPrimitiveAsync;
  64913. private _extensionsLoadMaterialAsync;
  64914. private _extensionsCreateMaterial;
  64915. private _extensionsLoadMaterialPropertiesAsync;
  64916. private _extensionsLoadTextureInfoAsync;
  64917. private _extensionsLoadAnimationAsync;
  64918. private _extensionsLoadSkinAsync;
  64919. private _extensionsLoadUriAsync;
  64920. /**
  64921. * Helper method called by a loader extension to load an glTF extension.
  64922. * @param context The context when loading the asset
  64923. * @param property The glTF property to load the extension from
  64924. * @param extensionName The name of the extension to load
  64925. * @param actionAsync The action to run
  64926. * @returns The promise returned by actionAsync or null if the extension does not exist
  64927. */
  64928. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64929. /**
  64930. * Helper method called by a loader extension to load a glTF extra.
  64931. * @param context The context when loading the asset
  64932. * @param property The glTF property to load the extra from
  64933. * @param extensionName The name of the extension to load
  64934. * @param actionAsync The action to run
  64935. * @returns The promise returned by actionAsync or null if the extra does not exist
  64936. */
  64937. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64938. /**
  64939. * Increments the indentation level and logs a message.
  64940. * @param message The message to log
  64941. */
  64942. logOpen(message: string): void;
  64943. /**
  64944. * Decrements the indentation level.
  64945. */
  64946. logClose(): void;
  64947. /**
  64948. * Logs a message
  64949. * @param message The message to log
  64950. */
  64951. log(message: string): void;
  64952. /**
  64953. * Starts a performance counter.
  64954. * @param counterName The name of the performance counter
  64955. */
  64956. startPerformanceCounter(counterName: string): void;
  64957. /**
  64958. * Ends a performance counter.
  64959. * @param counterName The name of the performance counter
  64960. */
  64961. endPerformanceCounter(counterName: string): void;
  64962. }
  64963. }
  64964. declare module BABYLON.GLTF2.Loader.Extensions {
  64965. /**
  64966. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64967. */
  64968. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64969. /** The name of this extension. */
  64970. readonly name: string;
  64971. /** Defines whether this extension is enabled. */
  64972. enabled: boolean;
  64973. private _loader;
  64974. private _lights?;
  64975. /** @hidden */
  64976. constructor(loader: GLTFLoader);
  64977. /** @hidden */
  64978. dispose(): void;
  64979. /** @hidden */
  64980. onLoading(): void;
  64981. /** @hidden */
  64982. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64983. private _loadLightAsync;
  64984. }
  64985. }
  64986. declare module BABYLON.GLTF2.Loader.Extensions {
  64987. /**
  64988. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64989. */
  64990. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64991. /** The name of this extension. */
  64992. readonly name: string;
  64993. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64994. dracoCompression?: DracoCompression;
  64995. /** Defines whether this extension is enabled. */
  64996. enabled: boolean;
  64997. private _loader;
  64998. /** @hidden */
  64999. constructor(loader: GLTFLoader);
  65000. /** @hidden */
  65001. dispose(): void;
  65002. /** @hidden */
  65003. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65004. }
  65005. }
  65006. declare module BABYLON.GLTF2.Loader.Extensions {
  65007. /**
  65008. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65009. */
  65010. export class KHR_lights implements IGLTFLoaderExtension {
  65011. /** The name of this extension. */
  65012. readonly name: string;
  65013. /** Defines whether this extension is enabled. */
  65014. enabled: boolean;
  65015. private _loader;
  65016. private _lights?;
  65017. /** @hidden */
  65018. constructor(loader: GLTFLoader);
  65019. /** @hidden */
  65020. dispose(): void;
  65021. /** @hidden */
  65022. onLoading(): void;
  65023. /** @hidden */
  65024. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65025. }
  65026. }
  65027. declare module BABYLON.GLTF2.Loader.Extensions {
  65028. /**
  65029. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65030. */
  65031. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65032. /** The name of this extension. */
  65033. readonly name: string;
  65034. /** Defines whether this extension is enabled. */
  65035. enabled: boolean;
  65036. private _loader;
  65037. /** @hidden */
  65038. constructor(loader: GLTFLoader);
  65039. /** @hidden */
  65040. dispose(): void;
  65041. /** @hidden */
  65042. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65043. private _loadSpecularGlossinessPropertiesAsync;
  65044. }
  65045. }
  65046. declare module BABYLON.GLTF2.Loader.Extensions {
  65047. /**
  65048. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65049. */
  65050. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65051. /** The name of this extension. */
  65052. readonly name: string;
  65053. /** Defines whether this extension is enabled. */
  65054. enabled: boolean;
  65055. private _loader;
  65056. /** @hidden */
  65057. constructor(loader: GLTFLoader);
  65058. /** @hidden */
  65059. dispose(): void;
  65060. /** @hidden */
  65061. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65062. private _loadUnlitPropertiesAsync;
  65063. }
  65064. }
  65065. declare module BABYLON.GLTF2.Loader.Extensions {
  65066. /**
  65067. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65068. */
  65069. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65070. /** The name of this extension. */
  65071. readonly name: string;
  65072. /** Defines whether this extension is enabled. */
  65073. enabled: boolean;
  65074. private _loader;
  65075. /** @hidden */
  65076. constructor(loader: GLTFLoader);
  65077. /** @hidden */
  65078. dispose(): void;
  65079. /** @hidden */
  65080. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65081. }
  65082. }
  65083. declare module BABYLON.GLTF2.Loader.Extensions {
  65084. /**
  65085. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65086. */
  65087. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65088. /** The name of this extension. */
  65089. readonly name: string;
  65090. /** Defines whether this extension is enabled. */
  65091. enabled: boolean;
  65092. private _loader;
  65093. private _clips;
  65094. private _emitters;
  65095. /** @hidden */
  65096. constructor(loader: GLTFLoader);
  65097. /** @hidden */
  65098. dispose(): void;
  65099. /** @hidden */
  65100. onLoading(): void;
  65101. /** @hidden */
  65102. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65103. /** @hidden */
  65104. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65105. /** @hidden */
  65106. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65107. private _loadClipAsync;
  65108. private _loadEmitterAsync;
  65109. private _getEventAction;
  65110. private _loadAnimationEventAsync;
  65111. }
  65112. }
  65113. declare module BABYLON.GLTF2.Loader.Extensions {
  65114. /**
  65115. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65116. */
  65117. export class MSFT_lod implements IGLTFLoaderExtension {
  65118. /** The name of this extension. */
  65119. readonly name: string;
  65120. /** Defines whether this extension is enabled. */
  65121. enabled: boolean;
  65122. /**
  65123. * Maximum number of LODs to load, starting from the lowest LOD.
  65124. */
  65125. maxLODsToLoad: number;
  65126. /**
  65127. * Observable raised when all node LODs of one level are loaded.
  65128. * The event data is the index of the loaded LOD starting from zero.
  65129. * Dispose the loader to cancel the loading of the next level of LODs.
  65130. */
  65131. onNodeLODsLoadedObservable: Observable<number>;
  65132. /**
  65133. * Observable raised when all material LODs of one level are loaded.
  65134. * The event data is the index of the loaded LOD starting from zero.
  65135. * Dispose the loader to cancel the loading of the next level of LODs.
  65136. */
  65137. onMaterialLODsLoadedObservable: Observable<number>;
  65138. private _loader;
  65139. private _nodeIndexLOD;
  65140. private _nodeSignalLODs;
  65141. private _nodePromiseLODs;
  65142. private _materialIndexLOD;
  65143. private _materialSignalLODs;
  65144. private _materialPromiseLODs;
  65145. /** @hidden */
  65146. constructor(loader: GLTFLoader);
  65147. /** @hidden */
  65148. dispose(): void;
  65149. /** @hidden */
  65150. onReady(): void;
  65151. /** @hidden */
  65152. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65153. /** @hidden */
  65154. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65155. /** @hidden */
  65156. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65157. /**
  65158. * Gets an array of LOD properties from lowest to highest.
  65159. */
  65160. private _getLODs;
  65161. private _disposeUnusedMaterials;
  65162. }
  65163. }
  65164. declare module BABYLON.GLTF2.Loader.Extensions {
  65165. /** @hidden */
  65166. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65167. readonly name: string;
  65168. enabled: boolean;
  65169. private _loader;
  65170. constructor(loader: GLTFLoader);
  65171. dispose(): void;
  65172. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65173. }
  65174. }
  65175. declare module BABYLON.GLTF2.Loader.Extensions {
  65176. /** @hidden */
  65177. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65178. readonly name: string;
  65179. enabled: boolean;
  65180. private _loader;
  65181. constructor(loader: GLTFLoader);
  65182. dispose(): void;
  65183. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /**
  65188. * Class reading and parsing the MTL file bundled with the obj file.
  65189. */
  65190. export class MTLFileLoader {
  65191. /**
  65192. * All material loaded from the mtl will be set here
  65193. */
  65194. materials: StandardMaterial[];
  65195. /**
  65196. * This function will read the mtl file and create each material described inside
  65197. * This function could be improve by adding :
  65198. * -some component missing (Ni, Tf...)
  65199. * -including the specific options available
  65200. *
  65201. * @param scene defines the scene the material will be created in
  65202. * @param data defines the mtl data to parse
  65203. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65204. */
  65205. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65206. /**
  65207. * Gets the texture for the material.
  65208. *
  65209. * If the material is imported from input file,
  65210. * We sanitize the url to ensure it takes the textre from aside the material.
  65211. *
  65212. * @param rootUrl The root url to load from
  65213. * @param value The value stored in the mtl
  65214. * @return The Texture
  65215. */
  65216. private static _getTexture;
  65217. }
  65218. /**
  65219. * Options for loading OBJ/MTL files
  65220. */
  65221. type MeshLoadOptions = {
  65222. /**
  65223. * Defines if UVs are optimized by default during load.
  65224. */
  65225. OptimizeWithUV: boolean;
  65226. /**
  65227. * Defines custom scaling of UV coordinates of loaded meshes.
  65228. */
  65229. UVScaling: Vector2;
  65230. /**
  65231. * Invert model on y-axis (does a model scaling inversion)
  65232. */
  65233. InvertY: boolean;
  65234. /**
  65235. * Invert Y-Axis of referenced textures on load
  65236. */
  65237. InvertTextureY: boolean;
  65238. /**
  65239. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65240. */
  65241. ImportVertexColors: boolean;
  65242. /**
  65243. * Compute the normals for the model, even if normals are present in the file.
  65244. */
  65245. ComputeNormals: boolean;
  65246. /**
  65247. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65248. */
  65249. SkipMaterials: boolean;
  65250. /**
  65251. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65252. */
  65253. MaterialLoadingFailsSilently: boolean;
  65254. };
  65255. /**
  65256. * OBJ file type loader.
  65257. * This is a babylon scene loader plugin.
  65258. */
  65259. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65260. /**
  65261. * Defines if UVs are optimized by default during load.
  65262. */
  65263. static OPTIMIZE_WITH_UV: boolean;
  65264. /**
  65265. * Invert model on y-axis (does a model scaling inversion)
  65266. */
  65267. static INVERT_Y: boolean;
  65268. /**
  65269. * Invert Y-Axis of referenced textures on load
  65270. */
  65271. static INVERT_TEXTURE_Y: boolean;
  65272. /**
  65273. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65274. */
  65275. static IMPORT_VERTEX_COLORS: boolean;
  65276. /**
  65277. * Compute the normals for the model, even if normals are present in the file.
  65278. */
  65279. static COMPUTE_NORMALS: boolean;
  65280. /**
  65281. * Defines custom scaling of UV coordinates of loaded meshes.
  65282. */
  65283. static UV_SCALING: Vector2;
  65284. /**
  65285. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65286. */
  65287. static SKIP_MATERIALS: boolean;
  65288. /**
  65289. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65290. *
  65291. * Defaults to true for backwards compatibility.
  65292. */
  65293. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65294. /**
  65295. * Defines the name of the plugin.
  65296. */
  65297. name: string;
  65298. /**
  65299. * Defines the extension the plugin is able to load.
  65300. */
  65301. extensions: string;
  65302. /** @hidden */
  65303. obj: RegExp;
  65304. /** @hidden */
  65305. group: RegExp;
  65306. /** @hidden */
  65307. mtllib: RegExp;
  65308. /** @hidden */
  65309. usemtl: RegExp;
  65310. /** @hidden */
  65311. smooth: RegExp;
  65312. /** @hidden */
  65313. vertexPattern: RegExp;
  65314. /** @hidden */
  65315. normalPattern: RegExp;
  65316. /** @hidden */
  65317. uvPattern: RegExp;
  65318. /** @hidden */
  65319. facePattern1: RegExp;
  65320. /** @hidden */
  65321. facePattern2: RegExp;
  65322. /** @hidden */
  65323. facePattern3: RegExp;
  65324. /** @hidden */
  65325. facePattern4: RegExp;
  65326. /** @hidden */
  65327. facePattern5: RegExp;
  65328. private _meshLoadOptions;
  65329. /**
  65330. * Creates loader for .OBJ files
  65331. *
  65332. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65333. */
  65334. constructor(meshLoadOptions?: MeshLoadOptions);
  65335. private static readonly currentMeshLoadOptions;
  65336. /**
  65337. * Calls synchronously the MTL file attached to this obj.
  65338. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65339. * Without this function materials are not displayed in the first frame (but displayed after).
  65340. * In consequence it is impossible to get material information in your HTML file
  65341. *
  65342. * @param url The URL of the MTL file
  65343. * @param rootUrl
  65344. * @param onSuccess Callback function to be called when the MTL file is loaded
  65345. * @private
  65346. */
  65347. private _loadMTL;
  65348. /**
  65349. * Instantiates a OBJ file loader plugin.
  65350. * @returns the created plugin
  65351. */
  65352. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65353. /**
  65354. * If the data string can be loaded directly.
  65355. *
  65356. * @param data string containing the file data
  65357. * @returns if the data can be loaded directly
  65358. */
  65359. canDirectLoad(data: string): boolean;
  65360. /**
  65361. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65362. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65363. * @param scene the scene the meshes should be added to
  65364. * @param data the OBJ data to load
  65365. * @param rootUrl root url to load from
  65366. * @param onProgress event that fires when loading progress has occured
  65367. * @param fileName Defines the name of the file to load
  65368. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65369. */
  65370. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65371. meshes: AbstractMesh[];
  65372. particleSystems: IParticleSystem[];
  65373. skeletons: Skeleton[];
  65374. animationGroups: AnimationGroup[];
  65375. }>;
  65376. /**
  65377. * Imports all objects from the loaded OBJ data and adds them to the scene
  65378. * @param scene the scene the objects should be added to
  65379. * @param data the OBJ data to load
  65380. * @param rootUrl root url to load from
  65381. * @param onProgress event that fires when loading progress has occured
  65382. * @param fileName Defines the name of the file to load
  65383. * @returns a promise which completes when objects have been loaded to the scene
  65384. */
  65385. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65386. /**
  65387. * Load into an asset container.
  65388. * @param scene The scene to load into
  65389. * @param data The data to import
  65390. * @param rootUrl The root url for scene and resources
  65391. * @param onProgress The callback when the load progresses
  65392. * @param fileName Defines the name of the file to load
  65393. * @returns The loaded asset container
  65394. */
  65395. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65396. /**
  65397. * Read the OBJ file and create an Array of meshes.
  65398. * Each mesh contains all information given by the OBJ and the MTL file.
  65399. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65400. *
  65401. * @param meshesNames
  65402. * @param scene Scene The scene where are displayed the data
  65403. * @param data String The content of the obj file
  65404. * @param rootUrl String The path to the folder
  65405. * @returns Array<AbstractMesh>
  65406. * @private
  65407. */
  65408. private _parseSolid;
  65409. }
  65410. }
  65411. declare module BABYLON {
  65412. /**
  65413. * STL file type loader.
  65414. * This is a babylon scene loader plugin.
  65415. */
  65416. export class STLFileLoader implements ISceneLoaderPlugin {
  65417. /** @hidden */
  65418. solidPattern: RegExp;
  65419. /** @hidden */
  65420. facetsPattern: RegExp;
  65421. /** @hidden */
  65422. normalPattern: RegExp;
  65423. /** @hidden */
  65424. vertexPattern: RegExp;
  65425. /**
  65426. * Defines the name of the plugin.
  65427. */
  65428. name: string;
  65429. /**
  65430. * Defines the extensions the stl loader is able to load.
  65431. * force data to come in as an ArrayBuffer
  65432. * we'll convert to string if it looks like it's an ASCII .stl
  65433. */
  65434. extensions: ISceneLoaderPluginExtensions;
  65435. /**
  65436. * Import meshes into a scene.
  65437. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65438. * @param scene The scene to import into
  65439. * @param data The data to import
  65440. * @param rootUrl The root url for scene and resources
  65441. * @param meshes The meshes array to import into
  65442. * @param particleSystems The particle systems array to import into
  65443. * @param skeletons The skeletons array to import into
  65444. * @param onError The callback when import fails
  65445. * @returns True if successful or false otherwise
  65446. */
  65447. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65448. /**
  65449. * Load into a scene.
  65450. * @param scene The scene to load into
  65451. * @param data The data to import
  65452. * @param rootUrl The root url for scene and resources
  65453. * @param onError The callback when import fails
  65454. * @returns true if successful or false otherwise
  65455. */
  65456. load(scene: Scene, data: any, rootUrl: string): boolean;
  65457. /**
  65458. * Load into an asset container.
  65459. * @param scene The scene to load into
  65460. * @param data The data to import
  65461. * @param rootUrl The root url for scene and resources
  65462. * @param onError The callback when import fails
  65463. * @returns The loaded asset container
  65464. */
  65465. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65466. private _isBinary;
  65467. private _parseBinary;
  65468. private _parseASCII;
  65469. }
  65470. }
  65471. declare module BABYLON {
  65472. /**
  65473. * Class for generating OBJ data from a Babylon scene.
  65474. */
  65475. export class OBJExport {
  65476. /**
  65477. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65478. * @param mesh defines the list of meshes to serialize
  65479. * @param materials defines if materials should be exported
  65480. * @param matlibname defines the name of the associated mtl file
  65481. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65482. * @returns the OBJ content
  65483. */
  65484. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65485. /**
  65486. * Exports the material(s) of a mesh in .MTL file format (text)
  65487. * @param mesh defines the mesh to extract the material from
  65488. * @returns the mtl content
  65489. */
  65490. static MTL(mesh: Mesh): string;
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /** @hidden */
  65495. export var __IGLTFExporterExtension: number;
  65496. /**
  65497. * Interface for extending the exporter
  65498. * @hidden
  65499. */
  65500. export interface IGLTFExporterExtension {
  65501. /**
  65502. * The name of this extension
  65503. */
  65504. readonly name: string;
  65505. /**
  65506. * Defines whether this extension is enabled
  65507. */
  65508. enabled: boolean;
  65509. /**
  65510. * Defines whether this extension is required
  65511. */
  65512. required: boolean;
  65513. }
  65514. }
  65515. declare module BABYLON.GLTF2.Exporter {
  65516. /** @hidden */
  65517. export var __IGLTFExporterExtensionV2: number;
  65518. /**
  65519. * Interface for a glTF exporter extension
  65520. * @hidden
  65521. */
  65522. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65523. /**
  65524. * Define this method to modify the default behavior before exporting a texture
  65525. * @param context The context when loading the asset
  65526. * @param babylonTexture The glTF texture info property
  65527. * @param mimeType The mime-type of the generated image
  65528. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65529. */
  65530. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65531. /**
  65532. * Define this method to modify the default behavior when exporting texture info
  65533. * @param context The context when loading the asset
  65534. * @param meshPrimitive glTF mesh primitive
  65535. * @param babylonSubMesh Babylon submesh
  65536. * @param binaryWriter glTF serializer binary writer instance
  65537. * @returns nullable IMeshPrimitive promise
  65538. */
  65539. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65540. /**
  65541. * Define this method to modify the default behavior when exporting a node
  65542. * @param context The context when exporting the node
  65543. * @param node glTF node
  65544. * @param babylonNode BabylonJS node
  65545. * @returns nullable INode promise
  65546. */
  65547. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65548. /**
  65549. * Called after the exporter state changes to EXPORTING
  65550. */
  65551. onExporting?(): void;
  65552. }
  65553. }
  65554. declare module BABYLON.GLTF2.Exporter {
  65555. /**
  65556. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65557. * @hidden
  65558. */
  65559. export class _GLTFMaterialExporter {
  65560. /**
  65561. * Represents the dielectric specular values for R, G and B
  65562. */
  65563. private static readonly _DielectricSpecular;
  65564. /**
  65565. * Allows the maximum specular power to be defined for material calculations
  65566. */
  65567. private static readonly _MaxSpecularPower;
  65568. /**
  65569. * Mapping to store textures
  65570. */
  65571. private _textureMap;
  65572. /**
  65573. * Numeric tolerance value
  65574. */
  65575. private static readonly _Epsilon;
  65576. /**
  65577. * Reference to the glTF Exporter
  65578. */
  65579. private _exporter;
  65580. constructor(exporter: _Exporter);
  65581. /**
  65582. * Specifies if two colors are approximately equal in value
  65583. * @param color1 first color to compare to
  65584. * @param color2 second color to compare to
  65585. * @param epsilon threshold value
  65586. */
  65587. private static FuzzyEquals;
  65588. /**
  65589. * Gets the materials from a Babylon scene and converts them to glTF materials
  65590. * @param scene babylonjs scene
  65591. * @param mimeType texture mime type
  65592. * @param images array of images
  65593. * @param textures array of textures
  65594. * @param materials array of materials
  65595. * @param imageData mapping of texture names to base64 textures
  65596. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65597. */
  65598. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65599. /**
  65600. * Makes a copy of the glTF material without the texture parameters
  65601. * @param originalMaterial original glTF material
  65602. * @returns glTF material without texture parameters
  65603. */
  65604. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65605. /**
  65606. * Specifies if the material has any texture parameters present
  65607. * @param material glTF Material
  65608. * @returns boolean specifying if texture parameters are present
  65609. */
  65610. _hasTexturesPresent(material: IMaterial): boolean;
  65611. /**
  65612. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65613. * @param babylonStandardMaterial
  65614. * @returns glTF Metallic Roughness Material representation
  65615. */
  65616. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65617. /**
  65618. * Computes the metallic factor
  65619. * @param diffuse diffused value
  65620. * @param specular specular value
  65621. * @param oneMinusSpecularStrength one minus the specular strength
  65622. * @returns metallic value
  65623. */
  65624. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65625. /**
  65626. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65627. * @param glTFMaterial glTF material
  65628. * @param babylonMaterial Babylon material
  65629. */
  65630. private static _SetAlphaMode;
  65631. /**
  65632. * Converts a Babylon Standard Material to a glTF Material
  65633. * @param babylonStandardMaterial BJS Standard Material
  65634. * @param mimeType mime type to use for the textures
  65635. * @param images array of glTF image interfaces
  65636. * @param textures array of glTF texture interfaces
  65637. * @param materials array of glTF material interfaces
  65638. * @param imageData map of image file name to data
  65639. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65640. */
  65641. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65642. /**
  65643. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65644. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65645. * @param mimeType mime type to use for the textures
  65646. * @param images array of glTF image interfaces
  65647. * @param textures array of glTF texture interfaces
  65648. * @param materials array of glTF material interfaces
  65649. * @param imageData map of image file name to data
  65650. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65651. */
  65652. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65653. /**
  65654. * Converts an image typed array buffer to a base64 image
  65655. * @param buffer typed array buffer
  65656. * @param width width of the image
  65657. * @param height height of the image
  65658. * @param mimeType mimetype of the image
  65659. * @returns base64 image string
  65660. */
  65661. private _createBase64FromCanvasAsync;
  65662. /**
  65663. * Generates a white texture based on the specified width and height
  65664. * @param width width of the texture in pixels
  65665. * @param height height of the texture in pixels
  65666. * @param scene babylonjs scene
  65667. * @returns white texture
  65668. */
  65669. private _createWhiteTexture;
  65670. /**
  65671. * 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
  65672. * @param texture1 first texture to resize
  65673. * @param texture2 second texture to resize
  65674. * @param scene babylonjs scene
  65675. * @returns resized textures or null
  65676. */
  65677. private _resizeTexturesToSameDimensions;
  65678. /**
  65679. * Converts an array of pixels to a Float32Array
  65680. * Throws an error if the pixel format is not supported
  65681. * @param pixels - array buffer containing pixel values
  65682. * @returns Float32 of pixels
  65683. */
  65684. private _convertPixelArrayToFloat32;
  65685. /**
  65686. * Convert Specular Glossiness Textures to Metallic Roughness
  65687. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65688. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65689. * @param diffuseTexture texture used to store diffuse information
  65690. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65691. * @param factors specular glossiness material factors
  65692. * @param mimeType the mime type to use for the texture
  65693. * @returns pbr metallic roughness interface or null
  65694. */
  65695. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65696. /**
  65697. * Converts specular glossiness material properties to metallic roughness
  65698. * @param specularGlossiness interface with specular glossiness material properties
  65699. * @returns interface with metallic roughness material properties
  65700. */
  65701. private _convertSpecularGlossinessToMetallicRoughness;
  65702. /**
  65703. * Calculates the surface reflectance, independent of lighting conditions
  65704. * @param color Color source to calculate brightness from
  65705. * @returns number representing the perceived brightness, or zero if color is undefined
  65706. */
  65707. private _getPerceivedBrightness;
  65708. /**
  65709. * Returns the maximum color component value
  65710. * @param color
  65711. * @returns maximum color component value, or zero if color is null or undefined
  65712. */
  65713. private _getMaxComponent;
  65714. /**
  65715. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65716. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65717. * @param mimeType mime type to use for the textures
  65718. * @param images array of glTF image interfaces
  65719. * @param textures array of glTF texture interfaces
  65720. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65721. * @param imageData map of image file name to data
  65722. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65723. * @returns glTF PBR Metallic Roughness factors
  65724. */
  65725. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65726. private _getGLTFTextureSampler;
  65727. private _getGLTFTextureWrapMode;
  65728. private _getGLTFTextureWrapModesSampler;
  65729. /**
  65730. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65731. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65732. * @param mimeType mime type to use for the textures
  65733. * @param images array of glTF image interfaces
  65734. * @param textures array of glTF texture interfaces
  65735. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65736. * @param imageData map of image file name to data
  65737. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65738. * @returns glTF PBR Metallic Roughness factors
  65739. */
  65740. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  65741. /**
  65742. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65743. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65744. * @param mimeType mime type to use for the textures
  65745. * @param images array of glTF image interfaces
  65746. * @param textures array of glTF texture interfaces
  65747. * @param materials array of glTF material interfaces
  65748. * @param imageData map of image file name to data
  65749. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65750. */
  65751. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65752. private setMetallicRoughnessPbrMaterial;
  65753. private getPixelsFromTexture;
  65754. /**
  65755. * Extracts a texture from a Babylon texture into file data and glTF data
  65756. * @param babylonTexture Babylon texture to extract
  65757. * @param mimeType Mime Type of the babylonTexture
  65758. * @return glTF texture info, or null if the texture format is not supported
  65759. */
  65760. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65761. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  65762. /**
  65763. * Builds a texture from base64 string
  65764. * @param base64Texture base64 texture string
  65765. * @param baseTextureName Name to use for the texture
  65766. * @param mimeType image mime type for the texture
  65767. * @param images array of images
  65768. * @param textures array of textures
  65769. * @param imageData map of image data
  65770. * @returns glTF texture info, or null if the texture format is not supported
  65771. */
  65772. private _getTextureInfoFromBase64;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /**
  65777. * Class for holding and downloading glTF file data
  65778. */
  65779. export class GLTFData {
  65780. /**
  65781. * Object which contains the file name as the key and its data as the value
  65782. */
  65783. glTFFiles: {
  65784. [fileName: string]: string | Blob;
  65785. };
  65786. /**
  65787. * Initializes the glTF file object
  65788. */
  65789. constructor();
  65790. /**
  65791. * Downloads the glTF data as files based on their names and data
  65792. */
  65793. downloadFiles(): void;
  65794. }
  65795. }
  65796. declare module BABYLON {
  65797. /**
  65798. * Holds a collection of exporter options and parameters
  65799. */
  65800. export interface IExportOptions {
  65801. /**
  65802. * Function which indicates whether a babylon node should be exported or not
  65803. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  65804. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  65805. */
  65806. shouldExportNode?(node: Node): boolean;
  65807. /**
  65808. * The sample rate to bake animation curves
  65809. */
  65810. animationSampleRate?: number;
  65811. /**
  65812. * Begin serialization without waiting for the scene to be ready
  65813. */
  65814. exportWithoutWaitingForScene?: boolean;
  65815. }
  65816. /**
  65817. * Class for generating glTF data from a Babylon scene.
  65818. */
  65819. export class GLTF2Export {
  65820. /**
  65821. * Exports the geometry of the scene to .gltf file format asynchronously
  65822. * @param scene Babylon scene with scene hierarchy information
  65823. * @param filePrefix File prefix to use when generating the glTF file
  65824. * @param options Exporter options
  65825. * @returns Returns an object with a .gltf file and associates texture names
  65826. * as keys and their data and paths as values
  65827. */
  65828. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65829. private static _PreExportAsync;
  65830. private static _PostExportAsync;
  65831. /**
  65832. * Exports the geometry of the scene to .glb file format asychronously
  65833. * @param scene Babylon scene with scene hierarchy information
  65834. * @param filePrefix File prefix to use when generating glb file
  65835. * @param options Exporter options
  65836. * @returns Returns an object with a .glb filename as key and data as value
  65837. */
  65838. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  65839. }
  65840. }
  65841. declare module BABYLON.GLTF2.Exporter {
  65842. /**
  65843. * @hidden
  65844. */
  65845. export class _GLTFUtilities {
  65846. /**
  65847. * Creates a buffer view based on the supplied arguments
  65848. * @param bufferIndex index value of the specified buffer
  65849. * @param byteOffset byte offset value
  65850. * @param byteLength byte length of the bufferView
  65851. * @param byteStride byte distance between conequential elements
  65852. * @param name name of the buffer view
  65853. * @returns bufferView for glTF
  65854. */
  65855. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  65856. /**
  65857. * Creates an accessor based on the supplied arguments
  65858. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  65859. * @param name The name of the accessor
  65860. * @param type The type of the accessor
  65861. * @param componentType The datatype of components in the attribute
  65862. * @param count The number of attributes referenced by this accessor
  65863. * @param byteOffset The offset relative to the start of the bufferView in bytes
  65864. * @param min Minimum value of each component in this attribute
  65865. * @param max Maximum value of each component in this attribute
  65866. * @returns accessor for glTF
  65867. */
  65868. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  65869. /**
  65870. * Calculates the minimum and maximum values of an array of position floats
  65871. * @param positions Positions array of a mesh
  65872. * @param vertexStart Starting vertex offset to calculate min and max values
  65873. * @param vertexCount Number of vertices to check for min and max values
  65874. * @returns min number array and max number array
  65875. */
  65876. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65877. min: number[];
  65878. max: number[];
  65879. };
  65880. /**
  65881. * Converts a new right-handed Vector3
  65882. * @param vector vector3 array
  65883. * @returns right-handed Vector3
  65884. */
  65885. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65886. /**
  65887. * Converts a Vector3 to right-handed
  65888. * @param vector Vector3 to convert to right-handed
  65889. */
  65890. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65891. /**
  65892. * Converts a three element number array to right-handed
  65893. * @param vector number array to convert to right-handed
  65894. */
  65895. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65896. /**
  65897. * Converts a new right-handed Vector3
  65898. * @param vector vector3 array
  65899. * @returns right-handed Vector3
  65900. */
  65901. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65902. /**
  65903. * Converts a Vector3 to right-handed
  65904. * @param vector Vector3 to convert to right-handed
  65905. */
  65906. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65907. /**
  65908. * Converts a three element number array to right-handed
  65909. * @param vector number array to convert to right-handed
  65910. */
  65911. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65912. /**
  65913. * Converts a Vector4 to right-handed
  65914. * @param vector Vector4 to convert to right-handed
  65915. */
  65916. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65917. /**
  65918. * Converts a Vector4 to right-handed
  65919. * @param vector Vector4 to convert to right-handed
  65920. */
  65921. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65922. /**
  65923. * Converts a Quaternion to right-handed
  65924. * @param quaternion Source quaternion to convert to right-handed
  65925. */
  65926. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65927. /**
  65928. * Converts a Quaternion to right-handed
  65929. * @param quaternion Source quaternion to convert to right-handed
  65930. */
  65931. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65932. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65933. }
  65934. }
  65935. declare module BABYLON.GLTF2.Exporter {
  65936. /**
  65937. * Converts Babylon Scene into glTF 2.0.
  65938. * @hidden
  65939. */
  65940. export class _Exporter {
  65941. /**
  65942. * Stores the glTF to export
  65943. */
  65944. _glTF: IGLTF;
  65945. /**
  65946. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65947. */
  65948. _bufferViews: IBufferView[];
  65949. /**
  65950. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65951. */
  65952. _accessors: IAccessor[];
  65953. /**
  65954. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65955. */
  65956. private _nodes;
  65957. /**
  65958. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65959. */
  65960. private _scenes;
  65961. /**
  65962. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65963. */
  65964. private _meshes;
  65965. /**
  65966. * Stores all the generated material information, which represents the appearance of each primitive
  65967. */
  65968. _materials: IMaterial[];
  65969. _materialMap: {
  65970. [materialID: number]: number;
  65971. };
  65972. /**
  65973. * Stores all the generated texture information, which is referenced by glTF materials
  65974. */
  65975. _textures: ITexture[];
  65976. /**
  65977. * Stores all the generated image information, which is referenced by glTF textures
  65978. */
  65979. _images: IImage[];
  65980. /**
  65981. * Stores all the texture samplers
  65982. */
  65983. _samplers: ISampler[];
  65984. /**
  65985. * Stores all the generated animation samplers, which is referenced by glTF animations
  65986. */
  65987. /**
  65988. * Stores the animations for glTF models
  65989. */
  65990. private _animations;
  65991. /**
  65992. * Stores the total amount of bytes stored in the glTF buffer
  65993. */
  65994. private _totalByteLength;
  65995. /**
  65996. * Stores a reference to the Babylon scene containing the source geometry and material information
  65997. */
  65998. _babylonScene: Scene;
  65999. /**
  66000. * Stores a map of the image data, where the key is the file name and the value
  66001. * is the image data
  66002. */
  66003. _imageData: {
  66004. [fileName: string]: {
  66005. data: Uint8Array;
  66006. mimeType: ImageMimeType;
  66007. };
  66008. };
  66009. /**
  66010. * Stores a map of the unique id of a node to its index in the node array
  66011. */
  66012. private _nodeMap;
  66013. /**
  66014. * Specifies if the Babylon scene should be converted to right-handed on export
  66015. */
  66016. _convertToRightHandedSystem: boolean;
  66017. /**
  66018. * Baked animation sample rate
  66019. */
  66020. private _animationSampleRate;
  66021. /**
  66022. * Callback which specifies if a node should be exported or not
  66023. */
  66024. private _shouldExportNode;
  66025. private _localEngine;
  66026. _glTFMaterialExporter: _GLTFMaterialExporter;
  66027. private _extensions;
  66028. private static _ExtensionNames;
  66029. private static _ExtensionFactories;
  66030. private _applyExtensions;
  66031. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66032. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66033. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66034. private _forEachExtensions;
  66035. private _extensionsOnExporting;
  66036. /**
  66037. * Load glTF serializer extensions
  66038. */
  66039. private _loadExtensions;
  66040. /**
  66041. * Creates a glTF Exporter instance, which can accept optional exporter options
  66042. * @param babylonScene Babylon scene object
  66043. * @param options Options to modify the behavior of the exporter
  66044. */
  66045. constructor(babylonScene: Scene, options?: IExportOptions);
  66046. /**
  66047. * Registers a glTF exporter extension
  66048. * @param name Name of the extension to export
  66049. * @param factory The factory function that creates the exporter extension
  66050. */
  66051. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66052. /**
  66053. * Un-registers an exporter extension
  66054. * @param name The name fo the exporter extension
  66055. * @returns A boolean indicating whether the extension has been un-registered
  66056. */
  66057. static UnregisterExtension(name: string): boolean;
  66058. /**
  66059. * Lazy load a local engine with premultiplied alpha set to false
  66060. */
  66061. _getLocalEngine(): Engine;
  66062. private reorderIndicesBasedOnPrimitiveMode;
  66063. /**
  66064. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66065. * clock-wise during export to glTF
  66066. * @param submesh BabylonJS submesh
  66067. * @param primitiveMode Primitive mode of the mesh
  66068. * @param sideOrientation the winding order of the submesh
  66069. * @param vertexBufferKind The type of vertex attribute
  66070. * @param meshAttributeArray The vertex attribute data
  66071. * @param byteOffset The offset to the binary data
  66072. * @param binaryWriter The binary data for the glTF file
  66073. */
  66074. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66075. /**
  66076. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66077. * clock-wise during export to glTF
  66078. * @param submesh BabylonJS submesh
  66079. * @param primitiveMode Primitive mode of the mesh
  66080. * @param sideOrientation the winding order of the submesh
  66081. * @param vertexBufferKind The type of vertex attribute
  66082. * @param meshAttributeArray The vertex attribute data
  66083. * @param byteOffset The offset to the binary data
  66084. * @param binaryWriter The binary data for the glTF file
  66085. */
  66086. private reorderTriangleFillMode;
  66087. /**
  66088. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66089. * clock-wise during export to glTF
  66090. * @param submesh BabylonJS submesh
  66091. * @param primitiveMode Primitive mode of the mesh
  66092. * @param sideOrientation the winding order of the submesh
  66093. * @param vertexBufferKind The type of vertex attribute
  66094. * @param meshAttributeArray The vertex attribute data
  66095. * @param byteOffset The offset to the binary data
  66096. * @param binaryWriter The binary data for the glTF file
  66097. */
  66098. private reorderTriangleStripDrawMode;
  66099. /**
  66100. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66101. * clock-wise during export to glTF
  66102. * @param submesh BabylonJS submesh
  66103. * @param primitiveMode Primitive mode of the mesh
  66104. * @param sideOrientation the winding order of the submesh
  66105. * @param vertexBufferKind The type of vertex attribute
  66106. * @param meshAttributeArray The vertex attribute data
  66107. * @param byteOffset The offset to the binary data
  66108. * @param binaryWriter The binary data for the glTF file
  66109. */
  66110. private reorderTriangleFanMode;
  66111. /**
  66112. * Writes the vertex attribute data to binary
  66113. * @param vertices The vertices to write to the binary writer
  66114. * @param byteOffset The offset into the binary writer to overwrite binary data
  66115. * @param vertexAttributeKind The vertex attribute type
  66116. * @param meshAttributeArray The vertex attribute data
  66117. * @param binaryWriter The writer containing the binary data
  66118. */
  66119. private writeVertexAttributeData;
  66120. /**
  66121. * Writes mesh attribute data to a data buffer
  66122. * Returns the bytelength of the data
  66123. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66124. * @param meshAttributeArray Array containing the attribute data
  66125. * @param binaryWriter The buffer to write the binary data to
  66126. * @param indices Used to specify the order of the vertex data
  66127. */
  66128. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66129. /**
  66130. * Generates glTF json data
  66131. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66132. * @param glTFPrefix Text to use when prefixing a glTF file
  66133. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66134. * @returns json data as string
  66135. */
  66136. private generateJSON;
  66137. /**
  66138. * Generates data for .gltf and .bin files based on the glTF prefix string
  66139. * @param glTFPrefix Text to use when prefixing a glTF file
  66140. * @returns GLTFData with glTF file data
  66141. */
  66142. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66143. /**
  66144. * Creates a binary buffer for glTF
  66145. * @returns array buffer for binary data
  66146. */
  66147. private _generateBinaryAsync;
  66148. /**
  66149. * Pads the number to a multiple of 4
  66150. * @param num number to pad
  66151. * @returns padded number
  66152. */
  66153. private _getPadding;
  66154. /**
  66155. * Generates a glb file from the json and binary data
  66156. * Returns an object with the glb file name as the key and data as the value
  66157. * @param glTFPrefix
  66158. * @returns object with glb filename as key and data as value
  66159. */
  66160. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66161. /**
  66162. * Sets the TRS for each node
  66163. * @param node glTF Node for storing the transformation data
  66164. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66165. */
  66166. private setNodeTransformation;
  66167. private getVertexBufferFromMesh;
  66168. /**
  66169. * Creates a bufferview based on the vertices type for the Babylon mesh
  66170. * @param kind Indicates the type of vertices data
  66171. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66172. * @param binaryWriter The buffer to write the bufferview data to
  66173. */
  66174. private createBufferViewKind;
  66175. /**
  66176. * The primitive mode of the Babylon mesh
  66177. * @param babylonMesh The BabylonJS mesh
  66178. */
  66179. private getMeshPrimitiveMode;
  66180. /**
  66181. * Sets the primitive mode of the glTF mesh primitive
  66182. * @param meshPrimitive glTF mesh primitive
  66183. * @param primitiveMode The primitive mode
  66184. */
  66185. private setPrimitiveMode;
  66186. /**
  66187. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66188. * @param meshPrimitive glTF mesh primitive
  66189. * @param attributeKind vertex attribute
  66190. * @returns boolean specifying if uv coordinates are present
  66191. */
  66192. private setAttributeKind;
  66193. /**
  66194. * Sets data for the primitive attributes of each submesh
  66195. * @param mesh glTF Mesh object to store the primitive attribute information
  66196. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66197. * @param binaryWriter Buffer to write the attribute data to
  66198. */
  66199. private setPrimitiveAttributesAsync;
  66200. /**
  66201. * Creates a glTF scene based on the array of meshes
  66202. * Returns the the total byte offset
  66203. * @param babylonScene Babylon scene to get the mesh data from
  66204. * @param binaryWriter Buffer to write binary data to
  66205. */
  66206. private createSceneAsync;
  66207. /**
  66208. * Creates a mapping of Node unique id to node index and handles animations
  66209. * @param babylonScene Babylon Scene
  66210. * @param nodes Babylon transform nodes
  66211. * @param shouldExportNode Callback specifying if a transform node should be exported
  66212. * @param binaryWriter Buffer to write binary data to
  66213. * @returns Node mapping of unique id to index
  66214. */
  66215. private createNodeMapAndAnimationsAsync;
  66216. /**
  66217. * Creates a glTF node from a Babylon mesh
  66218. * @param babylonMesh Source Babylon mesh
  66219. * @param binaryWriter Buffer for storing geometry data
  66220. * @returns glTF node
  66221. */
  66222. private createNodeAsync;
  66223. }
  66224. /**
  66225. * @hidden
  66226. *
  66227. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66228. */
  66229. export class _BinaryWriter {
  66230. /**
  66231. * Array buffer which stores all binary data
  66232. */
  66233. private _arrayBuffer;
  66234. /**
  66235. * View of the array buffer
  66236. */
  66237. private _dataView;
  66238. /**
  66239. * byte offset of data in array buffer
  66240. */
  66241. private _byteOffset;
  66242. /**
  66243. * Initialize binary writer with an initial byte length
  66244. * @param byteLength Initial byte length of the array buffer
  66245. */
  66246. constructor(byteLength: number);
  66247. /**
  66248. * Resize the array buffer to the specified byte length
  66249. * @param byteLength
  66250. */
  66251. private resizeBuffer;
  66252. /**
  66253. * Get an array buffer with the length of the byte offset
  66254. * @returns ArrayBuffer resized to the byte offset
  66255. */
  66256. getArrayBuffer(): ArrayBuffer;
  66257. /**
  66258. * Get the byte offset of the array buffer
  66259. * @returns byte offset
  66260. */
  66261. getByteOffset(): number;
  66262. /**
  66263. * Stores an UInt8 in the array buffer
  66264. * @param entry
  66265. * @param byteOffset If defined, specifies where to set the value as an offset.
  66266. */
  66267. setUInt8(entry: number, byteOffset?: number): void;
  66268. /**
  66269. * Gets an UInt32 in the array buffer
  66270. * @param entry
  66271. * @param byteOffset If defined, specifies where to set the value as an offset.
  66272. */
  66273. getUInt32(byteOffset: number): number;
  66274. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66275. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66276. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66277. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66278. /**
  66279. * Stores a Float32 in the array buffer
  66280. * @param entry
  66281. */
  66282. setFloat32(entry: number, byteOffset?: number): void;
  66283. /**
  66284. * Stores an UInt32 in the array buffer
  66285. * @param entry
  66286. * @param byteOffset If defined, specifies where to set the value as an offset.
  66287. */
  66288. setUInt32(entry: number, byteOffset?: number): void;
  66289. }
  66290. }
  66291. declare module BABYLON.GLTF2.Exporter {
  66292. /**
  66293. * @hidden
  66294. * Interface to store animation data.
  66295. */
  66296. export interface _IAnimationData {
  66297. /**
  66298. * Keyframe data.
  66299. */
  66300. inputs: number[];
  66301. /**
  66302. * Value data.
  66303. */
  66304. outputs: number[][];
  66305. /**
  66306. * Animation interpolation data.
  66307. */
  66308. samplerInterpolation: AnimationSamplerInterpolation;
  66309. /**
  66310. * Minimum keyframe value.
  66311. */
  66312. inputsMin: number;
  66313. /**
  66314. * Maximum keyframe value.
  66315. */
  66316. inputsMax: number;
  66317. }
  66318. /**
  66319. * @hidden
  66320. */
  66321. export interface _IAnimationInfo {
  66322. /**
  66323. * The target channel for the animation
  66324. */
  66325. animationChannelTargetPath: AnimationChannelTargetPath;
  66326. /**
  66327. * The glTF accessor type for the data.
  66328. */
  66329. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66330. /**
  66331. * Specifies if quaternions should be used.
  66332. */
  66333. useQuaternion: boolean;
  66334. }
  66335. /**
  66336. * @hidden
  66337. * Utility class for generating glTF animation data from BabylonJS.
  66338. */
  66339. export class _GLTFAnimation {
  66340. /**
  66341. * @ignore
  66342. *
  66343. * Creates glTF channel animation from BabylonJS animation.
  66344. * @param babylonTransformNode - BabylonJS mesh.
  66345. * @param animation - animation.
  66346. * @param animationChannelTargetPath - The target animation channel.
  66347. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66348. * @param useQuaternion - Specifies if quaternions are used.
  66349. * @returns nullable IAnimationData
  66350. */
  66351. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66352. private static _DeduceAnimationInfo;
  66353. /**
  66354. * @ignore
  66355. * Create node animations from the transform node animations
  66356. * @param babylonNode
  66357. * @param runtimeGLTFAnimation
  66358. * @param idleGLTFAnimations
  66359. * @param nodeMap
  66360. * @param nodes
  66361. * @param binaryWriter
  66362. * @param bufferViews
  66363. * @param accessors
  66364. * @param convertToRightHandedSystem
  66365. */
  66366. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66367. [key: number]: number;
  66368. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66369. /**
  66370. * @ignore
  66371. * Create node animations from the animation groups
  66372. * @param babylonScene
  66373. * @param glTFAnimations
  66374. * @param nodeMap
  66375. * @param nodes
  66376. * @param binaryWriter
  66377. * @param bufferViews
  66378. * @param accessors
  66379. * @param convertToRightHandedSystem
  66380. */
  66381. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66382. [key: number]: number;
  66383. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66384. private static AddAnimation;
  66385. /**
  66386. * Create a baked animation
  66387. * @param babylonTransformNode BabylonJS mesh
  66388. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66389. * @param animationChannelTargetPath animation target channel
  66390. * @param minFrame minimum animation frame
  66391. * @param maxFrame maximum animation frame
  66392. * @param fps frames per second of the animation
  66393. * @param inputs input key frames of the animation
  66394. * @param outputs output key frame data of the animation
  66395. * @param convertToRightHandedSystem converts the values to right-handed
  66396. * @param useQuaternion specifies if quaternions should be used
  66397. */
  66398. private static _CreateBakedAnimation;
  66399. private static _ConvertFactorToVector3OrQuaternion;
  66400. private static _SetInterpolatedValue;
  66401. /**
  66402. * Creates linear animation from the animation key frames
  66403. * @param babylonTransformNode BabylonJS mesh
  66404. * @param animation BabylonJS animation
  66405. * @param animationChannelTargetPath The target animation channel
  66406. * @param frameDelta The difference between the last and first frame of the animation
  66407. * @param inputs Array to store the key frame times
  66408. * @param outputs Array to store the key frame data
  66409. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66410. * @param useQuaternion Specifies if quaternions are used in the animation
  66411. */
  66412. private static _CreateLinearOrStepAnimation;
  66413. /**
  66414. * Creates cubic spline animation from the animation key frames
  66415. * @param babylonTransformNode BabylonJS mesh
  66416. * @param animation BabylonJS animation
  66417. * @param animationChannelTargetPath The target animation channel
  66418. * @param frameDelta The difference between the last and first frame of the animation
  66419. * @param inputs Array to store the key frame times
  66420. * @param outputs Array to store the key frame data
  66421. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66422. * @param useQuaternion Specifies if quaternions are used in the animation
  66423. */
  66424. private static _CreateCubicSplineAnimation;
  66425. private static _GetBasePositionRotationOrScale;
  66426. /**
  66427. * Adds a key frame value
  66428. * @param keyFrame
  66429. * @param animation
  66430. * @param outputs
  66431. * @param animationChannelTargetPath
  66432. * @param basePositionRotationOrScale
  66433. * @param convertToRightHandedSystem
  66434. * @param useQuaternion
  66435. */
  66436. private static _AddKeyframeValue;
  66437. /**
  66438. * Determine the interpolation based on the key frames
  66439. * @param keyFrames
  66440. * @param animationChannelTargetPath
  66441. * @param useQuaternion
  66442. */
  66443. private static _DeduceInterpolation;
  66444. /**
  66445. * Adds an input tangent or output tangent to the output data
  66446. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66447. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66448. * @param outputs The animation data by keyframe
  66449. * @param animationChannelTargetPath The target animation channel
  66450. * @param interpolation The interpolation type
  66451. * @param keyFrame The key frame with the animation data
  66452. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66453. * @param useQuaternion Specifies if quaternions are used
  66454. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66455. */
  66456. private static AddSplineTangent;
  66457. /**
  66458. * Get the minimum and maximum key frames' frame values
  66459. * @param keyFrames animation key frames
  66460. * @returns the minimum and maximum key frame value
  66461. */
  66462. private static calculateMinMaxKeyFrames;
  66463. }
  66464. }
  66465. declare module BABYLON.GLTF2.Exporter {
  66466. /** @hidden */
  66467. export var textureTransformPixelShader: {
  66468. name: string;
  66469. shader: string;
  66470. };
  66471. }
  66472. declare module BABYLON.GLTF2.Exporter.Extensions {
  66473. /**
  66474. * @hidden
  66475. */
  66476. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66477. /** Name of this extension */
  66478. readonly name: string;
  66479. /** Defines whether this extension is enabled */
  66480. enabled: boolean;
  66481. /** Defines whether this extension is required */
  66482. required: boolean;
  66483. /** Reference to the glTF exporter */
  66484. private _exporter;
  66485. constructor(exporter: _Exporter);
  66486. dispose(): void;
  66487. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66488. /**
  66489. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66490. * @param babylonTexture
  66491. * @param offset
  66492. * @param rotation
  66493. * @param scale
  66494. * @param scene
  66495. */
  66496. private _textureTransformTextureAsync;
  66497. }
  66498. }
  66499. declare module BABYLON.GLTF2.Exporter.Extensions {
  66500. /**
  66501. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66502. */
  66503. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66504. /** The name of this extension. */
  66505. readonly name: string;
  66506. /** Defines whether this extension is enabled. */
  66507. enabled: boolean;
  66508. /** Defines whether this extension is required */
  66509. required: boolean;
  66510. /** Reference to the glTF exporter */
  66511. private _exporter;
  66512. private _lights;
  66513. /** @hidden */
  66514. constructor(exporter: _Exporter);
  66515. /** @hidden */
  66516. dispose(): void;
  66517. /** @hidden */
  66518. onExporting(): void;
  66519. /**
  66520. * Define this method to modify the default behavior when exporting a node
  66521. * @param context The context when exporting the node
  66522. * @param node glTF node
  66523. * @param babylonNode BabylonJS node
  66524. * @returns nullable INode promise
  66525. */
  66526. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66527. }
  66528. }
  66529. declare module BABYLON {
  66530. /**
  66531. * Class for generating STL data from a Babylon scene.
  66532. */
  66533. export class STLExport {
  66534. /**
  66535. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66536. * @param meshes list defines the mesh to serialize
  66537. * @param download triggers the automatic download of the file.
  66538. * @param fileName changes the downloads fileName.
  66539. * @param binary changes the STL to a binary type.
  66540. * @param isLittleEndian toggle for binary type exporter.
  66541. * @returns the STL as UTF8 string
  66542. */
  66543. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66544. }
  66545. }
  66546. /**
  66547. * @ignoreChildren
  66548. * @ignore
  66549. */
  66550. declare module "babylonjs-gltf2interface" {
  66551. export = BABYLON.GLTF2;
  66552. }
  66553. /**
  66554. * Module for glTF 2.0 Interface
  66555. * @ignoreChildren
  66556. * @ignore
  66557. */
  66558. declare module BABYLON.GLTF2 {
  66559. /**
  66560. * The datatype of the components in the attribute
  66561. */
  66562. const enum AccessorComponentType {
  66563. /**
  66564. * Byte
  66565. */
  66566. BYTE = 5120,
  66567. /**
  66568. * Unsigned Byte
  66569. */
  66570. UNSIGNED_BYTE = 5121,
  66571. /**
  66572. * Short
  66573. */
  66574. SHORT = 5122,
  66575. /**
  66576. * Unsigned Short
  66577. */
  66578. UNSIGNED_SHORT = 5123,
  66579. /**
  66580. * Unsigned Int
  66581. */
  66582. UNSIGNED_INT = 5125,
  66583. /**
  66584. * Float
  66585. */
  66586. FLOAT = 5126,
  66587. }
  66588. /**
  66589. * Specifies if the attirbute is a scalar, vector, or matrix
  66590. */
  66591. const enum AccessorType {
  66592. /**
  66593. * Scalar
  66594. */
  66595. SCALAR = "SCALAR",
  66596. /**
  66597. * Vector2
  66598. */
  66599. VEC2 = "VEC2",
  66600. /**
  66601. * Vector3
  66602. */
  66603. VEC3 = "VEC3",
  66604. /**
  66605. * Vector4
  66606. */
  66607. VEC4 = "VEC4",
  66608. /**
  66609. * Matrix2x2
  66610. */
  66611. MAT2 = "MAT2",
  66612. /**
  66613. * Matrix3x3
  66614. */
  66615. MAT3 = "MAT3",
  66616. /**
  66617. * Matrix4x4
  66618. */
  66619. MAT4 = "MAT4",
  66620. }
  66621. /**
  66622. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66623. */
  66624. const enum AnimationChannelTargetPath {
  66625. /**
  66626. * Translation
  66627. */
  66628. TRANSLATION = "translation",
  66629. /**
  66630. * Rotation
  66631. */
  66632. ROTATION = "rotation",
  66633. /**
  66634. * Scale
  66635. */
  66636. SCALE = "scale",
  66637. /**
  66638. * Weights
  66639. */
  66640. WEIGHTS = "weights",
  66641. }
  66642. /**
  66643. * Interpolation algorithm
  66644. */
  66645. const enum AnimationSamplerInterpolation {
  66646. /**
  66647. * The animated values are linearly interpolated between keyframes
  66648. */
  66649. LINEAR = "LINEAR",
  66650. /**
  66651. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66652. */
  66653. STEP = "STEP",
  66654. /**
  66655. * The animation's interpolation is computed using a cubic spline with specified tangents
  66656. */
  66657. CUBICSPLINE = "CUBICSPLINE",
  66658. }
  66659. /**
  66660. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66661. */
  66662. const enum CameraType {
  66663. /**
  66664. * A perspective camera containing properties to create a perspective projection matrix
  66665. */
  66666. PERSPECTIVE = "perspective",
  66667. /**
  66668. * An orthographic camera containing properties to create an orthographic projection matrix
  66669. */
  66670. ORTHOGRAPHIC = "orthographic",
  66671. }
  66672. /**
  66673. * The mime-type of the image
  66674. */
  66675. const enum ImageMimeType {
  66676. /**
  66677. * JPEG Mime-type
  66678. */
  66679. JPEG = "image/jpeg",
  66680. /**
  66681. * PNG Mime-type
  66682. */
  66683. PNG = "image/png",
  66684. }
  66685. /**
  66686. * The alpha rendering mode of the material
  66687. */
  66688. const enum MaterialAlphaMode {
  66689. /**
  66690. * The alpha value is ignored and the rendered output is fully opaque
  66691. */
  66692. OPAQUE = "OPAQUE",
  66693. /**
  66694. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66695. */
  66696. MASK = "MASK",
  66697. /**
  66698. * 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)
  66699. */
  66700. BLEND = "BLEND",
  66701. }
  66702. /**
  66703. * The type of the primitives to render
  66704. */
  66705. const enum MeshPrimitiveMode {
  66706. /**
  66707. * Points
  66708. */
  66709. POINTS = 0,
  66710. /**
  66711. * Lines
  66712. */
  66713. LINES = 1,
  66714. /**
  66715. * Line Loop
  66716. */
  66717. LINE_LOOP = 2,
  66718. /**
  66719. * Line Strip
  66720. */
  66721. LINE_STRIP = 3,
  66722. /**
  66723. * Triangles
  66724. */
  66725. TRIANGLES = 4,
  66726. /**
  66727. * Triangle Strip
  66728. */
  66729. TRIANGLE_STRIP = 5,
  66730. /**
  66731. * Triangle Fan
  66732. */
  66733. TRIANGLE_FAN = 6,
  66734. }
  66735. /**
  66736. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66737. */
  66738. const enum TextureMagFilter {
  66739. /**
  66740. * Nearest
  66741. */
  66742. NEAREST = 9728,
  66743. /**
  66744. * Linear
  66745. */
  66746. LINEAR = 9729,
  66747. }
  66748. /**
  66749. * Minification filter. All valid values correspond to WebGL enums
  66750. */
  66751. const enum TextureMinFilter {
  66752. /**
  66753. * Nearest
  66754. */
  66755. NEAREST = 9728,
  66756. /**
  66757. * Linear
  66758. */
  66759. LINEAR = 9729,
  66760. /**
  66761. * Nearest Mip-Map Nearest
  66762. */
  66763. NEAREST_MIPMAP_NEAREST = 9984,
  66764. /**
  66765. * Linear Mipmap Nearest
  66766. */
  66767. LINEAR_MIPMAP_NEAREST = 9985,
  66768. /**
  66769. * Nearest Mipmap Linear
  66770. */
  66771. NEAREST_MIPMAP_LINEAR = 9986,
  66772. /**
  66773. * Linear Mipmap Linear
  66774. */
  66775. LINEAR_MIPMAP_LINEAR = 9987,
  66776. }
  66777. /**
  66778. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66779. */
  66780. const enum TextureWrapMode {
  66781. /**
  66782. * Clamp to Edge
  66783. */
  66784. CLAMP_TO_EDGE = 33071,
  66785. /**
  66786. * Mirrored Repeat
  66787. */
  66788. MIRRORED_REPEAT = 33648,
  66789. /**
  66790. * Repeat
  66791. */
  66792. REPEAT = 10497,
  66793. }
  66794. /**
  66795. * glTF Property
  66796. */
  66797. interface IProperty {
  66798. /**
  66799. * Dictionary object with extension-specific objects
  66800. */
  66801. extensions?: {
  66802. [key: string]: any;
  66803. };
  66804. /**
  66805. * Application-Specific data
  66806. */
  66807. extras?: any;
  66808. }
  66809. /**
  66810. * glTF Child of Root Property
  66811. */
  66812. interface IChildRootProperty extends IProperty {
  66813. /**
  66814. * The user-defined name of this object
  66815. */
  66816. name?: string;
  66817. }
  66818. /**
  66819. * Indices of those attributes that deviate from their initialization value
  66820. */
  66821. interface IAccessorSparseIndices extends IProperty {
  66822. /**
  66823. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66824. */
  66825. bufferView: number;
  66826. /**
  66827. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66828. */
  66829. byteOffset?: number;
  66830. /**
  66831. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  66832. */
  66833. componentType: AccessorComponentType;
  66834. }
  66835. /**
  66836. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  66837. */
  66838. interface IAccessorSparseValues extends IProperty {
  66839. /**
  66840. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  66841. */
  66842. bufferView: number;
  66843. /**
  66844. * The offset relative to the start of the bufferView in bytes. Must be aligned
  66845. */
  66846. byteOffset?: number;
  66847. }
  66848. /**
  66849. * Sparse storage of attributes that deviate from their initialization value
  66850. */
  66851. interface IAccessorSparse extends IProperty {
  66852. /**
  66853. * The number of attributes encoded in this sparse accessor
  66854. */
  66855. count: number;
  66856. /**
  66857. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  66858. */
  66859. indices: IAccessorSparseIndices;
  66860. /**
  66861. * 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
  66862. */
  66863. values: IAccessorSparseValues;
  66864. }
  66865. /**
  66866. * 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
  66867. */
  66868. interface IAccessor extends IChildRootProperty {
  66869. /**
  66870. * The index of the bufferview
  66871. */
  66872. bufferView?: number;
  66873. /**
  66874. * The offset relative to the start of the bufferView in bytes
  66875. */
  66876. byteOffset?: number;
  66877. /**
  66878. * The datatype of components in the attribute
  66879. */
  66880. componentType: AccessorComponentType;
  66881. /**
  66882. * Specifies whether integer data values should be normalized
  66883. */
  66884. normalized?: boolean;
  66885. /**
  66886. * The number of attributes referenced by this accessor
  66887. */
  66888. count: number;
  66889. /**
  66890. * Specifies if the attribute is a scalar, vector, or matrix
  66891. */
  66892. type: AccessorType;
  66893. /**
  66894. * Maximum value of each component in this attribute
  66895. */
  66896. max?: number[];
  66897. /**
  66898. * Minimum value of each component in this attribute
  66899. */
  66900. min?: number[];
  66901. /**
  66902. * Sparse storage of attributes that deviate from their initialization value
  66903. */
  66904. sparse?: IAccessorSparse;
  66905. }
  66906. /**
  66907. * Targets an animation's sampler at a node's property
  66908. */
  66909. interface IAnimationChannel extends IProperty {
  66910. /**
  66911. * The index of a sampler in this animation used to compute the value for the target
  66912. */
  66913. sampler: number;
  66914. /**
  66915. * The index of the node and TRS property to target
  66916. */
  66917. target: IAnimationChannelTarget;
  66918. }
  66919. /**
  66920. * The index of the node and TRS property that an animation channel targets
  66921. */
  66922. interface IAnimationChannelTarget extends IProperty {
  66923. /**
  66924. * The index of the node to target
  66925. */
  66926. node: number;
  66927. /**
  66928. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66929. */
  66930. path: AnimationChannelTargetPath;
  66931. }
  66932. /**
  66933. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66934. */
  66935. interface IAnimationSampler extends IProperty {
  66936. /**
  66937. * The index of an accessor containing keyframe input values, e.g., time
  66938. */
  66939. input: number;
  66940. /**
  66941. * Interpolation algorithm
  66942. */
  66943. interpolation?: AnimationSamplerInterpolation;
  66944. /**
  66945. * The index of an accessor, containing keyframe output values
  66946. */
  66947. output: number;
  66948. }
  66949. /**
  66950. * A keyframe animation
  66951. */
  66952. interface IAnimation extends IChildRootProperty {
  66953. /**
  66954. * An array of channels, each of which targets an animation's sampler at a node's property
  66955. */
  66956. channels: IAnimationChannel[];
  66957. /**
  66958. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66959. */
  66960. samplers: IAnimationSampler[];
  66961. }
  66962. /**
  66963. * Metadata about the glTF asset
  66964. */
  66965. interface IAsset extends IChildRootProperty {
  66966. /**
  66967. * A copyright message suitable for display to credit the content creator
  66968. */
  66969. copyright?: string;
  66970. /**
  66971. * Tool that generated this glTF model. Useful for debugging
  66972. */
  66973. generator?: string;
  66974. /**
  66975. * The glTF version that this asset targets
  66976. */
  66977. version: string;
  66978. /**
  66979. * The minimum glTF version that this asset targets
  66980. */
  66981. minVersion?: string;
  66982. }
  66983. /**
  66984. * A buffer points to binary geometry, animation, or skins
  66985. */
  66986. interface IBuffer extends IChildRootProperty {
  66987. /**
  66988. * 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
  66989. */
  66990. uri?: string;
  66991. /**
  66992. * The length of the buffer in bytes
  66993. */
  66994. byteLength: number;
  66995. }
  66996. /**
  66997. * A view into a buffer generally representing a subset of the buffer
  66998. */
  66999. interface IBufferView extends IChildRootProperty {
  67000. /**
  67001. * The index of the buffer
  67002. */
  67003. buffer: number;
  67004. /**
  67005. * The offset into the buffer in bytes
  67006. */
  67007. byteOffset?: number;
  67008. /**
  67009. * The lenth of the bufferView in bytes
  67010. */
  67011. byteLength: number;
  67012. /**
  67013. * The stride, in bytes
  67014. */
  67015. byteStride?: number;
  67016. }
  67017. /**
  67018. * An orthographic camera containing properties to create an orthographic projection matrix
  67019. */
  67020. interface ICameraOrthographic extends IProperty {
  67021. /**
  67022. * The floating-point horizontal magnification of the view. Must not be zero
  67023. */
  67024. xmag: number;
  67025. /**
  67026. * The floating-point vertical magnification of the view. Must not be zero
  67027. */
  67028. ymag: number;
  67029. /**
  67030. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67031. */
  67032. zfar: number;
  67033. /**
  67034. * The floating-point distance to the near clipping plane
  67035. */
  67036. znear: number;
  67037. }
  67038. /**
  67039. * A perspective camera containing properties to create a perspective projection matrix
  67040. */
  67041. interface ICameraPerspective extends IProperty {
  67042. /**
  67043. * The floating-point aspect ratio of the field of view
  67044. */
  67045. aspectRatio?: number;
  67046. /**
  67047. * The floating-point vertical field of view in radians
  67048. */
  67049. yfov: number;
  67050. /**
  67051. * The floating-point distance to the far clipping plane
  67052. */
  67053. zfar?: number;
  67054. /**
  67055. * The floating-point distance to the near clipping plane
  67056. */
  67057. znear: number;
  67058. }
  67059. /**
  67060. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67061. */
  67062. interface ICamera extends IChildRootProperty {
  67063. /**
  67064. * An orthographic camera containing properties to create an orthographic projection matrix
  67065. */
  67066. orthographic?: ICameraOrthographic;
  67067. /**
  67068. * A perspective camera containing properties to create a perspective projection matrix
  67069. */
  67070. perspective?: ICameraPerspective;
  67071. /**
  67072. * Specifies if the camera uses a perspective or orthographic projection
  67073. */
  67074. type: CameraType;
  67075. }
  67076. /**
  67077. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67078. */
  67079. interface IImage extends IChildRootProperty {
  67080. /**
  67081. * 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
  67082. */
  67083. uri?: string;
  67084. /**
  67085. * The image's MIME type
  67086. */
  67087. mimeType?: ImageMimeType;
  67088. /**
  67089. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67090. */
  67091. bufferView?: number;
  67092. }
  67093. /**
  67094. * Material Normal Texture Info
  67095. */
  67096. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67097. /**
  67098. * The scalar multiplier applied to each normal vector of the normal texture
  67099. */
  67100. scale?: number;
  67101. }
  67102. /**
  67103. * Material Occlusion Texture Info
  67104. */
  67105. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67106. /**
  67107. * A scalar multiplier controlling the amount of occlusion applied
  67108. */
  67109. strength?: number;
  67110. }
  67111. /**
  67112. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67113. */
  67114. interface IMaterialPbrMetallicRoughness {
  67115. /**
  67116. * The material's base color factor
  67117. */
  67118. baseColorFactor?: number[];
  67119. /**
  67120. * The base color texture
  67121. */
  67122. baseColorTexture?: ITextureInfo;
  67123. /**
  67124. * The metalness of the material
  67125. */
  67126. metallicFactor?: number;
  67127. /**
  67128. * The roughness of the material
  67129. */
  67130. roughnessFactor?: number;
  67131. /**
  67132. * The metallic-roughness texture
  67133. */
  67134. metallicRoughnessTexture?: ITextureInfo;
  67135. }
  67136. /**
  67137. * The material appearance of a primitive
  67138. */
  67139. interface IMaterial extends IChildRootProperty {
  67140. /**
  67141. * 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
  67142. */
  67143. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67144. /**
  67145. * The normal map texture
  67146. */
  67147. normalTexture?: IMaterialNormalTextureInfo;
  67148. /**
  67149. * The occlusion map texture
  67150. */
  67151. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67152. /**
  67153. * The emissive map texture
  67154. */
  67155. emissiveTexture?: ITextureInfo;
  67156. /**
  67157. * 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
  67158. */
  67159. emissiveFactor?: number[];
  67160. /**
  67161. * The alpha rendering mode of the material
  67162. */
  67163. alphaMode?: MaterialAlphaMode;
  67164. /**
  67165. * The alpha cutoff value of the material
  67166. */
  67167. alphaCutoff?: number;
  67168. /**
  67169. * Specifies whether the material is double sided
  67170. */
  67171. doubleSided?: boolean;
  67172. }
  67173. /**
  67174. * Geometry to be rendered with the given material
  67175. */
  67176. interface IMeshPrimitive extends IProperty {
  67177. /**
  67178. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67179. */
  67180. attributes: {
  67181. [name: string]: number;
  67182. };
  67183. /**
  67184. * The index of the accessor that contains the indices
  67185. */
  67186. indices?: number;
  67187. /**
  67188. * The index of the material to apply to this primitive when rendering
  67189. */
  67190. material?: number;
  67191. /**
  67192. * The type of primitives to render. All valid values correspond to WebGL enums
  67193. */
  67194. mode?: MeshPrimitiveMode;
  67195. /**
  67196. * 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
  67197. */
  67198. targets?: {
  67199. [name: string]: number;
  67200. }[];
  67201. }
  67202. /**
  67203. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67204. */
  67205. interface IMesh extends IChildRootProperty {
  67206. /**
  67207. * An array of primitives, each defining geometry to be rendered with a material
  67208. */
  67209. primitives: IMeshPrimitive[];
  67210. /**
  67211. * Array of weights to be applied to the Morph Targets
  67212. */
  67213. weights?: number[];
  67214. }
  67215. /**
  67216. * A node in the node hierarchy
  67217. */
  67218. interface INode extends IChildRootProperty {
  67219. /**
  67220. * The index of the camera referenced by this node
  67221. */
  67222. camera?: number;
  67223. /**
  67224. * The indices of this node's children
  67225. */
  67226. children?: number[];
  67227. /**
  67228. * The index of the skin referenced by this node
  67229. */
  67230. skin?: number;
  67231. /**
  67232. * A floating-point 4x4 transformation matrix stored in column-major order
  67233. */
  67234. matrix?: number[];
  67235. /**
  67236. * The index of the mesh in this node
  67237. */
  67238. mesh?: number;
  67239. /**
  67240. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67241. */
  67242. rotation?: number[];
  67243. /**
  67244. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67245. */
  67246. scale?: number[];
  67247. /**
  67248. * The node's translation along the x, y, and z axes
  67249. */
  67250. translation?: number[];
  67251. /**
  67252. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67253. */
  67254. weights?: number[];
  67255. }
  67256. /**
  67257. * Texture sampler properties for filtering and wrapping modes
  67258. */
  67259. interface ISampler extends IChildRootProperty {
  67260. /**
  67261. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67262. */
  67263. magFilter?: TextureMagFilter;
  67264. /**
  67265. * Minification filter. All valid values correspond to WebGL enums
  67266. */
  67267. minFilter?: TextureMinFilter;
  67268. /**
  67269. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67270. */
  67271. wrapS?: TextureWrapMode;
  67272. /**
  67273. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67274. */
  67275. wrapT?: TextureWrapMode;
  67276. }
  67277. /**
  67278. * The root nodes of a scene
  67279. */
  67280. interface IScene extends IChildRootProperty {
  67281. /**
  67282. * The indices of each root node
  67283. */
  67284. nodes: number[];
  67285. }
  67286. /**
  67287. * Joints and matrices defining a skin
  67288. */
  67289. interface ISkin extends IChildRootProperty {
  67290. /**
  67291. * 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
  67292. */
  67293. inverseBindMatrices?: number;
  67294. /**
  67295. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67296. */
  67297. skeleton?: number;
  67298. /**
  67299. * 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)
  67300. */
  67301. joints: number[];
  67302. }
  67303. /**
  67304. * A texture and its sampler
  67305. */
  67306. interface ITexture extends IChildRootProperty {
  67307. /**
  67308. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67309. */
  67310. sampler?: number;
  67311. /**
  67312. * The index of the image used by this texture
  67313. */
  67314. source: number;
  67315. }
  67316. /**
  67317. * Reference to a texture
  67318. */
  67319. interface ITextureInfo extends IProperty {
  67320. /**
  67321. * The index of the texture
  67322. */
  67323. index: number;
  67324. /**
  67325. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67326. */
  67327. texCoord?: number;
  67328. }
  67329. /**
  67330. * The root object for a glTF asset
  67331. */
  67332. interface IGLTF extends IProperty {
  67333. /**
  67334. * An array of accessors. An accessor is a typed view into a bufferView
  67335. */
  67336. accessors?: IAccessor[];
  67337. /**
  67338. * An array of keyframe animations
  67339. */
  67340. animations?: IAnimation[];
  67341. /**
  67342. * Metadata about the glTF asset
  67343. */
  67344. asset: IAsset;
  67345. /**
  67346. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67347. */
  67348. buffers?: IBuffer[];
  67349. /**
  67350. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67351. */
  67352. bufferViews?: IBufferView[];
  67353. /**
  67354. * An array of cameras
  67355. */
  67356. cameras?: ICamera[];
  67357. /**
  67358. * Names of glTF extensions used somewhere in this asset
  67359. */
  67360. extensionsUsed?: string[];
  67361. /**
  67362. * Names of glTF extensions required to properly load this asset
  67363. */
  67364. extensionsRequired?: string[];
  67365. /**
  67366. * An array of images. An image defines data used to create a texture
  67367. */
  67368. images?: IImage[];
  67369. /**
  67370. * An array of materials. A material defines the appearance of a primitive
  67371. */
  67372. materials?: IMaterial[];
  67373. /**
  67374. * An array of meshes. A mesh is a set of primitives to be rendered
  67375. */
  67376. meshes?: IMesh[];
  67377. /**
  67378. * An array of nodes
  67379. */
  67380. nodes?: INode[];
  67381. /**
  67382. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67383. */
  67384. samplers?: ISampler[];
  67385. /**
  67386. * The index of the default scene
  67387. */
  67388. scene?: number;
  67389. /**
  67390. * An array of scenes
  67391. */
  67392. scenes?: IScene[];
  67393. /**
  67394. * An array of skins. A skin is defined by joints and matrices
  67395. */
  67396. skins?: ISkin[];
  67397. /**
  67398. * An array of textures
  67399. */
  67400. textures?: ITexture[];
  67401. }
  67402. /**
  67403. * The glTF validation results
  67404. */
  67405. interface IGLTFValidationResults {
  67406. info: {
  67407. generator: string;
  67408. hasAnimations: boolean;
  67409. hasDefaultScene: boolean;
  67410. hasMaterials: boolean;
  67411. hasMorphTargets: boolean;
  67412. hasSkins: boolean;
  67413. hasTextures: boolean;
  67414. maxAttributesUsed: number;
  67415. primitivesCount: number
  67416. };
  67417. issues: {
  67418. messages: Array<string>;
  67419. numErrors: number;
  67420. numHints: number;
  67421. numInfos: number;
  67422. numWarnings: number;
  67423. truncated: boolean
  67424. };
  67425. mimeType: string;
  67426. uri: string;
  67427. validatedAt: string;
  67428. validatorVersion: string;
  67429. }
  67430. /**
  67431. * The glTF validation options
  67432. */
  67433. interface IGLTFValidationOptions {
  67434. uri?: string;
  67435. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67436. validateAccessorData?: boolean;
  67437. maxIssues?: number;
  67438. ignoredIssues?: Array<string>;
  67439. severityOverrides?: Object;
  67440. }
  67441. /**
  67442. * The glTF validator object
  67443. */
  67444. interface IGLTFValidator {
  67445. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67446. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67447. }
  67448. }
  67449. declare module BABYLON {
  67450. /** @hidden */
  67451. export var cellPixelShader: {
  67452. name: string;
  67453. shader: string;
  67454. };
  67455. }
  67456. declare module BABYLON {
  67457. /** @hidden */
  67458. export var cellVertexShader: {
  67459. name: string;
  67460. shader: string;
  67461. };
  67462. }
  67463. declare module BABYLON {
  67464. export class CellMaterial extends BABYLON.PushMaterial {
  67465. private _diffuseTexture;
  67466. diffuseTexture: BABYLON.BaseTexture;
  67467. diffuseColor: BABYLON.Color3;
  67468. _computeHighLevel: boolean;
  67469. computeHighLevel: boolean;
  67470. private _disableLighting;
  67471. disableLighting: boolean;
  67472. private _maxSimultaneousLights;
  67473. maxSimultaneousLights: number;
  67474. private _renderId;
  67475. constructor(name: string, scene: BABYLON.Scene);
  67476. needAlphaBlending(): boolean;
  67477. needAlphaTesting(): boolean;
  67478. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67479. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67480. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67481. getAnimatables(): BABYLON.IAnimatable[];
  67482. getActiveTextures(): BABYLON.BaseTexture[];
  67483. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67484. dispose(forceDisposeEffect?: boolean): void;
  67485. getClassName(): string;
  67486. clone(name: string): CellMaterial;
  67487. serialize(): any;
  67488. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67489. }
  67490. }
  67491. declare module BABYLON {
  67492. export class CustomShaderStructure {
  67493. FragmentStore: string;
  67494. VertexStore: string;
  67495. constructor();
  67496. }
  67497. export class ShaderSpecialParts {
  67498. constructor();
  67499. Fragment_Begin: string;
  67500. Fragment_Definitions: string;
  67501. Fragment_MainBegin: string;
  67502. Fragment_Custom_Diffuse: string;
  67503. Fragment_Before_Lights: string;
  67504. Fragment_Before_Fog: string;
  67505. Fragment_Custom_Alpha: string;
  67506. Fragment_Before_FragColor: string;
  67507. Vertex_Begin: string;
  67508. Vertex_Definitions: string;
  67509. Vertex_MainBegin: string;
  67510. Vertex_Before_PositionUpdated: string;
  67511. Vertex_Before_NormalUpdated: string;
  67512. Vertex_MainEnd: string;
  67513. }
  67514. export class CustomMaterial extends BABYLON.StandardMaterial {
  67515. static ShaderIndexer: number;
  67516. CustomParts: ShaderSpecialParts;
  67517. _isCreatedShader: boolean;
  67518. _createdShaderName: string;
  67519. _customUniform: string[];
  67520. _newUniforms: string[];
  67521. _newUniformInstances: any[];
  67522. _newSamplerInstances: BABYLON.Texture[];
  67523. FragmentShader: string;
  67524. VertexShader: string;
  67525. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67526. ReviewUniform(name: string, arr: string[]): string[];
  67527. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67528. constructor(name: string, scene: BABYLON.Scene);
  67529. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67530. Fragment_Begin(shaderPart: string): CustomMaterial;
  67531. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67532. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67533. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67534. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67535. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67536. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67537. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67538. Vertex_Begin(shaderPart: string): CustomMaterial;
  67539. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67540. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67541. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67542. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67543. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67544. }
  67545. }
  67546. declare module BABYLON {
  67547. export class ShaderAlebdoParts {
  67548. constructor();
  67549. Fragment_Begin: string;
  67550. Fragment_Definitions: string;
  67551. Fragment_MainBegin: string;
  67552. Fragment_Custom_Albedo: string;
  67553. Fragment_Before_Lights: string;
  67554. Fragment_Custom_MetallicRoughness: string;
  67555. Fragment_Custom_MicroSurface: string;
  67556. Fragment_Before_Fog: string;
  67557. Fragment_Custom_Alpha: string;
  67558. Fragment_Before_FragColor: string;
  67559. Vertex_Begin: string;
  67560. Vertex_Definitions: string;
  67561. Vertex_MainBegin: string;
  67562. Vertex_Before_PositionUpdated: string;
  67563. Vertex_Before_NormalUpdated: string;
  67564. Vertex_MainEnd: string;
  67565. }
  67566. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67567. static ShaderIndexer: number;
  67568. CustomParts: ShaderAlebdoParts;
  67569. _isCreatedShader: boolean;
  67570. _createdShaderName: string;
  67571. _customUniform: string[];
  67572. _newUniforms: string[];
  67573. _newUniformInstances: any[];
  67574. _newSamplerInstances: BABYLON.Texture[];
  67575. FragmentShader: string;
  67576. VertexShader: string;
  67577. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67578. ReviewUniform(name: string, arr: string[]): string[];
  67579. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67580. constructor(name: string, scene: BABYLON.Scene);
  67581. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67582. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67583. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67584. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67585. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67586. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67587. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67588. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67589. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67590. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67591. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67592. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67593. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67594. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67595. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67596. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67597. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67598. }
  67599. }
  67600. declare module BABYLON {
  67601. /** @hidden */
  67602. export var firePixelShader: {
  67603. name: string;
  67604. shader: string;
  67605. };
  67606. }
  67607. declare module BABYLON {
  67608. /** @hidden */
  67609. export var fireVertexShader: {
  67610. name: string;
  67611. shader: string;
  67612. };
  67613. }
  67614. declare module BABYLON {
  67615. export class FireMaterial extends BABYLON.PushMaterial {
  67616. private _diffuseTexture;
  67617. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67618. private _distortionTexture;
  67619. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67620. private _opacityTexture;
  67621. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67622. diffuseColor: BABYLON.Color3;
  67623. speed: number;
  67624. private _scaledDiffuse;
  67625. private _renderId;
  67626. private _lastTime;
  67627. constructor(name: string, scene: BABYLON.Scene);
  67628. needAlphaBlending(): boolean;
  67629. needAlphaTesting(): boolean;
  67630. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67631. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67632. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67633. getAnimatables(): BABYLON.IAnimatable[];
  67634. getActiveTextures(): BABYLON.BaseTexture[];
  67635. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67636. getClassName(): string;
  67637. dispose(forceDisposeEffect?: boolean): void;
  67638. clone(name: string): FireMaterial;
  67639. serialize(): any;
  67640. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67641. }
  67642. }
  67643. declare module BABYLON {
  67644. /** @hidden */
  67645. export var furPixelShader: {
  67646. name: string;
  67647. shader: string;
  67648. };
  67649. }
  67650. declare module BABYLON {
  67651. /** @hidden */
  67652. export var furVertexShader: {
  67653. name: string;
  67654. shader: string;
  67655. };
  67656. }
  67657. declare module BABYLON {
  67658. export class FurMaterial extends BABYLON.PushMaterial {
  67659. private _diffuseTexture;
  67660. diffuseTexture: BABYLON.BaseTexture;
  67661. private _heightTexture;
  67662. heightTexture: BABYLON.BaseTexture;
  67663. diffuseColor: BABYLON.Color3;
  67664. furLength: number;
  67665. furAngle: number;
  67666. furColor: BABYLON.Color3;
  67667. furOffset: number;
  67668. furSpacing: number;
  67669. furGravity: BABYLON.Vector3;
  67670. furSpeed: number;
  67671. furDensity: number;
  67672. furOcclusion: number;
  67673. furTexture: BABYLON.DynamicTexture;
  67674. private _disableLighting;
  67675. disableLighting: boolean;
  67676. private _maxSimultaneousLights;
  67677. maxSimultaneousLights: number;
  67678. highLevelFur: boolean;
  67679. _meshes: BABYLON.AbstractMesh[];
  67680. private _renderId;
  67681. private _furTime;
  67682. constructor(name: string, scene: BABYLON.Scene);
  67683. furTime: number;
  67684. needAlphaBlending(): boolean;
  67685. needAlphaTesting(): boolean;
  67686. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67687. updateFur(): void;
  67688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67690. getAnimatables(): BABYLON.IAnimatable[];
  67691. getActiveTextures(): BABYLON.BaseTexture[];
  67692. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67693. dispose(forceDisposeEffect?: boolean): void;
  67694. clone(name: string): FurMaterial;
  67695. serialize(): any;
  67696. getClassName(): string;
  67697. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67698. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67699. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /** @hidden */
  67704. export var gradientPixelShader: {
  67705. name: string;
  67706. shader: string;
  67707. };
  67708. }
  67709. declare module BABYLON {
  67710. /** @hidden */
  67711. export var gradientVertexShader: {
  67712. name: string;
  67713. shader: string;
  67714. };
  67715. }
  67716. declare module BABYLON {
  67717. export class GradientMaterial extends BABYLON.PushMaterial {
  67718. private _maxSimultaneousLights;
  67719. maxSimultaneousLights: number;
  67720. topColor: BABYLON.Color3;
  67721. topColorAlpha: number;
  67722. bottomColor: BABYLON.Color3;
  67723. bottomColorAlpha: number;
  67724. offset: number;
  67725. scale: number;
  67726. smoothness: number;
  67727. private _disableLighting;
  67728. disableLighting: boolean;
  67729. private _renderId;
  67730. constructor(name: string, scene: BABYLON.Scene);
  67731. needAlphaBlending(): boolean;
  67732. needAlphaTesting(): boolean;
  67733. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67734. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67735. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67736. getAnimatables(): BABYLON.IAnimatable[];
  67737. dispose(forceDisposeEffect?: boolean): void;
  67738. clone(name: string): GradientMaterial;
  67739. serialize(): any;
  67740. getClassName(): string;
  67741. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /** @hidden */
  67746. export var gridPixelShader: {
  67747. name: string;
  67748. shader: string;
  67749. };
  67750. }
  67751. declare module BABYLON {
  67752. /** @hidden */
  67753. export var gridVertexShader: {
  67754. name: string;
  67755. shader: string;
  67756. };
  67757. }
  67758. declare module BABYLON {
  67759. /**
  67760. * The grid materials allows you to wrap any shape with a grid.
  67761. * Colors are customizable.
  67762. */
  67763. export class GridMaterial extends BABYLON.PushMaterial {
  67764. /**
  67765. * Main color of the grid (e.g. between lines)
  67766. */
  67767. mainColor: BABYLON.Color3;
  67768. /**
  67769. * Color of the grid lines.
  67770. */
  67771. lineColor: BABYLON.Color3;
  67772. /**
  67773. * The scale of the grid compared to unit.
  67774. */
  67775. gridRatio: number;
  67776. /**
  67777. * Allows setting an offset for the grid lines.
  67778. */
  67779. gridOffset: BABYLON.Vector3;
  67780. /**
  67781. * The frequency of thicker lines.
  67782. */
  67783. majorUnitFrequency: number;
  67784. /**
  67785. * The visibility of minor units in the grid.
  67786. */
  67787. minorUnitVisibility: number;
  67788. /**
  67789. * The grid opacity outside of the lines.
  67790. */
  67791. opacity: number;
  67792. /**
  67793. * Determine RBG output is premultiplied by alpha value.
  67794. */
  67795. preMultiplyAlpha: boolean;
  67796. private _opacityTexture;
  67797. opacityTexture: BABYLON.BaseTexture;
  67798. private _gridControl;
  67799. private _renderId;
  67800. /**
  67801. * constructor
  67802. * @param name The name given to the material in order to identify it afterwards.
  67803. * @param scene The scene the material is used in.
  67804. */
  67805. constructor(name: string, scene: BABYLON.Scene);
  67806. /**
  67807. * Returns wehter or not the grid requires alpha blending.
  67808. */
  67809. needAlphaBlending(): boolean;
  67810. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67811. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67812. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67813. /**
  67814. * Dispose the material and its associated resources.
  67815. * @param forceDisposeEffect will also dispose the used effect when true
  67816. */
  67817. dispose(forceDisposeEffect?: boolean): void;
  67818. clone(name: string): GridMaterial;
  67819. serialize(): any;
  67820. getClassName(): string;
  67821. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /** @hidden */
  67826. export var lavaPixelShader: {
  67827. name: string;
  67828. shader: string;
  67829. };
  67830. }
  67831. declare module BABYLON {
  67832. /** @hidden */
  67833. export var lavaVertexShader: {
  67834. name: string;
  67835. shader: string;
  67836. };
  67837. }
  67838. declare module BABYLON {
  67839. export class LavaMaterial extends BABYLON.PushMaterial {
  67840. private _diffuseTexture;
  67841. diffuseTexture: BABYLON.BaseTexture;
  67842. noiseTexture: BABYLON.BaseTexture;
  67843. fogColor: BABYLON.Color3;
  67844. speed: number;
  67845. movingSpeed: number;
  67846. lowFrequencySpeed: number;
  67847. fogDensity: number;
  67848. private _lastTime;
  67849. diffuseColor: BABYLON.Color3;
  67850. private _disableLighting;
  67851. disableLighting: boolean;
  67852. private _unlit;
  67853. unlit: boolean;
  67854. private _maxSimultaneousLights;
  67855. maxSimultaneousLights: number;
  67856. private _scaledDiffuse;
  67857. private _renderId;
  67858. constructor(name: string, scene: BABYLON.Scene);
  67859. needAlphaBlending(): boolean;
  67860. needAlphaTesting(): boolean;
  67861. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67862. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67863. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67864. getAnimatables(): BABYLON.IAnimatable[];
  67865. getActiveTextures(): BABYLON.BaseTexture[];
  67866. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67867. dispose(forceDisposeEffect?: boolean): void;
  67868. clone(name: string): LavaMaterial;
  67869. serialize(): any;
  67870. getClassName(): string;
  67871. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67872. }
  67873. }
  67874. declare module BABYLON {
  67875. /** @hidden */
  67876. export var mixPixelShader: {
  67877. name: string;
  67878. shader: string;
  67879. };
  67880. }
  67881. declare module BABYLON {
  67882. /** @hidden */
  67883. export var mixVertexShader: {
  67884. name: string;
  67885. shader: string;
  67886. };
  67887. }
  67888. declare module BABYLON {
  67889. export class MixMaterial extends BABYLON.PushMaterial {
  67890. /**
  67891. * Mix textures
  67892. */
  67893. private _mixTexture1;
  67894. mixTexture1: BABYLON.BaseTexture;
  67895. private _mixTexture2;
  67896. mixTexture2: BABYLON.BaseTexture;
  67897. /**
  67898. * Diffuse textures
  67899. */
  67900. private _diffuseTexture1;
  67901. diffuseTexture1: BABYLON.Texture;
  67902. private _diffuseTexture2;
  67903. diffuseTexture2: BABYLON.Texture;
  67904. private _diffuseTexture3;
  67905. diffuseTexture3: BABYLON.Texture;
  67906. private _diffuseTexture4;
  67907. diffuseTexture4: BABYLON.Texture;
  67908. private _diffuseTexture5;
  67909. diffuseTexture5: BABYLON.Texture;
  67910. private _diffuseTexture6;
  67911. diffuseTexture6: BABYLON.Texture;
  67912. private _diffuseTexture7;
  67913. diffuseTexture7: BABYLON.Texture;
  67914. private _diffuseTexture8;
  67915. diffuseTexture8: BABYLON.Texture;
  67916. /**
  67917. * Uniforms
  67918. */
  67919. diffuseColor: BABYLON.Color3;
  67920. specularColor: BABYLON.Color3;
  67921. specularPower: number;
  67922. private _disableLighting;
  67923. disableLighting: boolean;
  67924. private _maxSimultaneousLights;
  67925. maxSimultaneousLights: number;
  67926. private _renderId;
  67927. constructor(name: string, scene: BABYLON.Scene);
  67928. needAlphaBlending(): boolean;
  67929. needAlphaTesting(): boolean;
  67930. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67931. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67932. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67933. getAnimatables(): BABYLON.IAnimatable[];
  67934. getActiveTextures(): BABYLON.BaseTexture[];
  67935. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67936. dispose(forceDisposeEffect?: boolean): void;
  67937. clone(name: string): MixMaterial;
  67938. serialize(): any;
  67939. getClassName(): string;
  67940. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67941. }
  67942. }
  67943. declare module BABYLON {
  67944. /** @hidden */
  67945. export var normalPixelShader: {
  67946. name: string;
  67947. shader: string;
  67948. };
  67949. }
  67950. declare module BABYLON {
  67951. /** @hidden */
  67952. export var normalVertexShader: {
  67953. name: string;
  67954. shader: string;
  67955. };
  67956. }
  67957. declare module BABYLON {
  67958. export class NormalMaterial extends BABYLON.PushMaterial {
  67959. private _diffuseTexture;
  67960. diffuseTexture: BABYLON.BaseTexture;
  67961. diffuseColor: BABYLON.Color3;
  67962. private _disableLighting;
  67963. disableLighting: boolean;
  67964. private _maxSimultaneousLights;
  67965. maxSimultaneousLights: number;
  67966. private _renderId;
  67967. constructor(name: string, scene: BABYLON.Scene);
  67968. needAlphaBlending(): boolean;
  67969. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67970. needAlphaTesting(): boolean;
  67971. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67972. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67973. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67974. getAnimatables(): BABYLON.IAnimatable[];
  67975. getActiveTextures(): BABYLON.BaseTexture[];
  67976. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67977. dispose(forceDisposeEffect?: boolean): void;
  67978. clone(name: string): NormalMaterial;
  67979. serialize(): any;
  67980. getClassName(): string;
  67981. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export var shadowOnlyPixelShader: {
  67987. name: string;
  67988. shader: string;
  67989. };
  67990. }
  67991. declare module BABYLON {
  67992. /** @hidden */
  67993. export var shadowOnlyVertexShader: {
  67994. name: string;
  67995. shader: string;
  67996. };
  67997. }
  67998. declare module BABYLON {
  67999. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68000. private _renderId;
  68001. private _activeLight;
  68002. constructor(name: string, scene: BABYLON.Scene);
  68003. shadowColor: BABYLON.Color3;
  68004. needAlphaBlending(): boolean;
  68005. needAlphaTesting(): boolean;
  68006. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68007. activeLight: BABYLON.IShadowLight;
  68008. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68009. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68010. clone(name: string): ShadowOnlyMaterial;
  68011. serialize(): any;
  68012. getClassName(): string;
  68013. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68014. }
  68015. }
  68016. declare module BABYLON {
  68017. /** @hidden */
  68018. export var simplePixelShader: {
  68019. name: string;
  68020. shader: string;
  68021. };
  68022. }
  68023. declare module BABYLON {
  68024. /** @hidden */
  68025. export var simpleVertexShader: {
  68026. name: string;
  68027. shader: string;
  68028. };
  68029. }
  68030. declare module BABYLON {
  68031. export class SimpleMaterial extends BABYLON.PushMaterial {
  68032. private _diffuseTexture;
  68033. diffuseTexture: BABYLON.BaseTexture;
  68034. diffuseColor: BABYLON.Color3;
  68035. private _disableLighting;
  68036. disableLighting: boolean;
  68037. private _maxSimultaneousLights;
  68038. maxSimultaneousLights: number;
  68039. private _renderId;
  68040. constructor(name: string, scene: BABYLON.Scene);
  68041. needAlphaBlending(): boolean;
  68042. needAlphaTesting(): boolean;
  68043. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68044. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68045. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68046. getAnimatables(): BABYLON.IAnimatable[];
  68047. getActiveTextures(): BABYLON.BaseTexture[];
  68048. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68049. dispose(forceDisposeEffect?: boolean): void;
  68050. clone(name: string): SimpleMaterial;
  68051. serialize(): any;
  68052. getClassName(): string;
  68053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68054. }
  68055. }
  68056. declare module BABYLON {
  68057. /** @hidden */
  68058. export var skyPixelShader: {
  68059. name: string;
  68060. shader: string;
  68061. };
  68062. }
  68063. declare module BABYLON {
  68064. /** @hidden */
  68065. export var skyVertexShader: {
  68066. name: string;
  68067. shader: string;
  68068. };
  68069. }
  68070. declare module BABYLON {
  68071. /**
  68072. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68073. * @see https://doc.babylonjs.com/extensions/sky
  68074. */
  68075. export class SkyMaterial extends BABYLON.PushMaterial {
  68076. /**
  68077. * Defines the overall luminance of sky in interval ]0, 1[.
  68078. */
  68079. luminance: number;
  68080. /**
  68081. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68082. */
  68083. turbidity: number;
  68084. /**
  68085. * Defines the sky appearance (light intensity).
  68086. */
  68087. rayleigh: number;
  68088. /**
  68089. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68090. */
  68091. mieCoefficient: number;
  68092. /**
  68093. * Defines the amount of haze particles following the Mie scattering theory.
  68094. */
  68095. mieDirectionalG: number;
  68096. /**
  68097. * Defines the distance of the sun according to the active scene camera.
  68098. */
  68099. distance: number;
  68100. /**
  68101. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68102. * "inclined".
  68103. */
  68104. inclination: number;
  68105. /**
  68106. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68107. * an object direction and a reference direction.
  68108. */
  68109. azimuth: number;
  68110. /**
  68111. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68112. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68113. */
  68114. sunPosition: BABYLON.Vector3;
  68115. /**
  68116. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68117. * .sunPosition property.
  68118. */
  68119. useSunPosition: boolean;
  68120. /**
  68121. * Defines an offset vector used to get a horizon offset.
  68122. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68123. */
  68124. cameraOffset: BABYLON.Vector3;
  68125. private _cameraPosition;
  68126. private _renderId;
  68127. /**
  68128. * Instantiates a new sky material.
  68129. * This material allows to create dynamic and texture free
  68130. * effects for skyboxes by taking care of the atmosphere state.
  68131. * @see https://doc.babylonjs.com/extensions/sky
  68132. * @param name Define the name of the material in the scene
  68133. * @param scene Define the scene the material belong to
  68134. */
  68135. constructor(name: string, scene: BABYLON.Scene);
  68136. /**
  68137. * Specifies if the material will require alpha blending
  68138. * @returns a boolean specifying if alpha blending is needed
  68139. */
  68140. needAlphaBlending(): boolean;
  68141. /**
  68142. * Specifies if this material should be rendered in alpha test mode
  68143. * @returns false as the sky material doesn't need alpha testing.
  68144. */
  68145. needAlphaTesting(): boolean;
  68146. /**
  68147. * Get the texture used for alpha test purpose.
  68148. * @returns null as the sky material has no texture.
  68149. */
  68150. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68151. /**
  68152. * Get if the submesh is ready to be used and all its information available.
  68153. * Child classes can use it to update shaders
  68154. * @param mesh defines the mesh to check
  68155. * @param subMesh defines which submesh to check
  68156. * @param useInstances specifies that instances should be used
  68157. * @returns a boolean indicating that the submesh is ready or not
  68158. */
  68159. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68160. /**
  68161. * Binds the submesh to this material by preparing the effect and shader to draw
  68162. * @param world defines the world transformation matrix
  68163. * @param mesh defines the mesh containing the submesh
  68164. * @param subMesh defines the submesh to bind the material to
  68165. */
  68166. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68167. /**
  68168. * Get the list of animatables in the material.
  68169. * @returns the list of animatables object used in the material
  68170. */
  68171. getAnimatables(): BABYLON.IAnimatable[];
  68172. /**
  68173. * Disposes the material
  68174. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68175. */
  68176. dispose(forceDisposeEffect?: boolean): void;
  68177. /**
  68178. * Makes a duplicate of the material, and gives it a new name
  68179. * @param name defines the new name for the duplicated material
  68180. * @returns the cloned material
  68181. */
  68182. clone(name: string): SkyMaterial;
  68183. /**
  68184. * Serializes this material in a JSON representation
  68185. * @returns the serialized material object
  68186. */
  68187. serialize(): any;
  68188. /**
  68189. * Gets the current class name of the material e.g. "SkyMaterial"
  68190. * Mainly use in serialization.
  68191. * @returns the class name
  68192. */
  68193. getClassName(): string;
  68194. /**
  68195. * Creates a sky material from parsed material data
  68196. * @param source defines the JSON representation of the material
  68197. * @param scene defines the hosting scene
  68198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68199. * @returns a new sky material
  68200. */
  68201. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68202. }
  68203. }
  68204. declare module BABYLON {
  68205. /** @hidden */
  68206. export var terrainPixelShader: {
  68207. name: string;
  68208. shader: string;
  68209. };
  68210. }
  68211. declare module BABYLON {
  68212. /** @hidden */
  68213. export var terrainVertexShader: {
  68214. name: string;
  68215. shader: string;
  68216. };
  68217. }
  68218. declare module BABYLON {
  68219. export class TerrainMaterial extends BABYLON.PushMaterial {
  68220. private _mixTexture;
  68221. mixTexture: BABYLON.BaseTexture;
  68222. private _diffuseTexture1;
  68223. diffuseTexture1: BABYLON.Texture;
  68224. private _diffuseTexture2;
  68225. diffuseTexture2: BABYLON.Texture;
  68226. private _diffuseTexture3;
  68227. diffuseTexture3: BABYLON.Texture;
  68228. private _bumpTexture1;
  68229. bumpTexture1: BABYLON.Texture;
  68230. private _bumpTexture2;
  68231. bumpTexture2: BABYLON.Texture;
  68232. private _bumpTexture3;
  68233. bumpTexture3: BABYLON.Texture;
  68234. diffuseColor: BABYLON.Color3;
  68235. specularColor: BABYLON.Color3;
  68236. specularPower: number;
  68237. private _disableLighting;
  68238. disableLighting: boolean;
  68239. private _maxSimultaneousLights;
  68240. maxSimultaneousLights: number;
  68241. private _renderId;
  68242. constructor(name: string, scene: BABYLON.Scene);
  68243. needAlphaBlending(): boolean;
  68244. needAlphaTesting(): boolean;
  68245. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68246. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68247. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68248. getAnimatables(): BABYLON.IAnimatable[];
  68249. getActiveTextures(): BABYLON.BaseTexture[];
  68250. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68251. dispose(forceDisposeEffect?: boolean): void;
  68252. clone(name: string): TerrainMaterial;
  68253. serialize(): any;
  68254. getClassName(): string;
  68255. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /** @hidden */
  68260. export var triplanarPixelShader: {
  68261. name: string;
  68262. shader: string;
  68263. };
  68264. }
  68265. declare module BABYLON {
  68266. /** @hidden */
  68267. export var triplanarVertexShader: {
  68268. name: string;
  68269. shader: string;
  68270. };
  68271. }
  68272. declare module BABYLON {
  68273. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68274. mixTexture: BABYLON.BaseTexture;
  68275. private _diffuseTextureX;
  68276. diffuseTextureX: BABYLON.BaseTexture;
  68277. private _diffuseTextureY;
  68278. diffuseTextureY: BABYLON.BaseTexture;
  68279. private _diffuseTextureZ;
  68280. diffuseTextureZ: BABYLON.BaseTexture;
  68281. private _normalTextureX;
  68282. normalTextureX: BABYLON.BaseTexture;
  68283. private _normalTextureY;
  68284. normalTextureY: BABYLON.BaseTexture;
  68285. private _normalTextureZ;
  68286. normalTextureZ: BABYLON.BaseTexture;
  68287. tileSize: number;
  68288. diffuseColor: BABYLON.Color3;
  68289. specularColor: BABYLON.Color3;
  68290. specularPower: number;
  68291. private _disableLighting;
  68292. disableLighting: boolean;
  68293. private _maxSimultaneousLights;
  68294. maxSimultaneousLights: number;
  68295. private _renderId;
  68296. constructor(name: string, scene: BABYLON.Scene);
  68297. needAlphaBlending(): boolean;
  68298. needAlphaTesting(): boolean;
  68299. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68302. getAnimatables(): BABYLON.IAnimatable[];
  68303. getActiveTextures(): BABYLON.BaseTexture[];
  68304. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68305. dispose(forceDisposeEffect?: boolean): void;
  68306. clone(name: string): TriPlanarMaterial;
  68307. serialize(): any;
  68308. getClassName(): string;
  68309. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68310. }
  68311. }
  68312. declare module BABYLON {
  68313. /** @hidden */
  68314. export var waterPixelShader: {
  68315. name: string;
  68316. shader: string;
  68317. };
  68318. }
  68319. declare module BABYLON {
  68320. /** @hidden */
  68321. export var waterVertexShader: {
  68322. name: string;
  68323. shader: string;
  68324. };
  68325. }
  68326. declare module BABYLON {
  68327. export class WaterMaterial extends BABYLON.PushMaterial {
  68328. renderTargetSize: BABYLON.Vector2;
  68329. private _bumpTexture;
  68330. bumpTexture: BABYLON.BaseTexture;
  68331. diffuseColor: BABYLON.Color3;
  68332. specularColor: BABYLON.Color3;
  68333. specularPower: number;
  68334. private _disableLighting;
  68335. disableLighting: boolean;
  68336. private _maxSimultaneousLights;
  68337. maxSimultaneousLights: number;
  68338. /**
  68339. * @param {number}: Represents the wind force
  68340. */
  68341. windForce: number;
  68342. /**
  68343. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68344. */
  68345. windDirection: BABYLON.Vector2;
  68346. /**
  68347. * @param {number}: Wave height, represents the height of the waves
  68348. */
  68349. waveHeight: number;
  68350. /**
  68351. * @param {number}: Bump height, represents the bump height related to the bump map
  68352. */
  68353. bumpHeight: number;
  68354. /**
  68355. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68356. */
  68357. private _bumpSuperimpose;
  68358. bumpSuperimpose: boolean;
  68359. /**
  68360. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68361. */
  68362. private _fresnelSeparate;
  68363. fresnelSeparate: boolean;
  68364. /**
  68365. * @param {boolean}: bump Waves modify the reflection.
  68366. */
  68367. private _bumpAffectsReflection;
  68368. bumpAffectsReflection: boolean;
  68369. /**
  68370. * @param {number}: The water color blended with the refraction (near)
  68371. */
  68372. waterColor: BABYLON.Color3;
  68373. /**
  68374. * @param {number}: The blend factor related to the water color
  68375. */
  68376. colorBlendFactor: number;
  68377. /**
  68378. * @param {number}: The water color blended with the reflection (far)
  68379. */
  68380. waterColor2: BABYLON.Color3;
  68381. /**
  68382. * @param {number}: The blend factor related to the water color (reflection, far)
  68383. */
  68384. colorBlendFactor2: number;
  68385. /**
  68386. * @param {number}: Represents the maximum length of a wave
  68387. */
  68388. waveLength: number;
  68389. /**
  68390. * @param {number}: Defines the waves speed
  68391. */
  68392. waveSpeed: number;
  68393. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68394. private _mesh;
  68395. private _refractionRTT;
  68396. private _reflectionRTT;
  68397. private _reflectionTransform;
  68398. private _lastTime;
  68399. private _lastDeltaTime;
  68400. private _renderId;
  68401. private _useLogarithmicDepth;
  68402. private _waitingRenderList;
  68403. /**
  68404. * Gets a boolean indicating that current material needs to register RTT
  68405. */
  68406. readonly hasRenderTargetTextures: boolean;
  68407. /**
  68408. * Constructor
  68409. */
  68410. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68411. useLogarithmicDepth: boolean;
  68412. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68413. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68414. addToRenderList(node: any): void;
  68415. enableRenderTargets(enable: boolean): void;
  68416. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68417. readonly renderTargetsEnabled: boolean;
  68418. needAlphaBlending(): boolean;
  68419. needAlphaTesting(): boolean;
  68420. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68423. private _createRenderTargets;
  68424. getAnimatables(): BABYLON.IAnimatable[];
  68425. getActiveTextures(): BABYLON.BaseTexture[];
  68426. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68427. dispose(forceDisposeEffect?: boolean): void;
  68428. clone(name: string): WaterMaterial;
  68429. serialize(): any;
  68430. getClassName(): string;
  68431. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68432. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /** @hidden */
  68437. export var asciiartPixelShader: {
  68438. name: string;
  68439. shader: string;
  68440. };
  68441. }
  68442. declare module BABYLON {
  68443. /**
  68444. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68445. *
  68446. * It basically takes care rendering the font front the given font size to a texture.
  68447. * This is used later on in the postprocess.
  68448. */
  68449. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68450. private _font;
  68451. private _text;
  68452. private _charSize;
  68453. /**
  68454. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68455. */
  68456. readonly charSize: number;
  68457. /**
  68458. * Create a new instance of the Ascii Art FontTexture class
  68459. * @param name the name of the texture
  68460. * @param font the font to use, use the W3C CSS notation
  68461. * @param text the caracter set to use in the rendering.
  68462. * @param scene the scene that owns the texture
  68463. */
  68464. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68465. /**
  68466. * Gets the max char width of a font.
  68467. * @param font the font to use, use the W3C CSS notation
  68468. * @return the max char width
  68469. */
  68470. private getFontWidth;
  68471. /**
  68472. * Gets the max char height of a font.
  68473. * @param font the font to use, use the W3C CSS notation
  68474. * @return the max char height
  68475. */
  68476. private getFontHeight;
  68477. /**
  68478. * Clones the current AsciiArtTexture.
  68479. * @return the clone of the texture.
  68480. */
  68481. clone(): AsciiArtFontTexture;
  68482. /**
  68483. * Parses a json object representing the texture and returns an instance of it.
  68484. * @param source the source JSON representation
  68485. * @param scene the scene to create the texture for
  68486. * @return the parsed texture
  68487. */
  68488. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68489. }
  68490. /**
  68491. * Option available in the Ascii Art Post Process.
  68492. */
  68493. export interface IAsciiArtPostProcessOptions {
  68494. /**
  68495. * The font to use following the w3c font definition.
  68496. */
  68497. font?: string;
  68498. /**
  68499. * The character set to use in the postprocess.
  68500. */
  68501. characterSet?: string;
  68502. /**
  68503. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68504. * This number is defined between 0 and 1;
  68505. */
  68506. mixToTile?: number;
  68507. /**
  68508. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68509. * This number is defined between 0 and 1;
  68510. */
  68511. mixToNormal?: number;
  68512. }
  68513. /**
  68514. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68515. *
  68516. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68517. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68518. */
  68519. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68520. /**
  68521. * The font texture used to render the char in the post process.
  68522. */
  68523. private _asciiArtFontTexture;
  68524. /**
  68525. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68526. * This number is defined between 0 and 1;
  68527. */
  68528. mixToTile: number;
  68529. /**
  68530. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68531. * This number is defined between 0 and 1;
  68532. */
  68533. mixToNormal: number;
  68534. /**
  68535. * Instantiates a new Ascii Art Post Process.
  68536. * @param name the name to give to the postprocess
  68537. * @camera the camera to apply the post process to.
  68538. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68539. */
  68540. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68541. }
  68542. }
  68543. declare module BABYLON {
  68544. /** @hidden */
  68545. export var digitalrainPixelShader: {
  68546. name: string;
  68547. shader: string;
  68548. };
  68549. }
  68550. declare module BABYLON {
  68551. /**
  68552. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68553. *
  68554. * It basically takes care rendering the font front the given font size to a texture.
  68555. * This is used later on in the postprocess.
  68556. */
  68557. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68558. private _font;
  68559. private _text;
  68560. private _charSize;
  68561. /**
  68562. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68563. */
  68564. readonly charSize: number;
  68565. /**
  68566. * Create a new instance of the Digital Rain FontTexture class
  68567. * @param name the name of the texture
  68568. * @param font the font to use, use the W3C CSS notation
  68569. * @param text the caracter set to use in the rendering.
  68570. * @param scene the scene that owns the texture
  68571. */
  68572. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68573. /**
  68574. * Gets the max char width of a font.
  68575. * @param font the font to use, use the W3C CSS notation
  68576. * @return the max char width
  68577. */
  68578. private getFontWidth;
  68579. /**
  68580. * Gets the max char height of a font.
  68581. * @param font the font to use, use the W3C CSS notation
  68582. * @return the max char height
  68583. */
  68584. private getFontHeight;
  68585. /**
  68586. * Clones the current DigitalRainFontTexture.
  68587. * @return the clone of the texture.
  68588. */
  68589. clone(): DigitalRainFontTexture;
  68590. /**
  68591. * Parses a json object representing the texture and returns an instance of it.
  68592. * @param source the source JSON representation
  68593. * @param scene the scene to create the texture for
  68594. * @return the parsed texture
  68595. */
  68596. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68597. }
  68598. /**
  68599. * Option available in the Digital Rain Post Process.
  68600. */
  68601. export interface IDigitalRainPostProcessOptions {
  68602. /**
  68603. * The font to use following the w3c font definition.
  68604. */
  68605. font?: string;
  68606. /**
  68607. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68608. * This number is defined between 0 and 1;
  68609. */
  68610. mixToTile?: number;
  68611. /**
  68612. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68613. * This number is defined between 0 and 1;
  68614. */
  68615. mixToNormal?: number;
  68616. }
  68617. /**
  68618. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68619. *
  68620. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68621. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68622. */
  68623. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68624. /**
  68625. * The font texture used to render the char in the post process.
  68626. */
  68627. private _digitalRainFontTexture;
  68628. /**
  68629. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68630. * This number is defined between 0 and 1;
  68631. */
  68632. mixToTile: number;
  68633. /**
  68634. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68635. * This number is defined between 0 and 1;
  68636. */
  68637. mixToNormal: number;
  68638. /**
  68639. * Instantiates a new Digital Rain Post Process.
  68640. * @param name the name to give to the postprocess
  68641. * @camera the camera to apply the post process to.
  68642. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68643. */
  68644. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68645. }
  68646. }
  68647. declare module BABYLON {
  68648. /** @hidden */
  68649. export var oceanPostProcessPixelShader: {
  68650. name: string;
  68651. shader: string;
  68652. };
  68653. }
  68654. declare module BABYLON {
  68655. /**
  68656. * Option available in the Ocean Post Process.
  68657. */
  68658. export interface IOceanPostProcessOptions {
  68659. /**
  68660. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68661. */
  68662. reflectionSize?: number | {
  68663. width: number;
  68664. height: number;
  68665. } | {
  68666. ratio: number;
  68667. };
  68668. /**
  68669. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68670. */
  68671. refractionSize?: number | {
  68672. width: number;
  68673. height: number;
  68674. } | {
  68675. ratio: number;
  68676. };
  68677. }
  68678. /**
  68679. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68680. *
  68681. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68682. * Example usage:
  68683. * var pp = new OceanPostProcess("myOcean", camera);
  68684. * pp.reflectionEnabled = true;
  68685. * pp.refractionEnabled = true;
  68686. */
  68687. export class OceanPostProcess extends BABYLON.PostProcess {
  68688. /**
  68689. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68690. */
  68691. /**
  68692. * Sets weither or not the real-time reflection is enabled on the ocean.
  68693. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68694. */
  68695. reflectionEnabled: boolean;
  68696. /**
  68697. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68698. */
  68699. /**
  68700. * Sets weither or not the real-time refraction is enabled on the ocean.
  68701. * Is set to true, the refraction render target texture will be used as refraction texture.
  68702. */
  68703. refractionEnabled: boolean;
  68704. /**
  68705. * Gets wether or not the post-processes is supported by the running hardware.
  68706. * This requires draw buffer supports.
  68707. */
  68708. readonly isSupported: boolean;
  68709. /**
  68710. * This is the reflection mirror texture used to display reflections on the ocean.
  68711. * By default, render list is empty.
  68712. */
  68713. reflectionTexture: BABYLON.MirrorTexture;
  68714. /**
  68715. * This is the refraction render target texture used to display refraction on the ocean.
  68716. * By default, render list is empty.
  68717. */
  68718. refractionTexture: BABYLON.RenderTargetTexture;
  68719. private _time;
  68720. private _cameraRotation;
  68721. private _cameraViewMatrix;
  68722. private _reflectionEnabled;
  68723. private _refractionEnabled;
  68724. private _geometryRenderer;
  68725. /**
  68726. * Instantiates a new Ocean Post Process.
  68727. * @param name the name to give to the postprocess.
  68728. * @camera the camera to apply the post process to.
  68729. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68730. */
  68731. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  68732. /**
  68733. * Returns the appropriate defines according to the current configuration.
  68734. */
  68735. private _getDefines;
  68736. /**
  68737. * Computes the current camera rotation as the shader requires a camera rotation.
  68738. */
  68739. private _computeCameraRotation;
  68740. }
  68741. }
  68742. declare module BABYLON {
  68743. /** @hidden */
  68744. export var brickProceduralTexturePixelShader: {
  68745. name: string;
  68746. shader: string;
  68747. };
  68748. }
  68749. declare module BABYLON {
  68750. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  68751. private _numberOfBricksHeight;
  68752. private _numberOfBricksWidth;
  68753. private _jointColor;
  68754. private _brickColor;
  68755. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68756. updateShaderUniforms(): void;
  68757. numberOfBricksHeight: number;
  68758. numberOfBricksWidth: number;
  68759. jointColor: BABYLON.Color3;
  68760. brickColor: BABYLON.Color3;
  68761. /**
  68762. * Serializes this brick procedural texture
  68763. * @returns a serialized brick procedural texture object
  68764. */
  68765. serialize(): any;
  68766. /**
  68767. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  68768. * @param parsedTexture defines parsed texture data
  68769. * @param scene defines the current scene
  68770. * @param rootUrl defines the root URL containing brick procedural texture information
  68771. * @returns a parsed Brick Procedural BABYLON.Texture
  68772. */
  68773. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  68774. }
  68775. }
  68776. declare module BABYLON {
  68777. /** @hidden */
  68778. export var cloudProceduralTexturePixelShader: {
  68779. name: string;
  68780. shader: string;
  68781. };
  68782. }
  68783. declare module BABYLON {
  68784. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  68785. private _skyColor;
  68786. private _cloudColor;
  68787. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68788. updateShaderUniforms(): void;
  68789. skyColor: BABYLON.Color4;
  68790. cloudColor: BABYLON.Color4;
  68791. /**
  68792. * Serializes this cloud procedural texture
  68793. * @returns a serialized cloud procedural texture object
  68794. */
  68795. serialize(): any;
  68796. /**
  68797. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  68798. * @param parsedTexture defines parsed texture data
  68799. * @param scene defines the current scene
  68800. * @param rootUrl defines the root URL containing cloud procedural texture information
  68801. * @returns a parsed Cloud Procedural BABYLON.Texture
  68802. */
  68803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /** @hidden */
  68808. export var fireProceduralTexturePixelShader: {
  68809. name: string;
  68810. shader: string;
  68811. };
  68812. }
  68813. declare module BABYLON {
  68814. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  68815. private _time;
  68816. private _speed;
  68817. private _autoGenerateTime;
  68818. private _fireColors;
  68819. private _alphaThreshold;
  68820. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68821. updateShaderUniforms(): void;
  68822. render(useCameraPostProcess?: boolean): void;
  68823. static readonly PurpleFireColors: BABYLON.Color3[];
  68824. static readonly GreenFireColors: BABYLON.Color3[];
  68825. static readonly RedFireColors: BABYLON.Color3[];
  68826. static readonly BlueFireColors: BABYLON.Color3[];
  68827. autoGenerateTime: boolean;
  68828. fireColors: BABYLON.Color3[];
  68829. time: number;
  68830. speed: BABYLON.Vector2;
  68831. alphaThreshold: number;
  68832. /**
  68833. * Serializes this fire procedural texture
  68834. * @returns a serialized fire procedural texture object
  68835. */
  68836. serialize(): any;
  68837. /**
  68838. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  68839. * @param parsedTexture defines parsed texture data
  68840. * @param scene defines the current scene
  68841. * @param rootUrl defines the root URL containing fire procedural texture information
  68842. * @returns a parsed Fire Procedural BABYLON.Texture
  68843. */
  68844. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  68845. }
  68846. }
  68847. declare module BABYLON {
  68848. /** @hidden */
  68849. export var grassProceduralTexturePixelShader: {
  68850. name: string;
  68851. shader: string;
  68852. };
  68853. }
  68854. declare module BABYLON {
  68855. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  68856. private _grassColors;
  68857. private _groundColor;
  68858. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68859. updateShaderUniforms(): void;
  68860. grassColors: BABYLON.Color3[];
  68861. groundColor: BABYLON.Color3;
  68862. /**
  68863. * Serializes this grass procedural texture
  68864. * @returns a serialized grass procedural texture object
  68865. */
  68866. serialize(): any;
  68867. /**
  68868. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  68869. * @param parsedTexture defines parsed texture data
  68870. * @param scene defines the current scene
  68871. * @param rootUrl defines the root URL containing grass procedural texture information
  68872. * @returns a parsed Grass Procedural BABYLON.Texture
  68873. */
  68874. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68875. }
  68876. }
  68877. declare module BABYLON {
  68878. /** @hidden */
  68879. export var marbleProceduralTexturePixelShader: {
  68880. name: string;
  68881. shader: string;
  68882. };
  68883. }
  68884. declare module BABYLON {
  68885. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68886. private _numberOfTilesHeight;
  68887. private _numberOfTilesWidth;
  68888. private _amplitude;
  68889. private _jointColor;
  68890. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68891. updateShaderUniforms(): void;
  68892. numberOfTilesHeight: number;
  68893. amplitude: number;
  68894. numberOfTilesWidth: number;
  68895. jointColor: BABYLON.Color3;
  68896. /**
  68897. * Serializes this marble procedural texture
  68898. * @returns a serialized marble procedural texture object
  68899. */
  68900. serialize(): any;
  68901. /**
  68902. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68903. * @param parsedTexture defines parsed texture data
  68904. * @param scene defines the current scene
  68905. * @param rootUrl defines the root URL containing marble procedural texture information
  68906. * @returns a parsed Marble Procedural BABYLON.Texture
  68907. */
  68908. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68909. }
  68910. }
  68911. declare module BABYLON {
  68912. /** @hidden */
  68913. export var normalMapProceduralTexturePixelShader: {
  68914. name: string;
  68915. shader: string;
  68916. };
  68917. }
  68918. declare module BABYLON {
  68919. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68920. private _baseTexture;
  68921. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68922. updateShaderUniforms(): void;
  68923. render(useCameraPostProcess?: boolean): void;
  68924. resize(size: any, generateMipMaps: any): void;
  68925. baseTexture: BABYLON.Texture;
  68926. /**
  68927. * Serializes this normal map procedural texture
  68928. * @returns a serialized normal map procedural texture object
  68929. */
  68930. serialize(): any;
  68931. /**
  68932. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68933. * @param parsedTexture defines parsed texture data
  68934. * @param scene defines the current scene
  68935. * @param rootUrl defines the root URL containing normal map procedural texture information
  68936. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68937. */
  68938. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68939. }
  68940. }
  68941. declare module BABYLON {
  68942. /** @hidden */
  68943. export var perlinNoiseProceduralTexturePixelShader: {
  68944. name: string;
  68945. shader: string;
  68946. };
  68947. }
  68948. declare module BABYLON {
  68949. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68950. time: number;
  68951. timeScale: number;
  68952. translationSpeed: number;
  68953. private _currentTranslation;
  68954. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68955. updateShaderUniforms(): void;
  68956. render(useCameraPostProcess?: boolean): void;
  68957. resize(size: any, generateMipMaps: any): void;
  68958. /**
  68959. * Serializes this perlin noise procedural texture
  68960. * @returns a serialized perlin noise procedural texture object
  68961. */
  68962. serialize(): any;
  68963. /**
  68964. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68965. * @param parsedTexture defines parsed texture data
  68966. * @param scene defines the current scene
  68967. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68968. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68969. */
  68970. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68971. }
  68972. }
  68973. declare module BABYLON {
  68974. /** @hidden */
  68975. export var roadProceduralTexturePixelShader: {
  68976. name: string;
  68977. shader: string;
  68978. };
  68979. }
  68980. declare module BABYLON {
  68981. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68982. private _roadColor;
  68983. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68984. updateShaderUniforms(): void;
  68985. roadColor: BABYLON.Color3;
  68986. /**
  68987. * Serializes this road procedural texture
  68988. * @returns a serialized road procedural texture object
  68989. */
  68990. serialize(): any;
  68991. /**
  68992. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68993. * @param parsedTexture defines parsed texture data
  68994. * @param scene defines the current scene
  68995. * @param rootUrl defines the root URL containing road procedural texture information
  68996. * @returns a parsed Road Procedural BABYLON.Texture
  68997. */
  68998. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68999. }
  69000. }
  69001. declare module BABYLON {
  69002. /** @hidden */
  69003. export var starfieldProceduralTexturePixelShader: {
  69004. name: string;
  69005. shader: string;
  69006. };
  69007. }
  69008. declare module BABYLON {
  69009. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69010. private _time;
  69011. private _alpha;
  69012. private _beta;
  69013. private _zoom;
  69014. private _formuparam;
  69015. private _stepsize;
  69016. private _tile;
  69017. private _brightness;
  69018. private _darkmatter;
  69019. private _distfading;
  69020. private _saturation;
  69021. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69022. updateShaderUniforms(): void;
  69023. time: number;
  69024. alpha: number;
  69025. beta: number;
  69026. formuparam: number;
  69027. stepsize: number;
  69028. zoom: number;
  69029. tile: number;
  69030. brightness: number;
  69031. darkmatter: number;
  69032. distfading: number;
  69033. saturation: number;
  69034. /**
  69035. * Serializes this starfield procedural texture
  69036. * @returns a serialized starfield procedural texture object
  69037. */
  69038. serialize(): any;
  69039. /**
  69040. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69041. * @param parsedTexture defines parsed texture data
  69042. * @param scene defines the current scene
  69043. * @param rootUrl defines the root URL containing startfield procedural texture information
  69044. * @returns a parsed Starfield Procedural BABYLON.Texture
  69045. */
  69046. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69047. }
  69048. }
  69049. declare module BABYLON {
  69050. /** @hidden */
  69051. export var woodProceduralTexturePixelShader: {
  69052. name: string;
  69053. shader: string;
  69054. };
  69055. }
  69056. declare module BABYLON {
  69057. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69058. private _ampScale;
  69059. private _woodColor;
  69060. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69061. updateShaderUniforms(): void;
  69062. ampScale: number;
  69063. woodColor: BABYLON.Color3;
  69064. /**
  69065. * Serializes this wood procedural texture
  69066. * @returns a serialized wood procedural texture object
  69067. */
  69068. serialize(): any;
  69069. /**
  69070. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69071. * @param parsedTexture defines parsed texture data
  69072. * @param scene defines the current scene
  69073. * @param rootUrl defines the root URL containing wood procedural texture information
  69074. * @returns a parsed Wood Procedural BABYLON.Texture
  69075. */
  69076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69077. }
  69078. }